[llvm-bugs] [Bug 51570] New: Emitted binary code changes when -g is enabled at -m32 -O1

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Aug 20 18:27:07 PDT 2021


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

            Bug ID: 51570
           Summary: Emitted binary code changes when -g is enabled at -m32
                    -O1
           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 for the following program (program.c) changes after toggling
the -g flag.

$ cat program.c
struct a {
  int b[100];
} c, d;
__attribute__((noinline)) struct a e() { return d; }
int main() { c = e(); }
$
$ clang-trunk -v
clang version 14.0.0 (https://github.com/llvm/llvm-project.git
3890ce708d4f94d0326172650ce22262f6b56661)
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 -c -m32 -O1 program.c ; objdump --disassemble --section=.text
program.o > no_g.txt
$ clang-trunk -c -m32 -O1 -g program.c ; objdump --disassemble --section=.text
program.o > g.txt
$ diff no_g.txt g.txt
26,39c26,40
<   31: 81 ec a4 01 00 00       sub    $0x1a4,%esp
<   37: 8d 74 24 14             lea    0x14(%esp),%esi
<   3b: 56                      push   %esi
<   3c: e8 fc ff ff ff          call   3d <main+0xd>
<   41: 83 c4 08                add    $0x8,%esp
<   44: 68 90 01 00 00          push   $0x190
<   49: 56                      push   %esi
<   4a: 68 00 00 00 00          push   $0x0
<   4f: e8 fc ff ff ff          call   50 <main+0x20>
<   54: 83 c4 10                add    $0x10,%esp
<   57: 31 c0                   xor    %eax,%eax
<   59: 81 c4 98 01 00 00       add    $0x198,%esp
<   5f: 5e                      pop    %esi
<   60: c3                      ret
---
>   31:	81 ec 98 01 00 00    	sub    $0x198,%esp
>   37:	83 ec 0c             	sub    $0xc,%esp
>   3a:	8d 74 24 14          	lea    0x14(%esp),%esi
>   3e:	56                   	push   %esi
>   3f:	e8 fc ff ff ff       	call   40 <main+0x10>
>   44:	83 c4 08             	add    $0x8,%esp
>   47:	68 90 01 00 00       	push   $0x190
>   4c:	56                   	push   %esi
>   4d:	68 00 00 00 00       	push   $0x0
>   52:	e8 fc ff ff ff       	call   53 <main+0x23>
>   57:	83 c4 10             	add    $0x10,%esp
>   5a:	31 c0                	xor    %eax,%eax
>   5c:	81 c4 98 01 00 00    	add    $0x198,%esp
>   62:	5e                   	pop    %esi
>   63:	c3                   	ret


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/20210821/6dbfead3/attachment.html>


More information about the llvm-bugs mailing list