public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "tlwang at uwaterloo dot ca" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug lto/107030] New: Emitted binary code changes when -g is enabled at -O2 -flto and optimize attribute
Date: Sun, 25 Sep 2022 04:34:28 +0000	[thread overview]
Message-ID: <bug-107030-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 107030
           Summary: Emitted binary code changes when -g is enabled at -O2
                    -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:

$ 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.O2a2UsOhYi-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 20220924 (experimental) [master -g4afaeaab5] (GCC)
$ cat attributes_program0_preprocessed.c
int a;
union {
  char b;
  long c;
} d = {0};
void e(f) { g(d.b); }
__attribute__((optimize(0))) static short h() {
  e(d.c);
  int i = a;
}
void g(j) {}
int main() {}
$ gcc-trunk -w -flto -O2 attributes_program0_preprocessed.c -o a.out; objdump
--disassemble --section=.text a.out > no_dbg.txt
$ gcc-trunk -w -flto -O2 attributes_program0_preprocessed.c -g -o a.out;
objdump --disassemble --section=.text a.out > dbg.txt
$ diff no_dbg.txt dbg.txt
96c96
<   401124:     8b 05 de 0e 00 00       mov    0xede(%rip),%eax        # 402008
<a>
---
>   401124:	8b 05 da 0e 00 00    	mov    0xeda(%rip),%eax        # 402004 <a>

             reply	other threads:[~2022-09-25  4:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-25  4:34 tlwang at uwaterloo dot ca [this message]
2022-09-25  4:51 ` [Bug lto/107030] " pinskia at gcc dot gnu.org
2022-09-25  6:49 ` schwab@linux-m68k.org
2022-09-26  9:25 ` rguenth at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-107030-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).