[PATCH] D21702: Hookup ProfileSummary with SampleProfilerLoader

Dehao Chen via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 24 14:53:51 PDT 2016


danielcdh updated this revision to Diff 61846.
danielcdh added a comment.

add testcase


http://reviews.llvm.org/D21702

Files:
  lib/Transforms/IPO/SampleProfile.cpp
  test/Transforms/PGOProfile/Inputs/PR28219.sampleprof
  test/Transforms/PGOProfile/PR28219.ll

Index: test/Transforms/PGOProfile/PR28219.ll
===================================================================
--- test/Transforms/PGOProfile/PR28219.ll
+++ test/Transforms/PGOProfile/PR28219.ll
@@ -1,12 +1,16 @@
 ; Test that we annotate entire program's summary and not just this module's
 ; RUN: llvm-profdata merge %S/Inputs/PR28219.proftext -o %t.profdata
 ; RUN: opt < %s -pgo-instr-use -pgo-test-profile-file=%t.profdata -S | FileCheck %s
+; RUN: opt < %s -sample-profile -sample-profile-file=%S/Inputs/PR28219.sampleprof -S | FileCheck %s
 
-define i32 @bar() {
+define i32 @bar() #0 !dbg !1 {
 entry:
-  ret i32 1
+  ret i32 1, !dbg !2
 }
+
 ; CHECK-DAG: {{![0-9]+}} = !{i32 1, !"ProfileSummary", {{![0-9]+}}}
 ; CHECK-DAG: {{![0-9]+}} = !{!"NumFunctions", i64 2}
 ; CHECK-DAG: {{![0-9]+}} = !{!"MaxFunctionCount", i64 3}
 
+!1 = distinct !DISubprogram(name: "bar")
+!2 = !DILocation(line: 2, scope: !2)
Index: test/Transforms/PGOProfile/Inputs/PR28219.sampleprof
===================================================================
--- /dev/null
+++ test/Transforms/PGOProfile/Inputs/PR28219.sampleprof
@@ -0,0 +1,4 @@
+bar:100:3
+ 1: 100
+foo:200:1
+ 1: 200
Index: lib/Transforms/IPO/SampleProfile.cpp
===================================================================
--- lib/Transforms/IPO/SampleProfile.cpp
+++ lib/Transforms/IPO/SampleProfile.cpp
@@ -1275,6 +1275,7 @@
       clearFunctionData();
       retval |= runOnFunction(F);
     }
+  M.setProfileSummary(Reader->getSummary().getMD(M.getContext()));
   return retval;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21702.61846.patch
Type: text/x-patch
Size: 1546 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160624/ba5181c0/attachment.bin>


More information about the llvm-commits mailing list