Skip to content

Commit

Permalink
Hookup ProfileSummary with SampleProfilerLoader
Browse files Browse the repository at this point in the history
Summary: Set ProfileSummary in SampleProfilerLoader.

Reviewers: davidxl, eraman

Subscribers: llvm-commits

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

llvm-svn: 273745
  • Loading branch information
danielcdh committed Jun 24, 2016
1 parent 449cdfd commit c66a06a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions llvm/lib/Transforms/IPO/SampleProfile.cpp
Expand Up @@ -1275,6 +1275,7 @@ bool SampleProfileLoader::runOnModule(Module &M) {
clearFunctionData();
retval |= runOnFunction(F);
}
M.setProfileSummary(Reader->getSummary().getMD(M.getContext()));
return retval;
}

Expand Down
4 changes: 4 additions & 0 deletions llvm/test/Transforms/SampleProfile/Inputs/summary.prof
@@ -0,0 +1,4 @@
bar:100:3
1: 100
foo:200:1
1: 200
14 changes: 14 additions & 0 deletions llvm/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)

0 comments on commit c66a06a

Please sign in to comment.