Open tvivies-amd opened 2 years ago
@llvm/issue-subscribers-debuginfo
I wonder if it is possible to save the debug info for the alloca Inst before it *is being eliminated and also have metadata about the %pixels1
alloca return value, as in: https://alive2.llvm.org/ce/z/_n-rjA
Note lines 17-18 in the tgt function. The question is what kind of resulting IR would we want after rewriting the uses of the operand of the dying instruction. Like line 17 or like line 18 (which is more about the GEP after the bitcast replacement?)
This is a good find, thanks for reporting the dropped variable location -- I'm not familiar with the transformation being performed, but would have expected RAUW to just swap one alloca for another, so this is a mild surprise,
Note lines 17-18 in the tgt function. The question is what kind of resulting IR would we want after rewriting the uses of the operand of the dying instruction.
I'd suggest line 17 is preferred -- there are various portions of code that try to match dbg.declare
s with alloca
s, it's easier if there's nothing in the way, and dbg.declare
aims only to identify the storage for a variable, not how it's used.
Thank you. We have corrected this so we will match the dbg.declare
with the alloca
instead and there is no new dbg.declare
on the GEP.
; CHECK-LABEL: define dso_local i8* @toplevel(
; CHECK: entry:
; CHECK-NEXT: %pixels1 = alloca [1500 x i8], align 8
; CHECK-NEXT: call void @llvm.dbg.declare(metadata [1500 x i8]* %pixels1, metadata !7, metadata !DIExpression()), !dbg !12
; CHECK-NEXT: %pixels1.sub = getelementptr inbounds [1500 x i8], [1500 x i8]* %pixels1, i64 0, i64 0
; CHECK-NEXT: ret i8* %pixels1.sub
define dso_local i8* @toplevel() {
entry:
%pixels = alloca [500 x %struct.Pixel]
call void @llvm.dbg.declare(metadata [500 x %struct.Pixel]* %pixels, metadata !11, metadata !DIExpression()), !dbg !12
%arraydecay = bitcast [500 x %struct.Pixel]* %pixels to i8*
ret i8* %arraydecay
}
as shown in the resulting IR after -instcombine
is in the CHECK lines.
Sweet, please do add me on the relevant review!
For the following IR after running instruction combine pass the operand of the
dbg.declare
intrinsic call is undef which make the call invalid. https://godbolt.org/z/qxn97vWrd