[llvm] 7a2f5dc - [CodeMetrics] use hasOneLiveUse instead of hasOneUse while analyzing inlinable callsites

Chuanqi Xu via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 25 22:47:34 PDT 2022


Author: Sinan Lin
Date: 2022-07-26T13:46:19+08:00
New Revision: 7a2f5dca09f022ca56d661acdd919da32147e767

URL: https://github.com/llvm/llvm-project/commit/7a2f5dca09f022ca56d661acdd919da32147e767
DIFF: https://github.com/llvm/llvm-project/commit/7a2f5dca09f022ca56d661acdd919da32147e767.diff

LOG: [CodeMetrics] use hasOneLiveUse instead of hasOneUse while analyzing inlinable callsites

It would be better for CodeMetrics to use hasOneLiveUse while analyzing
static and called once callsites, since inline cost now uses
hasOneLiveUse instead of hasOneUse to avoid overpessimization on dead
constant cases (since this patch https://reviews.llvm.org/D109294).

This change has no noticeable influence now, but it helps improve the
accuracy of cost models of passes that use CodeMetrics.

Reviewed By: fhahn, nikic

Differential Revision: https://reviews.llvm.org/D130461

Added: 
    

Modified: 
    llvm/lib/Analysis/CodeMetrics.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/CodeMetrics.cpp b/llvm/lib/Analysis/CodeMetrics.cpp
index 6d9084215dee0..ded842b92ae17 100644
--- a/llvm/lib/Analysis/CodeMetrics.cpp
+++ b/llvm/lib/Analysis/CodeMetrics.cpp
@@ -133,7 +133,8 @@ void CodeMetrics::analyzeBasicBlock(
         // When preparing for LTO, liberally consider calls as inline
         // candidates.
         if (!Call->isNoInline() && IsLoweredToCall &&
-            ((F->hasInternalLinkage() && F->hasOneUse()) || PrepareForLTO)) {
+            ((F->hasInternalLinkage() && F->hasOneLiveUse()) ||
+             PrepareForLTO)) {
           ++NumInlineCandidates;
         }
 


        


More information about the llvm-commits mailing list