<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - Debug info for induction variable points at next iteration's value"
   href="https://bugs.llvm.org/show_bug.cgi?id=35113">35113</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Debug info for induction variable points at next iteration's value
          </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>All
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>DebugInfo
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>aprantl@apple.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>void bar(float);
void f(float *input, long long n, long long s) {
  for (long long i = 0; i < n; i+=s )
    bar(input[i]);
}

clang -g -O1 -S -emit-llvm /tmp/loop.c  -o - 

...
for.body:                                         ; preds =
%for.body.preheader, %for.body
  %i.05 = phi i64 [ %add, %for.body ], [ 0, %for.body.preheader ]
  tail call void @llvm.dbg.value(metadata i64 %i.05, metadata !18, metadata
!DIExpression()), !dbg !23
  %arrayidx = getelementptr inbounds float, float* %input, i64 %i.05, !dbg !27
  %0 = load float, float* %arrayidx, align 4, !dbg !27, !tbaa !29
  tail call void @bar(float %0) #3, !dbg !33
  %add = add nsw i64 %i.05, %s, !dbg !34
  tail call void @llvm.dbg.value(metadata i64 %add, metadata !18, metadata
!DIExpression()), !dbg !23
  tail call void @llvm.dbg.value(metadata i64 %add, metadata !18, metadata
!DIExpression()), !dbg !23
  %cmp = icmp slt i64 %add, %n, !dbg !24
  br i1 %cmp, label %for.body, label %for.cond.cleanup, !dbg !26, !llvm.loop
!35
}

!7 = !{!"clang version 6.0.0 (trunk 316686) (llvm/trunk 316682)"}
!23 = !DILocation(line: 3, column: 18, scope: !19)
!34 = !DILocation(line: 3, column: 32, scope: !25)

There are two problems here:
1. The dbg.value describing %add is duplicated.
2. It is wrong. If we insert a dbg.value for %add I would either expect it to
have a DIExpression that subtracts %s (which we can't represent), *or* to have
a DILocation that clearly points to a source location after the increment.</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>