[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
Mon May 4 17:46:18 PDT 2020


lxfind updated this revision to Diff 261974.
lxfind added a comment.

Keep test for the original purpose by forcing function out of module


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,9 +6,7 @@
 
 declare void @foo()
 
-define void @foo_available() !dbg !11 {
-  ret void
-}
+declare void @bar()
 
 ; CHECK: define void @test({{.*}} !prof ![[ENTRY_TEST:[0-9]+]]
 define void @test(void ()*) !dbg !7 {
@@ -33,10 +31,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 both foo and bar 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.
+; CHECK: ![[ENTRY_TEST_LIVENESS]] = !{!"function_entry_count", i64 1, i64 6699318081062747564, i64 -2012135647395072713}
 
 !llvm.dbg.cu = !{!0}
 !llvm.module.flags = !{!8, !9}
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,5 @@
   1: 1000 foo3:1000
 test_liveness:1000:0
  1: foo:1000
-  1: foo_available:1000
+  1: bar:1000
    2: 1000
Index: llvm/include/llvm/ProfileData/SampleProf.h
===================================================================
--- llvm/include/llvm/ProfileData/SampleProf.h
+++ llvm/include/llvm/ProfileData/SampleProf.h
@@ -527,7 +527,11 @@
                             uint64_t Threshold) const {
     if (TotalSamples <= Threshold)
       return;
-    S.insert(getGUID(Name));
+    auto *F = M->getFunction(getFuncName());
+    if (!F || !F->getSubprogram()) {
+      // 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)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79379.261974.patch
Type: text/x-patch
Size: 2425 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200505/22e74b9b/attachment-0001.bin>


More information about the llvm-commits mailing list