<div dir="ltr">Yeah - we try to ensure that LLVM's debug info doesn't change what code is generated, but it's best effort - no one's done fuzzing/etc to make it especially robust.<br><br>If you want to investigate this I'd suggest using CReduce ( <a href="https://embed.cs.utah.edu/creduce/">https://embed.cs.utah.edu/creduce/</a> ) to reduce the example to something small/manageable and then possibly report it here and/or investigate it yourself (LLVM/Clang support dumping the intermediate representation after every pass (-mllvm -dump-after-all/-print-after-all, something like that, I forget the precise spelling) and you could see where the IR or machine IR diverges between the debuginfo/not-debuginfo cases) </div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Dec 29, 2020 at 6:26 AM 陈志伟 via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div style="overflow-wrap: break-word;">
<div>Hi folks, it’s my first post in llvm-dev mailing list, and definitely not the last :-)</div>
<div><br>
</div>
<div>Recently, I found an elf file built with or without debug info has different machine code generated. Sadly, it cannot be reproduced in a piece of code. Here is my investigation.</div>
<div><br>
</div>
<div>> clang -S -emit-llvm <a href="http://foo.cc" target="_blank">foo.cc</a> -O3 -ggdb3 -o dbg.ll</div>
<div>> clang -S -emit-llvm <a href="http://foo.cc" target="_blank">foo.cc</a> -O3 -o rel.ll</div>
<div><br>
</div>
<div>Where <a href="http://foo.cc" target="_blank">foo.cc</a> is a cc file in my company of 10k+ LOC and depends on tons of 3rd libraries.</div>
<div><br>
</div>
<div>The difference between dbg.ll and rel.ll are the llvm debug intrinsics. Emmmm, looks fine.</div>
<div><br>
</div>
<div>> llc dbg.ll -o dbg.s</div>
<div>> llc rel.ll -o rel.s</div>
<div><br>
</div>
<div>And the asm instructions are the same. Emmm, fine again.</div>
<div><br>
</div>
<div>> llvm-mc -filetype=obj dbg.s -o dbg.o</div>
<div>> llvm-mc -filetype=obj rel.s -o rel.o</div>
<div><br>
</div>
<div>The 2 obj files generated by LLVM assembler has DIFFERENT machine codes.</div>
<div><br>
</div>
<div>> 74 19 je f20</div>
<div><br>
</div>
<div>The obj compiled with debug info use 0x74 to represent a JE instruction, while</div>
<div><br>
</div>
<div>> 0f 84 15 00 00 00 je f20</div>
<div><br>
</div>
<div>The obj compiled without debug info use 0x0f 0x84 instead.</div>
<div><br>
</div>
<div>What? Why the debug info affects the generation of machine code? As a LLVM beginner, I’m willing to dive deeper to find the root cause. </div>
<div><br>
</div>
<div>Thanks in advance.</div>
<div><br>
</div>
<div>
<div dir="auto" style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
<div dir="auto" style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
<div>--</div>
<div>Zhiwei Chen<br>
<br>
</div>
</div>
</div>
</div>
<br>
</div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>