[llvm-bugs] [Bug 30612] New: llvm.dbg.value calls on phis appear in the wrong place

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Oct 4 11:40:17 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=30612

            Bug ID: 30612
           Summary: llvm.dbg.value calls on phis appear in the wrong place
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Transformation Utilities
          Assignee: unassignedbugs at nondot.org
          Reporter: rnk at google.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Consider this test case:

struct IntPair { int x, y; };
extern int g(int r);
extern int i;
extern int n;
int loop_csr() {
  struct IntPair o = {0, 0};
  for (i = 0; i < n; i++) {
    o.x = g(o.x);
    o.y = g(o.y);
  }
  return o.x + o.y;
}

The LLVM IR we get after -O1 for the loop body is:

for.body:                                         ; preds = %entry, %for.body
  %o.sroa.0.011 = phi i32 [ %call, %for.body ], [ 0, %entry ]
  %o.sroa.5.010 = phi i32 [ %call2, %for.body ], [ 0, %entry ]
  %call = tail call i32 @g(i32 %o.sroa.0.011) #5, !dbg !31
  tail call void @llvm.dbg.value(metadata i32 %call, i64 0, metadata !12,
metadata !19), !dbg !18
  %call2 = tail call i32 @g(i32 %o.sroa.5.010) #5, !dbg !33
  tail call void @llvm.dbg.value(metadata i32 %call2, i64 0, metadata !12,
metadata !20), !dbg !18
  %1 = load i32, i32* @i, align 4, !dbg !21, !tbaa !24
  %inc = add nsw i32 %1, 1, !dbg !21
  tail call void @llvm.dbg.value(metadata i32 %call, i64 0, metadata !12,
metadata !19), !dbg !18
  tail call void @llvm.dbg.value(metadata i32 %call2, i64 0, metadata !12,
metadata !20), !dbg !18
  store i32 %inc, i32* @i, align 4, !dbg !21, !tbaa !24
  %2 = load i32, i32* @n, align 4, !dbg !28, !tbaa !24
  %cmp = icmp slt i32 %inc, %2, !dbg !29
  br i1 %cmp, label %for.body, label %for.end, !dbg !30, !llvm.loop !34

The dbg.value calls appear misplaced. IMO they should appear after the phi, and
after the calls. We should be able to emit dwarf that says that, for the entire
loop body, o.x and o.y are in EDI and ESI respectively, but we can't because we
don't have debug value info on phis.

-- 
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/20161004/c6ccb5bd/attachment.html>


More information about the llvm-bugs mailing list