forked from OSchip/llvm-project
[Attributor][FIX] Track change status for AAIsDead properly
If we add a new live edge we need to indicate a change or otherwise the new live block is not shown to users. Similarly, new known dead ends and a changed `ToBeExploredFrom` set need to cause us to return CHANGED.
This commit is contained in:
parent
ebe817f98c
commit
8befd05aad
|
@ -3836,10 +3836,8 @@ ChangeStatus AAIsDeadFunction::updateImpl(Attributor &A) {
|
|||
|
||||
// Fast forward for uninteresting instructions. We could look for UB here
|
||||
// though.
|
||||
while (!I->isTerminator() && !isa<CallBase>(I)) {
|
||||
Change = ChangeStatus::CHANGED;
|
||||
while (!I->isTerminator() && !isa<CallBase>(I))
|
||||
I = I->getNextNode();
|
||||
}
|
||||
|
||||
AliveSuccessors.clear();
|
||||
|
||||
|
@ -3872,11 +3870,11 @@ ChangeStatus AAIsDeadFunction::updateImpl(Attributor &A) {
|
|||
|
||||
if (UsedAssumedInformation) {
|
||||
NewToBeExploredFrom.insert(I);
|
||||
} else {
|
||||
Change = ChangeStatus::CHANGED;
|
||||
if (AliveSuccessors.empty() ||
|
||||
(I->isTerminator() && AliveSuccessors.size() < I->getNumSuccessors()))
|
||||
KnownDeadEnds.insert(I);
|
||||
} else if (AliveSuccessors.empty() ||
|
||||
(I->isTerminator() &&
|
||||
AliveSuccessors.size() < I->getNumSuccessors())) {
|
||||
if (KnownDeadEnds.insert(I))
|
||||
Change = ChangeStatus::CHANGED;
|
||||
}
|
||||
|
||||
LLVM_DEBUG(dbgs() << "[AAIsDead] #AliveSuccessors: "
|
||||
|
@ -3890,15 +3888,23 @@ ChangeStatus AAIsDeadFunction::updateImpl(Attributor &A) {
|
|||
Worklist.push_back(AliveSuccessor);
|
||||
} else {
|
||||
// record the assumed live edge
|
||||
AssumedLiveEdges.insert(
|
||||
std::make_pair(I->getParent(), AliveSuccessor->getParent()));
|
||||
auto Edge = std::make_pair(I->getParent(), AliveSuccessor->getParent());
|
||||
if (AssumedLiveEdges.insert(Edge).second)
|
||||
Change = ChangeStatus::CHANGED;
|
||||
if (assumeLive(A, *AliveSuccessor->getParent()))
|
||||
Worklist.push_back(AliveSuccessor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ToBeExploredFrom = std::move(NewToBeExploredFrom);
|
||||
// Check if the content of ToBeExploredFrom changed, ignore the order.
|
||||
if (NewToBeExploredFrom.size() != ToBeExploredFrom.size() ||
|
||||
llvm::any_of(NewToBeExploredFrom, [&](const Instruction *I) {
|
||||
return !ToBeExploredFrom.count(I);
|
||||
})) {
|
||||
Change = ChangeStatus::CHANGED;
|
||||
ToBeExploredFrom = std::move(NewToBeExploredFrom);
|
||||
}
|
||||
|
||||
// If we know everything is live there is no need to query for liveness.
|
||||
// Instead, indicating a pessimistic fixpoint will cause the state to be
|
||||
|
|
Loading…
Reference in New Issue