public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/103465] New: Invalid note with -fno-reorder-blocks-and-partition
@ 2021-11-29 10:00 tomas.kalibera at gmail dot com
  2021-11-29 10:12 ` [Bug rtl-optimization/103465] " marxin at gcc dot gnu.org
                   ` (33 more replies)
  0 siblings, 34 replies; 35+ messages in thread
From: tomas.kalibera at gmail dot com @ 2021-11-29 10:00 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 103465
           Summary: Invalid note with -fno-reorder-blocks-and-partition
           Product: gcc
           Version: 11.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tomas.kalibera at gmail dot com
  Target Milestone: ---

With GCC 10.3.0 and 11.2.0, compiling this example with

-O2 -fno-reorder-blocks-and-partition

for Windows emits a note

uwi.c:3:9: note: '-freorder-blocks-and-partition' does not support unwind info
on this architecture
    3 | #pragma GCC optimize ("unroll-loops")
      |         ^~~
uwi.c:5:1: note: '-freorder-blocks-and-partition' does not support unwind info
on this architecture
    5 | int main(int argc, char **argv) {
      | ^~~

(even though asking GCC to _not_ perform that optimization)

#include<stdio.h>

#pragma GCC optimize ("unroll-loops")

int main(int argc, char **argv) {
  printf("Hello 1\n");
  printf("Hello 2\n");
  printf("Hello 3\n");
  return 0;
}

This note is emitted twice for this example and many times for bigger examples,
also for other GCC optimization options pragmas. The outputs can become large
(e.g. building R CRAN packages increased log file from about 1G to 12G).

The note is also emitted when -freorder-blocks-and-partition is given
(explicitly), which is probably intended, but it is not emitted when the
optimization is used implicitly as part of -O2.

The same problem exists with g++, except the wording of the note is "does not
work with exceptions on this architecture"

With "12.0" (5e5f880d0452ef2cffb94f4a686d56833c9f4215), the note is not emitted
with -fno-reorder-blocks-and-partition, however, the other problem remains. The
note is still not emitted when the optimization is enabled implicitly via -O2.

Related to Bug 103274; the reason for using -fno-reorder-blocks-and-partition
was to get valid unwind information for long jumps to work.

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

* [Bug rtl-optimization/103465] Invalid note with -fno-reorder-blocks-and-partition
  2021-11-29 10:00 [Bug rtl-optimization/103465] New: Invalid note with -fno-reorder-blocks-and-partition tomas.kalibera at gmail dot com
@ 2021-11-29 10:12 ` marxin at gcc dot gnu.org
  2021-11-29 10:17 ` tomas.kalibera at gmail dot com
                   ` (32 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-11-29 10:12 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |marxin at gcc dot gnu.org

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
I can take a look, what's the target please?

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

* [Bug rtl-optimization/103465] Invalid note with -fno-reorder-blocks-and-partition
  2021-11-29 10:00 [Bug rtl-optimization/103465] New: Invalid note with -fno-reorder-blocks-and-partition tomas.kalibera at gmail dot com
  2021-11-29 10:12 ` [Bug rtl-optimization/103465] " marxin at gcc dot gnu.org
@ 2021-11-29 10:17 ` tomas.kalibera at gmail dot com
  2021-11-29 10:18 ` marxin at gcc dot gnu.org
                   ` (31 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: tomas.kalibera at gmail dot com @ 2021-11-29 10:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Tomas Kalibera <tomas.kalibera at gmail dot com> ---
(In reply to Martin Liška from comment #1)
> I can take a look, what's the target please?

Thanks, x86_64-w64-mingw32 (with UCRT as the CRT, but that probably does not
matter).

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

* [Bug rtl-optimization/103465] Invalid note with -fno-reorder-blocks-and-partition
  2021-11-29 10:00 [Bug rtl-optimization/103465] New: Invalid note with -fno-reorder-blocks-and-partition tomas.kalibera at gmail dot com
  2021-11-29 10:12 ` [Bug rtl-optimization/103465] " marxin at gcc dot gnu.org
  2021-11-29 10:17 ` tomas.kalibera at gmail dot com
@ 2021-11-29 10:18 ` marxin at gcc dot gnu.org
  2021-11-29 13:23 ` marxin at gcc dot gnu.org
                   ` (30 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-11-29 10:18 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-11-29
           Assignee|unassigned at gcc dot gnu.org      |marxin at gcc dot gnu.org
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |ASSIGNED

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

* [Bug rtl-optimization/103465] Invalid note with -fno-reorder-blocks-and-partition
  2021-11-29 10:00 [Bug rtl-optimization/103465] New: Invalid note with -fno-reorder-blocks-and-partition tomas.kalibera at gmail dot com
                   ` (2 preceding siblings ...)
  2021-11-29 10:18 ` marxin at gcc dot gnu.org
@ 2021-11-29 13:23 ` marxin at gcc dot gnu.org
  2021-11-29 15:25 ` tomas.kalibera at gmail dot com
                   ` (29 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-11-29 13:23 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |WAITING

--- Comment #3 from Martin Liška <marxin at gcc dot gnu.org> ---
Let's speak about the current master:

> With "12.0" (5e5f880d0452ef2cffb94f4a686d56833c9f4215), the note is not
> emitted with -fno-reorder-blocks-and-partition, however, the other problem
> remains. The note is still not emitted when the optimization is enabled
> implicitly via -O2.

I see:

/xgcc -B. /home/marxin/Programming/testcases/pr103465.c -c -O2
-freorder-blocks-and-partition
/home/marxin/Programming/testcases/pr103465.c:2:9: note:
‘-freorder-blocks-and-partition’ does not support unwind info on this
architecture
    2 | #pragma GCC optimize ("unroll-loops")
      |         ^~~
/home/marxin/Programming/testcases/pr103465.c:4:1: note:
‘-freorder-blocks-and-partition’ does not support unwind info on this
architecture
    4 | int main(int argc, char **argv) {
      | ^~~

which seems correct to me. With only -O2 there's no note emitted and the flags
are properly dropped (same in -freorder-blocks-and-partition):

$ cat -n gcc/opts.c
...
  1133    if (opts->x_flag_unwind_tables
  1134        && !targetm_common.unwind_tables_default
  1135        && opts->x_flag_reorder_blocks_and_partition
  1136        && (ui_except == UI_SJLJ || ui_except >= UI_TARGET))
  1137      {
  1138        if (opts_set->x_flag_reorder_blocks_and_partition)
  1139          inform (loc,
  1140                  "%<-freorder-blocks-and-partition%> does not support "
  1141                  "unwind info on this architecture");
  1142        opts->x_flag_reorder_blocks_and_partition = 0;
  1143        opts->x_flag_reorder_blocks = 1;
  1144      }

So what's wrong with that, please?

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

* [Bug rtl-optimization/103465] Invalid note with -fno-reorder-blocks-and-partition
  2021-11-29 10:00 [Bug rtl-optimization/103465] New: Invalid note with -fno-reorder-blocks-and-partition tomas.kalibera at gmail dot com
                   ` (3 preceding siblings ...)
  2021-11-29 13:23 ` marxin at gcc dot gnu.org
@ 2021-11-29 15:25 ` tomas.kalibera at gmail dot com
  2021-12-09 13:39 ` marxin at gcc dot gnu.org
                   ` (28 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: tomas.kalibera at gmail dot com @ 2021-11-29 15:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Tomas Kalibera <tomas.kalibera at gmail dot com> ---
(In reply to Martin Liška from comment #3)
> Let's speak about the current master:
> 
> > With "12.0" (5e5f880d0452ef2cffb94f4a686d56833c9f4215), the note is not
> > emitted with -fno-reorder-blocks-and-partition, however, the other problem
> > remains. The note is still not emitted when the optimization is enabled
> > implicitly via -O2.
> 
> I see:
> 
> /xgcc -B. /home/marxin/Programming/testcases/pr103465.c -c -O2
> -freorder-blocks-and-partition
> /home/marxin/Programming/testcases/pr103465.c:2:9: note:
> ‘-freorder-blocks-and-partition’ does not support unwind info on this
> architecture
>     2 | #pragma GCC optimize ("unroll-loops")
>       |         ^~~
> /home/marxin/Programming/testcases/pr103465.c:4:1: note:
> ‘-freorder-blocks-and-partition’ does not support unwind info on this
> architecture
>     4 | int main(int argc, char **argv) {
>       | ^~~
> 
> which seems correct to me. With only -O2 there's no note emitted and the
> flags are properly dropped (same in -freorder-blocks-and-partition):
> 
> $ cat -n gcc/opts.c
> ...
>   1133    if (opts->x_flag_unwind_tables
>   1134        && !targetm_common.unwind_tables_default
>   1135        && opts->x_flag_reorder_blocks_and_partition
>   1136        && (ui_except == UI_SJLJ || ui_except >= UI_TARGET))
>   1137      {
>   1138        if (opts_set->x_flag_reorder_blocks_and_partition)
>   1139          inform (loc,
>   1140                  "%<-freorder-blocks-and-partition%> does not support
> "
>   1141                  "unwind info on this architecture");
>   1142        opts->x_flag_reorder_blocks_and_partition = 0;
>   1143        opts->x_flag_reorder_blocks = 1;
>   1144      }
> 
> So what's wrong with that, please?

Thanks for looking into this. I didn't realize an optimization can be dropped
silently - I only checked

x86_64-w64-mingw32-gcc -O2 -Q --help=optimizers

and that said "enabled". Sorry for that.

However, still talking about the current master only, I see a difference with
-O3, when I try on the repro example from Bug 103274 and -O3:

x86_64-w64-mingw32-gcc -c -S -O3 -fno-reorder-blocks-and-partition a.c -o
nropt.s

x86_64-w64-mingw32-gcc -c -S -O3 -freorder-blocks-and-partition a.c -o ropt.s
x86_64-w64-mingw32-gcc -c -S -O3  a.c -o noopt.s

All of these assembler files are different (and from my non-expert reading,
noopt.s uses the optimization and does have the invalid unwind information as
reported in Bug 103274). Is the optimization correctly dropped also with -O3
only?

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

* [Bug rtl-optimization/103465] Invalid note with -fno-reorder-blocks-and-partition
  2021-11-29 10:00 [Bug rtl-optimization/103465] New: Invalid note with -fno-reorder-blocks-and-partition tomas.kalibera at gmail dot com
                   ` (4 preceding siblings ...)
  2021-11-29 15:25 ` tomas.kalibera at gmail dot com
@ 2021-12-09 13:39 ` marxin at gcc dot gnu.org
  2021-12-09 13:40 ` marxin at gcc dot gnu.org
                   ` (27 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-12-09 13:39 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Martin Liška <marxin at gcc dot gnu.org> ---
> However, still talking about the current master only, I see a difference
> with -O3, when I try on the repro example from Bug 103274 and -O3:
> 
> x86_64-w64-mingw32-gcc -c -S -O3 -fno-reorder-blocks-and-partition a.c -o
> nropt.s
> 
> x86_64-w64-mingw32-gcc -c -S -O3 -freorder-blocks-and-partition a.c -o ropt.s
> x86_64-w64-mingw32-gcc -c -S -O3  a.c -o noopt.s
> 
> All of these assembler files are different (and from my non-expert reading,
> noopt.s uses the optimization and does have the invalid unwind information
> as reported in Bug 103274). Is the optimization correctly dropped also with
> -O3 only?

Hmmm, I've just tested the same with the locally built cross-compiler:
~/Programming/gcc/configure --enable-languages=c,c++
--prefix=/home/marxin/bin/gcc --disable-multilib --enable-host-shared
--disable-libsanitizer --enable-valgrind-annotations --disable-bootstrap
--target=x86_64-w64-mingw32

and it works fine, all 3 assembly files are identical.

cat 1.s
        .file   "pr103274.c"
        .text
        .section .rdata,"dr"
.LC0:
        .ascii "factor\0"
        .text
        .p2align 4
        .globl  _Z5dummyP7SEXPREC
        .def    _Z5dummyP7SEXPREC;      .scl    2;      .type   32;     .endef
        .seh_proc       _Z5dummyP7SEXPREC
_Z5dummyP7SEXPREC:
.LFB2:
        pushq   %r13
        .seh_pushreg    %r13
        pushq   %r12
        .seh_pushreg    %r12
        pushq   %rbp
        .seh_pushreg    %rbp
        pushq   %rdi
        .seh_pushreg    %rdi
        pushq   %rsi
        .seh_pushreg    %rsi
        pushq   %rbx
        .seh_pushreg    %rbx
        subq    $40, %rsp
        .seh_stackalloc 40
        .seh_endprologue
        movq    %rcx, %r12
        call    _Z11mypredicateP7SEXPREC
        testl   %eax, %eax
        jne     .L21
.L2:
        movq    .refptr.R_NilValue(%rip), %rax
        movq    (%rax), %rax
        addq    $40, %rsp
        popq    %rbx
        popq    %rsi
        popq    %rdi
        popq    %rbp
        popq    %r12
        popq    %r13
        ret
        .p2align 4,,10
        .p2align 3
.L21:
        movq    %r12, %rcx
        call    _Z11mygetattribP7SEXPREC
        movq    %rax, %rcx
        movq    %rax, %r13
        call    _Z8mylengthP7SEXPREC
        movl    %eax, %ebp
        testl   %eax, %eax
        jle     .L2
        movl    %eax, %r12d
        movl    $1, %esi
        leaq    .LC0(%rip), %rdi
        jmp     .L6
        .p2align 4,,10
        .p2align 3
.L8:
        movq    %rax, %rsi
.L6:
        movzbl  0(%r13), %ebx
        andl    $1, %ebx
        je      .L3
        leal    -1(%rsi), %edx
        movq    %r13, %rcx
        call    _Z11myaltstringP7SEXPRECi
        movq    %rdi, %rdx
        movq    %rax, %rcx
        addq    $8, %rcx
        call    _Z6strcmpPKcS0_
        testl   %eax, %eax
        je      .L5
.L22:
        cmpq    %r12, %rsi
        je      .L2
        leaq    1(%rsi), %rax
        testb   %bl, %bl
        jne     .L8
        movslq  %esi, %rsi
.L7:
        movq    8(%r13,%rsi,8), %rax
        movq    %rdi, %rdx
        leaq    8(%rax), %rcx
        call    _Z6strcmpPKcS0_
        testl   %eax, %eax
        je      .L5
        addq    $1, %rsi
        cmpl    %esi, %ebp
        jg      .L7
        jmp     .L2
        .p2align 4,,10
        .p2align 3
.L3:
        movq    0(%r13,%rsi,8), %rcx
        movq    %rdi, %rdx
        addq    $8, %rcx
        call    _Z6strcmpPKcS0_
        testl   %eax, %eax
        jne     .L22
.L5:
        call    _Z11myerrorcallv
        nop
        .seh_endproc
        .ident  "GCC: (GNU) 12.0.0 20211209 (experimental)"
        .def    _Z11mypredicateP7SEXPREC;       .scl    2;      .type   32;    
.endef
        .def    _Z11mygetattribP7SEXPREC;       .scl    2;      .type   32;    
.endef
        .def    _Z8mylengthP7SEXPREC;   .scl    2;      .type   32;     .endef
        .def    _Z11myaltstringP7SEXPRECi;      .scl    2;      .type   32;    
.endef
        .def    _Z6strcmpPKcS0_;        .scl    2;      .type   32;     .endef
        .def    _Z11myerrorcallv;       .scl    2;      .type   32;     .endef
        .section        .rdata$.refptr.R_NilValue, "dr"
        .globl  .refptr.R_NilValue
        .linkonce       discard
.refptr.R_NilValue:
        .quad   R_NilValue

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

* [Bug rtl-optimization/103465] Invalid note with -fno-reorder-blocks-and-partition
  2021-11-29 10:00 [Bug rtl-optimization/103465] New: Invalid note with -fno-reorder-blocks-and-partition tomas.kalibera at gmail dot com
                   ` (5 preceding siblings ...)
  2021-12-09 13:39 ` marxin at gcc dot gnu.org
@ 2021-12-09 13:40 ` marxin at gcc dot gnu.org
  2021-12-09 14:37 ` tomas.kalibera at gmail dot com
                   ` (26 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-12-09 13:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Martin Liška <marxin at gcc dot gnu.org> ---
Created attachment 51957
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51957&action=edit
Test-case used

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

* [Bug rtl-optimization/103465] Invalid note with -fno-reorder-blocks-and-partition
  2021-11-29 10:00 [Bug rtl-optimization/103465] New: Invalid note with -fno-reorder-blocks-and-partition tomas.kalibera at gmail dot com
                   ` (6 preceding siblings ...)
  2021-12-09 13:40 ` marxin at gcc dot gnu.org
@ 2021-12-09 14:37 ` tomas.kalibera at gmail dot com
  2021-12-09 14:41 ` tomas.kalibera at gmail dot com
                   ` (25 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: tomas.kalibera at gmail dot com @ 2021-12-09 14:37 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Tomas Kalibera <tomas.kalibera at gmail dot com> ---
(In reply to Martin Liška from comment #5)
> > However, still talking about the current master only, I see a difference
> > with -O3, when I try on the repro example from Bug 103274 and -O3:
> > 
> > x86_64-w64-mingw32-gcc -c -S -O3 -fno-reorder-blocks-and-partition a.c -o
> > nropt.s
> > 
> > x86_64-w64-mingw32-gcc -c -S -O3 -freorder-blocks-and-partition a.c -o ropt.s
> > x86_64-w64-mingw32-gcc -c -S -O3  a.c -o noopt.s
> > 
> > All of these assembler files are different (and from my non-expert reading,
> > noopt.s uses the optimization and does have the invalid unwind information
> > as reported in Bug 103274). Is the optimization correctly dropped also with
> > -O3 only?
> 
> Hmmm, I've just tested the same with the locally built cross-compiler:
> ~/Programming/gcc/configure --enable-languages=c,c++
> --prefix=/home/marxin/bin/gcc --disable-multilib --enable-host-shared
> --disable-libsanitizer --enable-valgrind-annotations --disable-bootstrap
> --target=x86_64-w64-mingw32
> 
> and it works fine, all 3 assembly files are identical.

I am uploading a Dockerfile and my copy of the example which reproduces my
observation, but please note, it was for
5e5f880d0452ef2cffb94f4a686d56833c9f4215.

nropt.s has (correct unwind info, no reordering)

.L5:
        call    myerrorcall
        nop
        .seh_endproc


but ropt.s is same as noopt.s (incorrect unwind info, reordering)

.L5:
        call    myerrorcall
        .seh_endproc
[...]
dummy.cold:
.L19:

So, from my reading the optimization was applied at -O3, it hence wasn't
dropped by target.

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

* [Bug rtl-optimization/103465] Invalid note with -fno-reorder-blocks-and-partition
  2021-11-29 10:00 [Bug rtl-optimization/103465] New: Invalid note with -fno-reorder-blocks-and-partition tomas.kalibera at gmail dot com
                   ` (7 preceding siblings ...)
  2021-12-09 14:37 ` tomas.kalibera at gmail dot com
@ 2021-12-09 14:41 ` tomas.kalibera at gmail dot com
  2021-12-09 14:44 ` tomas.kalibera at gmail dot com
                   ` (24 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: tomas.kalibera at gmail dot com @ 2021-12-09 14:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Tomas Kalibera <tomas.kalibera at gmail dot com> ---
Created attachment 51958
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51958&action=edit
Example for comment 7.

Example for Dockerfile for comment 7. To be placed in a new directory with that
Dockerfile.

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

* [Bug rtl-optimization/103465] Invalid note with -fno-reorder-blocks-and-partition
  2021-11-29 10:00 [Bug rtl-optimization/103465] New: Invalid note with -fno-reorder-blocks-and-partition tomas.kalibera at gmail dot com
                   ` (8 preceding siblings ...)
  2021-12-09 14:41 ` tomas.kalibera at gmail dot com
@ 2021-12-09 14:44 ` tomas.kalibera at gmail dot com
  2021-12-09 15:24 ` tomas.kalibera at gmail dot com
                   ` (23 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: tomas.kalibera at gmail dot com @ 2021-12-09 14:44 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Tomas Kalibera <tomas.kalibera at gmail dot com> ---
Created attachment 51959
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51959&action=edit
Dockerfile for comment 7

Dockerfile to reproduce behavior in comment 7. To be placed in a fresh
directory with a.c. The output files will appear in /build/out in the
container.

The Dockerfile is based on an earlier copy (reproducing something else) I got
from Martin Storsjo.

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

* [Bug rtl-optimization/103465] Invalid note with -fno-reorder-blocks-and-partition
  2021-11-29 10:00 [Bug rtl-optimization/103465] New: Invalid note with -fno-reorder-blocks-and-partition tomas.kalibera at gmail dot com
                   ` (9 preceding siblings ...)
  2021-12-09 14:44 ` tomas.kalibera at gmail dot com
@ 2021-12-09 15:24 ` tomas.kalibera at gmail dot com
  2021-12-09 15:28 ` marxin at gcc dot gnu.org
                   ` (22 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: tomas.kalibera at gmail dot com @ 2021-12-09 15:24 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from Tomas Kalibera <tomas.kalibera at gmail dot com> ---
(In reply to Tomas Kalibera from comment #7)
> (In reply to Martin Liška from comment #5)
> > > However, still talking about the current master only, I see a difference
> > > with -O3, when I try on the repro example from Bug 103274 and -O3:
> > > 
> > > x86_64-w64-mingw32-gcc -c -S -O3 -fno-reorder-blocks-and-partition a.c -o
> > > nropt.s
> > > 
> > > x86_64-w64-mingw32-gcc -c -S -O3 -freorder-blocks-and-partition a.c -o ropt.s
> > > x86_64-w64-mingw32-gcc -c -S -O3  a.c -o noopt.s
> > > 
> > > All of these assembler files are different (and from my non-expert reading,
> > > noopt.s uses the optimization and does have the invalid unwind information
> > > as reported in Bug 103274). Is the optimization correctly dropped also with
> > > -O3 only?
> > 
> > Hmmm, I've just tested the same with the locally built cross-compiler:
> > ~/Programming/gcc/configure --enable-languages=c,c++
> > --prefix=/home/marxin/bin/gcc --disable-multilib --enable-host-shared
> > --disable-libsanitizer --enable-valgrind-annotations --disable-bootstrap
> > --target=x86_64-w64-mingw32
> > 
> > and it works fine, all 3 assembly files are identical.
> 

It tried on the current GCC trunk as now
(747380f47da0da6c11fd5262ac428bb53433ea19). 

ropt.s is still the same as noopt.s. The unwinding information is correct now,
because Bug 103274 has been fixed in the meantime. However, indeed, the
reordering optimization is applied.

nropt.s has correct unwinding information without the reordering.

So, still, the reorder-stacks-and-partition optimization is not dropped by
target (though I am not claiming they should be dropped, I don't know, that's
only what I learned from your response to my original report).

For these results I've only changed the git version in the dockerfile.

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

* [Bug rtl-optimization/103465] Invalid note with -fno-reorder-blocks-and-partition
  2021-11-29 10:00 [Bug rtl-optimization/103465] New: Invalid note with -fno-reorder-blocks-and-partition tomas.kalibera at gmail dot com
                   ` (10 preceding siblings ...)
  2021-12-09 15:24 ` tomas.kalibera at gmail dot com
@ 2021-12-09 15:28 ` marxin at gcc dot gnu.org
  2021-12-09 15:44 ` marxin at gcc dot gnu.org
                   ` (21 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-12-09 15:28 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #11 from Martin Liška <marxin at gcc dot gnu.org> ---
(In reply to Tomas Kalibera from comment #9)
> Created attachment 51959 [details]
> Dockerfile for comment 7
> 
> Dockerfile to reproduce behavior in comment 7. To be placed in a fresh
> directory with a.c. The output files will appear in /build/out in the
> container.
> 
> The Dockerfile is based on an earlier copy (reproducing something else) I
> got from Martin Storsjo.

Thanks for it, I'm testing that right now.

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

* [Bug rtl-optimization/103465] Invalid note with -fno-reorder-blocks-and-partition
  2021-11-29 10:00 [Bug rtl-optimization/103465] New: Invalid note with -fno-reorder-blocks-and-partition tomas.kalibera at gmail dot com
                   ` (11 preceding siblings ...)
  2021-12-09 15:28 ` marxin at gcc dot gnu.org
@ 2021-12-09 15:44 ` marxin at gcc dot gnu.org
  2021-12-09 15:53 ` tomas.kalibera at gmail dot com
                   ` (20 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-12-09 15:44 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #12 from Martin Liška <marxin at gcc dot gnu.org> ---
> So, still, the reorder-stacks-and-partition optimization is not dropped by
> target (though I am not claiming they should be dropped, I don't know,
> that's only what I learned from your response to my original report).

I see. Can you see the following note:

                "%<-freorder-blocks-and-partition%> does not work "
                "with exceptions on this architecture");

w/ -freorder-blocks-and-partition option used?

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

* [Bug rtl-optimization/103465] Invalid note with -fno-reorder-blocks-and-partition
  2021-11-29 10:00 [Bug rtl-optimization/103465] New: Invalid note with -fno-reorder-blocks-and-partition tomas.kalibera at gmail dot com
                   ` (12 preceding siblings ...)
  2021-12-09 15:44 ` marxin at gcc dot gnu.org
@ 2021-12-09 15:53 ` tomas.kalibera at gmail dot com
  2021-12-09 15:55 ` tomas.kalibera at gmail dot com
                   ` (19 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: tomas.kalibera at gmail dot com @ 2021-12-09 15:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #13 from Tomas Kalibera <tomas.kalibera at gmail dot com> ---
(In reply to Martin Liška from comment #12)
> > So, still, the reorder-stacks-and-partition optimization is not dropped by
> > target (though I am not claiming they should be dropped, I don't know,
> > that's only what I learned from your response to my original report).
> 
> I see. Can you see the following note:
> 
> 		"%<-freorder-blocks-and-partition%> does not work "
> 		"with exceptions on this architecture");
> 
> w/ -freorder-blocks-and-partition option used?

Not with

x86_64-w64-mingw32-gcc -c -O3 -freorder-blocks-and-partition a.c 

but I do (the variant for C) with the original example for this bug report

x86_64-w64-mingw32-gcc -c -O3 -freorder-blocks-and-partition uwi.c -Wall
uwi.c:3:9: note: '-freorder-blocks-and-partition' does not support unwind info
on this architecture
    3 | #pragma GCC optimize ("unroll-loops")
      |         ^~~
uwi.c:5:1: note: '-freorder-blocks-and-partition' does not support unwind info
on this architecture
    5 | int main(int argc, char **argv) {
      | ^~~

this original example (uwi.c) has an GCC optimize pragma:

#include<stdio.h>

#pragma GCC optimize ("unroll-loops")

int main(int argc, char **argv) {
  printf("Hello 1\n");
  printf("Hello 2\n");
  printf("Hello 3\n");
  return 0;
}

For C++ I get the note with "does not work with exceptions on this
architecture"

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

* [Bug rtl-optimization/103465] Invalid note with -fno-reorder-blocks-and-partition
  2021-11-29 10:00 [Bug rtl-optimization/103465] New: Invalid note with -fno-reorder-blocks-and-partition tomas.kalibera at gmail dot com
                   ` (13 preceding siblings ...)
  2021-12-09 15:53 ` tomas.kalibera at gmail dot com
@ 2021-12-09 15:55 ` tomas.kalibera at gmail dot com
  2021-12-09 19:29 ` marxin at gcc dot gnu.org
                   ` (18 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: tomas.kalibera at gmail dot com @ 2021-12-09 15:55 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #14 from Tomas Kalibera <tomas.kalibera at gmail dot com> ---
Created attachment 51962
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51962&action=edit
example for comment 1 and 13

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

* [Bug rtl-optimization/103465] Invalid note with -fno-reorder-blocks-and-partition
  2021-11-29 10:00 [Bug rtl-optimization/103465] New: Invalid note with -fno-reorder-blocks-and-partition tomas.kalibera at gmail dot com
                   ` (14 preceding siblings ...)
  2021-12-09 15:55 ` tomas.kalibera at gmail dot com
@ 2021-12-09 19:29 ` marxin at gcc dot gnu.org
  2021-12-28 10:05 ` [Bug driver/103465] " cvs-commit at gcc dot gnu.org
                   ` (17 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-12-09 19:29 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |marxin at gcc dot gnu.org
   Target Milestone|---                         |12.0

--- Comment #15 from Martin Liška <marxin at gcc dot gnu.org> ---
All right, got it even with the cross compiler. So what happens with the
test-case
without the optimize attribute:

- options are parsed and finish_options is called:

  if (opts->x_flag_unwind_tables
      && !targetm_common.unwind_tables_default
      && opts->x_flag_reorder_blocks_and_partition
      && (ui_except == UI_SJLJ || ui_except >= UI_TARGET))
    {
      if (opts_set->x_flag_reorder_blocks_and_partition)
        inform (loc,
                "%<-freorder-blocks-and-partition%> does not support "
                "unwind info on this architecture");
      opts->x_flag_reorder_blocks_and_partition = 0;
      opts->x_flag_reorder_blocks = 1;
    }

It's not triggered because of opts->x_flag_unwind_tables is false by default,
but
the option is overwritten in target:

#0  ix86_recompute_optlev_based_flags (opts=0x3c6b1c0 <global_options>,
opts_set=0x3c6c8a0 <global_options_set>) at
/home/marxin/Programming/gcc/gcc/config/i386/i386-options.c:1787
#1  0x0000000001b1c126 in ix86_option_override_internal (main_args_p=true,
opts=0x3c6b1c0 <global_options>, opts_set=0x3c6c8a0 <global_options_set>) at
/home/marxin/Programming/gcc/gcc/config/i386/i386-options.c:2332
#2  0x0000000001b1de5f in ix86_option_override () at
/home/marxin/Programming/gcc/gcc/config/i386/i386-options.c:2961
#3  0x00000000014e44be in process_options (no_backend=false) at
/home/marxin/Programming/gcc/gcc/toplev.c:1238
#4  0x00000000014e6925 in toplev::main (this=0x7fffffffdb7a, argc=21,
argv=0x7fffffffdcc8) at /home/marxin/Programming/gcc/gcc/toplev.c:2320
#5  0x0000000002d423c8 in main (argc=21, argv=0x7fffffffdcc8) at
/home/marxin/Programming/gcc/gcc/main.c:39

...
  if (TARGET_64BIT_P (opts->x_ix86_isa_flags))
    {
      if (opts->x_optimize >= 1)
        SET_OPTION_IF_UNSET (opts, opts_set, flag_omit_frame_pointer,
                             !USE_IX86_FRAME_POINTER);
      if (opts->x_flag_asynchronous_unwind_tables
          && TARGET_64BIT_MS_ABI)
        SET_OPTION_IF_UNSET (opts, opts_set, flag_unwind_tables, 1);
...

and so x_flag_reorder_blocks_and_partition is not dropped. On the other hand,
when optimize attribute
is used, then finish_options is called for it and we see the note and the
flagged dropped.
So the checking code should be called both from process_options and
finish_options.

Option handling is a can of worms. Lemme test a patch tomorrow.

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

* [Bug driver/103465] Invalid note with -fno-reorder-blocks-and-partition
  2021-11-29 10:00 [Bug rtl-optimization/103465] New: Invalid note with -fno-reorder-blocks-and-partition tomas.kalibera at gmail dot com
                   ` (15 preceding siblings ...)
  2021-12-09 19:29 ` marxin at gcc dot gnu.org
@ 2021-12-28 10:05 ` cvs-commit at gcc dot gnu.org
  2021-12-28 10:06 ` marxin at gcc dot gnu.org
                   ` (16 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-12-28 10:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #16 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Liska <marxin@gcc.gnu.org>:

https://gcc.gnu.org/g:a187edd2b437fc9571d57f771a624963fcce08f8

commit r12-6131-ga187edd2b437fc9571d57f771a624963fcce08f8
Author: Martin Liska <mliska@suse.cz>
Date:   Fri Dec 10 09:58:52 2021 +0100

    driver: Improve option diagnostics [PR103465]

    It happens that options are parsed and various diagnostics happen
    in finish_options. That's a proper place as the function is also called
    for optimize/target attributes (pragmas). However, it is possible that
    target overwrites an option from command line and so the diagnostics
    does not happen. That's fixed in the patch.

    - options are parsed and finish_options is called:

      if (opts->x_flag_unwind_tables
          && !targetm_common.unwind_tables_default
          && opts->x_flag_reorder_blocks_and_partition
          && (ui_except == UI_SJLJ || ui_except >= UI_TARGET))
        {
          if (opts_set->x_flag_reorder_blocks_and_partition)
            inform (loc,
                    "%<-freorder-blocks-and-partition%> does not support "
                    "unwind info on this architecture");
          opts->x_flag_reorder_blocks_and_partition = 0;
          opts->x_flag_reorder_blocks = 1;
        }

    It's not triggered because of opts->x_flag_unwind_tables is false by
default, but
    the option is overwritten in target:

    ...
      if (TARGET_64BIT_P (opts->x_ix86_isa_flags))
        {
          if (opts->x_optimize >= 1)
            SET_OPTION_IF_UNSET (opts, opts_set, flag_omit_frame_pointer,
                                 !USE_IX86_FRAME_POINTER);
          if (opts->x_flag_asynchronous_unwind_tables
              && TARGET_64BIT_MS_ABI)
            SET_OPTION_IF_UNSET (opts, opts_set, flag_unwind_tables, 1);
    ...

            PR driver/103465

    gcc/ChangeLog:

            * opts.c (finish_options): More part of diagnostics to ...
            (diagnose_options): ... here. Call the function from both
            finish_options and process_options.
            * opts.h (diagnose_options): Declare.
            * toplev.c (process_options): Call diagnose_options.

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

* [Bug driver/103465] Invalid note with -fno-reorder-blocks-and-partition
  2021-11-29 10:00 [Bug rtl-optimization/103465] New: Invalid note with -fno-reorder-blocks-and-partition tomas.kalibera at gmail dot com
                   ` (16 preceding siblings ...)
  2021-12-28 10:05 ` [Bug driver/103465] " cvs-commit at gcc dot gnu.org
@ 2021-12-28 10:06 ` marxin at gcc dot gnu.org
  2022-01-06  7:32 ` [Bug driver/103465] [12 regression] -freorder-blocks-and-partition broken on 64-bit Windows ebotcazou at gcc dot gnu.org
                   ` (15 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-12-28 10:06 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

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

--- Comment #17 from Martin Liška <marxin at gcc dot gnu.org> ---
Fixed on master, not a backport material.

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

* [Bug driver/103465] [12 regression] -freorder-blocks-and-partition broken on 64-bit Windows
  2021-11-29 10:00 [Bug rtl-optimization/103465] New: Invalid note with -fno-reorder-blocks-and-partition tomas.kalibera at gmail dot com
                   ` (17 preceding siblings ...)
  2021-12-28 10:06 ` marxin at gcc dot gnu.org
@ 2022-01-06  7:32 ` ebotcazou at gcc dot gnu.org
  2022-01-06  9:51 ` marxin at gcc dot gnu.org
                   ` (14 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2022-01-06  7:32 UTC (permalink / raw)
  To: gcc-bugs

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

Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|FIXED                       |---
           Severity|normal                      |major
             Status|RESOLVED                    |REOPENED
                 CC|                            |ebotcazou at gcc dot gnu.org
            Summary|Invalid note with           |[12 regression]
                   |-fno-reorder-blocks-and-par |-freorder-blocks-and-partit
                   |tition                      |ion broken on 64-bit
                   |                            |Windows

--- Comment #18 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
The fix does more harm than good though since it disables
-freorder-blocks-and-partition entirely for 64-bit Windows.

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

* [Bug driver/103465] [12 regression] -freorder-blocks-and-partition broken on 64-bit Windows
  2021-11-29 10:00 [Bug rtl-optimization/103465] New: Invalid note with -fno-reorder-blocks-and-partition tomas.kalibera at gmail dot com
                   ` (18 preceding siblings ...)
  2022-01-06  7:32 ` [Bug driver/103465] [12 regression] -freorder-blocks-and-partition broken on 64-bit Windows ebotcazou at gcc dot gnu.org
@ 2022-01-06  9:51 ` marxin at gcc dot gnu.org
  2022-01-06 11:42 ` ebotcazou at gcc dot gnu.org
                   ` (13 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-01-06  9:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #19 from Martin Liška <marxin at gcc dot gnu.org> ---
(In reply to Eric Botcazou from comment #18)
> The fix does more harm than good though since it disables
> -freorder-blocks-and-partition entirely for 64-bit Windows.

Can you be more concrete about what's wrong with that? I haven't changed the
conditions that drop the flag, but only make it respect pragmas.

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

* [Bug driver/103465] [12 regression] -freorder-blocks-and-partition broken on 64-bit Windows
  2021-11-29 10:00 [Bug rtl-optimization/103465] New: Invalid note with -fno-reorder-blocks-and-partition tomas.kalibera at gmail dot com
                   ` (19 preceding siblings ...)
  2022-01-06  9:51 ` marxin at gcc dot gnu.org
@ 2022-01-06 11:42 ` ebotcazou at gcc dot gnu.org
  2022-01-06 12:47 ` marxin at gcc dot gnu.org
                   ` (12 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2022-01-06 11:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #20 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
> Can you be more concrete about what's wrong with that? I haven't changed the
> conditions that drop the flag, but only make it respect pragmas.

Previously the opts.c logic would trigger only with the pragma, now it triggers
even without it, disabling flag_reorder_blocks_and_partition in all cases:

  /* If user requested unwind info, then turn off the partitioning
     optimization.  */

  if (opts->x_flag_unwind_tables
      && !targetm_common.unwind_tables_default
      && opts->x_flag_reorder_blocks_and_partition
      && (ui_except == UI_SJLJ || ui_except >= UI_TARGET))
    {
      if (opts_set->x_flag_reorder_blocks_and_partition)
        inform (loc,
                "%<-freorder-blocks-and-partition%> does not support "
                "unwind info on this architecture");
      opts->x_flag_reorder_blocks_and_partition = 0;
      opts->x_flag_reorder_blocks = 1;
    }

  /* If the target requested unwind info, then turn off the partitioning
     optimization with a different message.  Likewise, if the target does not
     support named sections.  */

  if (opts->x_flag_reorder_blocks_and_partition
      && (!targetm_common.have_named_sections
          || (opts->x_flag_unwind_tables
              && targetm_common.unwind_tables_default
              && (ui_except == UI_SJLJ || ui_except >= UI_TARGET))))
    {
      if (opts_set->x_flag_reorder_blocks_and_partition)
        inform (loc,
                "%<-freorder-blocks-and-partition%> does not work "
                "on this architecture");
      opts->x_flag_reorder_blocks_and_partition = 0;
      opts->x_flag_reorder_blocks = 1;
    }


I guess that we need to define TARGET_UNWIND_TABLES_DEFAULT for 64-bit Windows
but that would probably only generate the second error instead of the first,
and we need none since -freorder-blocks-and-partition works fine there.

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

* [Bug driver/103465] [12 regression] -freorder-blocks-and-partition broken on 64-bit Windows
  2021-11-29 10:00 [Bug rtl-optimization/103465] New: Invalid note with -fno-reorder-blocks-and-partition tomas.kalibera at gmail dot com
                   ` (20 preceding siblings ...)
  2022-01-06 11:42 ` ebotcazou at gcc dot gnu.org
@ 2022-01-06 12:47 ` marxin at gcc dot gnu.org
  2022-01-06 13:45 ` ebotcazou at gcc dot gnu.org
                   ` (11 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-01-06 12:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #21 from Martin Liška <marxin at gcc dot gnu.org> ---
> Previously the opts.c logic would trigger only with the pragma, now it
> triggers even without it, disabling flag_reorder_blocks_and_partition in all
> cases:

I don't see why should it behave differently for command-line options and
options that are passed via #pragma GCC optimize (or optimize attribute). That
should behave the same.

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

* [Bug driver/103465] [12 regression] -freorder-blocks-and-partition broken on 64-bit Windows
  2021-11-29 10:00 [Bug rtl-optimization/103465] New: Invalid note with -fno-reorder-blocks-and-partition tomas.kalibera at gmail dot com
                   ` (21 preceding siblings ...)
  2022-01-06 12:47 ` marxin at gcc dot gnu.org
@ 2022-01-06 13:45 ` ebotcazou at gcc dot gnu.org
  2022-01-06 13:50 ` marxin at gcc dot gnu.org
                   ` (10 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2022-01-06 13:45 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #22 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
> I don't see why should it behave differently for command-line options and
> options that are passed via #pragma GCC optimize (or optimize attribute).
> That should behave the same.

Absolutely, but it should let -freorder-blocks-and-partition go through in both
cases, instead of disabling it in both cases as it does now.

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

* [Bug driver/103465] [12 regression] -freorder-blocks-and-partition broken on 64-bit Windows
  2021-11-29 10:00 [Bug rtl-optimization/103465] New: Invalid note with -fno-reorder-blocks-and-partition tomas.kalibera at gmail dot com
                   ` (22 preceding siblings ...)
  2022-01-06 13:45 ` ebotcazou at gcc dot gnu.org
@ 2022-01-06 13:50 ` marxin at gcc dot gnu.org
  2022-01-06 14:07 ` tomas.kalibera at gmail dot com
                   ` (9 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-01-06 13:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #23 from Martin Liška <marxin at gcc dot gnu.org> ---
> Absolutely, but it should let -freorder-blocks-and-partition go through in
> both cases, instead of disabling it in both cases as it does now.

That's something I'm complete fine with ;)

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

* [Bug driver/103465] [12 regression] -freorder-blocks-and-partition broken on 64-bit Windows
  2021-11-29 10:00 [Bug rtl-optimization/103465] New: Invalid note with -fno-reorder-blocks-and-partition tomas.kalibera at gmail dot com
                   ` (23 preceding siblings ...)
  2022-01-06 13:50 ` marxin at gcc dot gnu.org
@ 2022-01-06 14:07 ` tomas.kalibera at gmail dot com
  2022-01-06 17:17 ` [Bug target/103465] " ebotcazou at gcc dot gnu.org
                   ` (8 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: tomas.kalibera at gmail dot com @ 2022-01-06 14:07 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #24 from Tomas Kalibera <tomas.kalibera at gmail dot com> ---
FWIW, predict-22.c from GCC test suite is an example for which
reorder-blocks-and-partition has an effect (creates foo.cold) in GCC trunk, up
to but excluding

https://gcc.gnu.org/g:a187edd2b437fc9571d57f771a624963fcce08f8

The repro example I used for Bug 103274 (a.c) is not good for testing this
problem in the trunk, because the optimization is not applied on that specific
example already since

https://gcc.gnu.org/g:cd5ae148c47c6dee05adb19acd6a523f7187be7f

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

* [Bug target/103465] [12 regression] -freorder-blocks-and-partition broken on 64-bit Windows
  2021-11-29 10:00 [Bug rtl-optimization/103465] New: Invalid note with -fno-reorder-blocks-and-partition tomas.kalibera at gmail dot com
                   ` (24 preceding siblings ...)
  2022-01-06 14:07 ` tomas.kalibera at gmail dot com
@ 2022-01-06 17:17 ` ebotcazou at gcc dot gnu.org
  2022-01-06 22:18 ` tomas.kalibera at gmail dot com
                   ` (7 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2022-01-06 17:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #25 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
> That's something I'm complete fine with ;)

Time for a promotion of UI_SEH :-)

diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 5d0fc1d915d..f6206154e1a 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -228,15 +228,17 @@ enum stack_protector {
   SPCT_FLAG_EXPLICIT = 4
 };

-/* Types of unwind/exception handling info that can be generated.  */
+/* Types of unwind/exception handling info that can be generated.
+   Note that a UI_TARGET (or larger) setting is considered to be
+   incompatible with -freorder-blocks-and-partition.  */

 enum unwind_info_type
 {
   UI_NONE,
   UI_SJLJ,
   UI_DWARF2,
-  UI_TARGET,
   UI_SEH
+  UI_TARGET,
 };

 /* Callgraph node profile representation.  */

should do the job.  Tomas, can you give it a try?

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

* [Bug target/103465] [12 regression] -freorder-blocks-and-partition broken on 64-bit Windows
  2021-11-29 10:00 [Bug rtl-optimization/103465] New: Invalid note with -fno-reorder-blocks-and-partition tomas.kalibera at gmail dot com
                   ` (25 preceding siblings ...)
  2022-01-06 17:17 ` [Bug target/103465] " ebotcazou at gcc dot gnu.org
@ 2022-01-06 22:18 ` tomas.kalibera at gmail dot com
  2022-01-07  9:50 ` tomas.kalibera at gmail dot com
                   ` (6 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: tomas.kalibera at gmail dot com @ 2022-01-06 22:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #26 from Tomas Kalibera <tomas.kalibera at gmail dot com> ---

> should do the job.  Tomas, can you give it a try?

Thanks, so far I tried it only on predict-22.c and it works (with a fixed comma
as below), enables the optimization. I will do more testing tomorrow.

diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 0769a78a87c..f3559373433 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -228,15 +228,17 @@ enum stack_protector {
   SPCT_FLAG_EXPLICIT = 4
 };

-/* Types of unwind/exception handling info that can be generated.  */
+/* Types of unwind/exception handling info that can be generated.
+   Note that a UI_TARGET (or larger) setting is considered to be
+   incompatible with -freorder-blocks-and-partition.  */

 enum unwind_info_type
 { 
   UI_NONE,
   UI_SJLJ,
   UI_DWARF2,
-  UI_TARGET,
-  UI_SEH
+  UI_SEH,
+  UI_TARGET
 };

 /* Callgraph node profile representation.  */

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

* [Bug target/103465] [12 regression] -freorder-blocks-and-partition broken on 64-bit Windows
  2021-11-29 10:00 [Bug rtl-optimization/103465] New: Invalid note with -fno-reorder-blocks-and-partition tomas.kalibera at gmail dot com
                   ` (26 preceding siblings ...)
  2022-01-06 22:18 ` tomas.kalibera at gmail dot com
@ 2022-01-07  9:50 ` tomas.kalibera at gmail dot com
  2022-01-07 17:33 ` tomas.kalibera at gmail dot com
                   ` (5 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: tomas.kalibera at gmail dot com @ 2022-01-07  9:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #27 from Tomas Kalibera <tomas.kalibera at gmail dot com> ---

> > should do the job.  Tomas, can you give it a try?
> 
> Thanks, so far I tried it only on predict-22.c and it works (with a fixed
> comma as below), enables the optimization. I will do more testing tomorrow.

I've tested with

gcc12 (6aa0859afaf28f4fb13121352225bc5877e02a44)
gcc11 (a03aae8d9f5dbfe3ca3dbfe7eadc6bbe6fbbe1bc)
gcc10 (48e0da239f65b7cfa0e6f51f266c2e04f5ad9bbd)

I confirm that with the patch applied:

* the original bug report about invalid note about
'-freorder-blocks-and-partition' is fixed

* the optimization is applied by default at -O3, -O2 and can be enabled at -O1
via -f

* the optimization can be disabled via -fno- and via pragma

* -Q --help=optimizers issue for the option goes away, so "fixed" (though as I
understand from Martin other optimizations still disabled by target will
incorrectly appear as enabled)

So with this patch applied, I am happy for this bug report to be closed. Thanks
to both of you.

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

* [Bug target/103465] [12 regression] -freorder-blocks-and-partition broken on 64-bit Windows
  2021-11-29 10:00 [Bug rtl-optimization/103465] New: Invalid note with -fno-reorder-blocks-and-partition tomas.kalibera at gmail dot com
                   ` (27 preceding siblings ...)
  2022-01-07  9:50 ` tomas.kalibera at gmail dot com
@ 2022-01-07 17:33 ` tomas.kalibera at gmail dot com
  2022-01-10 11:44 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: tomas.kalibera at gmail dot com @ 2022-01-07 17:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #28 from Tomas Kalibera <tomas.kalibera at gmail dot com> ---
I've also tested the patch with GCC 10.3 (with several backports from gcc10
branch plus some minor fixes,
https://svn.r-project.org/R-dev-web/trunk/WindowsBuilds/winutf8/ucrt3/toolchain_libs/mxe/plugins/gcc10/).

I've built a cross-compiler and built R using it and ran the R regression
testsuite (check-all), with -O2. No issues found. The same testsuite was
previously triggering Bug 103274.

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

* [Bug target/103465] [12 regression] -freorder-blocks-and-partition broken on 64-bit Windows
  2021-11-29 10:00 [Bug rtl-optimization/103465] New: Invalid note with -fno-reorder-blocks-and-partition tomas.kalibera at gmail dot com
                   ` (28 preceding siblings ...)
  2022-01-07 17:33 ` tomas.kalibera at gmail dot com
@ 2022-01-10 11:44 ` cvs-commit at gcc dot gnu.org
  2022-01-10 16:06 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-01-10 11:44 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #29 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Eric Botcazou <ebotcazou@gcc.gnu.org>:

https://gcc.gnu.org/g:8234b0dcb2484f836d0fb8f12aa6b04f5e66db6f

commit r12-6405-g8234b0dcb2484f836d0fb8f12aa6b04f5e66db6f
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Mon Jan 10 12:40:10 2022 +0100

    Properly enable -freorder-blocks-and-partition on 64-bit Windows

    The PR uncovered that -freorder-blocks-and-partition was working by
accident
    on 64-bit Windows, i.e. the middle-end was supposed to disable it with SEH.
    After the change installed on mainline, the middle-end properly disables
it,
    which is too bad since a significant amount of work went into it for SEH.

    gcc/
            PR target/103465
            * coretypes.h (unwind_info_type): Swap UI_SEH and UI_TARGET.

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

* [Bug target/103465] [12 regression] -freorder-blocks-and-partition broken on 64-bit Windows
  2021-11-29 10:00 [Bug rtl-optimization/103465] New: Invalid note with -fno-reorder-blocks-and-partition tomas.kalibera at gmail dot com
                   ` (29 preceding siblings ...)
  2022-01-10 11:44 ` cvs-commit at gcc dot gnu.org
@ 2022-01-10 16:06 ` cvs-commit at gcc dot gnu.org
  2022-01-10 16:06 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-01-10 16:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #30 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Eric Botcazou
<ebotcazou@gcc.gnu.org>:

https://gcc.gnu.org/g:27e6c84c1f14a8195a3f9fb489c240ecc7a6257d

commit r11-9447-g27e6c84c1f14a8195a3f9fb489c240ecc7a6257d
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Mon Jan 10 12:40:10 2022 +0100

    Properly enable -freorder-blocks-and-partition on 64-bit Windows

    The PR uncovered that -freorder-blocks-and-partition was working by
accident
    on 64-bit Windows, i.e. the middle-end was supposed to disable it with SEH.
    After the change installed on mainline, the middle-end properly disables
it,
    which is too bad since a significant amount of work went into it for SEH.

    gcc/
            PR target/103465
            * coretypes.h (unwind_info_type): Swap UI_SEH and UI_TARGET.

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

* [Bug target/103465] [12 regression] -freorder-blocks-and-partition broken on 64-bit Windows
  2021-11-29 10:00 [Bug rtl-optimization/103465] New: Invalid note with -fno-reorder-blocks-and-partition tomas.kalibera at gmail dot com
                   ` (30 preceding siblings ...)
  2022-01-10 16:06 ` cvs-commit at gcc dot gnu.org
@ 2022-01-10 16:06 ` cvs-commit at gcc dot gnu.org
  2022-01-10 16:07 ` cvs-commit at gcc dot gnu.org
  2022-01-10 16:09 ` ebotcazou at gcc dot gnu.org
  33 siblings, 0 replies; 35+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-01-10 16:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #31 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Eric Botcazou
<ebotcazou@gcc.gnu.org>:

https://gcc.gnu.org/g:331733c384ed74539b38e5fa933b35818a109f5c

commit r10-10388-g331733c384ed74539b38e5fa933b35818a109f5c
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Mon Jan 10 12:40:10 2022 +0100

    Properly enable -freorder-blocks-and-partition on 64-bit Windows

    The PR uncovered that -freorder-blocks-and-partition was working by
accident
    on 64-bit Windows, i.e. the middle-end was supposed to disable it with SEH.
    After the change installed on mainline, the middle-end properly disables
it,
    which is too bad since a significant amount of work went into it for SEH.

    gcc/
            PR target/103465
            * coretypes.h (unwind_info_type): Swap UI_SEH and UI_TARGET.

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

* [Bug target/103465] [12 regression] -freorder-blocks-and-partition broken on 64-bit Windows
  2021-11-29 10:00 [Bug rtl-optimization/103465] New: Invalid note with -fno-reorder-blocks-and-partition tomas.kalibera at gmail dot com
                   ` (31 preceding siblings ...)
  2022-01-10 16:06 ` cvs-commit at gcc dot gnu.org
@ 2022-01-10 16:07 ` cvs-commit at gcc dot gnu.org
  2022-01-10 16:09 ` ebotcazou at gcc dot gnu.org
  33 siblings, 0 replies; 35+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-01-10 16:07 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #32 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Eric Botcazou
<ebotcazou@gcc.gnu.org>:

https://gcc.gnu.org/g:90e463661d81f85a2365b89bea2b0cc6070ae024

commit r9-9905-g90e463661d81f85a2365b89bea2b0cc6070ae024
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Mon Jan 10 12:40:10 2022 +0100

    Properly enable -freorder-blocks-and-partition on 64-bit Windows

    The PR uncovered that -freorder-blocks-and-partition was working by
accident
    on 64-bit Windows, i.e. the middle-end was supposed to disable it with SEH.
    After the change installed on mainline, the middle-end properly disables
it,
    which is too bad since a significant amount of work went into it for SEH.

    gcc/
            PR target/103465
            * coretypes.h (unwind_info_type): Swap UI_SEH and UI_TARGET.

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

* [Bug target/103465] [12 regression] -freorder-blocks-and-partition broken on 64-bit Windows
  2021-11-29 10:00 [Bug rtl-optimization/103465] New: Invalid note with -fno-reorder-blocks-and-partition tomas.kalibera at gmail dot com
                   ` (32 preceding siblings ...)
  2022-01-10 16:07 ` cvs-commit at gcc dot gnu.org
@ 2022-01-10 16:09 ` ebotcazou at gcc dot gnu.org
  33 siblings, 0 replies; 35+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2022-01-10 16:09 UTC (permalink / raw)
  To: gcc-bugs

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

Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
   Target Milestone|12.0                        |9.5
         Resolution|---                         |FIXED

--- Comment #33 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
.

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

end of thread, other threads:[~2022-01-10 16:09 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-29 10:00 [Bug rtl-optimization/103465] New: Invalid note with -fno-reorder-blocks-and-partition tomas.kalibera at gmail dot com
2021-11-29 10:12 ` [Bug rtl-optimization/103465] " marxin at gcc dot gnu.org
2021-11-29 10:17 ` tomas.kalibera at gmail dot com
2021-11-29 10:18 ` marxin at gcc dot gnu.org
2021-11-29 13:23 ` marxin at gcc dot gnu.org
2021-11-29 15:25 ` tomas.kalibera at gmail dot com
2021-12-09 13:39 ` marxin at gcc dot gnu.org
2021-12-09 13:40 ` marxin at gcc dot gnu.org
2021-12-09 14:37 ` tomas.kalibera at gmail dot com
2021-12-09 14:41 ` tomas.kalibera at gmail dot com
2021-12-09 14:44 ` tomas.kalibera at gmail dot com
2021-12-09 15:24 ` tomas.kalibera at gmail dot com
2021-12-09 15:28 ` marxin at gcc dot gnu.org
2021-12-09 15:44 ` marxin at gcc dot gnu.org
2021-12-09 15:53 ` tomas.kalibera at gmail dot com
2021-12-09 15:55 ` tomas.kalibera at gmail dot com
2021-12-09 19:29 ` marxin at gcc dot gnu.org
2021-12-28 10:05 ` [Bug driver/103465] " cvs-commit at gcc dot gnu.org
2021-12-28 10:06 ` marxin at gcc dot gnu.org
2022-01-06  7:32 ` [Bug driver/103465] [12 regression] -freorder-blocks-and-partition broken on 64-bit Windows ebotcazou at gcc dot gnu.org
2022-01-06  9:51 ` marxin at gcc dot gnu.org
2022-01-06 11:42 ` ebotcazou at gcc dot gnu.org
2022-01-06 12:47 ` marxin at gcc dot gnu.org
2022-01-06 13:45 ` ebotcazou at gcc dot gnu.org
2022-01-06 13:50 ` marxin at gcc dot gnu.org
2022-01-06 14:07 ` tomas.kalibera at gmail dot com
2022-01-06 17:17 ` [Bug target/103465] " ebotcazou at gcc dot gnu.org
2022-01-06 22:18 ` tomas.kalibera at gmail dot com
2022-01-07  9:50 ` tomas.kalibera at gmail dot com
2022-01-07 17:33 ` tomas.kalibera at gmail dot com
2022-01-10 11:44 ` cvs-commit at gcc dot gnu.org
2022-01-10 16:06 ` cvs-commit at gcc dot gnu.org
2022-01-10 16:06 ` cvs-commit at gcc dot gnu.org
2022-01-10 16:07 ` cvs-commit at gcc dot gnu.org
2022-01-10 16:09 ` ebotcazou 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).