<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Nov 7, 2019, at 15:10, Yaohui Chen via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class="">Hi Folks,<div class=""><br class=""></div><div class="">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 </div><div class="">"LLVM ERROR: invalid symbol redefinition".</div><div class=""><br class=""></div><div class="">After digging around we figured out that because the symbols defined by inline assembly directives "<span style="white-space:pre-wrap;background-color:rgb(255,255,255)" class=""><font face="arial, sans-serif" class="">module asm</font></span>" are not checked if they are duplicated when llvm-link links the bitcode files. </div><div class=""><br class=""></div><div class="">However, in MCStreamer, the program will abort because it find out there are actually multiple symbols defined in that final bitcode file.</div><div class=""><br class=""></div><div class="">I am wondering is it a good idea to have this inconsistency behavior, <a href="https://llvm.org/docs/LangRef.html#module-level-inline-assembly" class="">here</a> 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 symbols.</div><div class=""><br class=""></div><div class="">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? </div></div></div></div></div></div></blockquote><div><br class=""></div><div>LLVM doesn't really understand the semantics of an inline assembly string. From its point of view it's just a string to expand and paste into the generated code just before it runs the assembler. As a result, llvm-link isn't aware that there's a symbol inside the inline assembly.</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div class="">In addition, could you provide some suggestion on how we can resolve this without manually editing the erroneous bc file?</div></div></div></div></div></div></blockquote><div><br class=""></div>If the exact name doesn't really matter then you may be able to use ${:uid} (<a href="http://llvm.org/docs/LangRef.html#inline-assembler-expressions" class="">http://llvm.org/docs/LangRef.html#inline-assembler-expressions</a>) to add a unique number to each one. I don't know if that works in module-level assembly though.<br class=""><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div class="">Thanks in advance,</div><div class="">Eric</div><div class=""><br class=""></div><div class="">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.</div><div class=""><br class=""></div><div class="">PPS: I am using llvm-9.0.</div><div class="">  </div><div class=""></div></div></div></div></div>
<span id="cid:f_k2pbehz00"><kobject-example.bc></span><span id="cid:f_k2pbehzr1"><kset-example.bc></span>_______________________________________________<br class="">LLVM Developers mailing list<br class=""><a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class="">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev<br class=""></div></blockquote></div><br class=""></body></html>