<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 - Assertion `CountVarDIE && "DIE for count is not yet instantiated"' failed."
   href="https://bugs.llvm.org/show_bug.cgi?id=36263">36263</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Assertion `CountVarDIE && "DIE for count is not yet instantiated"' failed.
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

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

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

        <tr>
          <th>OS</th>
          <td>Linux
          </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>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>david.stenberg@ericsson.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=19823" name="attach_19823" title="IR reproducer.">attachment 19823</a> <a href="attachment.cgi?id=19823&action=edit" title="IR reproducer.">[details]</a></span>
IR reproducer.

Seen on trunk (rL324422).

When compiling the attached IR file using:

  llc -O0 -filetype=asm -mtriple x86_64-unknown-linux-gnu -mcpu=x86-64 -o
./foo.s ./foo.opt.ll

the following crash is seen:

  llc: ../lib/CodeGen/AsmPrinter/DwarfUnit.cpp:1355: void
llvm::DwarfUnit::constructSubrangeDIE(llvm::DIE &, const llvm::DISubrange *,
llvm::DIE *): Assertion `CountVarDIE && "DIE for count is not yet
instantiated"' failed.
  #0 0x0000000001d744f4 PrintStackTraceSignalHandler(void*)
(/repo/llvm/build-all-clang40/bin/llc+0x1d744f4)
  #1 0x0000000001d74836 SignalHandler(int)
(/repo/llvm/build-all-clang40/bin/llc+0x1d74836)
  #2 0x00007fdfdb120850 __restore_rt (/lib64/libpthread.so.0+0xf850)
  #3 0x00007fdfda2cb875 __GI_raise (/lib64/libc.so.6+0x32875)
  #4 0x00007fdfda2cce51 __GI_abort (/lib64/libc.so.6+0x33e51)
  #5 0x00007fdfda2c4740 __GI___assert_fail (/lib64/libc.so.6+0x2b740)
  #6 0x00000000013e7249 (/repo/llvm/build-all-clang40/bin/llc+0x13e7249)
  #7 0x00000000013e53d1 llvm::DwarfUnit::constructArrayTypeDIE(llvm::DIE&,
llvm::DICompositeType const*) (/repo/llvm/build-all-clang40/bin/llc+0x13e53d1)
  #8 0x00000000013e4400 llvm::DwarfUnit::constructTypeDIE(llvm::DIE&,
llvm::DICompositeType const*) (/repo/llvm/build-all-clang40/bin/llc+0x13e4400)
  #9 0x00000000013e345d llvm::DwarfUnit::getOrCreateTypeDIE(llvm::MDNode
const*) (/repo/llvm/build-all-clang40/bin/llc+0x13e345d)
  #10 0x00000000013e312c llvm::DwarfUnit::addType(llvm::DIE&, llvm::DIType
const*, llvm::dwarf::Attribute)
(/repo/llvm/build-all-clang40/bin/llc+0x13e312c)
  #11 0x0000000001414d71
llvm::DwarfCompileUnit::applyVariableAttributes(llvm::DbgVariable const&,
llvm::DIE&) (/repo/llvm/build-all-clang40/bin/llc+0x1414d71)
  #12 0x0000000001414758
llvm::DwarfCompileUnit::constructVariableDIEImpl(llvm::DbgVariable const&,
bool) (/repo/llvm/build-all-clang40/bin/llc+0x1414758)
  #13 0x0000000001413a97
llvm::DwarfCompileUnit::createScopeChildrenDIE(llvm::LexicalScope*,
llvm::SmallVectorImpl<llvm::DIE*>&, bool*)
(/repo/llvm/build-all-clang40/bin/llc+0x1413a97)
  #14 0x000000000141337a
llvm::DwarfCompileUnit::constructScopeDIE(llvm::LexicalScope*,
llvm::SmallVectorImpl<llvm::DIE*>&)
(/repo/llvm/build-all-clang40/bin/llc+0x141337a)
  #15 0x0000000001413c9e
llvm::DwarfCompileUnit::createScopeChildrenDIE(llvm::LexicalScope*,
llvm::SmallVectorImpl<llvm::DIE*>&, bool*)
(/repo/llvm/build-all-clang40/bin/llc+0x1413c9e)
  #16 0x000000000141337a
llvm::DwarfCompileUnit::constructScopeDIE(llvm::LexicalScope*,
llvm::SmallVectorImpl<llvm::DIE*>&)
(/repo/llvm/build-all-clang40/bin/llc+0x141337a)
  #17 0x0000000001413c9e
llvm::DwarfCompileUnit::createScopeChildrenDIE(llvm::LexicalScope*,
llvm::SmallVectorImpl<llvm::DIE*>&, bool*)
(/repo/llvm/build-all-clang40/bin/llc+0x1413c9e)
  #18 0x000000000141337a
llvm::DwarfCompileUnit::constructScopeDIE(llvm::LexicalScope*,
llvm::SmallVectorImpl<llvm::DIE*>&)
(/repo/llvm/build-all-clang40/bin/llc+0x141337a)
  #19 0x0000000001413c9e
llvm::DwarfCompileUnit::createScopeChildrenDIE(llvm::LexicalScope*,
llvm::SmallVectorImpl<llvm::DIE*>&, bool*)
(/repo/llvm/build-all-clang40/bin/llc+0x1413c9e)
  #20 0x0000000001415ce7
llvm::DwarfCompileUnit::constructAbstractSubprogramScopeDIE(llvm::LexicalScope*)
(/repo/llvm/build-all-clang40/bin/llc+0x1415ce7)

The IR file was generated by running the following commands on the attached C
file:

  clang -mllvm -disable-llvm-optzns -S -emit-llvm
--target=x86_64-unknown-linux-gnu -g foo.c -o ./foo.ll
  opt -mcpu=x86-64 -always-inline -O1 -S -o ./foo.opt.ll ./foo.ll

I'm not very knowledgeable about LLVM's inner working for this, but I noted
that the vla_expr variable is not included in the list of local variables for
the scope when running createScopeChildrenDIE(), whereas it is that in the
input IR file:

!21 = distinct !DILexicalBlock(scope: !18, file: !1, line: 5, column: 31)
!22 = !DILocalVariable(name: "vla_expr", scope: !21, file: !1, line: 6, type:
!23)
!25 = !DILocalVariable(name: "vn", scope: !21, file: !1, line: 6, type: !26)
!26 = !DICompositeType(tag: DW_TAG_array_type, baseType: !10, elements: !27)
!27 = !{!28}
!28 = !DISubrange(count: !22)</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>