LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 51569 - Emitted binary code changes when -g is enabled at -O0 -m32
Summary: Emitted binary code changes when -g is enabled at -O0 -m32
Status: NEW
Alias: None
Product: libraries
Classification: Unclassified
Component: Loop Optimizer (show other bugs)
Version: trunk
Hardware: PC All
: P enhancement
Assignee: Unassigned LLVM Bugs
URL:
Keywords:
Depends on:
Blocks: 37728
  Show dependency tree
 
Reported: 2021-08-20 18:21 PDT by Theodore Wang
Modified: 2021-08-20 19:45 PDT (History)
3 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Theodore Wang 2021-08-20 18:21:52 PDT
The .text section for the following program (program.c) changes after toggling the -g flag.

$ cat program.c
int a, b;
void c() {
  for (;;)
    ;
}
int main() {}
$
$ 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 -O0 program.c ; objdump --disassemble --section=.text program.o > no_g.txt
$ clang-trunk -c -m32 -O0 -g program.c ; objdump --disassemble --section=.text program.o > g.txt
$ diff no_g.txt g.txt
10,11c10,11
<    3:	e9 00 00 00 00       	jmp    8 <b+0x4>
<    8:	e9 fb ff ff ff       	jmp    8 <b+0x4>
---
>    3:	e9 00 00 00 00       	jmp    8 <c+0x8>
>    8:	e9 fb ff ff ff       	jmp    8 <c+0x8>