[flang-commits] [flang] [llvm] [OpenMPIRBuilder] Clear the debug location when emitting reduction helpers (PR #211395)
Spencer Bryngelson via flang-commits
flang-commits at lists.llvm.org
Thu Jul 23 06:40:36 PDT 2026
sbryngelson wrote:
CI caught a real gap in this patch, now fixed.
Clearing the builder's debug location at the top of the helper is not sufficient. `emitInterWarpCopyFunction` emits two `kmpc_barrier` calls that forward the caller's location explicitly:
```cpp
createBarrier(LocationDescription(Builder.saveIP(), Loc.DL), ...)
```
`createBarrier` calls `updateToLocation`, which re-establishes that location part way through the helper, so everything after the first barrier is scoped to the kernel again. On current `main` that leaves 58 `!dbg` in `_omp_reduction_inter_warp_copy_func`, and the first one resolves to the kernel's subprogram:
```
!27 = !DILocation(line: 28, column: 9, scope: !6)
!6 = distinct !DISubprogram(name: "__omp_offloading_..._k__l28", ...)
```
That is the bug this PR is meant to fix, so the test was right to fail. Both barriers now pass `DebugLoc()`.
I had verified the earlier revision against `02c51adb8ff2`, where this does not reproduce, and did not re-check on tip before pushing. My mistake.
Re-verified on `d1d3891077f6`:
| suite | result |
|---|---|
| check-flang | 4608 passed, 11 expected failures, 0 failures |
| clang/test/OpenMP | 1573 passed |
| mlir/test/Target/LLVMIR | 406 passed |
| OpenMPIRBuilder unit tests | 101 passed |
The test fails without the change and passes with it.
https://github.com/llvm/llvm-project/pull/211395
More information about the flang-commits
mailing list