[PATCH] D79379: Don't add function to import list if it's defined in the same module
Xun Li via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 5 17:17:25 PDT 2020
lxfind updated this revision to Diff 262266.
lxfind added a comment.
Also use isDeclaration for body samples, add test case
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D79379/new/
https://reviews.llvm.org/D79379
Files:
llvm/include/llvm/ProfileData/SampleProf.h
llvm/test/Transforms/SampleProfile/Inputs/function_metadata.compact.afdo
llvm/test/Transforms/SampleProfile/Inputs/function_metadata.prof
llvm/test/Transforms/SampleProfile/function_metadata.ll
Index: llvm/test/Transforms/SampleProfile/function_metadata.ll
===================================================================
--- llvm/test/Transforms/SampleProfile/function_metadata.ll
+++ llvm/test/Transforms/SampleProfile/function_metadata.ll
@@ -6,7 +6,11 @@
declare void @foo()
-define void @foo_available() !dbg !11 {
+declare void @bar()
+
+declare !dbg !13 void @bar_dbg()
+
+define void @bar_available() !dbg !14 {
ret void
}
@@ -33,10 +37,10 @@
; metadata.
; CHECK: ![[ENTRY_TEST]] = !{!"function_entry_count", i64 1, i64 2494702099028631698, i64 6699318081062747564, i64 7682762345278052905, i64 -7908226060800700466, i64 -2012135647395072713}
-; Check GUIDs for both foo and foo_available are included in the metadata to
+; Check GUIDs for foo, bar and bar_dbg are included in the metadata to
; make sure the liveness analysis can capture the dependency from test_liveness
-; to foo_available.
-; CHECK: ![[ENTRY_TEST_LIVENESS]] = !{!"function_entry_count", i64 1, i64 4005816710939881937, i64 6699318081062747564}
+; to bar. bar_available should not be included as it's within the same module.
+; CHECK: ![[ENTRY_TEST_LIVENESS]] = !{!"function_entry_count", i64 1, i64 6699318081062747564, i64 -2012135647395072713, i64 -1522495160813492905}
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!8, !9}
@@ -52,6 +56,8 @@
!10 = !{!"clang version 3.5 "}
!11 = distinct !DISubprogram(name: "foo_available", line: 7, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 7, file: !1, scope: !1, type: !6, retainedNodes: !2)
!12 = distinct !DISubprogram(name: "test_liveness", line: 7, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 7, file: !1, scope: !1, type: !6, retainedNodes: !2)
+!13 = !DISubprogram(name: "bar_dbg", scope: !1, file: !1, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized)
+!14 = distinct !DISubprogram(name: "bar_available", line: 7, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 7, file: !1, scope: !1, type: !6, retainedNodes: !2)
!15 = !DILexicalBlockFile(discriminator: 1, file: !1, scope: !7)
!17 = distinct !DILexicalBlock(line: 10, column: 0, file: !1, scope: !7)
!18 = !DILocation(line: 10, scope: !17)
Index: llvm/test/Transforms/SampleProfile/Inputs/function_metadata.prof
===================================================================
--- llvm/test/Transforms/SampleProfile/Inputs/function_metadata.prof
+++ llvm/test/Transforms/SampleProfile/Inputs/function_metadata.prof
@@ -13,5 +13,6 @@
1: 1000 foo3:1000
test_liveness:1000:0
1: foo:1000
- 1: foo_available:1000
+ 1: bar:1000
+ 1: 2000 bar_dbg:1000 bar_available:1000
2: 1000
Index: llvm/include/llvm/ProfileData/SampleProf.h
===================================================================
--- llvm/include/llvm/ProfileData/SampleProf.h
+++ llvm/include/llvm/ProfileData/SampleProf.h
@@ -527,14 +527,18 @@
uint64_t Threshold) const {
if (TotalSamples <= Threshold)
return;
- S.insert(getGUID(Name));
+ auto *F = M->getFunction(getFuncName());
+ if (!F || F->isDeclaration()) {
+ // Add to the import list only when it's defined out of module.
+ S.insert(getGUID(Name));
+ }
// Import hot CallTargets, which may not be available in IR because full
// profile annotation cannot be done until backend compilation in ThinLTO.
for (const auto &BS : BodySamples)
for (const auto &TS : BS.second.getCallTargets())
if (TS.getValue() > Threshold) {
const Function *Callee = M->getFunction(getFuncName(TS.getKey()));
- if (!Callee || !Callee->getSubprogram())
+ if (!Callee || Callee->isDeclaration())
S.insert(getGUID(TS.getKey()));
}
for (const auto &CS : CallsiteSamples)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79379.262266.patch
Type: text/x-patch
Size: 3970 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200506/1d00984b/attachment.bin>
More information about the llvm-commits
mailing list