Skip to content

Commit 3fd5e80

Browse files
committed
[loop-region] Change LoopRegion::getParentID() to return the optional ParentID instead of attempting to use the value and asserting.
1 parent 7772ae7 commit 3fd5e80

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

include/swift/SILOptimizer/Analysis/LoopRegionAnalysis.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ class LoopRegion {
570570

571571
/// Return the ID of the parent region of this BB. Asserts if this is a
572572
/// function region.
573-
unsigned getParentID() const { return *ParentID; }
573+
Optional<unsigned> getParentID() const { return ParentID; }
574574

575575
unsigned getRPONumber() const {
576576
if (isBlock())

lib/SILOptimizer/Analysis/LoopRegionAnalysis.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -512,10 +512,10 @@ static void getExitingRegions(LoopRegionFunctionInfo *LRFI, SILLoop *Loop,
512512
// this subloop's region. That is the *true* exiting region.
513513
for (auto *BB : ExitingBlocks) {
514514
auto *Region = LRFI->getRegion(BB);
515-
unsigned RegionParentID = Region->getParentID();
515+
unsigned RegionParentID = *Region->getParentID();
516516
while (RegionParentID != LRegion->getID()) {
517517
Region = LRFI->getRegion(RegionParentID);
518-
RegionParentID = Region->getParentID();
518+
RegionParentID = *Region->getParentID();
519519
}
520520
ExitingRegions.push_back(Region->getID());
521521
}
@@ -745,7 +745,7 @@ getRegionForNonLocalSuccessor(const LoopRegion *Child, unsigned SuccID) const {
745745
LoopRegion::SuccessorID Succ = {0, 0};
746746

747747
do {
748-
Iter = getRegion(Iter->getParentID());
748+
Iter = getRegion(*Iter->getParentID());
749749
Succ = Iter->Succs[SuccID].getValue();
750750
SuccID = Succ.ID;
751751
} while (Succ.IsNonLocal);
@@ -876,7 +876,7 @@ struct LoopRegionWrapper {
876876
LoopRegion *Region;
877877

878878
LoopRegionWrapper *getParent() const {
879-
unsigned ParentIndex = Region->getParentID();
879+
unsigned ParentIndex = *Region->getParentID();
880880
return &FuncInfo.Data[ParentIndex];
881881
}
882882

@@ -922,7 +922,7 @@ struct alledge_iterator
922922
}
923923
// If we have a non-local id, just return the parent region's data.
924924
if ((*SuccIter)->IsNonLocal)
925-
return &Wrapper->FuncInfo.Data[Wrapper->Region->getParentID()];
925+
return &Wrapper->FuncInfo.Data[*(Wrapper->Region->getParentID())];
926926
// Otherwise return the data associated with this successor.
927927
return &Wrapper->FuncInfo.Data[(*SuccIter)->ID];
928928
}

0 commit comments

Comments
 (0)