public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug lto/107036] New: Emitted binary code changes when -g is enabled at -O1 -flto and optimize attribute
@ 2022-09-26  1:53 tlwang at uwaterloo dot ca
  0 siblings, 0 replies; only message in thread
From: tlwang at uwaterloo dot ca @ 2022-09-26  1:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107036

            Bug ID: 107036
           Summary: Emitted binary code changes when -g is enabled at -O1
                    -flto and optimize attribute
           Product: gcc
           Version: 13.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 when compiling attributes_program0_preprocessed.c as shown below:

$ cat attributes_program0_preprocessed.c
struct {
  volatile short a;
  int b;
} c = {1};
void d() { short e = c.b; }
void f() {}
void g() { c.a; }
__attribute__((optimize(0))) int main() {
  f(g);
  d();
}
$ 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/13.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /tmp/tmp.KbBz3lKFoo-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 13.0.0 20220925 (experimental) [master -g28a61ecdc] (GCC)
tlwang@cartesian:~/inline_asm_bugs/3966721184$ gcc-trunk -w -flto -O1
attributes_program0_preprocessed.c -o a.out ; objdump --disassemble
--section=.text a.out > no_dbg.txt
$ gcc-trunk -w -flto -O1 attributes_program0_preprocessed.c -g -o a.out ;
objdump --disassemble --section=.text a.out > dbg.txt
$ diff no_dbg.txt dbg.txt
98,100c98,101
<   401113:     0f b7 05 ee 0e 00 00    movzwl 0xeee(%rip),%eax        # 402008
<c>
<   40111a:     c3                      retq
<   40111b:     0f 1f 44 00 00          nopl   0x0(%rax,%rax,1)
---
>   401113:	c3                   	retq
>   401114:	66 2e 0f 1f 84 00 00 	nopw   %cs:0x0(%rax,%rax,1)
>   40111b:	00 00 00
>   40111e:	66 90                	xchg   %ax,%ax

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-09-26  1:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-26  1:53 [Bug lto/107036] New: Emitted binary code changes when -g is enabled at -O1 -flto and optimize attribute tlwang at uwaterloo dot ca

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).