[PATCH] D21546: Fix PR28219: Use profile summary from reader and not compute it

Jake VanAdrighem via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 20 20:14:18 PDT 2016


So even after applying this patch, IRMover is still emitting an error. I
believe the root cause of this is that we do a pointer based comparison of
the metadata values. This has worked until now when we have constant values
because we unique them in the IR, but doesn't for the ProfileSummary value
which references another metadata entry. If you could, please take a look
and let me know if I'm seeing things correctly.

On Mon, Jun 20, 2016 at 6:33 PM, Easwaran Raman via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> eraman created this revision.
> eraman added reviewers: davidxl, JakeVanAdrighem.
> eraman added a subscriber: llvm-commits.
>
> This fixes the root cause of PR28219 - profile summar metadata mismatch in
> LTO mode. This probably needs an LTO test too - what would be the right
> place to have it?
>
> http://reviews.llvm.org/D21546
>
> Files:
>   lib/Transforms/Instrumentation/PGOInstrumentation.cpp
>   test/Transforms/PGOProfile/Inputs/PR28219.proftext
>   test/Transforms/PGOProfile/PR28219.ll
>
> Index: test/Transforms/PGOProfile/PR28219.ll
> ===================================================================
> --- /dev/null
> +++ 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}
> +
> Index: test/Transforms/PGOProfile/Inputs/PR28219.proftext
> ===================================================================
> --- /dev/null
> +++ test/Transforms/PGOProfile/Inputs/PR28219.proftext
> @@ -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
> Index: lib/Transforms/Instrumentation/PGOInstrumentation.cpp
> ===================================================================
> --- lib/Transforms/Instrumentation/PGOInstrumentation.cpp
> +++ lib/Transforms/Instrumentation/PGOInstrumentation.cpp
> @@ -879,7 +879,6 @@
>
>    std::vector<Function *> HotFunctions;
>    std::vector<Function *> ColdFunctions;
> -  InstrProfSummaryBuilder Builder(ProfileSummaryBuilder::DefaultCutoffs);
>    for (auto &F : M) {
>      if (F.isDeclaration())
>        continue;
> @@ -891,15 +890,13 @@
>      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
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160620/6a7904a1/attachment-0001.html>


More information about the llvm-commits mailing list