[Attributor] Add checks needed as we strengthen value simplify

This commit is contained in:
Johannes Doerfert 2022-05-19 13:12:49 -05:00
parent 393be12b74
commit 0ece283f03
2 changed files with 16 additions and 3 deletions

View File

@ -2002,9 +2002,13 @@ ChangeStatus Attributor::cleanupIR() {
for (auto &U : OldV->uses())
if (Entry.second || !U.getUser()->isDroppable())
Uses.push_back(&U);
for (Use *U : Uses)
for (Use *U : Uses) {
if (auto *I = dyn_cast<Instruction>(U->getUser()))
if (!isRunOn(*I->getFunction()))
continue;
ReplaceUse(U, NewV);
}
}
for (auto &V : InvokeWithDeadSuccessor)
if (InvokeInst *II = dyn_cast_or_null<InvokeInst>(V)) {

View File

@ -4895,7 +4895,12 @@ struct AAInstanceInfoImpl : public AAInstanceInfo {
const auto &ArgInstanceInfoAA = A.getAAFor<AAInstanceInfo>(
*this, IRPosition::callsite_argument(*CB, CB->getArgOperandNo(&U)),
DepClassTy::OPTIONAL);
if (ArgInstanceInfoAA.isAssumedUniqueForAnalysis())
if (!ArgInstanceInfoAA.isAssumedUniqueForAnalysis())
return false;
// If this call base might reach the scope again we might forward the
// argument back here. This is very conservative.
if (AA::isPotentiallyReachable(A, *CB, *Scope, *this, nullptr))
return false;
return true;
}
return false;
@ -5201,6 +5206,8 @@ ChangeStatus AANoCaptureImpl::updateImpl(Attributor &A) {
// AAReturnedValues, e.g., track all values that escape through returns
// directly somehow.
auto CheckReturnedArgs = [&](const AAReturnedValues &RVAA) {
if (!RVAA.getState().isValidState())
return false;
bool SeenConstant = false;
for (auto &It : RVAA.returned_values()) {
if (isa<Constant>(It.first)) {
@ -6433,6 +6440,8 @@ ChangeStatus AAHeapToStackFunction::updateImpl(Attributor &A) {
dbgs() << "[H2S] unique free call might free unknown allocations\n");
return false;
}
if (DI->PotentialAllocationCalls.empty())
return true;
if (DI->PotentialAllocationCalls.size() > 1) {
LLVM_DEBUG(dbgs() << "[H2S] unique free call might free "
<< DI->PotentialAllocationCalls.size()