From 604d3935d1816f28479562be67c7f96b49c2a951 Mon Sep 17 00:00:00 2001 From: Easwaran Raman Date: Tue, 21 Jun 2016 19:29:49 +0000 Subject: [PATCH] Fix PR28219: Use profile summary from reader and not compute it Differentiaal revision: http://reviews.llvm.org/D21546 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273301 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../Instrumentation/PGOInstrumentation.cpp | 5 +---- test/Transforms/PGOProfile/Inputs/PR28219.proftext | 10 ++++++++++ test/Transforms/PGOProfile/PR28219.ll | 12 ++++++++++++ 3 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 test/Transforms/PGOProfile/Inputs/PR28219.proftext create mode 100644 test/Transforms/PGOProfile/PR28219.ll diff --git a/lib/Transforms/Instrumentation/PGOInstrumentation.cpp b/lib/Transforms/Instrumentation/PGOInstrumentation.cpp index 6168f9ef77d..27f32b3de56 100644 --- a/lib/Transforms/Instrumentation/PGOInstrumentation.cpp +++ b/lib/Transforms/Instrumentation/PGOInstrumentation.cpp @@ -879,7 +879,6 @@ static bool annotateAllFunctions( std::vector HotFunctions; std::vector 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 diff --git a/test/Transforms/PGOProfile/Inputs/PR28219.proftext b/test/Transforms/PGOProfile/Inputs/PR28219.proftext new file mode 100644 index 00000000000..7ebc13cd128 --- /dev/null +++ b/test/Transforms/PGOProfile/Inputs/PR28219.proftext @@ -0,0 +1,10 @@ +# :ir is the flag to indicate this is IR level profile. +:ir +@bar +256 +1 +2 +@foo +512 +1 +3 diff --git a/test/Transforms/PGOProfile/PR28219.ll b/test/Transforms/PGOProfile/PR28219.ll new file mode 100644 index 00000000000..a0e1904c333 --- /dev/null +++ b/test/Transforms/PGOProfile/PR28219.ll @@ -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} + -- 2.50.1