diff options
author | Florian Hahn <flo@fhahn.com> | 2021-01-19 14:34:55 +0000 |
---|---|---|
committer | Florian Hahn <flo@fhahn.com> | 2021-01-19 14:37:36 +0000 |
commit | 3747b69b531299f7a2a0289b8a59ac7234e47d4f (patch) | |
tree | 776816914f78703207ab0d2fd15efac907cfe979 /llvm/lib/Analysis/CodeMetrics.cpp | |
parent | c42f5ca3d84c7b0d4e735ab3794718c429369309 (diff) | |
download | llvm-3747b69b531299f7a2a0289b8a59ac7234e47d4f.zip llvm-3747b69b531299f7a2a0289b8a59ac7234e47d4f.tar.gz llvm-3747b69b531299f7a2a0289b8a59ac7234e47d4f.tar.bz2 |
[LoopRotate] Calls not lowered to calls should not block rotation.
83daa49758a1 made loop-rotate more conservative in the presence of
function calls in the prepare-for-lto stage. The code did not properly
account for calls that are no actual function calls, like calls to
intrinsics. This patch updates the code to ensure only calls that are
lowered to actual calls are considered inline candidates.
Diffstat (limited to 'llvm/lib/Analysis/CodeMetrics.cpp')
-rw-r--r-- | llvm/lib/Analysis/CodeMetrics.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/CodeMetrics.cpp b/llvm/lib/Analysis/CodeMetrics.cpp index fca62c1..157811c 100644 --- a/llvm/lib/Analysis/CodeMetrics.cpp +++ b/llvm/lib/Analysis/CodeMetrics.cpp @@ -125,12 +125,13 @@ void CodeMetrics::analyzeBasicBlock( // Special handling for calls. if (const auto *Call = dyn_cast<CallBase>(&I)) { if (const Function *F = Call->getCalledFunction()) { + bool IsLoweredToCall = TTI.isLoweredToCall(F); // If a function is both internal and has a single use, then it is // extremely likely to get inlined in the future (it was probably // exposed by an interleaved devirtualization pass). // When preparing for LTO, liberally consider calls as inline // candidates. - if (!Call->isNoInline() && + if (!Call->isNoInline() && IsLoweredToCall && ((F->hasInternalLinkage() && F->hasOneUse()) || PrepareForLTO)) { ++NumInlineCandidates; } @@ -142,7 +143,7 @@ void CodeMetrics::analyzeBasicBlock( if (F == BB->getParent()) isRecursive = true; - if (TTI.isLoweredToCall(F)) + if (IsLoweredToCall) ++NumCalls; } else { // We don't want inline asm to count as a call - that would prevent loop |