[llvm-bugs] [Bug 52027] New: Emitted binary code changes at -O0 when compiling through -S

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Sep 30 18:26:26 PDT 2021


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

            Bug ID: 52027
           Summary: Emitted binary code changes at -O0 when compiling
                    through -S
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Common Code Generator Code
          Assignee: unassignedbugs at nondot.org
          Reporter: tlwang at uwaterloo.ca
                CC: cnsun at uwaterloo.ca, llvm-bugs at lists.llvm.org
            Blocks: 37728

The .text section of program0.c changes when the program is compiled through
-S.

$ cat program0.c
int main(int a, char *b[]) { a && 0; }
$
$ clang-trunk -v
clang version 14.0.0 (https://github.com/llvm/llvm-project.git
2303391d1f543f4e57f9ed0fc68bad2d4cf890dc)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/cnsun/usr/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
$
$ clang-trunk -O0 -S program0.c -o program0.s
$ clang-trunk -O0 -c program0.s -o program0.out
$ objdump --disassemble --section=.text program0.out > s.txt
$ clang-trunk -O0 -c program0.c -o program0.out
$ objdump --disassemble --section=.text program0.out > no_s.txt
$ diff s.txt no_s.txt
16,23c16,23
<   1b: 74 07                   je     24 <main+0x24>
<   1d: 31 c0                   xor    %eax,%eax
<   1f: 88 45 ef                mov    %al,-0x11(%rbp)
<   22: eb 00                   jmp    24 <main+0x24>
<   24: 8a 45 ef                mov    -0x11(%rbp),%al
<   27: 8b 45 fc                mov    -0x4(%rbp),%eax
<   2a: 5d                      pop    %rbp
<   2b: c3                      retq
---
>   1b:	0f 84 0a 00 00 00    	je     2b <main+0x2b>
>   21:	31 c0                	xor    %eax,%eax
>   23:	88 45 ef             	mov    %al,-0x11(%rbp)
>   26:	e9 00 00 00 00       	jmpq   2b <main+0x2b>
>   2b:	8a 45 ef             	mov    -0x11(%rbp),%al
>   2e:	8b 45 fc             	mov    -0x4(%rbp),%eax
>   31:	5d                   	pop    %rbp
>   32:	c3                   	retq


Referenced Bugs:

https://bugs.llvm.org/show_bug.cgi?id=37728
[Bug 37728] [meta] Make llvm passes debug info invariant
-- 
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/20211001/ad8539a9/attachment-0001.html>


More information about the llvm-bugs mailing list