[PATCH] D58260: [INLINER] allow inlining of blockaddresses if sole uses are callbrs
Nick Desaulniers via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 23 12:57:11 PDT 2019
nickdesaulniers added a comment.
@chandlerc alternatively, if I drop the posted changed to llvm/lib/Analysis/CGSCCPassManager.cpp and instead do:
diff --git a/llvm/include/llvm/Analysis/LazyCallGraph.h b/llvm/include/llvm/Analysis/La
zyCallGraph.h
index 328654763b59..62e062a30718 100644
--- a/llvm/include/llvm/Analysis/LazyCallGraph.h
+++ b/llvm/include/llvm/Analysis/LazyCallGraph.h
@@ -1082,12 +1082,21 @@ public:
continue;
}
+ // The blockaddress constant expression is a weird special case, we can't
+ // generically walk its operands the way we do for all other constants.
if (BlockAddress *BA = dyn_cast<BlockAddress>(C)) {
- // The blockaddress constant expression is a weird special case, we
- // can't generically walk its operands the way we do for all other
- // constants.
+ bool AllUsersAreSameFn = true;
+ for (User *U : BA->users())
+ if (Instruction *I = dyn_cast<Instruction>(U))
+ if (I->getFunction() != BA->getFunction()) {
+ AllUsersAreSameFn = false;
+ break;
+ }
if (Visited.insert(BA->getFunction()).second)
- Worklist.push_back(BA->getFunction());
+ // If the blockaddress' function it refers to a function it's not
+ // defined within, visit the other function.
+ if (!AllUsersAreSameFn)
+ Worklist.push_back(BA->getFunction());
continue;
}
This also works. I *think* it's correct that we don't want to re-visit the function the blockaddress refers to, if it refers to the same function the blockaddress is within. LazyCallGraphTest.HandleBlockAddress tests what happens with the blockaddress refers to a block outside the scope of the current function.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58260/new/
https://reviews.llvm.org/D58260
More information about the llvm-commits
mailing list