JIT: Duplicate function epilogs may be generated
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
Research direction
Start with the linked Godbolt reproduction and compare the generated G_M43597_IG05 and G_M43597_IG07 epilogs in the assembly output. Trace the JIT code-generation path responsible for these return blocks and verify the result on the supplied TwoEpilogs example. Done means equivalent epilogs are shared or otherwise no longer duplicated, with the generated code becoming smaller.
Written by the indexing model from the issue text.
Description
Following example generates two identical function epilogs. I would expect some overall size improvements from only having a single epilog and jumping to it. https://godbolt.org/z/Mch1hGKfx
static bool TwoEpilogs(in Matrix4x4 a, in Matrix4x4 b)
{
var c = a * b;
if (c[0, 0] == 1.0f && c[1, 1] == 1.0f)
{
return true;
}
return false;
}
G_M43597_IG05 and G_M43597_IG07 are the same
; Method Program.EntryPoint:TwoEpilogs(byref,byref):ubyte (FullOpts)
G_M43597_IG01: ;; offset=0x0000
sub rsp, 152
vmovaps xmmword ptr [rsp+0x80], xmm6
vmovaps xmmword ptr [rsp+0x70], xmm7
vmovaps xmmword ptr [rsp+0x60], xmm8
vmovaps xmmword ptr [rsp+0x50], xmm9
vmovaps xmmword ptr [rsp+0x40], xmm10
vxorps xmm4, xmm4, xmm4
vmovdqu ymmword ptr [rsp], ymm4
vmovdqu ymmword ptr [rsp+0x20], ymm4
;; size=55 bbWeight=1 PerfScore 14.58
G_M43597_IG02: ;; offset=0x0037
; bunch of multiplication code
vucomiss xmm0, dword ptr [reloc @RWD00]
jp SHORT G_M43597_IG04
jne SHORT G_M43597_IG04
;; size=302 bbWeight=1 PerfScore 122.00
G_M43597_IG03: ;; offset=0x0165
vmovss xmm0, dword ptr [rsp+0x14]
vucomiss xmm0, dword ptr [reloc @RWD00]
jp SHORT G_M43597_IG04
je SHORT G_M43597_IG06
;; size=18 bbWeight=0.50 PerfScore 4.50
G_M43597_IG04: ;; offset=0x0177
xor eax, eax
;; size=2 bbWeight=0.50 PerfScore 0.12
G_M43597_IG05: ;; offset=0x0179
vmovaps xmm6, xmmword ptr [rsp+0x80]
vmovaps xmm7, xmmword ptr [rsp+0x70]
vmovaps xmm8, xmmword ptr [rsp+0x60]
vmovaps xmm9, xmmword ptr [rsp+0x50]
vmovaps xmm10, xmmword ptr [rsp+0x40]
add rsp, 152
ret
;; size=41 bbWeight=0.50 PerfScore 10.62
G_M43597_IG06: ;; offset=0x01A2
mov eax, 1
;; size=5 bbWeight=0.50 PerfScore 0.12
G_M43597_IG07: ;; offset=0x01A7
vmovaps xmm6, xmmword ptr [rsp+0x80]
vmovaps xmm7, xmmword ptr [rsp+0x70]
vmovaps xmm8, xmmword ptr [rsp+0x60]
vmovaps xmm9, xmmword ptr [rsp+0x50]
vmovaps xmm10, xmmword ptr [rsp+0x40]
add rsp, 152
ret
;; size=41 bbWeight=0.50 PerfScore 10.62
RWD00 dd 3F800000h ; 1
; Total bytes of code: 464
- Dominant language
- C#
- Stars
- 18.3k
- Forks
- 5.6k
- PR merge metrics
- PR metrics pending
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dotnet/runtime
-
agentic-workflows untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
area-System.Reflection blocking-clean-ci-optional Known Build Error os-mac-os-x untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
area-CodeGen-coreclr untriaged
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
agentic-workflows untriaged
Difficulty 1/5 Under an hour Newbie friendliness 78/100
-
area-VM-meta-mono untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
:watch: Not Triaged 11.0 fundamentals/subsvc
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
dotnet/AspNetCore.Docs#37699 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
SubtitleEdit/subtitleedit#15108 · 1 comment ·
-
area/docs-content Bug pulumi/docs
Difficulty 1/5 1-3 hours Newbie friendliness 94/100
-
Create parent directories only after the containment check in InstallHelper.TryExtractToDirectory Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
PowerShell/PSResourceGet#2056 ·