[clang] [llvm] [profcheck][coro] Adding Branch weights PGO in Coroutines Passes (PR #184466)
Jin Huang via cfe-commits
cfe-commits at lists.llvm.org
Sun Jun 28 23:42:34 PDT 2026
================
----------------
jinhuang1102 wrote:
I have added `--include-generated-funcs` as suggested. But the upstream CI now fails on `coro-noop.ll` with the following error:
```
# .---command stderr------------
# | /__w/llvm-project/llvm-project/llvm/test/Transforms/Coroutines/coro-noop.ll:30:15: error: CHECK-SAME: expected string not found in input
# | ; CHECK-SAME: ) !prof [[PROF5:![0-9]+]] {
# | ^
# | <stdin>:8:18: note: scanning from here
# | define ptr @noop() {
# | ^
# | <stdin>:13:25: note: possible intended match here
# | ; Function Attrs: nounwind memory(none)
# | ^
# | /__w/llvm-project/llvm-project/llvm/test/Transforms/Coroutines/coro-noop.ll:48:12: error: undefined variable: PROF5
# | ; CHECK: [[PROF5]] = !{!"function_entry_count", i64 1000}
# | ^
# | <stdin>:34:2: note: possible intended match here
# | !8 = !{!"function_entry_count", i64 0}
# | ^
# |
# | Input file: <stdin>
# | Check file: /__w/llvm-project/llvm-project/llvm/test/Transforms/Coroutines/coro-noop.ll
# |
# | -dump-input=help explains the following input dump.
# |
# | Input was:
# | <<<<<<
# | 1: ; ModuleID = '<stdin>'
# | 2: source_filename = "<stdin>"
# | 3:
# | 4: %NoopCoro.Frame = type { ptr, ptr }
# | 5:
# | 6: @NoopCoro.Frame.Const = private constant %NoopCoro.Frame { ptr @__NoopCoro_ResumeDestroy, ptr @__NoopCoro_ResumeDestroy }, no_sanitize_address, no_sanitize_hwaddress
# | 7:
# | 8: define ptr @noop() {
# | same:30'0 { search range start (exclusive)
# | same:30'1 error: no match found in search range
# | 9: entry:
# | 10: ret ptr @NoopCoro.Frame.Const
# | 11: }
# | 12:
# | 13: ; Function Attrs: nounwind memory(none)
# | same:30'2 ? possible intended match
# | 14: declare ptr @llvm.coro.noop() #0
# | 15:
# | 16: define internal void @__NoopCoro_ResumeDestroy(ptr %0) !dbg !5 !prof !8 {
# | same:30'3 } search range end (exclusive)
# | 17: entry:
# | 18: ret void
# | 19: }
# | 20:
# | 21: attributes #0 = { nounwind memory(none) }
# | 22:
# | 23: !llvm.dbg.cu = !{!0}
# | 24: !llvm.module.flags = !{!3, !4}
# | 25:
# | 26: !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "hand-written", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
# | 27: !1 = !DIFile(filename: "<stdin>", directory: "")
# | 28: !2 = !{}
# | 29: !3 = !{i32 2, !"Dwarf Version", i32 4}
# | 30: !4 = !{i32 2, !"Debug Info Version", i32 3}
# | check:48'0 { search range start (exclusive)
# | check:48'1 error: match failed for invalid pattern
# | check:48'2 undefined variable: PROF5
# | 31: !5 = distinct !DISubprogram(name: "__NoopCoro_ResumeDestroy", linkageName: "__NoopCoro_ResumeDestroy", scope: null, file: !1, type: !6, flags: DIFlagArtificial, spFlags: DISPFlagDefinition, unit: !0)
# | 32: !6 = !DISubroutineType(types: !7)
# | 33: !7 = !{null, null}
# | 34: !8 = !{!"function_entry_count", i64 0}
# | check:48'3 ? possible intended match
# | check:48'4 } search range end (exclusive)
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1
```
Strangely, this test passes locally in my environment, even when I configured CMake with `-DLLVM_ENABLE_ASSERTIONS=Off` to match a potential release-build behavior:
```
cmake -GNinja ../llvm -DCMAKE_C_COMPILER=clang-19 -DCMAKE_CXX_COMPILER=clang++-19 -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=Off -DCMAKE_EXPORT_COMPILE_COMMANDS=On -DLLVM_ENABLE_PROJECTS='clang;compiler-rt;lld' -DLLVM_LIT_ARGS="--exclude-xfail" -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON -DCMAKE_C_COMPILER_TARGET=x86_64-unknown-linux-gnu
```
The failure is because `noop()` function in upstream `opt` output doesn't have `!porf` metadata, while in my local `opt` output it has `!prof !5`.
Since my local workspace is clean and fully pushed, I suspect there might be some environmental or implicit CMake configuration differences that affect how PGO metadata is attached to this no-op coroutine.
Any insights on what might cause this divergence would be greatly appreciated!
https://github.com/llvm/llvm-project/pull/184466
More information about the cfe-commits
mailing list