<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/56575>56575</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Emitted binary changes when -g is enabled with -O3
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</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 when `-g` is enabled:
```
$ clang-trunk -v
clang version 15.0.0 (https://github.com/llvm/llvm-project.git 77b72fbc71638d5610923bcfae096ff308cd85e1)
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 int a;
short b, g;
int f, e, h;
void(i)(short j) { j *b; }
int k(a *j, short l) {
short a;
for (;;) {
int c;
long d;
e = 0;
for (; e;)
asm("" : "+m"(a));
g = 0;
for (; g != 1;)
if (h) {
if (l)
return f;
i(0 == j);
asm("" : "=m"(c), "+m"(d));
}
}
}
void main() {}
$
$ clang-trunk -w -O3 -g -c inline_asm_program0_preprocessed.c -o a.out; objdump a.out --disassemble --section=.text a.out > g.txt
$ clang-trunk -w -O3 -c inline_asm_program0_preprocessed.c -o a.out; objdump a.out --disassemble --section=.text a.out > no_g.txt
$ diff no_g.txt g.txt
15,53c15,47
< 16: 85 c0 test %eax,%eax
< 18: 74 1f je 39 <k+0x29>
< 1a: c7 05 00 00 00 00 00 movl $0x0,0x0(%rip) # 24 <k+0x14>
< 21: 00 00 00
< 24: 66 c7 05 00 00 00 00 movw $0x0,0x0(%rip) # 2d <k+0x1d>
< 2b: 00 00
< 2d: 66 85 f6 test %si,%si
< 30: 74 1c je 4e <k+0x3e>
< 32: 8b 05 00 00 00 00 mov 0x0(%rip),%eax # 38 <k+0x28>
< 38: c3 retq
< 39: c7 05 00 00 00 00 00 movl $0x0,0x0(%rip) # 43 <k+0x33>
< 40: 00 00 00
< 43: 66 c7 05 00 00 00 00 movw $0x0,0x0(%rip) # 4c <k+0x3c>
< 4a: 00 00
< 4c: eb 52 jmp a0 <k+0x90>
< 4e: ba 01 00 00 00 mov $0x1,%edx
< 53: 31 c9 xor %ecx,%ecx
< 55: 66 66 2e 0f 1f 84 00 data16 nopw %cs:0x0(%rax,%rax,1)
< 5c: 00 00 00 00
< 60: 85 d2 test %edx,%edx
< 62: ba 00 00 00 00 mov $0x0,%edx
< 67: 74 0f je 78 <k+0x68>
< 69: 8b 05 00 00 00 00 mov 0x0(%rip),%eax # 6f <k+0x5f>
< 6f: 0f b7 0d 00 00 00 00 movzwl 0x0(%rip),%ecx # 76 <k+0x66>
< 76: 89 c2 mov %eax,%edx
< 78: 66 83 f9 01 cmp $0x1,%cx
< 7c: 75 e2 jne 60 <k+0x50>
< 7e: c7 05 00 00 00 00 00 movl $0x0,0x0(%rip) # 88 <k+0x78>
< 85: 00 00 00
< 88: 66 c7 05 00 00 00 00 movw $0x0,0x0(%rip) # 91 <k+0x81>
< 8f: 00 00
< 91: 31 c9 xor %ecx,%ecx
< 93: 89 c2 mov %eax,%edx
< 95: 85 c0 test %eax,%eax
< 97: 75 c7 jne 60 <k+0x50>
< 99: 0f 1f 80 00 00 00 00 nopl 0x0(%rax)
< a0: eb fe jmp a0 <k+0x90>
< a2: 66 66 66 66 66 2e 0f data16 data16 data16 data16 nopw %cs:0x0(%rax,%rax,1)
< a9: 1f 84 00 00 00 00 00
---
> 16: c7 05 00 00 00 00 00 movl $0x0,0x0(%rip) # 20 <k+0x10>
> 1d: 00 00 00
> 20: 66 c7 05 00 00 00 00 movw $0x0,0x0(%rip) # 29 <k+0x19>
> 27: 00 00
> 29: 85 c0 test %eax,%eax
> 2b: 74 53 je 80 <k+0x70>
> 2d: ba 01 00 00 00 mov $0x1,%edx
> 32: 31 c9 xor %ecx,%ecx
> 34: 66 66 66 2e 0f 1f 84 data16 data16 nopw %cs:0x0(%rax,%rax,1)
> 3b: 00 00 00 00 00
> 40: 85 d2 test %edx,%edx
> 42: ba 00 00 00 00 mov $0x0,%edx
> 47: 74 14 je 5d <k+0x4d>
> 49: 66 85 f6 test %si,%si
> 4c: 75 34 jne 82 <k+0x72>
> 4e: 8b 05 00 00 00 00 mov 0x0(%rip),%eax # 54 <k+0x44>
> 54: 0f b7 0d 00 00 00 00 movzwl 0x0(%rip),%ecx # 5b <k+0x4b>
> 5b: 89 c2 mov %eax,%edx
> 5d: 66 83 f9 01 cmp $0x1,%cx
> 61: 75 dd jne 40 <k+0x30>
> 63: c7 05 00 00 00 00 00 movl $0x0,0x0(%rip) # 6d <k+0x5d>
> 6a: 00 00 00
> 6d: 66 c7 05 00 00 00 00 movw $0x0,0x0(%rip) # 76 <k+0x66>
> 74: 00 00
> 76: 31 c9 xor %ecx,%ecx
> 78: 89 c2 mov %eax,%edx
> 7a: 85 c0 test %eax,%eax
> 7c: 75 c2 jne 40 <k+0x30>
> 7e: 66 90 xchg %ax,%ax
> 80: eb fe jmp 80 <k+0x70>
> 82: 8b 05 00 00 00 00 mov 0x0(%rip),%eax # 88 <k+0x78>
> 88: c3 retq
> 89: 0f 1f 80 00 00 00 00 nopl 0x0(%rax)
55,56c49,50
< 00000000000000b0 <main>:
< b0: c3 retq
---
> 0000000000000090 <main>:
> 90: c3 retq
71,109c65,97
< 16: 85 c0 test %eax,%eax
< 18: 74 1f je 39 <k+0x29>
< 1a: c7 05 00 00 00 00 00 movl $0x0,0x0(%rip) # 24 <k+0x14>
< 21: 00 00 00
< 24: 66 c7 05 00 00 00 00 movw $0x0,0x0(%rip) # 2d <k+0x1d>
< 2b: 00 00
< 2d: 66 85 f6 test %si,%si
< 30: 74 1c je 4e <k+0x3e>
< 32: 8b 05 00 00 00 00 mov 0x0(%rip),%eax # 38 <k+0x28>
< 38: c3 retq
< 39: c7 05 00 00 00 00 00 movl $0x0,0x0(%rip) # 43 <k+0x33>
< 40: 00 00 00
< 43: 66 c7 05 00 00 00 00 movw $0x0,0x0(%rip) # 4c <k+0x3c>
< 4a: 00 00
< 4c: eb 52 jmp a0 <k+0x90>
< 4e: ba 01 00 00 00 mov $0x1,%edx
< 53: 31 c9 xor %ecx,%ecx
< 55: 66 66 2e 0f 1f 84 00 data16 nopw %cs:0x0(%rax,%rax,1)
< 5c: 00 00 00 00
< 60: 85 d2 test %edx,%edx
< 62: ba 00 00 00 00 mov $0x0,%edx
< 67: 74 0f je 78 <k+0x68>
< 69: 8b 05 00 00 00 00 mov 0x0(%rip),%eax # 6f <k+0x5f>
< 6f: 0f b7 0d 00 00 00 00 movzwl 0x0(%rip),%ecx # 76 <k+0x66>
< 76: 89 c2 mov %eax,%edx
< 78: 66 83 f9 01 cmp $0x1,%cx
< 7c: 75 e2 jne 60 <k+0x50>
< 7e: c7 05 00 00 00 00 00 movl $0x0,0x0(%rip) # 88 <k+0x78>
< 85: 00 00 00
< 88: 66 c7 05 00 00 00 00 movw $0x0,0x0(%rip) # 91 <k+0x81>
< 8f: 00 00
< 91: 31 c9 xor %ecx,%ecx
< 93: 89 c2 mov %eax,%edx
< 95: 85 c0 test %eax,%eax
< 97: 75 c7 jne 60 <k+0x50>
< 99: 0f 1f 80 00 00 00 00 nopl 0x0(%rax)
< a0: eb fe jmp a0 <k+0x90>
< a2: 66 66 66 66 66 2e 0f data16 data16 data16 data16 nopw %cs:0x0(%rax,%rax,1)
< a9: 1f 84 00 00 00 00 00
---
> 16: c7 05 00 00 00 00 00 movl $0x0,0x0(%rip) # 20 <k+0x10>
> 1d: 00 00 00
> 20: 66 c7 05 00 00 00 00 movw $0x0,0x0(%rip) # 29 <k+0x19>
> 27: 00 00
> 29: 85 c0 test %eax,%eax
> 2b: 74 53 je 80 <k+0x70>
> 2d: ba 01 00 00 00 mov $0x1,%edx
> 32: 31 c9 xor %ecx,%ecx
> 34: 66 66 66 2e 0f 1f 84 data16 data16 nopw %cs:0x0(%rax,%rax,1)
> 3b: 00 00 00 00 00
> 40: 85 d2 test %edx,%edx
> 42: ba 00 00 00 00 mov $0x0,%edx
> 47: 74 14 je 5d <k+0x4d>
> 49: 66 85 f6 test %si,%si
> 4c: 75 34 jne 82 <k+0x72>
> 4e: 8b 05 00 00 00 00 mov 0x0(%rip),%eax # 54 <k+0x44>
> 54: 0f b7 0d 00 00 00 00 movzwl 0x0(%rip),%ecx # 5b <k+0x4b>
> 5b: 89 c2 mov %eax,%edx
> 5d: 66 83 f9 01 cmp $0x1,%cx
> 61: 75 dd jne 40 <k+0x30>
> 63: c7 05 00 00 00 00 00 movl $0x0,0x0(%rip) # 6d <k+0x5d>
> 6a: 00 00 00
> 6d: 66 c7 05 00 00 00 00 movw $0x0,0x0(%rip) # 76 <k+0x66>
> 74: 00 00
> 76: 31 c9 xor %ecx,%ecx
> 78: 89 c2 mov %eax,%edx
> 7a: 85 c0 test %eax,%eax
> 7c: 75 c2 jne 40 <k+0x30>
> 7e: 66 90 xchg %ax,%ax
> 80: eb fe jmp 80 <k+0x70>
> 82: 8b 05 00 00 00 00 mov 0x0(%rip),%eax # 88 <k+0x78>
> 88: c3 retq
> 89: 0f 1f 80 00 00 00 00 nopl 0x0(%rax)
111,112c99,100
< 00000000000000b0 <main>:
< b0: c3 retq
---
> 0000000000000090 <main>:
> 90: c3 retq
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztWkuTozYQ_jWeiwqXkMTr4MPOY1M55ZDcp4QkbGYxTACPvfn1aQkMAmPHM3alKilclBF6dH_9UKvdJi7kz9UfG4WWtTrUqFKiToscJUWJFj5O8yzN1Suvtq_vZbEu-RZDQ0FbqKpScilgEhIb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