diff options
author | Erik Desjardins <erikdesjardinspublic@gmail.com> | 2021-10-07 08:14:56 -0700 |
---|---|---|
committer | Mircea Trofin <mtrofin@google.com> | 2021-10-07 08:33:25 -0700 |
commit | 11c8efd4db0fe58a2858459353cc5c0c41565ee5 (patch) | |
tree | 4e49db7776b879ecfea37b9035d5101b2da60f42 /llvm/lib/Analysis/InlineCost.cpp | |
parent | 3a5aa57c9b1c01c990700bfcedcebc14ef9a97dc (diff) | |
download | llvm-11c8efd4db0fe58a2858459353cc5c0c41565ee5.zip llvm-11c8efd4db0fe58a2858459353cc5c0c41565ee5.tar.gz llvm-11c8efd4db0fe58a2858459353cc5c0c41565ee5.tar.bz2 |
[Inline] Introduce Constant::hasOneLiveUse, use it instead of hasOneUse in inline cost model (PR51667)
Otherwise, inlining costs may be pessimized by dead constants.
Fixes https://bugs.llvm.org/show_bug.cgi?id=51667.
Reviewed By: mtrofin, aeubanks
Differential Revision: https://reviews.llvm.org/D109294
Diffstat (limited to 'llvm/lib/Analysis/InlineCost.cpp')
-rw-r--r-- | llvm/lib/Analysis/InlineCost.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp index 4db7fae..3cb56dc 100644 --- a/llvm/lib/Analysis/InlineCost.cpp +++ b/llvm/lib/Analysis/InlineCost.cpp @@ -1859,8 +1859,8 @@ void InlineCostCallAnalyzer::updateThreshold(CallBase &Call, Function &Callee) { SingleBBBonus = Threshold * SingleBBBonusPercent / 100; VectorBonus = Threshold * VectorBonusPercent / 100; - bool OnlyOneCallAndLocalLinkage = - F.hasLocalLinkage() && F.hasOneUse() && &F == Call.getCalledFunction(); + bool OnlyOneCallAndLocalLinkage = F.hasLocalLinkage() && F.hasOneLiveUse() && + &F == Call.getCalledFunction(); // If there is only one call of the function, and it has internal linkage, // the cost of inlining it drops dramatically. It may seem odd to update // Cost in updateThreshold, but the bonus depends on the logic in this method. @@ -2665,7 +2665,7 @@ InlineResult CallAnalyzer::analyze() { onBlockAnalyzed(BB); } - bool OnlyOneCallAndLocalLinkage = F.hasLocalLinkage() && F.hasOneUse() && + bool OnlyOneCallAndLocalLinkage = F.hasLocalLinkage() && F.hasOneLiveUse() && &F == CandidateCall.getCalledFunction(); // If this is a noduplicate call, we can still inline as long as // inlining this would cause the removal of the caller (so the instruction |