<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/110482>110482</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang 18.1.8 generates incorrect debug info for double precison float parameter at optimisation level -O1 (ARM cortex-m4, soft float target)
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Rick-Brewin
</td>
</tr>
</table>
<pre>
Self-contained reproduction C source code attached as a text file: [repro.c.txt](https://github.com/user-attachments/files/17188039/repro.c.txt)
Building the above source with the following compiler options:
`-mcpu=cortex-m4 -mthumb -target arm-none-eabi -fshort-enums -fsigned-char -gdwarf-4 -fomit-frame-pointer -g -O1 -mfloat-abi=soft -save-temps`
.... generates an incorrect register pair (R2,R4) in the debug info describing the location of parameter "ian" in function "lets_go()". While the debug experience at optimisation levels higher than -O0 can be fragmented, the compiler should prefer to output no location info at all instead of misleading location info. The debugger (in this case GNU gdb (Ubuntu 9.2-0ubuntu1~20.04.2) 9.2) has no way to detect that the location description is inaccurate.
GDB output, connecting to qemu-system-gnuarmeclipse 2.8.0:
```
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from repro.elf...
(gdb) b lets_go
Breakpoint 1 at 0x106: file repro.c, line 14.
(gdb) target remote localhost:12345
Remote debugging using localhost:12345
main () at repro.c:4
4 {
(gdb) c
Continuing.
Breakpoint 1, lets_go (phil=<optimized out>, grant=1.1754920000000001e-308, dot=<optimized out>, ethel=<optimized out>, ian=1.1754909290959615e-308) at repro.c:14
14 double pat = ethel + ian; /* first natural breakpoint in lets_go() is here; ian has incorrect register location description at -O1 */
(gdb)
```
As we can see, parameter "ian" is described as having the value 1.1754909290959615e-308, but the correct value is 128966e+150.
Generated debug information, collected using objdump -W:
Variable description for various parameters, including 'ian':
```
<1><7e>: Abbrev Number: 3 (DW_TAG_subprogram)
<7f> DW_AT_low_pc : 0xf0
<83> DW_AT_high_pc : 0xd0
<87> DW_AT_frame_base : 1 byte block: 5d (DW_OP_reg13 (r13))
<89> DW_AT_GNU_all_call_sites: 1
<89> DW_AT_name : (indirect string, offset: 0x1c4): lets_go
<8d> DW_AT_decl_file : 1
<8e> DW_AT_decl_line : 11
<8f> DW_AT_prototyped : 1
<8f> DW_AT_type : <0xf9>
<93> DW_AT_external : 1
<2><93>: Abbrev Number: 5 (DW_TAG_formal_parameter)
<94> DW_AT_location : 0x91 (location list)
<98> DW_AT_name : (indirect string, offset: 0x276): phil
<9c> DW_AT_decl_file : 1
<9d> DW_AT_decl_line : 11
<9e> DW_AT_type : <0xf9>
<2><a2>: Abbrev Number: 5 (DW_TAG_formal_parameter)
<a3> DW_AT_location : 0xc7 (location list)
<a7> DW_AT_name : (indirect string, offset: 0x21b): grant
<ab> DW_AT_decl_file : 1
<ac> DW_AT_decl_line : 11
<ad> DW_AT_type : <0xf9>
<2><b1>: Abbrev Number: 5 (DW_TAG_formal_parameter)
<b2> DW_AT_location : 0xee (location list)
<b6> DW_AT_name : (indirect string, offset: 0xfc): dot
<ba> DW_AT_decl_file : 1
<bb> DW_AT_decl_line : 11
<bc> DW_AT_type : <0xf9>
<2><c0>: Abbrev Number: 6 (DW_TAG_formal_parameter)
<c1> DW_AT_name : (indirect string, offset: 0x397): ethel
<c5> DW_AT_decl_file : 1
<c6> DW_AT_decl_line : 11
<c7> DW_AT_type : <0xf9>
<2><cb>: Abbrev Number: 5 (DW_TAG_formal_parameter)
<cc> DW_AT_location : 0x0 (location list)
<d0> DW_AT_name : (indirect string, offset: 0x5af): ian
<d4> DW_AT_decl_file : 1
<d5> DW_AT_decl_line : 11
<d6> DW_AT_type : <0xf9>
```
Location list info for parameter "ian":
```
Contents of the .debug_loc section:
Offset Begin End Expression
00000000 000000f8 000000fe (DW_OP_piece: 4; DW_OP_reg3 (r3); DW_OP_piece: 4)
0000000f 000000fe 00000104 (DW_OP_piece: 4; DW_OP_reg4 (r4); DW_OP_piece: 4)
0000001e 00000104 0000010c (DW_OP_reg2 (r2); DW_OP_piece: 4; DW_OP_reg4 (r4); DW_OP_piece: 4)
0000002e 0000010c 0000011c (DW_OP_piece: 4; DW_OP_reg4 (r4); DW_OP_piece: 4)
0000003d 0000011c 00000120 (DW_OP_reg2 (r2); DW_OP_piece: 4; DW_OP_reg4 (r4); DW_OP_piece: 4)
0000004d 00000120 00000128 (DW_OP_reg2 (r2); DW_OP_piece: 4; DW_OP_reg3 (r3); DW_OP_piece: 4)
0000005d <End of list>
```
Relevant location at breakpoint (PC 0x106):
```
0000001e 00000104 0000010c (DW_OP_reg2 (r2); DW_OP_piece: 4; DW_OP_reg4 (r4); DW_OP_piece: 4)
```
This incorrectly states that 'ian' is located in registers r2 and r4.
The generated assembly for the beginning of lets_go (harvested from -save-temps) states:
```
lets_go:
.Lfunc_begin1:
.loc 1 12 0 is_stmt 1 @ repro.c:12:0
.fnstart
.cfi_startproc
@ %bb.0:
.save {r4, r5, r6, r7, r8, r9, r10, r11, lr}
push.w {r4, r5, r6, r7, r8, r9, r10, r11, lr}
.cfi_def_cfa_offset 36
.cfi_offset lr, -4
.cfi_offset r11, -8
.cfi_offset r10, -12
.cfi_offset r9, -16
.cfi_offset r8, -20
.cfi_offset r7, -24
.cfi_offset r6, -28
.cfi_offset r5, -32
.cfi_offset r4, -36
.pad #4
sub sp, #4
.cfi_def_cfa_offset 40
mov r10, r1
.Ltmp5:
@DEBUG_VALUE: lets_go:ian <- [DW_OP_LLVM_fragment 32 32] $r3
ldrd r7, r1, [sp, #48]
.Ltmp6:
@DEBUG_VALUE: lets_go:sharon <- 5.990000e-200
@DEBUG_VALUE: lets_go:ethel <- undef
mov r4, r3
.Ltmp7:
@DEBUG_VALUE: lets_go:ian <- [DW_OP_LLVM_fragment 32 32] $r4
mov r5, r2
ldrd r2, r3, [sp, #56]
@DEBUG_VALUE: lets_go:phil <- [DW_OP_LLVM_fragment 0 32] undef
.Ltmp8:
@DEBUG_VALUE: lets_go:phil <- [DW_OP_LLVM_fragment 32 32] $r10
@DEBUG_VALUE: lets_go:grant <- [DW_OP_LLVM_fragment 0 32] $r5
@DEBUG_VALUE: lets_go:grant <- [DW_OP_LLVM_fragment 32 32] $r4
@DEBUG_VALUE: lets_go:dot <- [DW_OP_LLVM_fragment 0 32] undef
@DEBUG_VALUE: lets_go:dot <- [DW_OP_LLVM_fragment 32 32] undef
@DEBUG_VALUE: lets_go:ian <- [DW_OP_LLVM_fragment 0 32] $r2
mov r11, r0
.Ltmp9:
.loc 1 14 24 prologue_end @ repro.c:14:24
mov r0, r7
```
Corresponding disassembly up to the breakpoint site (PC 0x106):
```
000000f0 <lets_go>:
f0: e92d 4ff0 stmdb sp!, {r4, r5, r6, r7, r8, r9, sl, fp, lr}
f4: b081 sub sp, #4
f6: 468a mov sl, r1
f8: e9dd 710c ldrd r7, r1, [sp, #48] ; 0x30
fc: 461c mov r4, r3
fe: 4615 mov r5, r2
100: e9dd 230e ldrd r2, r3, [sp, #56] ; 0x38
104: 4683 mov fp, r0
106: 4638 mov r0, r7
```
Please let me know if any other information would be useful to reproduce this.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzEWk9zo7qy_zTKpgsKBLZhkUUSJ7OZc-bUvJkzS5eAxugMSDxJxMlbvM9-SxLY2HGczJ97L5XCBFo_df-61WoJmNZ8KxCvyeKWLNZXbDCNVNefefk9uFW44-KqkNXz9f9gWwelFIZxgRUo7JWshtJwKeAOtBxUiVDKCoEZw8oGK2AaGBh8MlDzFklyA2Rx6xqGZWieDFmsCc0aY3pNkhtCHwh92HLTDEVYyo7Qh0GjCjxch8JoQh8skv2NV3GWRUlO6MMckeYkWpPoxp9vB95WXGzBNAiskI84KbrjpnF3a9m2cmdlStn1vEUFsrdGOZVmWGQZBV3ZDyRZl1IZfAq6FILONENXQGCY2qIBprpASIEBsoJDUOtGKhOgGDpt_7NEV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