<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 fails in bitcode writer with LLVM 12 RC5+"
   href="https://bugs.llvm.org/show_bug.cgi?id=49919">49919</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Assertion fails in bitcode writer with LLVM 12 RC5+
          </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>Windows NT
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>release blocker
          </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>kinke@gmx.net
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=24743" name="attach_24743" title=".ll file">attachment 24743</a> <a href="attachment.cgi?id=24743&action=edit" title=".ll file">[details]</a></span>
.ll file

While testing LLVM 12 RC5+ (fa0971b87f) with LDC, I've hit a bitcode writer
assertion when targeting x86_64-windows-msvc. Creating textual LLVM assembly,
textual machine assembly and machine code works fine, just the bitcode fails -
pretty bad news for LTO. Switching the triple to x86_64-linux-gnu makes it work
as well.

I'm attaching the trivial textual LLVM assembly. The stack trace is:

Assertion failed: Val && "isa<> used on a null pointer", file
C:\LDC\llvm-project\llvm\include\llvm/Support/Casting.h, line 104
 #0 0x00007ff6d3c4bfd6 HandleAbort
C:\LDC\llvm-project\llvm\lib\Support\Windows\Signals.inc:408:0
 #1 0x00007ff6d4277cd4 raise
minkernel\crts\ucrt\src\appcrt\misc\signal.cpp:547:0
 #2 0x00007ff6d4266708 abort
minkernel\crts\ucrt\src\appcrt\startup\abort.cpp:71:0
 #3 0x00007ff6d426d518 common_assert_to_stderr<wchar_t>
minkernel\crts\ucrt\src\appcrt\startup\assert.cpp:175:0
 #4 0x00007ff6d426d63a _wassert
minkernel\crts\ucrt\src\appcrt\startup\assert.cpp:443:0
 #5 0x00007ff6d349bc1f llvm::ValueEnumerator::EnumerateType(class llvm::Type *)
C:\LDC\llvm-project\llvm\lib\Bitcode\Writer\ValueEnumerator.cpp:916:0
 #6 0x00007ff6d349fb90 llvm::ValueEnumerator::incorporateFunction(class
llvm::Function const &)
C:\LDC\llvm-project\llvm\lib\Bitcode\Writer\ValueEnumerator.cpp:1001:0
 #7 0x00007ff6d346f499 llvm::SmallVectorTemplateCommon<unsigned
int,void>::getFirstEl
C:\LDC\llvm-project\llvm\include\llvm\ADT\SmallVector.h:114:0
 #8 0x00007ff6d346f499 llvm::SmallVectorTemplateCommon<unsigned
int,void>::SmallVectorTemplateCommon
C:\LDC\llvm-project\llvm\include\llvm\ADT\SmallVector.h:121:0
 #9 0x00007ff6d346f499 llvm::SmallVectorTemplateBase<unsigned
int,1>::SmallVectorTemplateBase
C:\LDC\llvm-project\llvm\include\llvm\ADT\SmallVector.h:472:0
#10 0x00007ff6d346f499 llvm::SmallVectorImpl<unsigned int>::SmallVectorImpl
C:\LDC\llvm-project\llvm\include\llvm\ADT\SmallVector.h:573:0
#11 0x00007ff6d346f499 llvm::SmallVector<unsigned int,64>::SmallVector
C:\LDC\llvm-project\llvm\include\llvm\ADT\SmallVector.h:1171:0
#12 0x00007ff6d346f499 `anonymous
namespace'::ModuleBitcodeWriter::writeFunction
C:\LDC\llvm-project\llvm\lib\Bitcode\Writer\BitcodeWriter.cpp:3268:0
#13 0x00007ff6d3460376 llvm::operator!=
C:\LDC\llvm-project\llvm\include\llvm\ADT\ilist_iterator.h:148:0
#14 0x00007ff6d3460376 `anonymous namespace'::ModuleBitcodeWriter::write
C:\LDC\llvm-project\llvm\lib\Bitcode\Writer\BitcodeWriter.cpp:4396:0
#15 0x00007ff6d34601e7 `anonymous
namespace'::ModuleBitcodeWriterBase::~ModuleBitcodeWriterBase
C:\LDC\llvm-project\llvm\lib\Bitcode\Writer\BitcodeWriter.cpp:156:0
#16 0x00007ff6d34601e7 llvm::BitcodeWriter::writeModule(class llvm::Module
const &, bool, class llvm::ModuleSummaryIndex const *, bool, class
std::array<unsigned int, 5> *)
C:\LDC\llvm-project\llvm\lib\Bitcode\Writer\BitcodeWriter.cpp:4576:0
#17 0x00007ff6d3460bd7 llvm::WriteBitcodeToFile(class llvm::Module const &,
class llvm::raw_ostream &, bool, class llvm::ModuleSummaryIndex const *, bool,
class std::array<unsigned int, 5> *)
C:\LDC\llvm-project\llvm\lib\Bitcode\Writer\BitcodeWriter.cpp:4603:0
#18 0x00007ff6d125a498 writeModule(class llvm::Module *, char const *)
C:\LDC\ldc\driver\toobj.cpp:390:0
#19 0x00007ff6d11e55aa
std::unique_ptr<llvm::ToolOutputFile,std::default_delete<llvm::ToolOutputFile>
<span class="quote">>::operator bool C:\Program Files (x86)\Microsoft Visual</span >
Studio\2019\Community\VC\Tools\MSVC\14.28.29333\include\memory:2672:0
#20 0x00007ff6d11e55aa ldc::CodeGenerator::writeAndFreeLLModule(char const *)
C:\LDC\ldc\driver\codegenerator.cpp:274:0
#21 0x00007ff6d11e611e Logger::enabled C:\LDC\ldc\gen\logger.h:106:0
#22 0x00007ff6d11e611e ldc::CodeGenerator::emit(class Module *)
C:\LDC\ldc\driver\codegenerator.cpp:282:0
#23 0x00007ff6d1176592 llvm::timeTraceProfilerEnabled
C:\LDC\LLVM-x64\include\llvm\Support\TimeProfiler.h:34:0
#24 0x00007ff6d1176592 TimeTraceScope::~TimeTraceScope
C:\LDC\ldc\driver\timetrace.h:56:0
#25 0x00007ff6d1176592 codegenModules(struct Array<class Module *> &)
C:\LDC\ldc\driver\main.cpp:1197:0
#26 0x00007ff6d103ebe9 mars_mainBody(struct Param &, struct Array<char const *>
&, struct Array<char const *> &) C:\LDC\ldc\dmd\mars.d:882:0
#27 0x00007ff6d1174975 cppmain(void) C:\LDC\ldc\driver\main.cpp:1141:0
#28 0x00007ff6d4052cc9 _D2rt6dmain212_d_run_main2UAAamPUQgZiZ6runAllMFZv
(C:\LDC\ninja-ldc\bin\ldc2.exe+0x3102cc9)
#29 0x00007ff6d4052997 _d_run_main2 (C:\LDC\ninja-ldc\bin\ldc2.exe+0x3102997)
#30 0x00007ff6d4052c53 _d_wrun_main (C:\LDC\ninja-ldc\bin\ldc2.exe+0x3102c53)
#31 0x00007ff6d11740a3 wmain C:\LDC\ldc\driver\main.cpp:1007:0</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>