[Bug lto/104589] New: Emitted binary code changes when -g is enabled at -O0 -flto and optimize attribute
tlwang at uwaterloo dot ca
gcc-bugzilla@gcc.gnu.org
Fri Feb 18 06:50:42 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104589
Bug ID: 104589
Summary: Emitted binary code changes when -g is enabled at -O0
-flto and optimize attribute
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: lto
Assignee: unassigned at gcc dot gnu.org
Reporter: tlwang at uwaterloo dot ca
CC: marxin at gcc dot gnu.org
Target Milestone: ---
This occurs in preprocessed.c, as shown below:
$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/scratch/software/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/12.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /tmp/tmp.m8P0CFupUR-gcc-builder/gcc/configure
--enable-languages=c,c++,lto --enable-checking-yes --enable-multiarch
--prefix=/scratch/software/gcc-trunk --disable-bootstrap
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.0.1 20220217 (experimental) [master -g837eb1262] (GCC)
$
$ cat preprocessed.c
short a, b;
int c, d;
__attribute__((always_inline)) __attribute__((optimize(1))) short e() {
for (; 0;)
return 0;
d = b;
c = ({
int g = b;
g &&a ? g : a;
});
short f;
return 8;
# 8 ""
}
int main() {
strcmp("");
e();
}
$
$ gcc-trunk -flto -w -O0 preprocessed.c; objdump --disassemble --section=.text
a.out > no_debug.txt
$ gcc-trunk -flto -w -O0 -g preprocessed.c; objdump --disassemble
--section=.text a.out > debug.txt
$ diff no_debug.txt debug.txt
94c94
< 401126: 75 08 jne 401130 <main+0x2a>
---
> 401126: 75 09 jne 401131 <main+0x2b>
97,101c97,102
< 401130: 89 05 fa 2e 00 00 mov %eax,0x2efa(%rip) #
404030 <c>
< 401136: b8 00 00 00 00 mov $0x0,%eax
< 40113b: 5d pop %rbp
< 40113c: c3 retq
< 40113d: 0f 1f 00 nopl (%rax)
---
> 401130: 90 nop
> 401131: 89 05 f9 2e 00 00 mov %eax,0x2ef9(%rip) # 404030 <c>
> 401137: b8 00 00 00 00 mov $0x0,%eax
> 40113c: 5d pop %rbp
> 40113d: c3 retq
> 40113e: 66 90 xchg %ax,%ax
More information about the Gcc-bugs
mailing list