<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 - Module Verifier bug makes llc/opt refuses to accept bitcode file generated by clang-6.0"
   href="https://bugs.llvm.org/show_bug.cgi?id=38009">38009</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Module Verifier bug makes llc/opt refuses to accept bitcode file generated by clang-6.0
          </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>simachijun@gmail.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=20502" name="attach_20502" title="The bitcode file of the program in description generated by clang++-6.0">attachment 20502</a> <a href="attachment.cgi?id=20502&action=edit" title="The bitcode file of the program in description generated by clang++-6.0">[details]</a></span>
The bitcode file of the program in description generated by clang++-6.0

As mentioned in the LLVM Developer
Policy[<a href="https://llvm.org/docs/DeveloperPolicy.html#ir-backwards-compatibility">https://llvm.org/docs/DeveloperPolicy.html#ir-backwards-compatibility</a>],
the current LLVM version supports loading any bitcode since version 3.0.

However, even a bitcode file generated by building a C++ program as below using
clang++-6.0 will make llc-7.0/opt-7.0 on trunk refuses to accept and outputs
errors.

More info:
1. I tried to use the LLVM IR (.ll) generated by clang++-6.0 and transformed it
into LLVM bitcode (.bc) using llvm-as-7.0 and opt-7.0 works just fine.
2. opt-7.0 also works fine with clang++-7.0 on trunk. 
3. Call opt-7.0 using bitcode file generated by clang++-6.0 with
-disable-verify works fine.

It seems that this incompatibility bug is caused by changes in
llvm/lib/IR/Verifier.cpp of either [1] <a href="https://reviews.llvm.org/rL322317">https://reviews.llvm.org/rL322317</a> or [2]
<a href="https://reviews.llvm.org/rL322806">https://reviews.llvm.org/rL322806</a>. (I am not so sure).

C++ program source code:

```
#include<cstdio>
#include<iostream>
int main()
{
  printf("");
  std::cout<<"";
}
```
```
$ clang++-6.0 -stdlib=libc++ -emit-llvm -O0 -c main.cpp -o main.bc
$ opt-7.0 -disable-output -O0 < ./main.bc
GlobalValue with non default visibility must be dso_local!
%"class.std::__1::basic_streambuf"* (%"class.std::__1::basic_streambuf"*, i8*,
i8*, i8*, %"class.std::__1::ios_base"*, i8)*
@_ZNSt3__116__pad_and_outputIcNS_11char_traitsIcEEEENS_19ostreambuf_iteratorIT_T0_EES6_PKS4_S8_S8_RNS_8ios_baseES4_
GlobalValue with non default visibility must be dso_local!
void (i8*)* @__clang_call_terminate
GlobalValue with private or internal linkage must be dso_local!
[1 x i8]* @.str
opt-7.0: -: error: input module is broken!

```</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>