[llvm] 0ece283 - [Attributor] Add checks needed as we strengthen value simplify
Johannes Doerfert via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 9 04:42:00 PDT 2022
Author: Johannes Doerfert
Date: 2022-06-09T13:41:23+02:00
New Revision: 0ece283f0326103afce93960588d4f33ca81bfcd
URL: https://github.com/llvm/llvm-project/commit/0ece283f0326103afce93960588d4f33ca81bfcd
DIFF: https://github.com/llvm/llvm-project/commit/0ece283f0326103afce93960588d4f33ca81bfcd.diff
LOG: [Attributor] Add checks needed as we strengthen value simplify
Added:
Modified:
llvm/lib/Transforms/IPO/Attributor.cpp
llvm/lib/Transforms/IPO/AttributorAttributes.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index 085307ef72cc..888d3a1b6c4f 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -2002,8 +2002,12 @@ 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)
diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index 42a42d84f9bd..5c2d7d518b14 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -4895,8 +4895,13 @@ struct AAInstanceInfoImpl : public AAInstanceInfo {
const auto &ArgInstanceInfoAA = A.getAAFor<AAInstanceInfo>(
*this, IRPosition::callsite_argument(*CB, CB->getArgOperandNo(&U)),
DepClassTy::OPTIONAL);
- if (ArgInstanceInfoAA.isAssumedUniqueForAnalysis())
- return true;
+ 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()
More information about the llvm-commits
mailing list