std::vector<Function *> HotFunctions;
std::vector<Function *> ColdFunctions;
- InstrProfSummaryBuilder Builder(ProfileSummaryBuilder::DefaultCutoffs);
for (auto &F : M) {
if (F.isDeclaration())
continue;
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
--- /dev/null
+; 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}
+