Skip to content

Commit 5bcc1c9

Browse files
Also fix SDSUs
No test because it's not possible currently to sneak a STORE_LCL_VAR into an expression in RyuJit, at least not in a way that'd break the current code.
1 parent 564c1b8 commit 5bcc1c9

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

src/coreclr/jit/llvmlssa.cpp

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,16 @@ class ShadowStackAllocator
615615

616616
void SpillSdsuValue(LIR::Range& blockRange, GenTree* defNode, unsigned* pSpillLclNum)
617617
{
618+
// Like with candidates, the GC status of an SDSU can change during its lifetime, so we need to check it
619+
// at every safepoint, in the general case. We could tighten this by filtering out more SDSUs early (like
620+
// 'null' and such), but live-across-a-safepoint SDSUs are not that common, so we currently don't.
621+
INDEBUG(NotExposedReason reason(this));
622+
if (!IsGcExposedSdsuValue(defNode, DefStatus::Active DEBUGARG(&reason)))
623+
{
624+
JITDUMPEXEC(reason.Print("[%06u] is live, but not exposed: ", "\n", Compiler::dspTreeID(defNode)));
625+
return;
626+
}
627+
618628
if (*pSpillLclNum != BAD_VAR_NUM)
619629
{
620630
// We may have already spilled this def live across multiple safe points.
@@ -812,7 +822,6 @@ class ShadowStackAllocator
812822
}
813823

814824
LclVarDsc* varDsc;
815-
INDEBUG(NotExposedReason reason(this));
816825
if (IsCandidateLocalNode(node, &varDsc))
817826
{
818827
JITDUMP(" -- Processing a candidate:\n");
@@ -839,8 +848,7 @@ class ShadowStackAllocator
839848
IncrementActiveUseCount(varDsc->GetPerSsaData(ssaNum));
840849
}
841850
}
842-
else if (node->IsValue() && !node->IsUnusedValue() && IsGcExposedType(node) &&
843-
IsGcExposedSdsuValue(node, DefStatus::Active DEBUGARG(&reason)))
851+
else if (node->IsValue() && !node->IsUnusedValue() && IsGcExposedType(node))
844852
{
845853
node->gtLIRFlags |= LIR::Flags::Mark;
846854
m_liveSdsuGcDefs.AddOrUpdate(node, BAD_VAR_NUM);
@@ -855,17 +863,7 @@ class ShadowStackAllocator
855863
}
856864
if (node->TypeIs(TYP_STRUCT))
857865
{
858-
// TODO-LLVM: delete this once we're up to date with upstream deleting "STORE_DYN_BLK".
859-
if (node->OperIs(GT_IND))
860-
{
861-
return false;
862-
}
863-
if (!node->GetLayout(m_compiler)->HasGCPtr())
864-
{
865-
return false;
866-
}
867-
868-
return true;
866+
return node->GetLayout(m_compiler)->HasGCPtr();
869867
}
870868

871869
return false;

0 commit comments

Comments
 (0)