[PATCH] D39480: Include GUIDs from the same module when computing GUIDs that needs to be imported.

Dehao Chen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 31 14:46:52 PDT 2017


danielcdh created this revision.
Herald added subscribers: mehdi_amini, sanjoy.

In the compile phase of SamplePGO+ThinLTO, ICP is not invoked. Instead, indirect call targets will be included as function metadata for ThinIndex to buidl the call graph. This should not only include functions defined in other modules, but also functions defined in the same module, otherwise ThinIndex may find the callee dead and eliminate it, while ICP in backend will revive the symbol, which leads to undefined symbol.


https://reviews.llvm.org/D39480

Files:
  include/llvm/ProfileData/SampleProf.h
  test/Transforms/SampleProfile/Inputs/import.prof
  test/Transforms/SampleProfile/import.ll


Index: test/Transforms/SampleProfile/import.ll
===================================================================
--- test/Transforms/SampleProfile/import.ll
+++ test/Transforms/SampleProfile/import.ll
@@ -5,6 +5,10 @@
 
 declare void @foo()
 
+define void @foo_available() !dbg !11 {
+  ret void
+}
+
 define void @test(void ()*) !dbg !7 {
   %2 = alloca void ()*
   store void ()* %0, void ()** %2
@@ -17,7 +21,7 @@
 
 ; GUIDs of foo, bar, foo1, foo2 and foo3 should be included in the metadata to
 ; make sure hot inline stacks are imported.
-; CHECK: !{!"function_entry_count", i64 1, i64 2494702099028631698, i64 6699318081062747564, i64 7682762345278052905,  i64 -7908226060800700466, i64 -2012135647395072713}
+; CHECK: !{!"function_entry_count", i64 1, i64 2494702099028631698, i64 4005816710939881937, i64 6699318081062747564, i64 7682762345278052905,  i64 -7908226060800700466, i64 -2012135647395072713}
 
 !llvm.dbg.cu = !{!0}
 !llvm.module.flags = !{!8, !9}
@@ -31,6 +35,7 @@
 !8 = !{i32 2, !"Dwarf Version", i32 4}
 !9 = !{i32 1, !"Debug Info Version", i32 3}
 !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, variables: !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: test/Transforms/SampleProfile/Inputs/import.prof
===================================================================
--- test/Transforms/SampleProfile/Inputs/import.prof
+++ test/Transforms/SampleProfile/Inputs/import.prof
@@ -6,3 +6,5 @@
   1: 1000
  4: foo2:1000
   1: 1000 foo3:1000
+ 4: foo_available:1000
+  1: 1000
Index: include/llvm/ProfileData/SampleProf.h
===================================================================
--- include/llvm/ProfileData/SampleProf.h
+++ include/llvm/ProfileData/SampleProf.h
@@ -360,9 +360,7 @@
                              uint64_t Threshold) const {
     if (TotalSamples <= Threshold)
       return;
-    Function *F = M->getFunction(Name);
-    if (!F || !F->getSubprogram())
-      S.insert(Function::getGUID(Name));
+    S.insert(Function::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)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39480.121067.patch
Type: text/x-patch
Size: 2528 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171031/aff1ff6c/attachment.bin>


More information about the llvm-commits mailing list