[llvm-dev] LLVM trunk generates different machine code for JCC instruction w/ or w/o debug info
陈志伟 via llvm-dev
llvm-dev at lists.llvm.org
Tue Dec 29 06:25:40 PST 2020
Hi folks, it’s my first post in llvm-dev mailing list, and definitely not the last :-)
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.
> clang -S -emit-llvm foo.cc<http://foo.cc> -O3 -ggdb3 -o dbg.ll
> clang -S -emit-llvm foo.cc<http://foo.cc> -O3 -o rel.ll
Where foo.cc<http://foo.cc> is a cc file in my company of 10k+ LOC and depends on tons of 3rd libraries.
The difference between dbg.ll and rel.ll are the llvm debug intrinsics. Emmmm, looks fine.
> llc dbg.ll -o dbg.s
> llc rel.ll -o rel.s
And the asm instructions are the same. Emmm, fine again.
> llvm-mc -filetype=obj dbg.s -o dbg.o
> llvm-mc -filetype=obj rel.s -o rel.o
The 2 obj files generated by LLVM assembler has DIFFERENT machine codes.
> 74 19 je f20
The obj compiled with debug info use 0x74 to represent a JE instruction, while
> 0f 84 15 00 00 00 je f20
The obj compiled without debug info use 0x0f 0x84 instead.
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.
Thanks in advance.
--
Zhiwei Chen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20201229/228ad217/attachment.html>
More information about the llvm-dev
mailing list