Bug 48344 - powerpc ICE with -fstack-limit-register=r2
Summary: powerpc ICE with -fstack-limit-register=r2
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: ---
Assignee: kelvin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-29 21:42 UTC by Khem Raj
Modified: 2021-11-17 07:36 UTC (History)
3 users (show)

See Also:
Host: i686-linux-gnu
Target: powerpc-linux-uclibc
Build: i686-linux-gnu
Known to work: 4.1.1
Known to fail: 4.5.3, 4.6.0
Last reconfirmed: 2015-11-22 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Khem Raj 2011-03-29 21:42:58 UTC
when compiling following testcase

void foo ()
{
    int N = 2;
    int slots[N];

}

with -fstack-limit-register=r2 for ppc32 gcc ICEs


$ powerpc-linux-uclibc-gcc-4.6.0 -fstack-limit-register=r2 a.c
a.c: In function ‘foo’:
a.c:6:1: error: unrecognizable insn:
(insn 35 34 36 3 (set (reg:SI 144)
        (reg 2 2)) a.c:4 -1
     (nil))
a.c:6:1: internal compiler error: in extract_insn, at recog.c:2109
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.


Here is how I configured gcc

Using built-in specs.
COLLECT_GCC=powerpc-linux-uclibc-gcc-4.6.0
COLLECT_LTO_WRAPPER=/home/kraj/work/cross/powerpc-linux-uclibc/tools/libexec/gcc/powerpc-linux-uclibc/4.6.0/lto-wrapper
Target: powerpc-linux-uclibc
Configured with: /home/kraj/work/cross/powerpc-linux-uclibc/../../gcc.git/configure --target=powerpc-linux-uclibc --prefix=/home/kraj/work/cross/powerpc-linux-uclibc/tools --with-sysroot=/home/kraj/work/cross/powerpc-linux-uclibc/sysroot --enable-__cxa_atexit --disable-libssp --disable-libgomp --disable-libmudflap --enable-languages=c,c++ --disable-multilib
Comment 1 Khem Raj 2011-04-01 20:43:26 UTC
I could track it down to commit 148869 on trunk 

Step 1 of VSX changes: Powerpc infrstructure changes

ChangeLog goes like this

2009-06-23  Michael Meissner  <meissner@linux.vnet.ibm.com>
	    Pat Haugen  <pthaugen@us.ibm.com>
	    Revital Eres  <eres@il.ibm.com>

	* config.in (HAVE_AS_POPCNTD): Add default definition.
	(HAVE_AS_LWSYNC): Ditto.

	* configure.ac (gcc_cv_as_powerpc_mfpgpr): Provide real binutils
	release number.
	(gcc_cv_as_powerpc_cmpb): Ditto.
	(gcc_cv_as_powerpc_dfp): Ditto.
	(gcc_cv_as_powerpc_vsx): Ditto.
	(gcc_cv_as_powerpc_popcntd): Add feature test for assembler
	supporting the popcntd/lwsync instructions.
	(gcc_cv_as_powerpc_lwsync): Ditto.
	* configure: Regenerate.

	* config/rs6000/aix53.h (ASM_CPU_SPEC): Add support for
	-mcpu=native and -mcpu=power7.
	* config/rs6000/aix61.h (ASM_CPU_SPEC): Ditto.

...
Comment 2 Segher Boessenkool 2015-11-22 00:26:37 UTC
Confirmed with current trunk.
Comment 3 kelvin 2016-01-07 17:37:03 UTC
Author: kelvin
Date: Thu Jan  7 17:36:30 2016
New Revision: 232135

URL: https://gcc.gnu.org/viewcvs?rev=232135&root=gcc&view=rev
Log:
This branch holds development associated with work on bugzilla pr 48344.

Added:
    branches/ibm/kelvin-pr48344/
      - copied from r232134, trunk/
Comment 4 David Edelsohn 2016-01-11 20:23:32 UTC
The ICE appears to be the missing mode on r2, but I thought that the SET would be generated by -fstack-limit-register common code.

However, r2 is a fixed register for SVR4 ABI, so the specific choice of r2 seems strange. The user specifically wants a fixed register and knows that it will not be used for GOT access in this specific use case?
Comment 5 kelvin 2016-02-16 23:12:51 UTC
Author: kelvin
Date: Tue Feb 16 23:12:19 2016
New Revision: 233477

URL: https://gcc.gnu.org/viewcvs?rev=233477&root=gcc&view=rev
Log:
[gcc]

2016-02-16  Kelvin Nilsen  <kelvin@gcc.gnu.org>

	PR Target/48344
	* opts-global.c (handle_common_deferred_options): Introduce and
	initialize two global variables to remember command-line options
	specifying a stack-limiting register.
	* opts.h: Add extern declarations of the two new global variables. 
	* emit-rtl.c (init_emit_once): Initialize the stack_limit_rtx
	variable based on the values of the two new global variables.

[gcc/testsuite]

2016-02-16  Kelvin Nilsen  <kelvin@gcc.gnu.org>

	PR Target/48344
	* gcc.target/powerpc/pr48344-1.c: New test.



Added:
    trunk/gcc/testsuite/gcc.target/powerpc/pr48344-1.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/emit-rtl.c
    trunk/gcc/opts-global.c
    trunk/gcc/opts.h
    trunk/gcc/testsuite/ChangeLog
Comment 6 kelvin 2016-02-17 01:15:11 UTC
Fixed.