diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2021-02-16 20:13:02 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2021-02-16 20:13:02 +0000 |
commit | b60736ec1405bb0a8dd40989f67ef4c93da068ab (patch) | |
tree | 5c43fbb7c9fc45f0f87e0e6795a86267dbd12f9d /llvm/lib/Analysis/CodeMetrics.cpp | |
parent | cfca06d7963fa0909f90483b42a6d7d194d01e08 (diff) | |
download | src-b60736ec1405bb0a8dd40989f67ef4c93da068ab.tar.gz src-b60736ec1405bb0a8dd40989f67ef4c93da068ab.zip |
Vendor import of llvm-project main 8e464dd76bef, the last commit beforevendor/llvm-project/llvmorg-12-init-17869-g8e464dd76bef
the upstream release/12.x branch was created.
Diffstat (limited to 'llvm/lib/Analysis/CodeMetrics.cpp')
-rw-r--r-- | llvm/lib/Analysis/CodeMetrics.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/llvm/lib/Analysis/CodeMetrics.cpp b/llvm/lib/Analysis/CodeMetrics.cpp index 0b2b6f9bfa46..157811c04eb5 100644 --- a/llvm/lib/Analysis/CodeMetrics.cpp +++ b/llvm/lib/Analysis/CodeMetrics.cpp @@ -112,9 +112,9 @@ void CodeMetrics::collectEphemeralValues( /// Fill in the current structure with information gleaned from the specified /// block. -void CodeMetrics::analyzeBasicBlock(const BasicBlock *BB, - const TargetTransformInfo &TTI, - const SmallPtrSetImpl<const Value*> &EphValues) { +void CodeMetrics::analyzeBasicBlock( + const BasicBlock *BB, const TargetTransformInfo &TTI, + const SmallPtrSetImpl<const Value *> &EphValues, bool PrepareForLTO) { ++NumBlocks; unsigned NumInstsBeforeThisBB = NumInsts; for (const Instruction &I : *BB) { @@ -125,11 +125,16 @@ void CodeMetrics::analyzeBasicBlock(const BasicBlock *BB, // 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). - if (!Call->isNoInline() && F->hasInternalLinkage() && F->hasOneUse()) + // When preparing for LTO, liberally consider calls as inline + // candidates. + if (!Call->isNoInline() && IsLoweredToCall && + ((F->hasInternalLinkage() && F->hasOneUse()) || PrepareForLTO)) { ++NumInlineCandidates; + } // If this call is to function itself, then the function is recursive. // Inlining it into other functions is a bad idea, because this is @@ -138,7 +143,7 @@ void CodeMetrics::analyzeBasicBlock(const BasicBlock *BB, 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 |