<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 --- - [crash] add-discriminators pass handles inlined locations incorrectly"
   href="https://llvm.org/bugs/show_bug.cgi?id=30681">30681</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[crash] add-discriminators pass handles inlined locations incorrectly
          </td>
        </tr>

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

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

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </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>aprantl@apple.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>Created <span class=""><a href="attachment.cgi?id=17430" name="attach_17430" title="t.ll">attachment 17430</a> <a href="attachment.cgi?id=17430&action=edit" title="t.ll">[details]</a></span>
t.ll

In the following example the add-discriminators pass is incorrectly setting the
scope of a non-inlined instruction (br) to the scope of its inlined predecessor
(%call.i).
This causes the LLVM Verifier to fail and assertions to fire.

To reproduce run:
clang-4.0 -cc1 -emit-obj  -disable-llvm-optzns t.ll -o /dev/null -mllvm
-debug-only=add-discriminators
warning: overriding the module target triple with x86_64-apple-darwin16.1.0
t.c:1:27:1  %call.i = tail call i8* @__memset_chk(i8* null, i32 0, i64 0, i64
%0) #2, !dbg !19
t.c:1:9:1  br label %for.cond, !dbg !21, !llvm.loop !22
!dbg attachment points at wrong subprogram for function
!7 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 1, type: !8,
isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: true, unit: !0,
variables: !2)
i32 ()* @f
  br label %for.cond, !dbg !21, !llvm.loop !22
!21 = !DILocation(line: 1, column: 9, scope: !20)
!20 = !DILexicalBlockFile(scope: !12, file: !1, discriminator: 1)
!12 = distinct !DISubprogram(name: "g", scope: !1, file: !1, line: 1, type: !8,
isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: true, unit: !0,
variables: !2)
!dbg attachment points at wrong subprogram for function
!7 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 1, type: !8,
isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: true, unit: !0,
variables: !2)
i32 ()* @f
  br label %for.cond, !dbg !21, !llvm.loop !22
!21 = !DILocation(line: 1, column: 9, scope: !20)
!20 = !DILexicalBlockFile(scope: !12, file: !1, discriminator: 1)
!12 = distinct !DISubprogram(name: "g", scope: !1, file: !1, line: 1, type: !8,
isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: true, unit: !0,
variables: !2)
Assertion failed: (cast<DISubprogram>(Scope)->describes(MF->getFunction())),
function getOrCreateRegularScope, file ../lib/CodeGen/LexicalScopes.cpp, line
159.
Stack dump:
0.    Program arguments:
/Volumes/Fusion/Data/llvm/_build.ninja.release/bin/clang-4.0 -cc1 -emit-obj
-disable-llvm-optzns t.ll -o /dev/null -mllvm -debug-only=add-discriminators 
1.    Code generation
2.    Running pass 'Function Pass Manager' on module 't.ll'.
3.    Running pass 'Live DEBUG_VALUE analysis' on function '@f'
Abort trap: 6</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>