summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeonard Grey <lgrey@chromium.org>2021-10-28 11:27:01 -0400
committerNico Weber <thakis@chromium.org>2021-10-28 11:32:49 -0400
commit793b481f54f8343bc3e6041f4400fe54166529a9 (patch)
treedb1a77b9dcf9816c08b0926d1660b856c33ad164
parent6f9c25167d16acff3ff8e4f54a8c14a2a175fc59 (diff)
downloadllvm-793b481f54f8343bc3e6041f4400fe54166529a9.tar.gz
[CGProfile] Don't emit call graph profile edges with zero weight
With D112160 and D112164, on a Chrome Mac build this reduces the total size of CGProfile sections by 78% (around 25% eliminated entirely) and total size of object files by 0.14%. Differential Revision: https://reviews.llvm.org/D112655
-rw-r--r--llvm/lib/Transforms/Instrumentation/CGProfile.cpp2
-rw-r--r--llvm/test/Instrumentation/cgprofile.ll6
2 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/CGProfile.cpp b/llvm/lib/Transforms/Instrumentation/CGProfile.cpp
index 9acd82c005e6..1a7f7a365ce4 100644
--- a/llvm/lib/Transforms/Instrumentation/CGProfile.cpp
+++ b/llvm/lib/Transforms/Instrumentation/CGProfile.cpp
@@ -53,6 +53,8 @@ static bool runCGProfilePass(
InstrProfSymtab Symtab;
auto UpdateCounts = [&](TargetTransformInfo &TTI, Function *F,
Function *CalledF, uint64_t NewCount) {
+ if (NewCount == 0)
+ return;
if (!CalledF || !TTI.isLoweredToCall(CalledF) ||
CalledF->hasDLLImportStorageClass())
return;
diff --git a/llvm/test/Instrumentation/cgprofile.ll b/llvm/test/Instrumentation/cgprofile.ll
index 8458b9949f32..5e2f2665ab0f 100644
--- a/llvm/test/Instrumentation/cgprofile.ll
+++ b/llvm/test/Instrumentation/cgprofile.ll
@@ -14,6 +14,7 @@ declare i32 @func2()
declare i32 @func3()
declare i32 @func4()
declare dllimport i32 @func5()
+declare i32 @func6()
define void @freq(i1 %cond) !prof !1 {
%tmp = load i32 ()*, i32 ()** @foo, align 8
@@ -29,7 +30,7 @@ B:
!1 = !{!"function_entry_count", i64 32}
!2 = !{!"branch_weights", i32 5, i32 10}
-!3 = !{!"VP", i32 0, i64 1600, i64 7651369219802541373, i64 1030, i64 -4377547752858689819, i64 410, i64 -6929281286627296573, i64 150, i64 -2545542355363006406, i64 10, i64 3667884930908592509, i64 0}
+!3 = !{!"VP", i32 0, i64 1600, i64 7651369219802541373, i64 1030, i64 -4377547752858689819, i64 410, i64 -6929281286627296573, i64 150, i64 -2545542355363006406, i64 10, i64 3667884930908592509, i64 1, i64 15435711456043681792, i64 0}
; CHECK: !llvm.module.flags = !{![[cgprof:[0-9]+]]}
; CHECK: ![[cgprof]] = !{i32 5, !"CG Profile", ![[prof:[0-9]+]]}
@@ -41,4 +42,5 @@ B:
; CHECK: ![[e4]] = !{void (i1)* @freq, i32 ()* @func1, i64 10}
; CHECK: ![[e5]] = !{void (i1)* @freq, void ()* @a, i64 11}
; CHECK: ![[e6]] = !{void (i1)* @freq, void ()* @b, i64 21}
-; CHECK-NOT: !{void (i1)* @freq, void ()* @func5, i64 0} \ No newline at end of file
+; CHECK-NOT: !{void (i1)* @freq, void ()* @func5, i64 1}
+; CHECK-NOT: !{void (i1)* @freq, void ()* @func6, i64 0}