[llvm] [CSSPGO] Return error_code for missing probe profile (PR #102085)
Lei Wang via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 5 17:56:58 PDT 2024
================
@@ -0,0 +1,327 @@
+; RUN: opt < %s -passes=sample-profile --overwrite-existing-weights -sample-profile-file=%S/Inputs/pseudo-probe-missing-probe.prof | opt -passes='print<branch-prob>' -disable-output 2>&1 | FileCheck %s
+
+; CHECK: edge %while.body -> %if.then probability is 0x7212005e / 0x80000000 = 89.12% [HOT edge]
+; CHECK: edge %while.body -> %if.else probability is 0x0dedffa2 / 0x80000000 = 10.88%
+
+; CHECK-NOT: edge %while.body -> %if.then probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
+; CHECK-NOT: edge %while.body -> %if.else probability is 0x00000000 / 0x80000000 = 0.00%
+
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+ at x = dso_local global i32 0, align 4, !dbg !0
+
+; Function Attrs: noinline nounwind uwtable
+define dso_local void @bar(i32 noundef %i) #0 !dbg !47 !prof !52 {
----------------
wlei-llvm wrote:
> This test case is quite large. Feels like it can be simplified as we only need the input profile to miss a probe?
>
> Also why do we need to have `!prof` on the input IR? I thought we just want to make sure we have non-zero profile attached after profile loading, so we don't need profile metadata on input, and we don't need `--overwrite-existing-weights`. Relatedly, we can check `!prof` of output IR, rather than relying on printing BPI?
It's kind of on purpose, for the reason:
1) As mentioned in my last comment, I need an inlined case to repro the "null" return value for `findFunctionSamples `, so this needs a post-link IR. Also use `--overwrite-existing-weights` to be exactly repro the issue.
2) Profile inference(both PROFI or non-PROFI) will try "fix" the unreasonable count, for simple small case, e.g. a simple if-else.
```
100 100
0 0 unknown unknown
100 100
```
I can't repro the issue. the unreasonable 0 count is also fixed into a even flow (50 - 50).
>Relatedly, we can check !prof of output IR, rather than relying on printing BPI?
Sounds good.
https://github.com/llvm/llvm-project/pull/102085
More information about the llvm-commits
mailing list