[PATCH] D58260: [INLINER] allow inlining of address taken blocks
James Y Knight via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 15 10:31:42 PST 2019
jyknight added inline comments.
================
Comment at: llvm/include/llvm/IR/BasicBlock.h:393-395
+ /// Returns true if there are any uses of the address of this basic block
+ /// that are call instructions (which may allow the address of this basic
+ /// block to escape).
----------------
Calls are not the only thing which may allow the value to escape. A store to externally-accessible memory will too, for example. The right implementation of this predicate is going to involve calling into something like PointerMayBeCaptured, *but* that's not setup to deal properly with constants at the moment, only SSA values within a function.
This should be something like:
Returns true if there are any uses of the address of this basic block that may escape the function. At the moment, this is a very conservative approximation, and treats ANY use except as a "noescape" parameter to a call as potentially escaping.
================
Comment at: llvm/lib/IR/BasicBlock.cpp:445
+bool BasicBlock::addressPotentiallyEscapesFunction() {
+ for (const Use& U : BlockAddress::get(this)->uses())
----------------
This will need to use a worklist loop, to handle a few kinds of uses. Something like this:
1. If the use isa<Constant> && !isa<GlobalValue> (most particularly to handle a pointer bitcast): add all the uses of _that_ to the worklist to check.
2. Call with nocapture attribute -> OK, keep checking.
3. Anything else -> potentially escapes, return true.
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