[all-commits] [llvm/llvm-project] c5978f: [llvm][IR] Extend BranchWeightMetadata to track pr...

Paul Kirth via All-commits all-commits at lists.llvm.org
Mon Jun 10 11:27:42 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c5978f1eb5eeca8610b9dfce1fcbf1f473911cd8
      https://github.com/llvm/llvm-project/commit/c5978f1eb5eeca8610b9dfce1fcbf1f473911cd8
  Author: Paul Kirth <paulkirth at google.com>
  Date:   2024-06-10 (Mon, 10 Jun 2024)

  Changed paths:
    M clang/test/CodeGenCXX/attr-likelihood-if-vs-builtin-expect.cpp
    M llvm/docs/BranchWeightMetadata.rst
    M llvm/include/llvm/IR/MDBuilder.h
    M llvm/include/llvm/IR/ProfDataUtils.h
    M llvm/lib/CodeGen/CodeGenPrepare.cpp
    M llvm/lib/IR/Instruction.cpp
    M llvm/lib/IR/Instructions.cpp
    M llvm/lib/IR/MDBuilder.cpp
    M llvm/lib/IR/Metadata.cpp
    M llvm/lib/IR/ProfDataUtils.cpp
    M llvm/lib/IR/Verifier.cpp
    M llvm/lib/Transforms/IPO/SampleProfile.cpp
    M llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp
    M llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
    M llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
    M llvm/lib/Transforms/Scalar/JumpThreading.cpp
    M llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp
    M llvm/lib/Transforms/Utils/Local.cpp
    M llvm/lib/Transforms/Utils/LoopPeel.cpp
    M llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
    M llvm/lib/Transforms/Utils/SimplifyCFG.cpp
    M llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
    M llvm/test/Transforms/LowerExpectIntrinsic/basic.ll
    M llvm/test/Transforms/LowerExpectIntrinsic/expect-with-probability.ll
    M llvm/test/Transforms/LowerExpectIntrinsic/expect_nonboolean.ll
    M llvm/test/Transforms/LowerExpectIntrinsic/phi_merge.ll
    M llvm/test/Transforms/LowerExpectIntrinsic/phi_or.ll
    M llvm/test/Transforms/LowerExpectIntrinsic/phi_tern.ll
    M llvm/test/Transforms/LowerExpectIntrinsic/phi_unexpect.ll
    M llvm/test/Transforms/PhaseOrdering/AArch64/hoist-runtime-checks.ll

  Log Message:
  -----------
  [llvm][IR] Extend BranchWeightMetadata to track provenance of weights (#86609)

This patch implements the changes to LLVM IR discussed in

https://discourse.llvm.org/t/rfc-update-branch-weights-metadata-to-allow-tracking-branch-weight-origins/75032

In this patch, we add an optional field to MD_prof metadata nodes for
branch weights, which can be used to distinguish weights added from
`llvm.expect*` intrinsics from those added via other methods, e.g.
from profiles or inserted by the compiler.

One of the major motivations, is for use with MisExpect diagnostics,
which need to know if branch_weight metadata originates from an
llvm.expect intrinsic. Without that information, we end up checking
branch weights multiple times in the case if ThinLTO + SampleProfiling,
leading to some inaccuracy in how we report MisExpect related
diagnostics to users.

Since we change the format of MD_prof metadata in a fundamental way, we
need to update code handling branch weights in a number of places.

We also update the lang ref for branch weights to reflect the change.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list