[PATCH] D56587: Fix sign/zero extension in Dwarf expressions.
Markus Lavin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 13 23:27:31 PST 2019
markus added a comment.
In D56587#1354394 <https://reviews.llvm.org/D56587#1354394>, @vsk wrote:
> Thanks for the patch.
>
> t’s not obvious to me from skimming what the bug is with sign extension expressions. Could you describe what goes wrong, and maybe share a small program which shows the debugger behaving incorrectly?
What @bjope said and as for an example consider the following on x86
#include <stdlib.h>
short foo(short x) {
int y = x;
return y;
}
int main(int argc, char **argv) {
return foo(strtol(argv[1], NULL, 0));
}
Compiled in a somewhat contrived manner
clang dbg.c -O0 -g3 -S -emit-llvm
sed -i 's/optnone//' dbg.ll
opt -mem2reg -instcombine dbg.ll -S -o dbg.opt.ll
llc -O0 dbg.opt.ll -o dbg.s
gcc dbg.s -o dbg
gdb --args ./dbg 0xf000
(gdb) b foo
Breakpoint 1 at 0x400517: file dbg.c, line 4.
(gdb) r
Starting program: /repo/elavkje/llvm/my-dbg-test/dwarf-sext/dbg 0xf000
Breakpoint 1, foo (x=-4096) at dbg.c:4
4 return y;
(gdb) whatis x
type = short
(gdb) p y
$1 = -1
(gdb) whatis y
type = int
(gdb)
It is clear that **y should not read as -1** at that point.
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D56587/new/
https://reviews.llvm.org/D56587
More information about the llvm-commits
mailing list