| Issue |
235238
|
| Summary |
[SPARC] leaf functions: argument locations still name %i registers, gdb shows wrong values
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
shalseth
|
In a leaf function gdb shows the wrong value for the arguments when the code is built with clang:
```c
struct foo { long b; int a; };
__attribute__((noinline)) int get(struct foo *p)
{
return p->a;
}
int main(void)
{
static volatile struct foo foo = { 1, 2 };
struct foo f = foo;
return get(&f) != 2;
}
```
```
$ clang -g -O2 -o leaf leaf.c
$ gdb -batch -ex 'break get' -ex run -ex 'info registers o0 i0' ./leaf
Breakpoint 1, get (p=0x1) at leaf.c:5
5 return p->a;
o0 0x7fefffff448 8791798051912
i0 0x1 1
```
`get` doesn't open a register window, so `p` is in %o0, but the DWARF says %i0:
```
00000000000007e0 <get>:
7e0: retl
7e4: ldsw [ %o0 + 8 ], %o0
DW_AT_frame_base (DW_OP_reg30 I6)
DW_AT_name ("get")
DW_AT_location (DW_OP_reg24 I0)
DW_AT_name ("p")
```
gcc 16.2 does open a window here (`save` / `return %i7 + 8`) and describes `p` with a location list, and gdb shows `p=0x7fefffff448` with that build, so it's not a direct comparison, but at least gdb itself seems fine.
Looking at `-print-after-all`, the load is rewritten to %o0 by prolog-epilog, but the DBG_VALUE for `p` isn't:
```
After Virtual Register Rewriter:
DBG_VALUE $i0, $noreg, !"p", !DIExpression(), debug-location !33; leaf.c:0 line no:3
renamable $i0 = LDSWri killed renamable $i0, 8, debug-location !35
After Prologue/Epilogue Insertion & Frame Finalization:
DBG_VALUE $i0, $noreg, !"p", !DIExpression(), debug-location !33; leaf.c:0 line no:3
$o0 = LDSWri killed $o0, 8, debug-location !35
```
In a Rust build of a similar function (rustc's `tests/debuginfo/opt/dead_refs.rs`) the other DBG_VALUEs on the same value do end up as `$o0` and only the argument one keeps `$i0`, so it seems to be that one in particular that's missed.
`DW_AT_frame_base` is also %i6 in a function that never does `save`. Nothing in this example uses it, so I don't know if that matters in practice.
clang 23.1.4, GCC 16.2.1, gdb 18.1, UltraSPARC T4-1, Linux sparc64.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs