Skip to content

Commit fcf020f

Browse files
authored
[AssumptionCache] Don't use ResultElem for assumption list (NFC) (#160462)
ResultElem stores a weak handle of an assume, plus an index for referring to a specific operand bundle. This makes sense for the results of assumptionsFor(), which refers to specific operands of assumes. However, assumptions() is a plain list of assumes. It does *not* contain separate entries for each operand bundles. The operand bundle index is always ExprResultIdx. As such, we should be directly using WeakVH for this case, without the additional wrapper.
1 parent 755ffa3 commit fcf020f

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

llvm/include/llvm/Analysis/AssumptionCache.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class AssumptionCache {
6565

6666
/// Vector of weak value handles to calls of the \@llvm.assume
6767
/// intrinsic.
68-
SmallVector<ResultElem, 4> AssumeHandles;
68+
SmallVector<WeakVH, 4> AssumeHandles;
6969

7070
class LLVM_ABI AffectedValueCallbackVH final : public CallbackVH {
7171
AssumptionCache *AC;
@@ -148,7 +148,7 @@ class AssumptionCache {
148148
/// FIXME: We should replace this with pointee_iterator<filter_iterator<...>>
149149
/// when we can write that to filter out the null values. Then caller code
150150
/// will become simpler.
151-
MutableArrayRef<ResultElem> assumptions() {
151+
MutableArrayRef<WeakVH> assumptions() {
152152
if (!Scanned)
153153
scanFunction();
154154
return AssumeHandles;

llvm/lib/Analysis/AssumptionCache.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ void AssumptionCache::scanFunction() {
172172
for (BasicBlock &B : F)
173173
for (Instruction &I : B)
174174
if (isa<AssumeInst>(&I))
175-
AssumeHandles.push_back({&I, ExprResultIdx});
175+
AssumeHandles.push_back(&I);
176176

177177
// Mark the scan as complete.
178178
Scanned = true;
@@ -188,7 +188,7 @@ void AssumptionCache::registerAssumption(AssumeInst *CI) {
188188
if (!Scanned)
189189
return;
190190

191-
AssumeHandles.push_back({CI, ExprResultIdx});
191+
AssumeHandles.push_back(CI);
192192

193193
#ifndef NDEBUG
194194
assert(CI->getParent() &&

llvm/lib/Transforms/Scalar/DropUnnecessaryAssumes.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ DropUnnecessaryAssumesPass::run(Function &F, FunctionAnalysisManager &FAM) {
2121
AssumptionCache &AC = FAM.getResult<AssumptionAnalysis>(F);
2222
bool Changed = false;
2323

24-
for (AssumptionCache::ResultElem &Elem : AC.assumptions()) {
25-
auto *Assume = cast_or_null<AssumeInst>(Elem.Assume);
24+
for (const WeakVH &Elem : AC.assumptions()) {
25+
auto *Assume = cast_or_null<AssumeInst>(Elem);
2626
if (!Assume)
2727
continue;
2828

0 commit comments

Comments
 (0)