[llvm] r273301 - Fix PR28219: Use profile summary from reader and not compute it
Easwaran Raman via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 21 12:29:50 PDT 2016
Author: eraman
Date: Tue Jun 21 14:29:49 2016
New Revision: 273301
URL: http://llvm.org/viewvc/llvm-project?rev=273301&view=rev
Log:
Fix PR28219: Use profile summary from reader and not compute it
Differentiaal revision: http://reviews.llvm.org/D21546
Added:
llvm/trunk/test/Transforms/PGOProfile/Inputs/PR28219.proftext
llvm/trunk/test/Transforms/PGOProfile/PR28219.ll
Modified:
llvm/trunk/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
Modified: llvm/trunk/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/PGOInstrumentation.cpp?rev=273301&r1=273300&r2=273301&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/PGOInstrumentation.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/PGOInstrumentation.cpp Tue Jun 21 14:29:49 2016
@@ -879,7 +879,6 @@ static bool annotateAllFunctions(
std::vector<Function *> HotFunctions;
std::vector<Function *> ColdFunctions;
- InstrProfSummaryBuilder Builder(ProfileSummaryBuilder::DefaultCutoffs);
for (auto &F : M) {
if (F.isDeclaration())
continue;
@@ -891,15 +890,13 @@ static bool annotateAllFunctions(
Func.populateCounters();
Func.setBranchWeights();
Func.annotateIndirectCallSites();
- if (!Func.getProfileRecord().Counts.empty())
- Builder.addRecord(Func.getProfileRecord());
PGOUseFunc::FuncFreqAttr FreqAttr = Func.getFuncFreqAttr();
if (FreqAttr == PGOUseFunc::FFA_Cold)
ColdFunctions.push_back(&F);
else if (FreqAttr == PGOUseFunc::FFA_Hot)
HotFunctions.push_back(&F);
}
- M.setProfileSummary(Builder.getSummary()->getMD(M.getContext()));
+ M.setProfileSummary(PGOReader->getSummary().getMD(M.getContext()));
// Set function hotness attribute from the profile.
// We have to apply these attributes at the end because their presence
// can affect the BranchProbabilityInfo of any callers, resulting in an
Added: llvm/trunk/test/Transforms/PGOProfile/Inputs/PR28219.proftext
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/PGOProfile/Inputs/PR28219.proftext?rev=273301&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/PGOProfile/Inputs/PR28219.proftext (added)
+++ llvm/trunk/test/Transforms/PGOProfile/Inputs/PR28219.proftext Tue Jun 21 14:29:49 2016
@@ -0,0 +1,10 @@
+# :ir is the flag to indicate this is IR level profile.
+:ir
+ at bar
+256
+1
+2
+ at foo
+512
+1
+3
Added: llvm/trunk/test/Transforms/PGOProfile/PR28219.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/PGOProfile/PR28219.ll?rev=273301&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/PGOProfile/PR28219.ll (added)
+++ llvm/trunk/test/Transforms/PGOProfile/PR28219.ll Tue Jun 21 14:29:49 2016
@@ -0,0 +1,12 @@
+; 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
+
+define i32 @bar() {
+entry:
+ ret i32 1
+}
+; CHECK-DAG: {{![0-9]+}} = !{i32 1, !"ProfileSummary", {{![0-9]+}}}
+; CHECK-DAG: {{![0-9]+}} = !{!"NumFunctions", i64 2}
+; CHECK-DAG: {{![0-9]+}} = !{!"MaxFunctionCount", i64 3}
+
More information about the llvm-commits
mailing list