[llvm-bugs] [Bug 38009] New: Module Verifier bug makes llc/opt refuses to accept bitcode file generated by clang-6.0

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Jul 1 03:21:08 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=38009

            Bug ID: 38009
           Summary: Module Verifier bug makes llc/opt refuses to accept
                    bitcode file generated by clang-6.0
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: simachijun at gmail.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 20502
  --> https://bugs.llvm.org/attachment.cgi?id=20502&action=edit
The bitcode file of the program in description generated by clang++-6.0

As mentioned in the LLVM Developer
Policy[https://llvm.org/docs/DeveloperPolicy.html#ir-backwards-compatibility],
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] https://reviews.llvm.org/rL322317 or [2]
https://reviews.llvm.org/rL322806. (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!

```

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180701/feba6d98/attachment.html>


More information about the llvm-bugs mailing list