diff options
author | Joshua Cao <cao.joshua@yahoo.com> | 2023-01-22 23:26:37 -0800 |
---|---|---|
committer | Joshua Cao <cao.joshua@yahoo.com> | 2023-01-24 20:16:46 -0800 |
commit | f9599bbc7a3f831e1793a549d8a7a19265f3e504 (patch) | |
tree | 57e3957a8befdd2f86715da360be6e5f0b3e0946 /llvm/lib/Analysis/AssumptionCache.cpp | |
parent | 5ba8ecb6cc7b76e7124566e53a3bce9393763a20 (diff) | |
download | llvm-f9599bbc7a3f831e1793a549d8a7a19265f3e504.zip llvm-f9599bbc7a3f831e1793a549d8a7a19265f3e504.tar.gz llvm-f9599bbc7a3f831e1793a549d8a7a19265f3e504.tar.bz2 |
[AssumptionCache] caches @llvm.experimental.guard's
As discussed in https://github.com/llvm/llvm-project/issues/59901
This change is not NFC. There is one SCEV and EarlyCSE test that have an
improved analysis/optimization case. Rest of the tests are not failing.
I've mostly only added cleanup to SCEV since that is where this issue
started. As a follow up, I believe there is more cleanup opportunity in
SCEV and other affected passes.
There could be cases where there are missed registerAssumption of
guards, but this case is not so bad because there will be no
miscompilation. AssumptionCacheTracker should take care of deleted
guards.
Differential Revision: https://reviews.llvm.org/D142330
Diffstat (limited to 'llvm/lib/Analysis/AssumptionCache.cpp')
-rw-r--r-- | llvm/lib/Analysis/AssumptionCache.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/llvm/lib/Analysis/AssumptionCache.cpp b/llvm/lib/Analysis/AssumptionCache.cpp index 11796ef..2d648cc 100644 --- a/llvm/lib/Analysis/AssumptionCache.cpp +++ b/llvm/lib/Analysis/AssumptionCache.cpp @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// // -// This file contains a pass that keeps track of @llvm.assume intrinsics in -// the functions of a module. +// This file contains a pass that keeps track of @llvm.assume and +// @llvm.experimental.guard intrinsics in the functions of a module. // //===----------------------------------------------------------------------===// @@ -140,7 +140,7 @@ findAffectedValues(CallBase *CI, TargetTransformInfo *TTI, } } -void AssumptionCache::updateAffectedValues(AssumeInst *CI) { +void AssumptionCache::updateAffectedValues(CondGuardInst *CI) { SmallVector<AssumptionCache::ResultElem, 16> Affected; findAffectedValues(CI, TTI, Affected); @@ -153,7 +153,7 @@ void AssumptionCache::updateAffectedValues(AssumeInst *CI) { } } -void AssumptionCache::unregisterAssumption(AssumeInst *CI) { +void AssumptionCache::unregisterAssumption(CondGuardInst *CI) { SmallVector<AssumptionCache::ResultElem, 16> Affected; findAffectedValues(CI, TTI, Affected); @@ -217,7 +217,7 @@ void AssumptionCache::scanFunction() { // to this cache. for (BasicBlock &B : F) for (Instruction &I : B) - if (isa<AssumeInst>(&I)) + if (isa<CondGuardInst>(&I)) AssumeHandles.push_back({&I, ExprResultIdx}); // Mark the scan as complete. @@ -225,10 +225,10 @@ void AssumptionCache::scanFunction() { // Update affected values. for (auto &A : AssumeHandles) - updateAffectedValues(cast<AssumeInst>(A)); + updateAffectedValues(cast<CondGuardInst>(A)); } -void AssumptionCache::registerAssumption(AssumeInst *CI) { +void AssumptionCache::registerAssumption(CondGuardInst *CI) { // If we haven't scanned the function yet, just drop this assumption. It will // be found when we scan later. if (!Scanned) @@ -238,9 +238,9 @@ void AssumptionCache::registerAssumption(AssumeInst *CI) { #ifndef NDEBUG assert(CI->getParent() && - "Cannot register @llvm.assume call not in a basic block"); + "Cannot a register CondGuardInst not in a basic block"); assert(&F == CI->getParent()->getParent() && - "Cannot register @llvm.assume call not in this function"); + "Cannot a register CondGuardInst not in this function"); // We expect the number of assumptions to be small, so in an asserts build // check that we don't accumulate duplicates and that all assumptions point @@ -252,8 +252,8 @@ void AssumptionCache::registerAssumption(AssumeInst *CI) { assert(&F == cast<Instruction>(VH)->getParent()->getParent() && "Cached assumption not inside this function!"); - assert(match(cast<CallInst>(VH), m_Intrinsic<Intrinsic::assume>()) && - "Cached something other than a call to @llvm.assume!"); + assert(isa<CondGuardInst>(VH) && + "Cached something other than CondGuardInst!"); assert(AssumptionSet.insert(VH).second && "Cache contains multiple copies of a call!"); } |