[llvm] f543539 - [CGProfile] don't emit cgprofile entry if called function is dllimport
Zequan Wu via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 23 16:57:32 PDT 2020
Author: Zequan Wu
Date: 2020-09-23T16:56:54-07:00
New Revision: f5435399e823746bbe1737b95c853d77a42e1ac3
URL: https://github.com/llvm/llvm-project/commit/f5435399e823746bbe1737b95c853d77a42e1ac3
DIFF: https://github.com/llvm/llvm-project/commit/f5435399e823746bbe1737b95c853d77a42e1ac3.diff
LOG: [CGProfile] don't emit cgprofile entry if called function is dllimport
Differential Revision: https://reviews.llvm.org/D88127
Added:
Modified:
llvm/lib/Transforms/Instrumentation/CGProfile.cpp
llvm/test/Instrumentation/cgprofile.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Instrumentation/CGProfile.cpp b/llvm/lib/Transforms/Instrumentation/CGProfile.cpp
index 0cc0d9b07387..9acd82c005e6 100644
--- a/llvm/lib/Transforms/Instrumentation/CGProfile.cpp
+++ b/llvm/lib/Transforms/Instrumentation/CGProfile.cpp
@@ -53,7 +53,8 @@ static bool runCGProfilePass(
InstrProfSymtab Symtab;
auto UpdateCounts = [&](TargetTransformInfo &TTI, Function *F,
Function *CalledF, uint64_t NewCount) {
- if (!CalledF || !TTI.isLoweredToCall(CalledF))
+ if (!CalledF || !TTI.isLoweredToCall(CalledF) ||
+ CalledF->hasDLLImportStorageClass())
return;
uint64_t &Count = Counts[std::make_pair(F, CalledF)];
Count = SaturatingAdd(Count, NewCount);
diff --git a/llvm/test/Instrumentation/cgprofile.ll b/llvm/test/Instrumentation/cgprofile.ll
index 70a1f81aa53e..8458b9949f32 100644
--- a/llvm/test/Instrumentation/cgprofile.ll
+++ b/llvm/test/Instrumentation/cgprofile.ll
@@ -13,6 +13,7 @@ declare i32 @func1()
declare i32 @func2()
declare i32 @func3()
declare i32 @func4()
+declare dllimport i32 @func5()
define void @freq(i1 %cond) !prof !1 {
%tmp = load i32 ()*, i32 ()** @foo, align 8
@@ -28,7 +29,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}
+!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}
; CHECK: !llvm.module.flags = !{![[cgprof:[0-9]+]]}
; CHECK: ![[cgprof]] = !{i32 5, !"CG Profile", ![[prof:[0-9]+]]}
@@ -40,3 +41,4 @@ 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
More information about the llvm-commits
mailing list