| Issue |
242754
|
| Summary |
[AMDGPU][R600] A debug use keeps an LDS atomic in its _RET form
|
| Labels |
backend:AMDGPU,
debuginfo
|
| Assignees |
|
| Reporter |
yqtian-se
|
With `-g`, an LDS atomic whose result is only used by a debug value keeps its
`_RET` form (`LDS_ADD_RET` plus a read of `OQAP`), so the code differs from
`-g0`, which emits `LDS_ADD`.
Reproducer (`input.cl`):
```c
kernel void f(local int *p, int v) { int r = __atomic_fetch_add(p, v, __ATOMIC_SEQ_CST); }
```
R600 has no disassembler, so compare the assembly:
```sh
clang --target=r600-- -mcpu=cypress -O2 -nogpulib -g -S input.cl -o g.s
clang --target=r600-- -mcpu=cypress -O2 -nogpulib -g0 -S input.cl -o g0.s
diff g0.s g.s # compare the instruction lines; debug directives also differ
```
Actual (`-g0` vs `-g`, LLVM main `9ce8918945cf`; the `.text` bytes also differ):
```diff
- ALU 2, @0, KC0[CB0:0-32], KC1[]
- MOV T0.W, KC0[2].Y,
+ ALU 0, @4, KC0[CB0:0-32], KC1[]
+ ALU 0, @5, KC0[CB0:0-32], KC1[]
+ ALU 1, @6, KC0[], KC1[]
+ CF_END
+ ALU clause starting at 4:
+ MOV * T0.W, KC0[2].Y,
+ ALU clause starting at 5:
MOV * T1.W, KC0[2].Z,
- LDS_ADD * T0.W, T1.W,
- RETURN
+ ALU clause starting at 6:
+ LDS_ADD_RET * OQAP, T0.W, T1.W,
+ MOV * T0.X, OQAP,
```
Expected: `LDS_ADD` in one clause under `-g` too.
**Possible cause.** The R600 custom inserter
(https://github.com/llvm/llvm-project/blob/9ce8918945cf/llvm/lib/Target/AMDGPU/R600ISelLowering.cpp#L232) switches an `LDS_*_RET`
to the no-return form only when `MRI.use_empty()` of its result. The
`DBG_VALUE` of `r` counts as a use, so the `_RET` form is kept under `-g`.
Checking `use_nodbg_empty()` would fix the RET/NORET choice; the debug use of
the result would then have to be set undef, as the value is no longer computed.
**Overlap with #229631.** The difference above has two causes. This issue is
the `_RET`/no-return choice. The extra clause splits are #229631 (R600 post-RA
passes treat `DBG_VALUE` as an ordinary instruction when forming clauses).
On this source, a build with only the `use_empty` change still differs in the
clauses, and a build with only the clause changes still emits `LDS_ADD_RET`;
both are needed for equal output.
This issue is assisted by Claude and reviewed by yqtian-se.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs