[llvm-dev] Dangling debug value or bug in argument elimination pass?

Sergei Larin via llvm-dev llvm-dev at lists.llvm.org
Fri Apr 15 11:56:25 PDT 2016


 

I will start from afar… When a dead function argument is removed, should we keep around the debug info for it?

 

I have the following case:

 

define internal fastcc void @foo(i8* %aa, i8* %reg, i8* %field, i32 %bb, ...) unnamed_addr #3 !dbg !28 {

entry:

  call void @llvm.dbg.value(metabb i8* %aa, i64 0, metabb !34, metabb !47), !dbg !57

  call void @llvm.dbg.value(metabb i8* %reg, i64 0, metabb !35, metabb !47), !dbg !58

  call void @llvm.dbg.value(metabb i8* %field, i64 0, metabb !36, metabb !47), !dbg !59

  call void @llvm.dbg.value(metabb i32 %bb, i64 0, metabb !37, metabb !47), !dbg !60

 

During dead argument elimination pass, some of the arguments are found “dead” (which they are) and removed, without removing  their correspondent llvm.dbg.value:

 

...

DAE - Removing argument 1 (reg) from foo

DAE - Removing argument 2 (field) from foo

...

…

 

define internal fastcc void @foo(i8* %aa, i32 %bb, ...) unnamed_addr #3 !dbg !28 {

entry:

  call void @llvm.dbg.value(metabb !2, i64 0, metabb !34, metabb !47), !dbg !57

  call void @llvm.dbg.value(metabb i8* null, i64 0, metabb !35, metabb !47), !dbg !58

  call void @llvm.dbg.value(metabb i8* null, i64 0, metabb !36, metabb !47), !dbg !59

  call void @llvm.dbg.value(metabb !2, i64 0, metabb !37, metabb !47), !dbg !60

 

>From that point on we carry dead debug info and correspondent metadata (DILocalVariable):

 

!33 = !{!34, !35, !36, !37, ...}

!34 = !DILocalVariable(name: "aa", arg: 1, scope: !28, file: !11, line: 90, type: !14)

!35 = !DILocalVariable(name: "reg", arg: 2, scope: !28, file: !11, line: 90, type: !31)

!36 = !DILocalVariable(name: "field", arg: 3, scope: !28, file: !11, line: 90, type: !31)

!37 = !DILocalVariable(name: "bb", arg: 4, scope: !28, file: !11, line: 90, type: !6)

 

In some instances it is wasteful but harmless, in others verifier is extremely unhappy about it.

 

The question is:

1)      Should llvm.dbg.value for dead argument has been deleted?

2)      Should DILocalVariable has been deleted?

 

Thanks…

 

 

Sergei

 

---

Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160415/a66be887/attachment.html>


More information about the llvm-dev mailing list