public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug lto/104589] New: Emitted binary code changes when -g is enabled at -O0 -flto and optimize attribute
@ 2022-02-18  6:50 tlwang at uwaterloo dot ca
  2022-02-18  7:45 ` [Bug rtl-optimization/104589] " rguenth at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: tlwang at uwaterloo dot ca @ 2022-02-18  6:50 UTC (permalink / raw)
  To: gcc-bugs

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug rtl-optimization/104589] Emitted binary code changes when -g is enabled at -O0 -flto and optimize attribute
  2022-02-18  6:50 [Bug lto/104589] New: Emitted binary code changes when -g is enabled at -O0 -flto and optimize attribute tlwang at uwaterloo dot ca
@ 2022-02-18  7:45 ` rguenth at gcc dot gnu.org
  2022-02-22 10:20 ` [Bug rtl-optimization/104589] [11/12 Regression] Emitted binary code changes when -g is enabled at -O0 -flto and optimize attribute since r11-3026-gfea13fcd0da03535 marxin at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-02-18  7:45 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
           Keywords|                            |compare-debug-failure
          Component|lto                         |rtl-optimization
   Last reconfirmed|                            |2022-02-18

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.  .optimized are the same besides UID differences.  The only
visible RTL difference is

-(insn 17 16 32 4 (set (reg:SI 0 ax [orig:84 _4 ] [84])
+(insn 17 16 18 4 (set (reg:SI 0 ax [orig:84 _4 ] [84])
         (sign_extend:SI (reg:HI 0 ax [orig:86 _6 ] [86]))) "t.c":9:15 158
{exte
ndhisi2}
      (nil))
-(insn 32 17 18 4 (const_int 0 [0]) "t.c":9:15 928 {nop}
-     (nil))
-(code_label 18 32 19 5 3 (nil) [1 uses])
-(note 19 18 48 5 [bb 5] NOTE_INSN_BASIC_BLOCK)
-(note 48 19 20 5 0x7ffff63501e0 NOTE_INSN_BLOCK_END)
-(insn 20 48 49 5 (set (mem/c:SI (symbol_ref:DI ("c") [flags 0x2]  <var_decl
0x7
ffff6523d80 c>) [2 c+0 S4 A32])
+(code_label 18 17 19 5 3 (nil) [1 uses])
+(note 19 18 20 5 [bb 5] NOTE_INSN_BASIC_BLOCK)
+(insn 20 19 21 5 (set (mem/c:SI (symbol_ref:DI ("c") [flags 0x2]  <var_decl
0x7
ffff6523d80 c>) [2 c+0 S4 A32])
         (reg:SI 0 ax [orig:84 _4 ] [84])) "t.c":7:5 81 {*movsi_internal}
      (nil))

so there's an explicit extra 'nop' and a missing BLOCK_END note. 
-gno-statement-frontiers does not fix it.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug rtl-optimization/104589] [11/12 Regression] Emitted binary code changes when -g is enabled at -O0 -flto and optimize attribute since r11-3026-gfea13fcd0da03535
  2022-02-18  6:50 [Bug lto/104589] New: Emitted binary code changes when -g is enabled at -O0 -flto and optimize attribute tlwang at uwaterloo dot ca
  2022-02-18  7:45 ` [Bug rtl-optimization/104589] " rguenth at gcc dot gnu.org
@ 2022-02-22 10:20 ` marxin at gcc dot gnu.org
  2022-03-01 15:21 ` jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-02-22 10:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
Started with r11-3026-gfea13fcd0da03535.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug rtl-optimization/104589] [11/12 Regression] Emitted binary code changes when -g is enabled at -O0 -flto and optimize attribute since r11-3026-gfea13fcd0da03535
  2022-02-18  6:50 [Bug lto/104589] New: Emitted binary code changes when -g is enabled at -O0 -flto and optimize attribute tlwang at uwaterloo dot ca
  2022-02-18  7:45 ` [Bug rtl-optimization/104589] " rguenth at gcc dot gnu.org
  2022-02-22 10:20 ` [Bug rtl-optimization/104589] [11/12 Regression] Emitted binary code changes when -g is enabled at -O0 -flto and optimize attribute since r11-3026-gfea13fcd0da03535 marxin at gcc dot gnu.org
@ 2022-03-01 15:21 ` jakub at gcc dot gnu.org
  2022-03-02  9:49 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-03-01 15:21 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |jakub at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 52539
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52539&action=edit
gcc12-pr104589.patch

Untested fix.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug rtl-optimization/104589] [11/12 Regression] Emitted binary code changes when -g is enabled at -O0 -flto and optimize attribute since r11-3026-gfea13fcd0da03535
  2022-02-18  6:50 [Bug lto/104589] New: Emitted binary code changes when -g is enabled at -O0 -flto and optimize attribute tlwang at uwaterloo dot ca
                   ` (2 preceding siblings ...)
  2022-03-01 15:21 ` jakub at gcc dot gnu.org
@ 2022-03-02  9:49 ` cvs-commit at gcc dot gnu.org
  2022-03-02  9:53 ` [Bug rtl-optimization/104589] [11 " jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-03-02  9:49 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:2e1b00367abaf8b6dbb47fd8518d9ac69c326a06

commit r12-7447-g2e1b00367abaf8b6dbb47fd8518d9ac69c326a06
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Mar 2 10:48:14 2022 +0100

    cfgrtl: Fix up -g vs. -g0 code generation -flto differences in
fixup_reorder_chain [PR104589]

    This is similar to PR104237 and similarly to that, no testcase included
    for the testsuite, as we don't have a framework to compile/link with
    -g -flto and -g0 -flto and compare -fdump-final-insns= results from
    the lto1 compilations.

    With -flto, whether two location_t compare equal or not and just
    express the same location is a lottery.

    2022-03-02  Jakub Jelinek  <jakub@redhat.com>

            PR rtl-optimization/104589
            * cfgrtl.cc (fixup_reorder_chain): Use loc_equal instead of direct
            INSN_LOCATION comparison with goto_locus.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug rtl-optimization/104589] [11 Regression] Emitted binary code changes when -g is enabled at -O0 -flto and optimize attribute since r11-3026-gfea13fcd0da03535
  2022-02-18  6:50 [Bug lto/104589] New: Emitted binary code changes when -g is enabled at -O0 -flto and optimize attribute tlwang at uwaterloo dot ca
                   ` (3 preceding siblings ...)
  2022-03-02  9:49 ` cvs-commit at gcc dot gnu.org
@ 2022-03-02  9:53 ` jakub at gcc dot gnu.org
  2022-03-02  9:54 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-03-02  9:53 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[11/12 Regression] Emitted  |[11 Regression] Emitted
                   |binary code changes when -g |binary code changes when -g
                   |is enabled at -O0 -flto and |is enabled at -O0 -flto and
                   |optimize attribute since    |optimize attribute since
                   |r11-3026-gfea13fcd0da03535  |r11-3026-gfea13fcd0da03535

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed on the trunk so far.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug rtl-optimization/104589] [11 Regression] Emitted binary code changes when -g is enabled at -O0 -flto and optimize attribute since r11-3026-gfea13fcd0da03535
  2022-02-18  6:50 [Bug lto/104589] New: Emitted binary code changes when -g is enabled at -O0 -flto and optimize attribute tlwang at uwaterloo dot ca
                   ` (4 preceding siblings ...)
  2022-03-02  9:53 ` [Bug rtl-optimization/104589] [11 " jakub at gcc dot gnu.org
@ 2022-03-02  9:54 ` jakub at gcc dot gnu.org
  2022-03-29  5:53 ` cvs-commit at gcc dot gnu.org
  2022-03-30  8:15 ` jakub at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-03-02  9:54 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |11.3
           Priority|P3                          |P2

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug rtl-optimization/104589] [11 Regression] Emitted binary code changes when -g is enabled at -O0 -flto and optimize attribute since r11-3026-gfea13fcd0da03535
  2022-02-18  6:50 [Bug lto/104589] New: Emitted binary code changes when -g is enabled at -O0 -flto and optimize attribute tlwang at uwaterloo dot ca
                   ` (5 preceding siblings ...)
  2022-03-02  9:54 ` jakub at gcc dot gnu.org
@ 2022-03-29  5:53 ` cvs-commit at gcc dot gnu.org
  2022-03-30  8:15 ` jakub at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-03-29  5:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:7737259ceaa490a1cc75415efa00f3631a7e17df

commit r11-9723-g7737259ceaa490a1cc75415efa00f3631a7e17df
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Mar 2 10:48:14 2022 +0100

    cfgrtl: Fix up -g vs. -g0 code generation -flto differences in
fixup_reorder_chain [PR104589]

    This is similar to PR104237 and similarly to that, no testcase included
    for the testsuite, as we don't have a framework to compile/link with
    -g -flto and -g0 -flto and compare -fdump-final-insns= results from
    the lto1 compilations.

    With -flto, whether two location_t compare equal or not and just
    express the same location is a lottery.

    2022-03-02  Jakub Jelinek  <jakub@redhat.com>

            PR rtl-optimization/104589
            * cfgrtl.c (fixup_reorder_chain): Use loc_equal instead of direct
            INSN_LOCATION comparison with goto_locus.

    (cherry picked from commit 2e1b00367abaf8b6dbb47fd8518d9ac69c326a06)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug rtl-optimization/104589] [11 Regression] Emitted binary code changes when -g is enabled at -O0 -flto and optimize attribute since r11-3026-gfea13fcd0da03535
  2022-02-18  6:50 [Bug lto/104589] New: Emitted binary code changes when -g is enabled at -O0 -flto and optimize attribute tlwang at uwaterloo dot ca
                   ` (6 preceding siblings ...)
  2022-03-29  5:53 ` cvs-commit at gcc dot gnu.org
@ 2022-03-30  8:15 ` jakub at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-03-30  8:15 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed for 11.3 too.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-03-30  8:15 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-18  6:50 [Bug lto/104589] New: Emitted binary code changes when -g is enabled at -O0 -flto and optimize attribute tlwang at uwaterloo dot ca
2022-02-18  7:45 ` [Bug rtl-optimization/104589] " rguenth at gcc dot gnu.org
2022-02-22 10:20 ` [Bug rtl-optimization/104589] [11/12 Regression] Emitted binary code changes when -g is enabled at -O0 -flto and optimize attribute since r11-3026-gfea13fcd0da03535 marxin at gcc dot gnu.org
2022-03-01 15:21 ` jakub at gcc dot gnu.org
2022-03-02  9:49 ` cvs-commit at gcc dot gnu.org
2022-03-02  9:53 ` [Bug rtl-optimization/104589] [11 " jakub at gcc dot gnu.org
2022-03-02  9:54 ` jakub at gcc dot gnu.org
2022-03-29  5:53 ` cvs-commit at gcc dot gnu.org
2022-03-30  8:15 ` jakub at gcc dot gnu.org

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).