Skip to content

Commit b67d9ff

Browse files
jakobbotscheiriktsarpalis
authored andcommitted
JIT: Make all static base helpers byref typed in async functions (#130317)
There were a handful of static base helpers that we treated as returning `TYP_I_IMPL`. At the same time VN considers these helpers to be invariant, allowing them to be CSE'd. However, these helpers are not invariant in async functions. Initially I explicitly marked VNs referring to these helpers as killed across async suspensions in CSE (see first commits on this PR). However, figuring out which VNs refer to those helpers is actually non-trivial when you take VNPhiDef and other functions into account. Instead this PR just changes the type of these helpers to let the standard byref handling pick them up. A more ideal solution would be some kind of thread-SSA that worked like memory SSA and were passed as an input to these VNs. But that's much more complicated. Fix #130212
1 parent 11e067c commit b67d9ff

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/coreclr/jit/flowgraph.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,11 @@ GenTreeCall* Compiler::fgGetStaticsCCtorHelper(CORINFO_CLASS_HANDLE cls, CorInfo
758758

759759
case CORINFO_HELP_GETPINNED_GCSTATIC_BASE:
760760
case CORINFO_HELP_GETPINNED_NONGCSTATIC_BASE:
761-
type = TYP_I_IMPL;
761+
// In async calls we model these helpers as byrefs to get "killed
762+
// across suspensions" behavior for free, while also properly
763+
// ensuring derived addresses are byref typed and are treated
764+
// similarly.
765+
type = compIsAsync() ? TYP_BYREF : TYP_I_IMPL;
762766
break;
763767

764768
case CORINFO_HELP_INITCLASS:

0 commit comments

Comments
 (0)