LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 36263 - Assertion `CountVarDIE && "DIE for count is not yet instantiated"' failed.
Summary: Assertion `CountVarDIE && "DIE for count is not yet instantiated"' failed.
Status: RESOLVED FIXED
Alias: None
Product: new-bugs
Classification: Unclassified
Component: new bugs (show other bugs)
Version: trunk
Hardware: PC Linux
: P normal
Assignee: Sander de Smalen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-02-07 03:53 PST by David Stenberg
Modified: 2018-02-19 02:03 PST (History)
3 users (show)

See Also:
Fixed By Commit(s):


Attachments
IR reproducer. (5.72 KB, text/plain)
2018-02-07 03:53 PST, David Stenberg
Details
Original C file. (175 bytes, text/plain)
2018-02-07 03:54 PST, David Stenberg
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Stenberg 2018-02-07 03:53:08 PST
Created attachment 19823 [details]
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)
Comment 1 David Stenberg 2018-02-07 03:54:03 PST
Created attachment 19824 [details]
Original C file.
Comment 2 Volodymyr Sapsai 2018-02-09 12:01:18 PST
Please validate with TOT. r324412 and r324677 should have fixed the issue.
Comment 3 David Stenberg 2018-02-13 00:21:25 PST
(In reply to Volodymyr Sapsai from comment #2)
> Please validate with TOT. r324412 and r324677 should have fixed the issue.

Thanks for the suggestion. Unfortunately, this is still seen on TOT.

With those commits, the list of local variables are sorted in DwarfCompileUnit::createScopeChildrenDIE; however, in this case the vla_expr variable is not included in that list (for some reason).
Comment 4 Sander de Smalen 2018-02-19 02:03:56 PST
This issue is fixed by https://reviews.llvm.org/rL325438 and https://reviews.llvm.org/rL325427.