[llvm-dev] Inconsistency in llvm-link and opt (MCStreamer)

Yaohui Chen via llvm-dev llvm-dev at lists.llvm.org
Thu Nov 7 15:10:28 PST 2019

Hi Folks,

My colleague and I ran into this problem when we tried to run our custom
analysis on the latest kernel. We used llvm-link to generate the final
bitcode and when we ran opt we got the error
"LLVM ERROR: invalid symbol redefinition".

After digging around we figured out that because the symbols defined by
inline assembly directives "module asm" are not checked if they are
duplicated when llvm-link links the bitcode files.

However, in MCStreamer, the program will abort because it find out there
are actually multiple symbols defined in that final bitcode file.

I am wondering is it a good idea to have this inconsistency behavior, here
<https://llvm.org/docs/LangRef.html#module-level-inline-assembly> the
document says it is intended for llvm-link to simply concatenate symbols
defined by inline asm without checking duplication, as it does for other
normally defined symbols. The problem is having this erroneous bitcode,
other tools in the pipeline can't work correctly since there are duplicated

Ideally, llvm-link should've pointed out the redefinition error, but since
it is a documented behavior there must be some reason. I am wondering what
that could be?

In addition, could you provide some suggestion on how we can resolve this
without manually editing the erroneous bc file?

Thanks in advance,

PS: if you want to reproduce the behavior, I attached the 2 bitcode files
that can be linked successfully by llvm-link but if you try to use opt to
parse it and generate a new bitcode, the program error out.

PPS: I am using llvm-9.0.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20191107/531717ee/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kobject-example.bc
Type: application/octet-stream
Size: 12188 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20191107/531717ee/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kset-example.bc
Type: application/octet-stream
Size: 17712 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20191107/531717ee/attachment-0001.obj>

More information about the llvm-dev mailing list