From 7fb830e3d2fc373f8d3e04934080d186d418441c Mon Sep 17 00:00:00 2001 From: Dehao Chen Date: Fri, 24 Jun 2016 22:57:06 +0000 Subject: [PATCH] Hookup ProfileSummary with SampleProfilerLoader Summary: Set ProfileSummary in SampleProfilerLoader. Reviewers: davidxl, eraman Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D21702 llvm-svn: 273745 --- lib/Transforms/IPO/SampleProfile.cpp | 1 + test/Transforms/SampleProfile/Inputs/summary.prof | 4 ++++ test/Transforms/SampleProfile/summary.ll | 14 ++++++++++++++ 3 files changed, 19 insertions(+) create mode 100644 test/Transforms/SampleProfile/Inputs/summary.prof create mode 100644 test/Transforms/SampleProfile/summary.ll diff --git a/lib/Transforms/IPO/SampleProfile.cpp b/lib/Transforms/IPO/SampleProfile.cpp index d25d9d4be1e..b6a112d530e 100644 --- a/lib/Transforms/IPO/SampleProfile.cpp +++ b/lib/Transforms/IPO/SampleProfile.cpp @@ -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 index 00000000000..49a5b57d5e6 --- /dev/null +++ b/test/Transforms/SampleProfile/Inputs/summary.prof @@ -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 index 00000000000..49b1d2c3633 --- /dev/null +++ b/test/Transforms/SampleProfile/summary.ll @@ -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)