[PATCH] D75326: [entry values] X86: Describe effects of MOV{8,16}ri (PR45053)
David Stenberg via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 2 03:53:56 PST 2020
dstenb added a comment.
In D75326#1898465 <https://reviews.llvm.org/D75326#1898465>, @vsk wrote:
> If OP_piece in an entry value really /is/ an issue, please confirm, and I'll update the x86 describeLoadedValue to just return 'None' for mov{8,16}ri (it doesn't seem worth it to me to do anything more complicated).
I applied this patch on top of 5900d3f2e94f710d73a89931953ce0a3d928c70d <https://reviews.llvm.org/rG5900d3f2e94f710d73a89931953ce0a3d928c70d>. I was unable to get the IR reproducer listed here up and running, but I tried it out with the following example:
caller.c:
extern int call(int);
int main() {
call(0x11223344);
return 0;
}
callee.c:
int global;
int call(int param) {
global = param; // side effect to keep param.
asm __volatile("movl $0xdeadbeef, %%edi" : : : "rdi"); // clobber reg.
return 0; // print param here.
}
in which I changed the parameter setup to:
$edi = MOV32ri 287454020, debug-location !15 ; 0x11223344
$di = MOV16ri 21862, debug-location !15 ; 0x5566
CALL64pcrel32 @call, csr_64, implicit $rsp, implicit $ssp, implicit killed $edi, implicit-def $rsp, implicit-def $ssp, implicit-def dead $eax, debug-location !15
producing the following call site parameter entry:
0x00000050: DW_TAG_GNU_call_site_parameter
DW_AT_location (DW_OP_reg5 RDI)
DW_AT_GNU_call_site_value (DW_OP_constu 0x5566, DW_OP_stack_value, DW_OP_piece 0x2)
and the following location list for the parameter in the callee:
DW_AT_location (0x00000000:
[0x0000000000201110, 0x000000000020111b): DW_OP_reg5 RDI
[0x000000000020111b, 0x000000000020111e): DW_OP_GNU_entry_value(DW_OP_reg5 RDI), DW_OP_stack_value)
When I print that in GDB 8.2.1, `0x5566` is printed instead of `0x11225566` which is the actual parameter value:
(gdb) print /x param
$1 = 0x5566
(gdb) disas
Dump of assembler code for function call:
0x0000000000201110 <+0>: mov %edi,0x2eea(%rip) # 0x204000 <global>
0x0000000000201116 <+6>: mov $0xdeadbeef,%edi
=> 0x000000000020111b <+11>: xor %eax,%eax
0x000000000020111d <+13>: retq
End of assembler dump.
With LLDB trunk (5900d3f2e94f710d73a89931953ce0a3d928c70d <https://reviews.llvm.org/rG5900d3f2e94f710d73a89931953ce0a3d928c70d>), the clobbered register value (0xdeadbeef) is printed, even though the address is covered by an entry value (compare the PC to the location list printed above):
(lldb) print param
(int) $0 = 0xdeadbeef
(lldb) disas
a.out`call:
0x201110 <+0>: movl %edi, 0x2eea(%rip) ; global
0x201116 <+6>: movl $0xdeadbeef, %edi ; imm = 0xDEADBEEF
-> 0x20111b <+11>: xorl %eax, %eax
0x20111d <+13>: retq
I'm not very familiar with LLDB (especially when using entry values), so sorry if I have overlooked something and that is only a user error!
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D75326/new/
https://reviews.llvm.org/D75326
More information about the llvm-commits
mailing list