[llvm-bugs] [Bug 34545] New: DBG_VALUE being lost in LiveDebugVariables
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Sep 11 02:31:02 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=34545
Bug ID: 34545
Summary: DBG_VALUE being lost in LiveDebugVariables
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Common Code Generator Code
Assignee: unassignedbugs at nondot.org
Reporter: karl-johan.karlsson at ericsson.com
CC: llvm-bugs at lists.llvm.org
The program:
volatile int var = 8;
volatile unsigned sc = 1;
int main() {
int bazinga = var;
bazinga <<= sc;
var = bazinga;
return bazinga;
}
Compile with:
clang -S -emit-llvm -Xclang -O1 --target=x86_64-unknown-linux-gnu -g 'bar.c' -o
'./bar.ll'
opt -mcpu=x86-64 -O1 -S -o './bar.opt.ll' './bar.ll'
llc -O1 -filetype=obj -mtriple x86_64-unknown-linux-gnu -mcpu=x86-64 -o
'./bar.obj' './bar.opt.ll'
Adding the options -print-after-all and -debug to the llc binary show:
Before LiveDebugVariables:
# *** IR Dump After Machine Instruction Scheduler ***:
# Machine code for function main: NoPHIs, TracksLiveness
0B BB#0: derived from LLVM BB %entry
16B %vreg3<def> = MOV32rm %RIP, 1, %noreg, <ga:@var>, %noreg;
mem:Volatile LD4[@var](tbaa=!23)(dereferenceable) GR32:%vreg3 dbg:bar.c:4:17
DBG_VALUE %vreg3, %noreg, !"bazinga", <!DIExpression()>;
GR32:%vreg3 line no:4
32B %vreg1<def> = MOV32rm %RIP, 1, %noreg, <ga:@sc>, %noreg;
mem:Volatile LD4[@sc](tbaa=!23)(dereferenceable) GR32:%vreg1 dbg:bar.c:5:15
64B %CL<def> = COPY %vreg1:sub_8bit; GR32:%vreg1 dbg:bar.c:5:11
96B %vreg3<def,tied1> = SHL32rCL %vreg3<tied0>,
%EFLAGS<imp-def,dead>, %CL<imp-use,kill>; GR32:%vreg3 dbg:bar.c:5:11
DBG_VALUE %vreg3, %noreg, !"bazinga", <!DIExpression()>;
GR32:%vreg3 line no:4
112B MOV32mr %RIP, 1, %noreg, <ga:@var>, %noreg, %vreg3;
mem:Volatile ST4[@var](tbaa=!23) GR32:%vreg3 dbg:bar.c:6:7
128B %EAX<def> = COPY %vreg3; GR32:%vreg3 dbg:bar.c:7:3
144B RET 0, %EAX<kill>; dbg:bar.c:7:3
Debug variables are computed (the range for the variable bazinga ends before
slot idx 128):
********** COMPUTING LIVE DEBUG VARIABLES: main **********
********** DEBUG VARIABLES **********
!"bazinga,4" [16r;128r):0 Loc0=%vreg3
# *** IR Dump After Debug Variable Analysis ***:
# Machine code for function main: NoPHIs, TracksLiveness
0B BB#0: derived from LLVM BB %entry
16B %vreg3<def> = MOV32rm %RIP, 1, %noreg, <ga:@var>, %noreg;
mem:Volatile LD4[@var](tbaa=!23)(dereferenceable) GR32:%vreg3 dbg:bar.c:4:17
32B %vreg1<def> = MOV32rm %RIP, 1, %noreg, <ga:@sc>, %noreg;
mem:Volatile LD4[@sc](tbaa=!23)(dereferenceable) GR32:%vreg1 dbg:bar.c:5:15
64B %CL<def> = COPY %vreg1:sub_8bit; GR32:%vreg1 dbg:bar.c:5:11
96B %vreg3<def,tied1> = SHL32rCL %vreg3<tied0>,
%EFLAGS<imp-def,dead>, %CL<imp-use,kill>; GR32:%vreg3 dbg:bar.c:5:11
112B MOV32mr %RIP, 1, %noreg, <ga:@var>, %noreg, %vreg3;
mem:Volatile ST4[@var](tbaa=!23) GR32:%vreg3 dbg:bar.c:6:7
128B %EAX<def> = COPY %vreg3; GR32:%vreg3 dbg:bar.c:7:3
144B RET 0, %EAX<kill>; dbg:bar.c:7:3
Later in the log we see this:
********** EMITTING LIVE DEBUG VARIABLES **********
!"bazinga,4" [16r;128r):0 Loc0=%vreg3
[16r;128r):0 BB#0-160B
# *** IR Dump After Virtual Register Rewriter ***:
# Machine code for function main: NoPHIs, TracksLiveness, NoVRegs
0B BB#0: derived from LLVM BB %entry
16B %EAX<def> = MOV32rm %RIP, 1, %noreg, <ga:@var>, %noreg;
mem:Volatile LD4[@var](tbaa=!23)(dereferenceable) dbg:bar.c:4:17
DBG_VALUE %EAX, %noreg, !"bazinga", <!DIExpression()>; line
no:4
32B %ECX<def> = MOV32rm %RIP, 1, %noreg, <ga:@sc>, %noreg;
mem:Volatile LD4[@sc](tbaa=!23)(dereferenceable) dbg:bar.c:5:15
64B %CL<def> = KILL %CL, %ECX<imp-use,kill>; dbg:bar.c:5:11
96B %EAX<def,tied1> = SHL32rCL %EAX<kill,tied0>,
%EFLAGS<imp-def,dead>, %CL<imp-use>; dbg:bar.c:5:11
112B MOV32mr %RIP, 1, %noreg, <ga:@var>, %noreg, %EAX; mem:Volatile
ST4[@var](tbaa=!23) dbg:bar.c:6:7
144B RET 0, %EAX; dbg:bar.c:7:3
The LiveDebugVariables pass has re-inserted DBG_VALUEs. But the DBG_VALUE after
the SHL32rCL is now gone.
This must be a fault, since DwarfDebug will end the range for a debug variable
when the physical reg is defined, or at basic block end. So I think that
LiveDebugVariables must insert new DBG_VALUE instructions whenever the physical
register that the debug variable is connected to is updated (within the slot
idx
range).
If trying the binary in gdb and trying to print the variable bazinga after the
shift it show <optimized out>.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170911/bc6fad62/attachment.html>
More information about the llvm-bugs
mailing list