[llvm] [Inliner][TTI][AMDGPU] Add size growth TTI hook for unreachable-termed bb (PR #217014)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 13 06:27:04 PDT 2026
================
@@ -1994,31 +1991,6 @@ bool CallAnalyzer::isKnownNonNullInCallee(Value *V) {
return false;
}
-bool CallAnalyzer::allowSizeGrowth(CallBase &Call) {
- // If the normal destination of the invoke or the parent block of the call
- // site is unreachable-terminated, there is little point in inlining this
- // unless there is literally zero cost.
- // FIXME: Note that it is possible that an unreachable-terminated block has a
- // hot entry. For example, in below scenario inlining hot_call_X() may be
- // beneficial :
- // main() {
- // hot_call_1();
- // ...
- // hot_call_N()
- // exit(0);
- // }
- // For now, we are not handling this corner case here as it is rare in real
- // code. In future, we should elaborate this based on BPI and BFI in more
- // general threshold adjusting heuristics in updateThreshold().
- if (InvokeInst *II = dyn_cast<InvokeInst>(&Call)) {
- if (isa<UnreachableInst>(II->getNormalDest()->getTerminator()))
- return false;
- } else if (isa<UnreachableInst>(Call.getParent()->getTerminator()))
- return false;
-
----------------
arsenm wrote:
This check doesn't make sense to me to start with, and the comment alludes to the fact that this isn't good. It would make more sense to me to treat the ends-in-unreachable case as a cost function modifier in updateThreshold, rather than just not-inspecting the rest of the block. Can you try generically changing updateThreshold to do something better instead
https://github.com/llvm/llvm-project/pull/217014
More information about the llvm-commits
mailing list