<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - llvm.dbg.value calls on phis appear in the wrong place"
   href="https://llvm.org/bugs/show_bug.cgi?id=30612">30612</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>llvm.dbg.value calls on phis appear in the wrong place
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Transformation Utilities
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>rnk@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>