@@ -615,6 +615,16 @@ class ShadowStackAllocator
615
615
616
616
void SpillSdsuValue (LIR::Range& blockRange, GenTree* defNode, unsigned * pSpillLclNum)
617
617
{
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
+
618
628
if (*pSpillLclNum != BAD_VAR_NUM)
619
629
{
620
630
// We may have already spilled this def live across multiple safe points.
@@ -812,7 +822,6 @@ class ShadowStackAllocator
812
822
}
813
823
814
824
LclVarDsc* varDsc;
815
- INDEBUG (NotExposedReason reason (this ));
816
825
if (IsCandidateLocalNode (node, &varDsc))
817
826
{
818
827
JITDUMP (" -- Processing a candidate:\n " );
@@ -839,8 +848,7 @@ class ShadowStackAllocator
839
848
IncrementActiveUseCount (varDsc->GetPerSsaData (ssaNum));
840
849
}
841
850
}
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))
844
852
{
845
853
node->gtLIRFlags |= LIR::Flags::Mark;
846
854
m_liveSdsuGcDefs.AddOrUpdate (node, BAD_VAR_NUM);
@@ -855,17 +863,7 @@ class ShadowStackAllocator
855
863
}
856
864
if (node->TypeIs (TYP_STRUCT))
857
865
{
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 ();
869
867
}
870
868
871
869
return false ;
0 commit comments