]> granicus.if.org Git - llvm/commitdiff
Hookup ProfileSummary with SampleProfilerLoader
authorDehao Chen <dehao@google.com>
Fri, 24 Jun 2016 22:57:06 +0000 (22:57 +0000)
committerDehao Chen <dehao@google.com>
Fri, 24 Jun 2016 22:57:06 +0000 (22:57 +0000)
Summary: Set ProfileSummary in SampleProfilerLoader.

Reviewers: davidxl, eraman

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D21702

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273745 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/IPO/SampleProfile.cpp
test/Transforms/SampleProfile/Inputs/summary.prof [new file with mode: 0644]
test/Transforms/SampleProfile/summary.ll [new file with mode: 0644]

index d25d9d4be1e6d61776460019df06feb78d75414b..b6a112d530ec1cd66a7447caaf65996718bbfe65 100644 (file)
@@ -1275,6 +1275,7 @@ bool SampleProfileLoader::runOnModule(Module &M) {
       clearFunctionData();
       retval |= runOnFunction(F);
     }
+  M.setProfileSummary(Reader->getSummary().getMD(M.getContext()));
   return retval;
 }
 
diff --git a/test/Transforms/SampleProfile/Inputs/summary.prof b/test/Transforms/SampleProfile/Inputs/summary.prof
new file mode 100644 (file)
index 0000000..49a5b57
--- /dev/null
@@ -0,0 +1,4 @@
+bar:100:3
+ 1: 100
+foo:200:1
+ 1: 200
diff --git a/test/Transforms/SampleProfile/summary.ll b/test/Transforms/SampleProfile/summary.ll
new file mode 100644 (file)
index 0000000..49b1d2c
--- /dev/null
@@ -0,0 +1,14 @@
+; Test that we annotate entire program's summary to IR.
+; RUN: opt < %s -sample-profile -sample-profile-file=%S/Inputs/summary.prof -S | FileCheck %s
+
+define i32 @bar() #0 !dbg !1 {
+entry:
+  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)