[Bug target/87928] [7/8/9 Regression] ICE in ix86_compute_frame_layout, at config/i386/i386.c:11161 since r228607

2018-11-20 Thread ubizjak at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87928

--- Comment #12 from Uroš Bizjak  ---
(In reply to Martin Liška from comment #11)
> Uros: Can the bug be marked as resolved?
Well, it is marked as such.

[Bug target/87928] [7/8/9 Regression] ICE in ix86_compute_frame_layout, at config/i386/i386.c:11161 since r228607

2018-11-20 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87928

--- Comment #11 from Martin Liška  ---
Uros: Can the bug be marked as resolved?

[Bug target/87928] [7/8/9 Regression] ICE in ix86_compute_frame_layout, at config/i386/i386.c:11161 since r228607

2018-11-18 Thread daniel.santos at pobox dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87928

--- Comment #10 from Daniel Santos  ---
(In reply to Uroš Bizjak from comment #9)
> Fixed everywhere.

Thank you Uros, great work!

It's an easy mistake to assume that you're "on one system/ABI or another" and
forget about function-level attributes.  But I've never been too crazy about
the way some globals and macros are sort-of hidden in .md or .opt files and
generated in the build (like ix86_abi).

[Bug target/87928] [7/8/9 Regression] ICE in ix86_compute_frame_layout, at config/i386/i386.c:11161 since r228607

2018-11-18 Thread ubizjak at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87928

Uroš Bizjak  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #9 from Uroš Bizjak  ---
Fixed everywhere.

[Bug target/87928] [7/8/9 Regression] ICE in ix86_compute_frame_layout, at config/i386/i386.c:11161 since r228607

2018-11-18 Thread uros at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87928

--- Comment #8 from uros at gcc dot gnu.org ---
Author: uros
Date: Sun Nov 18 21:36:30 2018
New Revision: 266254

URL: https://gcc.gnu.org/viewcvs?rev=266254=gcc=rev
Log:
Backport from mainline
2018-11-11  Uros Bizjak  

PR target/87928
* config/i386/i386.h (STACK_BOUNDARY): Use TARGET_64BIT_MS_ABI
instead of (TARGET_64BIT && ix86_abi == MS_ABI).
* config/i386/darwin.h (STACK_BOUNDARY): Ditto.
* config/i386/cygming.h (STACK_BOUNDARY): Remove.

testsuite/ChangeLog:

Backport from mainline
2018-11-11  Uros Bizjak  

PR target/87928
* gcc.target/i386/pr87928.c: New test.


Added:
branches/gcc-7-branch/gcc/testsuite/gcc.target/i386/pr87928.c
Modified:
branches/gcc-7-branch/gcc/ChangeLog
branches/gcc-7-branch/gcc/config/i386/cygming.h
branches/gcc-7-branch/gcc/config/i386/darwin.h
branches/gcc-7-branch/gcc/config/i386/i386.h
branches/gcc-7-branch/gcc/testsuite/ChangeLog

[Bug target/87928] [7/8/9 Regression] ICE in ix86_compute_frame_layout, at config/i386/i386.c:11161 since r228607

2018-11-18 Thread uros at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87928

--- Comment #7 from uros at gcc dot gnu.org ---
Author: uros
Date: Sun Nov 18 20:41:32 2018
New Revision: 266253

URL: https://gcc.gnu.org/viewcvs?rev=266253=gcc=rev
Log:
Backport from mainline
2018-11-11  Uros Bizjak  

PR target/87928
* config/i386/i386.h (STACK_BOUNDARY): Use TARGET_64BIT_MS_ABI
instead of (TARGET_64BIT && ix86_abi == MS_ABI).
* config/i386/darwin.h (STACK_BOUNDARY): Ditto.
* config/i386/cygming.h (STACK_BOUNDARY): Remove.

testsuite/ChangeLog:

Backport from mainline
2018-11-11  Uros Bizjak  

PR target/87928
* gcc.target/i386/pr87928.c: New test.


Added:
branches/gcc-8-branch/gcc/testsuite/gcc.target/i386/pr87928.c
Modified:
branches/gcc-8-branch/gcc/ChangeLog
branches/gcc-8-branch/gcc/config/i386/cygming.h
branches/gcc-8-branch/gcc/config/i386/darwin.h
branches/gcc-8-branch/gcc/config/i386/i386.h
branches/gcc-8-branch/gcc/testsuite/ChangeLog

[Bug target/87928] [7/8/9 Regression] ICE in ix86_compute_frame_layout, at config/i386/i386.c:11161 since r228607

2018-11-11 Thread uros at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87928

--- Comment #6 from uros at gcc dot gnu.org ---
Author: uros
Date: Sun Nov 11 17:49:33 2018
New Revision: 266016

URL: https://gcc.gnu.org/viewcvs?rev=266016=gcc=rev
Log:
PR target/87928
* config/i386/i386.h (STACK_BOUNDARY): Use TARGET_64BIT_MS_ABI
instead of (TARGET_64BIT && ix86_abi == MS_ABI).
* config/i386/darwin.h (STACK_BOUNDARY): Ditto.
* config/i386/cygming.h (STACK_BOUNDARY): Remove.

testsuite /Changelog:

PR target/87928
* gcc.target/i386/pr87928.c: New test.


Added:
trunk/gcc/testsuite/gcc.target/i386/pr87928.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/config/i386/cygming.h
trunk/gcc/config/i386/darwin.h
trunk/gcc/config/i386/i386.h
trunk/gcc/testsuite/ChangeLog

[Bug target/87928] [7/8/9 Regression] ICE in ix86_compute_frame_layout, at config/i386/i386.c:11161 since r228607

2018-11-09 Thread ubizjak at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87928

Uroš Bizjak  changed:

   What|Removed |Added

 Target||x86_64
 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |ubizjak at gmail dot com

--- Comment #5 from Uroš Bizjak  ---
Patch at [1].

[1] https://gcc.gnu.org/ml/gcc-patches/2018-11/msg00679.html

[Bug target/87928] [7/8/9 Regression] ICE in ix86_compute_frame_layout, at config/i386/i386.c:11161 since r228607

2018-11-08 Thread ubizjak at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87928

Uroš Bizjak  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
 CC||ktietz at gcc dot gnu.org
 Ever confirmed|0   |1

--- Comment #4 from Uroš Bizjak  ---
(In reply to Martin Liška from comment #0)
> Following causes ICE:
> 
> $ gcc
> /home/marxin/Programming/gcc/gcc/testsuite/gcc.target/i386/aggregate-ret4.c
> -mabi=ms -O1 -mstackrealign
> during RTL pass: pro_and_epilogue
> /home/marxin/Programming/gcc/gcc/testsuite/gcc.target/i386/aggregate-ret4.c:
> In function ‘bar’:
> /home/marxin/Programming/gcc/gcc/testsuite/gcc.target/i386/aggregate-ret4.c:
> 24:1: internal compiler error: in ix86_compute_frame_layout, at
> config/i386/i386.c:11161
>24 | }
>   | ^
> 0x73ba80 ix86_compute_frame_layout
>   /home/marxin/Programming/gcc/gcc/config/i386/i386.c:11161
> 0x111ef6f ix86_finalize_stack_frame_flags
>   /home/marxin/Programming/gcc/gcc/config/i386/i386.c:12925
> 0x11255e4 ix86_expand_prologue()
>   /home/marxin/Programming/gcc/gcc/config/i386/i386.c:13035
> 0x145df8a gen_prologue()
>   /home/marxin/Programming/gcc/gcc/config/i386/i386.md:12984
> 0x1107728 target_gen_prologue
>   /home/marxin/Programming/gcc/gcc/config/i386/i386.md:18928
> 0xab61c1 make_prologue_seq
>   /home/marxin/Programming/gcc/gcc/function.c:5713
> 0xab6367 thread_prologue_and_epilogue_insns()
>   /home/marxin/Programming/gcc/gcc/function.c:5830
> 0xab6a96 rest_of_handle_thread_prologue_and_epilogue
>   /home/marxin/Programming/gcc/gcc/function.c:6321
> 0xab6a96 execute
>   /home/marxin/Programming/gcc/gcc/function.c:6363

This happens in i386.c:

--cut here--
  /* 64-bit MS ABI seem to require stack alignment to be always 16,
 except for function prologues, leaf functions and when the defult
 incoming stack boundary is overriden at command line or via
 force_align_arg_pointer attribute.  */
  if ((TARGET_64BIT_MS_ABI && crtl->preferred_stack_boundary < 128)
  && (!crtl->is_leaf || cfun->calls_alloca != 0
  || ix86_current_function_calls_tls_descriptor
  || ix86_incoming_stack_boundary < 128))
{
  crtl->preferred_stack_boundary = 128;
  crtl->stack_alignment_needed = 128;
}

  stack_alignment_needed = crtl->stack_alignment_needed / BITS_PER_UNIT;
  preferred_alignment = crtl->preferred_stack_boundary / BITS_PER_UNIT;

  gcc_assert (!size || stack_alignment_needed);
  gcc_assert (preferred_alignment >= STACK_BOUNDARY / BITS_PER_UNIT);
  gcc_assert (preferred_alignment <= stack_alignment_needed);
--cut here--

Where TARGET_64BIT_MS_ABI gets defined as:

#define TARGET_64BIT_MS_ABI (TARGET_64BIT && ix86_cfun_abi () == MS_ABI)

and STACK_BOUNDARY:

#define STACK_BOUNDARY \
  (TARGET_64BIT && ix86_abi == MS_ABI ? 128 : BITS_PER_WORD)

Please note that the former definition depends on ix86_cfun_abi, which depends
on __attribute__(([sysv_abi|ms_abi])), while the later depends on ix86_abi
global variable. In the testcase, ix86_cfun_abi () returns SYSV_ABI due to
function __attribute__ override, while ix86_abi returns MS_ABI.

The following patch redefines STACK_BOUNDARY to:

 #define STACK_BOUNDARY \
- (TARGET_64BIT && ix86_abi == MS_ABI ? 128 : BITS_PER_WORD)
+  (TARGET_64BIT && ix86_cfun_abi () == MS_ABI ? 128 : BITS_PER_WORD)

so, STACK_BOUNDARY now also depends on function __attribute__.

The patch also removes unneeded redefinition of STACK_BOUNDARY from cygming.h.

--cut here--
diff --git a/gcc/config/i386/cygming.h b/gcc/config/i386/cygming.h
index d7c7dd7057bf..0a3c9a0dd401 100644
--- a/gcc/config/i386/cygming.h
+++ b/gcc/config/i386/cygming.h
@@ -268,9 +268,6 @@ do {\
bytes in one go.  */
 #define CHECK_STACK_LIMIT 4000

-#undef STACK_BOUNDARY
-#define STACK_BOUNDARY (TARGET_64BIT && ix86_abi == MS_ABI ? 128 :
BITS_PER_WORD)
-
 /* By default, target has a 80387, uses IEEE compatible arithmetic,
returns float values in the 387 and needs stack probes.
We also align doubles to 64-bits for MSVC default compatibility.  */
diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
index 58caab2bb55b..a85b43134092 100644
--- a/gcc/config/i386/i386.h
+++ b/gcc/config/i386/i386.h
@@ -808,7 +808,7 @@ extern const char *host_detect_local_cpu (int argc, const
char **argv);

 /* Boundary (in *bits*) on which stack pointer should be aligned.  */
 #define STACK_BOUNDARY \
- (TARGET_64BIT && ix86_abi == MS_ABI ? 128 : BITS_PER_WORD)
+  (TARGET_64BIT && ix86_cfun_abi () == MS_ABI ? 128 : BITS_PER_WORD)

 /* Stack boundary of the main function guaranteed by OS.  */
 #define MAIN_STACK_BOUNDARY (TARGET_64BIT ? 128 : 32)
--cut here--

Adding Kai to CC. The patch also needs to be tested on Windows targets.

[Bug target/87928] [7/8/9 Regression] ICE in ix86_compute_frame_layout, at config/i386/i386.c:11161 since r228607

2018-11-08 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87928

Richard Biener  changed:

   What|Removed |Added

   Target Milestone|--- |7.4

[Bug target/87928] [7/8/9 Regression] ICE in ix86_compute_frame_layout, at config/i386/i386.c:11161 since r228607

2018-11-08 Thread ubizjak at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87928

--- Comment #3 from Uroš Bizjak  ---
(In reply to Uroš Bizjak from comment #2)
> (In reply to Martin Liška from comment #1)
> > One more similar back-trace:
> > 
> > $ gcc
> > /home/marxin/Programming/gcc/gcc/testsuite/gcc.target/x86_64/abi/callabi/
> > func-1.c -Ofast -mcall-ms2sysv-xlogues -mandroid -mavx512vpopcntdq
> > during RTL pass: reload
> > /home/marxin/Programming/gcc/gcc/testsuite/gcc.target/x86_64/abi/callabi/
> > func-1.c: In function ‘func_cross’:
> > /home/marxin/Programming/gcc/gcc/testsuite/gcc.target/x86_64/abi/callabi/
> > func-1.c:20:1: internal compiler error: in ix86_compute_frame_layout, at
> > config/i386/i386.c:11169
> 
> The ICE happens for different reason, it is not due to alignment issues as
> in previous one, but happens with -mcall-ms2sysv-xlogues. CC author.

Actually, the testcase doesn't ICE for me.

[Bug target/87928] [7/8/9 Regression] ICE in ix86_compute_frame_layout, at config/i386/i386.c:11161 since r228607

2018-11-08 Thread ubizjak at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87928

Uroš Bizjak  changed:

   What|Removed |Added

 CC||daniel.santos at pobox dot com

--- Comment #2 from Uroš Bizjak  ---
(In reply to Martin Liška from comment #1)
> One more similar back-trace:
> 
> $ gcc
> /home/marxin/Programming/gcc/gcc/testsuite/gcc.target/x86_64/abi/callabi/
> func-1.c -Ofast -mcall-ms2sysv-xlogues -mandroid -mavx512vpopcntdq
> during RTL pass: reload
> /home/marxin/Programming/gcc/gcc/testsuite/gcc.target/x86_64/abi/callabi/
> func-1.c: In function ‘func_cross’:
> /home/marxin/Programming/gcc/gcc/testsuite/gcc.target/x86_64/abi/callabi/
> func-1.c:20:1: internal compiler error: in ix86_compute_frame_layout, at
> config/i386/i386.c:11169

The ICE happens for different reason, it is not due to alignment issues as in
previous one, but happens with -mcall-ms2sysv-xlogues. CC author.

[Bug target/87928] [7/8/9 Regression] ICE in ix86_compute_frame_layout, at config/i386/i386.c:11161 since r228607

2018-11-07 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87928

--- Comment #1 from Martin Liška  ---
One more similar back-trace:

$ gcc
/home/marxin/Programming/gcc/gcc/testsuite/gcc.target/x86_64/abi/callabi/func-1.c
-Ofast -mcall-ms2sysv-xlogues -mandroid -mavx512vpopcntdq
during RTL pass: reload
/home/marxin/Programming/gcc/gcc/testsuite/gcc.target/x86_64/abi/callabi/func-1.c:
In function ‘func_cross’:
/home/marxin/Programming/gcc/gcc/testsuite/gcc.target/x86_64/abi/callabi/func-1.c:20:1:
internal compiler error: in ix86_compute_frame_layout, at
config/i386/i386.c:11169
   20 | }
  | ^
0x73bae0 ix86_compute_frame_layout
/home/marxin/Programming/gcc/gcc/config/i386/i386.c:11169
0xc268af update_reg_eliminate
/home/marxin/Programming/gcc/gcc/lra-eliminations.c:1207
0xc28f97 lra_eliminate(bool, bool)
/home/marxin/Programming/gcc/gcc/lra-eliminations.c:1460
0xc2058a lra_constraints(bool)
/home/marxin/Programming/gcc/gcc/lra-constraints.c:4716
0xc0d2a0 lra(_IO_FILE*)
/home/marxin/Programming/gcc/gcc/lra.c:2446
0xbbe87c do_reload
/home/marxin/Programming/gcc/gcc/ira.c:5469
0xbbe87c execute
/home/marxin/Programming/gcc/gcc/ira.c:5653