diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2021-06-13 19:31:46 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2021-06-13 19:37:19 +0000 |
commit | e8d8bef961a50d4dc22501cde4fb9fb0be1b2532 (patch) | |
tree | 94f04805f47bb7c59ae29690d8952b6074fff602 /contrib/llvm-project/llvm/lib/Analysis/CodeMetrics.cpp | |
parent | bb130ff39747b94592cb26d71b7cb097b9a4ea6b (diff) | |
parent | b60736ec1405bb0a8dd40989f67ef4c93da068ab (diff) |
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Analysis/CodeMetrics.cpp')
-rw-r--r-- | contrib/llvm-project/llvm/lib/Analysis/CodeMetrics.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/contrib/llvm-project/llvm/lib/Analysis/CodeMetrics.cpp b/contrib/llvm-project/llvm/lib/Analysis/CodeMetrics.cpp index 0b2b6f9bfa46..157811c04eb5 100644 --- a/contrib/llvm-project/llvm/lib/Analysis/CodeMetrics.cpp +++ b/contrib/llvm-project/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 |