[LLVMbugs] [Bug 14023] New: Loop unroller and other passes fail to update Debugger information for register-mapped variables

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Oct 4 10:19:07 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=14023

             Bug #: 14023
           Summary: Loop unroller and other passes fail to update Debugger
                    information for register-mapped variables
           Product: libraries
           Version: trunk
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Core LLVM classes
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: pickensd at synopsys.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


The loop unroller fails to update the "call @llvm.dbg.value" instructions as it
unrolls the body of a loop. Thus, the generated dwarf does not properly track
the value of any register-based variable that is updated on each iteration of
the loop.

Test case:

int sum(int *vector){
    int result = 0;
    for (int i = 0; i < 8; i++){
       result += vector[i];
    }
    return result;
}


Bitcode output at -O3 (x86 target):

define i32 @sum(i32* nocapture %vector) nounwind readonly {
entry:
tail call void @llvm.dbg.value(metadata !{i32* %vector}, i64 0, metadata !13),
!dbg !18
  tail call void @llvm.dbg.value(metadata !2, i64 0, metadata !14), !dbg !19
  tail call void @llvm.dbg.value(metadata !2, i64 0, metadata !16), !dbg !20
  %0 = load i32* %vector, align 4, !dbg !21, !tbaa !23
  tail call void @llvm.dbg.value(metadata !{i32 %0}, i64 0, metadata !14), !dbg
!21
  tail call void @llvm.dbg.value(metadata !26, i64 0, metadata !16), !dbg !27
  %arrayidx.1 = getelementptr inbounds i32* %vector, i32 1, !dbg !21
  %1 = load i32* %arrayidx.1, align 4, !dbg !21, !tbaa !23
  %add.1 = add nsw i32 %1, %0, !dbg !21

>>>WRONG: the following should be "!{i32 %add.1}"
  tail call void @llvm.dbg.value(metadata !{i32 %0}, i64 0, metadata !14), !dbg
!21
>>>WRONG: below !26 is !{i32 1}   Should be !{i32 2}
  tail call void @llvm.dbg.value(metadata !26, i64 0, metadata !16), !dbg !27
  %arrayidx.2 = getelementptr inbounds i32* %vector, i32 2, !dbg !21
  %2 = load i32* %arrayidx.2, align 4, !dbg !21, !tbaa !23
  %add.2 = add nsw i32 %2, %add.1, !dbg !21
>>>WRONG:the following should be "!{i32 %add.2}"
  tail call void @llvm.dbg.value(metadata !{i32 %0}, i64 0, metadata !14), !dbg
!21
>>>WRONG: below !26 is !{i32 1}. Should be !{i32 3}
  tail call void @llvm.dbg.value(metadata !26, i64 0, metadata !16), !dbg !27
  ... etc.


The problem appears to be systemic with metadata references to virtual
registers. Such registers do not appear as "uses"; therefore, they don't get
updated as optimizations occur. Not only does the loop unroller exhibit this
problem, but so does the Loop Rotate pass, the Loop Strength Reduce pass, and
any other pass that remaps virtual registers that correspond to local
variables.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list