@@ -678,27 +678,24 @@ lowerStatepointMetaArgs(SmallVectorImpl<SDValue> &Ops,
678
678
SDValue SDV = Builder.getValue (V);
679
679
SDValue Loc = Builder.StatepointLowering .getLocation (SDV);
680
680
681
- if (LowerAsVReg. count (SDV )) {
682
- SpillMap[V] = None;
683
- } else if (Loc. getNode ()) {
681
+ if (Loc. getNode ( )) {
682
+ // If this is a value we spilled, remember where for when we visit the
683
+ // gc.relocate corresponding to this gc.statepoint
684
684
SpillMap[V] = cast<FrameIndexSDNode>(Loc)->getIndex ();
685
685
} else {
686
- // Record value as visited, but not spilled. This is case for allocas
687
- // and constants. For this values we can avoid emitting spill load while
688
- // visiting corresponding gc_relocate.
689
- // Actually we do not need to record them in this map at all.
690
- // We do this only to check that we are not relocating any unvisited
691
- // value.
686
+ // If we didn't spill the value - allocas, constants, and values lowered
687
+ // as tied vregs - mark them as visited, but not spilled. Marking them
688
+ // visited (as opposed to simply missing in the map), allows tighter
689
+ // assertion checking.
692
690
SpillMap[V] = None;
693
691
694
- // Default llvm mechanisms for exporting values which are used in
695
- // different basic blocks does not work for gc relocates.
696
- // Note that it would be incorrect to teach llvm that all relocates are
697
- // uses of the corresponding values so that it would automatically
698
- // export them. Relocates of the spilled values does not use original
699
- // value.
700
- if (Relocate->getParent () != StatepointInstr->getParent ())
692
+ // Conservatively export all values used by gc.relocates outside this
693
+ // block. This is currently only needed for expressions which don't need
694
+ // relocation, but will likely be extended for vreg case shortly.
695
+ if (Relocate->getParent () != StatepointInstr->getParent ()) {
701
696
Builder.ExportFromCurrentBlock (V);
697
+ assert (!LowerAsVReg.count (SDV));
698
+ }
702
699
}
703
700
}
704
701
}
@@ -844,9 +841,9 @@ SDValue SelectionDAGBuilder::LowerAsSTATEPOINT(
844
841
SmallVector<EVT, 8 > NodeTys;
845
842
for (auto &Ptr : SI.Ptrs ) {
846
843
SDValue SD = getValue (Ptr );
847
- if (LowerAsVReg.count (SD)) {
848
- NodeTys. push_back (SD. getValueType ()) ;
849
- }
844
+ if (! LowerAsVReg.count (SD))
845
+ continue ;
846
+ NodeTys. push_back (SD. getValueType ());
850
847
}
851
848
LLVM_DEBUG (dbgs () << " Statepoint has " << NodeTys.size () << " results\n " );
852
849
assert (NodeTys.size () == LowerAsVReg.size () && " Inconsistent GC Ptr lowering" );
@@ -866,8 +863,9 @@ SDValue SelectionDAGBuilder::LowerAsSTATEPOINT(
866
863
for (const auto *Relocate : SI.GCRelocates ) {
867
864
Value *Derived = Relocate->getDerivedPtr ();
868
865
SDValue SD = getValue (Derived);
869
- if (LowerAsVReg.count (SD))
870
- DPtrMap[Derived] = SDValue (StatepointMCNode, LowerAsVReg[SD]);
866
+ if (!LowerAsVReg.count (SD))
867
+ continue ;
868
+ DPtrMap[Derived] = SDValue (StatepointMCNode, LowerAsVReg[SD]);
871
869
}
872
870
873
871
// Build the GC_TRANSITION_END node if necessary.
0 commit comments