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 tree-optimization/100781] New: Emitted binary code changes when -g is enabled at -O2
Date: Wed, 26 May 2021 21:12:06 +0000	[thread overview]
Message-ID: <bug-100781-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 100781
           Summary: Emitted binary code changes when -g is enabled at -O2
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tlwang at uwaterloo dot ca
  Target Milestone: ---

The .text section for the following program (transformed_program0.c) changes
after toggling the -g flag. 

$ cat transformed_program0.c
struct a {
  int b;
};
long c(short d, long e, struct a f) {
g:;
  int h = f.b <= e, i = d, n = h >= d;
  if (!n)
    goto j;
  goto k;
j:;
  long l = 5;
  if (l)
    goto m;
  d = 0;
m:
  if (d)
    return f.b;
k:
  goto g;
}
int main() {}
$
$ 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.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /tmp/tmp.tVhv2eaPzV-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.0 20210526 (experimental) [master revision
:21638bbbf:1fd76b24306ed4df4cf9e797d900699ed59ce7f7] (GCC)
$
$ gcc-trunk transformed_program0.c -O2 -w ; objdump --disassemble a.out >
"no-g.txt"
$ gcc-trunk transformed_program0.c -O2 -w -g; objdump --disassemble a.out >
"g.txt"
$ diff no-g.txt g.txt
108,111c108,111
<   401125:     89 f9                   mov    %edi,%ecx
<   401127:     0f bf ff                movswl %di,%edi
<   40112a:     49 39 f0                cmp    %rsi,%r8
<   40112d:     0f 9e c0                setle  %al
---
>   401125:	0f bf ff             	movswl %di,%edi
>   401128:	4c 39 c6             	cmp    %r8,%rsi
>   40112b:	0f 9d c0             	setge  %al
>   40112e:	66 90                	xchg   %ax,%ax
114,118c114,117
<   401134:     66 85 c9                test   %cx,%cx
<   401137:     74 f7                   je     401130 <c+0x10>
<   401139:     4c 89 c0                mov    %r8,%rax
<   40113c:     c3                      retq
<   40113d:     0f 1f 00                nopl   (%rax)
---
>   401134:	4c 89 c0             	mov    %r8,%rax
>   401137:	c3                   	retq
>   401138:	0f 1f 84 00 00 00 00 	nopl   0x0(%rax,%rax,1)
>   40113f:	00

             reply	other threads:[~2021-05-26 21:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-26 21:12 tlwang at uwaterloo dot ca [this message]
2021-05-26 21:30 ` [Bug tree-optimization/100781] [12 Regression] " pinskia at gcc dot gnu.org
2021-05-26 21:31 ` pinskia at gcc dot gnu.org
2021-05-26 21:33 ` pinskia at gcc dot gnu.org
2021-05-26 21:38 ` pinskia at gcc dot gnu.org
2021-05-27  6:20 ` aldyh at gcc dot gnu.org
2021-05-27 18:13 ` amacleod at redhat dot com
2021-06-01  1:32 ` cvs-commit at gcc dot gnu.org
2021-06-01  1:36 ` amacleod at redhat dot com
2021-06-01  1:36 ` amacleod at redhat dot com
2021-07-14 21:58 ` cvs-commit 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-100781-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).