[llvm] [PGO] Add ProfileInjector and ProfileVerifier passes (PR #147388)
Mircea Trofin via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 21 08:12:26 PDT 2025
================
@@ -0,0 +1,20 @@
+; Test that prof-inject only injects missing metadata
+
+; RUN: opt -passes=prof-inject %s -S -o - | FileCheck %s
+
+define void @foo(i32 %i) {
+ %c = icmp eq i32 %i, 0
+ br i1 %c, label %yes, label %no, !prof !0
+yes:
+ br i1 %c, label %yes2, label %no
+yes2:
+ ret void
+no:
+ ret void
+}
+
+!0 = !{!"branch_weights", i32 1, i32 2}
+; CHECK: br i1 %c, label %yes, label %no, !prof !0
+; CHECK: br i1 %c, label %yes2, label %no, !prof !1
+; CHECK: !0 = !{!"branch_weights", i32 1, i32 2}
+; CHECK: !1 = !{!"branch_weights", i32 429496729, i32 715827882}
----------------
mtrofin wrote:
In inject, we get the Branch Probability Info. If there's no profile info, that analysis will compute some guesstimate (we can use profi later, but same idea). Inject will turn around and insert those branch probabilities as metadata.
https://github.com/llvm/llvm-project/pull/147388
More information about the llvm-commits
mailing list