Skip to content

Commit f543539

Browse files
committed
[CGProfile] don't emit cgprofile entry if called function is dllimport
Differential Revision: https://reviews.llvm.org/D88127
1 parent 2bd5e3f commit f543539

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

llvm/lib/Transforms/Instrumentation/CGProfile.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ static bool runCGProfilePass(
5353
InstrProfSymtab Symtab;
5454
auto UpdateCounts = [&](TargetTransformInfo &TTI, Function *F,
5555
Function *CalledF, uint64_t NewCount) {
56-
if (!CalledF || !TTI.isLoweredToCall(CalledF))
56+
if (!CalledF || !TTI.isLoweredToCall(CalledF) ||
57+
CalledF->hasDLLImportStorageClass())
5758
return;
5859
uint64_t &Count = Counts[std::make_pair(F, CalledF)];
5960
Count = SaturatingAdd(Count, NewCount);

llvm/test/Instrumentation/cgprofile.ll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ declare i32 @func1()
1313
declare i32 @func2()
1414
declare i32 @func3()
1515
declare i32 @func4()
16+
declare dllimport i32 @func5()
1617

1718
define void @freq(i1 %cond) !prof !1 {
1819
%tmp = load i32 ()*, i32 ()** @foo, align 8
@@ -28,7 +29,7 @@ B:
2829

2930
!1 = !{!"function_entry_count", i64 32}
3031
!2 = !{!"branch_weights", i32 5, i32 10}
31-
!3 = !{!"VP", i32 0, i64 1600, i64 7651369219802541373, i64 1030, i64 -4377547752858689819, i64 410, i64 -6929281286627296573, i64 150, i64 -2545542355363006406, i64 10}
32+
!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}
3233

3334
; CHECK: !llvm.module.flags = !{![[cgprof:[0-9]+]]}
3435
; CHECK: ![[cgprof]] = !{i32 5, !"CG Profile", ![[prof:[0-9]+]]}
@@ -40,3 +41,4 @@ B:
4041
; CHECK: ![[e4]] = !{void (i1)* @freq, i32 ()* @func1, i64 10}
4142
; CHECK: ![[e5]] = !{void (i1)* @freq, void ()* @a, i64 11}
4243
; CHECK: ![[e6]] = !{void (i1)* @freq, void ()* @b, i64 21}
44+
; CHECK-NOT: !{void (i1)* @freq, void ()* @func5, i64 0}

0 commit comments

Comments
 (0)