@@ -445,9 +445,8 @@ int LateLowerGCFrame::Number(State &S, Value *V) {
445
445
if (it != S.AllPtrNumbering .end ())
446
446
return it->second ;
447
447
int Number;
448
- if (isa<Constant>(CurrentV) ||
449
- ((isa<Argument>(CurrentV) || isa<AllocaInst>(CurrentV) ||
450
- isa<AddrSpaceCastInst>(CurrentV)) &&
448
+ if (isa<Constant>(CurrentV) || isa<Argument>(CurrentV) ||
449
+ ((isa<AllocaInst>(CurrentV) || isa<AddrSpaceCastInst>(CurrentV)) &&
451
450
getValueAddrSpace (CurrentV) != AddressSpace::Tracked)) {
452
451
// We know this is rooted in the parent
453
452
Number = -1 ;
@@ -831,8 +830,9 @@ void LateLowerGCFrame::ComputeLiveSets(Function &F, State &S) {
831
830
if ((unsigned )i >= LS.size () || !LS[i])
832
831
continue ;
833
832
for (int Idx = LS.find_first (); Idx >= 0 ; Idx = LS.find_next (Idx)) {
834
- if (Idx == i)
835
- continue ;
833
+ // We explicitly let i be a neighbor of itself, to distinguish
834
+ // between being the only value live at a safepoint, vs not
835
+ // being live at any safepoint.
836
836
Neighbors.push_back (Idx);
837
837
}
838
838
}
@@ -916,6 +916,8 @@ struct PEOIterator {
916
916
Elements[NextElement].weight = (unsigned )-1 ;
917
917
// Raise neighbors
918
918
for (int Neighbor : Neighbors[NextElement]) {
919
+ if (Neighbor == NextElement)
920
+ continue ;
919
921
Element &NElement = Elements[Neighbor];
920
922
// Already processed. Don't re-enqueue
921
923
if (NElement.weight == (unsigned )-1 )
@@ -947,6 +949,10 @@ std::vector<int> LateLowerGCFrame::ColorRoots(const State &S) {
947
949
assert (Colors[ActiveElement] == -1 );
948
950
UsedColors.resize (MaxAssignedColor + 2 , false );
949
951
UsedColors.reset ();
952
+ if (S.Neighbors [ActiveElement].empty ()) {
953
+ // No need to color a value not live at any safe point
954
+ continue ;
955
+ }
950
956
for (int Neighbor : S.Neighbors [ActiveElement]) {
951
957
if (Colors[Neighbor] == -1 )
952
958
continue ;
0 commit comments