<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/56523>56523</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Emitted binary changes when -g is enabled with -O1
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
theo-lw
</td>
</tr>
</table>
<pre>
The .text section for `inline_asm_program0_preprocessed.c` changes after toggling the `-g` flag.
```
$ clang-trunk -v
clang version 15.0.0 (https://github.com/llvm/llvm-project.git a17c90daf2e7c3b1817ec29ad6648ce89b927f9a)
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
$
$ cat inline_asm_program0_preprocessed.c
typedef char b;
b aj, c, d;
void e() {
int f;
for (; f;) {
b ag[4];
int **ah[6] = {**ah, *ah};
ag[f];
f = 0;
for (; f < 1; f++)
for (; d;)
if (ag[2])
asm("");
}
}
int *g() {
for (;;) {
b a;
aj = 0;
if (c)
asm("");
else {
int am[1];
return am;
}
}
}
void main() {
g();
e();
}
$
$ clang-trunk -w -O1 inline_asm_program0_preprocessed.c -c -g3 -o a.out; objdump --disassemble --section=.text a.out > g.txt
$ clang-trunk -w -O1 inline_asm_program0_preprocessed.c -c -o a.out; objdump --disassemble --section=.text a.out > no_g.txt
$ diff no_g.txt g.txt
28,31c28
< 47: 66 0f 1f 84 00 00 00 nopw 0x0(%rax,%rax,1)
< 4e: 00 00
< 50: c6 05 00 00 00 00 00 movb $0x0,0x0(%rip) # 57 <main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