[llvm-bugs] [Bug 33355] New: Loop Unswitch creates duplicated dbg.declare
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Jun 8 02:53:48 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=33355
Bug ID: 33355
Summary: Loop Unswitch creates duplicated dbg.declare
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: mattias.v.eriksson at ericsson.com
CC: llvm-bugs at lists.llvm.org
Created attachment 18591
--> https://bugs.llvm.org/attachment.cgi?id=18591&action=edit
Reproducer for duplicated dbg.declare
The function f2 has a byval argument that is dead ("dum"). f2 is
inlined into f3 and the dbg.declare is inlined to reflect
that "dum" is "p1" in the inlined code.
Input to 'Function Integration/Inlining':
; Function Attrs: nounwind readonly
define i16 @f2(%struct.S* byval nocapture readnone align 1 %dum)
local_unnamed_addr #0 !dbg !11 {
entry:
call void @llvm.dbg.declare(metadata %struct.S* %dum, metadata !18, metadata
!19), !dbg !20
%0 = load i16, i16* @a, align 1, !dbg !21, !tbaa !22
ret i16 %0, !dbg !26
}
define void @f3(%struct.S* byval align 1 %p1) local_unnamed_addr #2 !dbg !27 {
entry:
call void @llvm.dbg.declare(metadata %struct.S* %p1, metadata !31, metadata
!19), !dbg !32
br label %lbl1, !dbg !33
lbl1: ; preds = %lbl1, %entry
%call = call i16 @f2(%struct.S* byval nonnull align 1 %p1), !dbg !34
After 'Function Integration/Inlining':
; Function Attrs: nounwind
define void @f3(%struct.S* byval align 1 %p1) local_unnamed_addr #2 !dbg !27 {
entry:
call void @llvm.dbg.declare(metadata %struct.S* %p1, metadata !31, metadata
!19), !dbg !32
br label %lbl1, !dbg !33
lbl1: ; preds = %lbl1, %entry
call void @llvm.dbg.declare(metadata %struct.S* %p1, metadata !18, metadata
!19), !dbg !34
%0 = load i16, i16* @a, align 1, !dbg !36, !tbaa !22
call void @f1(i16 %0), !dbg !37
Some relevant metadata:
!18 = !DILocalVariable(name: "dum", arg: 1, scope: !11, file: !3, line: 8,
type: !14)
!19 = !DIExpression()
!31 = !DILocalVariable(name: "p1", arg: 1, scope: !27, file: !3, line: 15,
type: !14)
A while later, 'Unswitch loops' duplicates dum's dbg.declare:
define void @f3(%struct.S* byval nocapture readonly align 1 %p1)
local_unnamed_addr #2 !dbg !27 {
...
lbl1.us: ; preds = %lbl1.us,
%entry.split.us
call void @llvm.dbg.declare(metadata %struct.S* %p1, metadata !18, metadata
!19), !dbg !34
%1 = load i16, i16* @a, align 1, !dbg !36, !tbaa !22
call void @f1(i16 %1), !dbg !37
...
lbl1: ; preds = %lbl1, %entry.split
call void @llvm.dbg.declare(metadata %struct.S* %p1, metadata !18, metadata
!19), !dbg !34
%2 = load i16, i16* @a, align 1, !dbg !36, !tbaa !22
call void @f1(i16 %2), !dbg !37
And then in the late stages of llc I get a crash in DwarfDebug
because it expects that there can't be duplicate dbg.declares.
(Same assertion as in bug 33157.)
I am a bit confused about how dbg.declare is supposed to work in
this case. The documentation says: "This intrinsic provides
information about a local element (e.g., variable). The first
argument is metadata holding the alloca for the variable." But
there is no alloca associated with %p1 here. Is this an omission
in the documentation?
Are duplicated dbg.declares allowed? Then the bug is in
DwarfDebug for crashing, not in loop unswitch.
Reproduce like this:
opt -S -inline -functionattrs -licm -loop-unswitch -o - inline.ll | grep
dbg.declare | sort | uniq -c
1 call void @llvm.dbg.declare(metadata %struct.S* %dum, metadata !18,
metadata !19), !dbg !20
2 call void @llvm.dbg.declare(metadata %struct.S* %p1, metadata !18,
metadata !19), !dbg !34
1 call void @llvm.dbg.declare(metadata %struct.S* %p1, metadata !31,
metadata !19), !dbg !32
1 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
--
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/20170608/295febf7/attachment.html>
More information about the llvm-bugs
mailing list