[LLVMbugs] [Bug 14020] New: Dwarf information for register-mapped variables incomplete

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Oct 4 09:17:52 PDT 2012


             Bug #: 14020
           Summary: Dwarf 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 PromoteMem2Reg::RenamePass() method in
lib/Transforms/Utils/PromoteMemoryToRegister.cpp is failing to generate the
necessary "call llvm.dbg.value" instructions to record the state of a
register-mapped auto variable.

Test case:
#include <stdio.h>

static void foo(int a, int b){
    for (int i = a; i < b; i++){

int main(){
    return 0;

Bitcode output at -O1 (x86 target) below. Notice the llvm.dbg.value that
*should* be generated but is missing:

define internal fastcc void @foo() nounwind {
for.body:                                         ; preds = %for.body, %entry
  %i.01 = phi i32 [ 123, %entry ], [ %inc, %for.body ]
>>>>>>MISSING>>>>:   tail call void @llvm.dbg.value(metadata !{i32 %i.01}, i64 0, metadata !17), !dbg !30

  %call = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x
i8]* @.str, i32 0, i32 0), i32 %i.01) nounwind, !dbg !28
  %inc = add nsw i32 %i.01, 1, !dbg !30
  tail call void @llvm.dbg.value(metadata !{i32 %inc}, i64 0, metadata !17),
!dbg !30
  %exitcond = icmp eq i32 %inc, 456, !dbg !27
  br i1 %exitcond, label %for.end, label %for.body, !dbg !27

The method "RenamePass" in lib/Transforms/Utils/PromoteMemoryToRegister.cpp
inserts "call @llvm.dbg.value" for the StoreInst case of an auto-variable, but
fails to do so for the LoadInst case. Thus, the generated Dwarf is just plain
wrong in that it does not properly track the value of "i" as the debugger steps
through the loop. You will notice that the debugger mistakenly reports that "i"
has the initial value "123" at the start of each iteration of the loop.

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