Skip to content

Commit 4c28137

Browse files
Consolidate importer spilling code V2 (dotnet#72744)
* Consolidate importer spilling code (dotnet#72291) * Add tests * Fix losing GLOB_REF on the LHS The comment states we don't need it, which is incorrect. Diffs are improvements because we block forward substitution of calls into "ASG(BLK(ADDR(LCL_VAR<field>, ...)))", which allows morph to leave the "can be replaced with its field" local alone. * Prospective fix Spill "glob refs" on stores to "aliased" locals. * Delete now-not-necessary code * Fix up asserts * Clean out '(unsigned)CHECK_SPILL_ALL/NONE' casts * Don't manually spill for 'st[s]fld' * Revert 'Clean out '(unsigned)CHECK_SPILL_ALL/NONE' casts' * Fix assignments done via return buffers The mistake in logic was that the only trees which could modify unaliased locals are assignments, which is not true, calls can do that as well. One day we will move the return buffer handling out of importer, but until then, special handling is required. An alternative fix would have been to bring back the explicit "impSpillLclRefs" to "stloc/starg" code, but that would contradict the overall goal of consolidating the spilling logic.
1 parent 8a64275 commit 4c28137

4 files changed

Lines changed: 511 additions & 159 deletions

File tree

src/coreclr/jit/compiler.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3803,11 +3803,8 @@ class Compiler
38033803
Statement* impLastStmt; // The last statement for the current BB.
38043804

38053805
public:
3806-
enum
3807-
{
3808-
CHECK_SPILL_ALL = -1,
3809-
CHECK_SPILL_NONE = -2
3810-
};
3806+
static const unsigned CHECK_SPILL_ALL = static_cast<unsigned>(-1);
3807+
static const unsigned CHECK_SPILL_NONE = static_cast<unsigned>(-2);
38113808

38123809
void impBeginTreeList();
38133810
void impEndTreeList(BasicBlock* block, Statement* firstStmt, Statement* lastStmt);
@@ -4007,7 +4004,7 @@ class Compiler
40074004
void impSpillSpecialSideEff();
40084005
void impSpillSideEffect(bool spillGlobEffects, unsigned chkLevel DEBUGARG(const char* reason));
40094006
void impSpillSideEffects(bool spillGlobEffects, unsigned chkLevel DEBUGARG(const char* reason));
4010-
void impSpillLclRefs(unsigned lclNum);
4007+
void impSpillLclRefs(unsigned lclNum, unsigned chkLevel);
40114008

40124009
BasicBlock* impPushCatchArgOnStack(BasicBlock* hndBlk, CORINFO_CLASS_HANDLE clsHnd, bool isSingleBlockFilter);
40134010

0 commit comments

Comments
 (0)