User account creation filtered due to spam.

Bug 48470 - ICE in expand_expr_addr_expr_1 at expr.c:6835
Summary: ICE in expand_expr_addr_expr_1 at expr.c:6835
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.4.5
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-05 19:41 UTC by Stephen Cleary
Modified: 2015-08-03 19:36 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Proprocessed source (built with -E, since -save-temps is an unrecognized option) (19.82 KB, text/plain)
2011-04-05 19:41 UTC, Stephen Cleary
Details
reduced test case (84 bytes, text/plain)
2011-04-06 19:48 UTC, Mikael Pettersson
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Stephen Cleary 2011-04-05 19:41:42 UTC
Created attachment 23886 [details]
Proprocessed source (built with -E, since -save-temps is an unrecognized option)

Version (output from --version, since -v is apparently a verbose flag, not a version flag):

GNU C (GCC) version 4.4.5 (arm-unknown-elf)
        compiled by GNU C version 3.4.4 (mingw special), GMP version 4.3.2, MPFR
 version 2.4.2.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072


Command line:

"C:/Program Files/Rowley Associates Limited/CrossWorks for ARM 2.0/gcc/bin/cc1" -fmessage-length=0 -mcpu=arm7tdmi -mthumb-interwork -mlittle-endian -mfpu=vfp -mfloat-abi=soft -nostdinc "-isystemC:/Program Files/Rowley Associates Limited/CrossWorks for ARM 2.0/include" "-isystemC:/Documents and Settings/sacleary/Local Settings/Application Data/Rowley Associates Limited/CrossWorks for ARM/packages/include" "-IC:/Code/v2/LN-200 IMU/../Components/include/FreeRTOS" "-IC:/Code/v2/LN-200 IMU/../Components/include/lwIP" "-IC:/Code/v2/LN-200 IMU/../Components/include/lwIP/ipv4" "-IC:/Code/v2/LN-200 IMU/../Components/include/lwIP glue" -I. "-IC:/Code/v2/LN-200 IMU/../Components/include" "-IC:/Code/v2/LN-200 IMU/../Common" -D__ARM_ARCH_4T__ -D__CROSSWORKS_ARM -D__CROSSWORKS_MAJOR_VERSION=2 -D__CROSSWORKS_MINOR_VERSION=0 -D__CROSSWORKS_REVISION=8 -D__TARGET_PROCESSOR=AT91SAM7X256 -DOSCILLATOR_CLOCK_FREQUENCY=18432000 "-DBOARDINIPATH = "imu.ini"" "-DdefaultIPAddr = 0x0006000A" "-DdefaultCANAddr = 0x00100600" "-DdefaultMacAddrA = 0x06" "-DBOARD_ID = BOARD_TYPE_LN200" "-D_DRIVES = 1" -D__THUMB -D__FLASH_BUILD -DNDEBUG -DSAM7_GCC -DTHUMB_INTERWORK -DSUPERVISOR_START -DSMARTPIGHARDWARE -MD "FPGA ISR.d" -MQ "FPGA ISR.o" -Werror -quiet -g1 -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -fms-extensions -O1 -fno-dwarf2-cfi-asm -fno-builtin "C:/Code/v2/LN-200 IMU/FPGA ISR.c"
Comment 1 Mikael Pettersson 2011-04-05 22:30:36 UTC
I can easily reproduce the ICE with gcc-4.4.5 and 4.5.2 targeting arm-linux-gnueabi, using the command line

gcc -O1 -S test.i

-mcpu= etc options don't seem to make any difference.

gcc-4.3.5 works.  Haven't been able to check 4.6.0 yet because there the test case triggers errors in code that isn't valid C1X.
Comment 2 Mikael Pettersson 2011-04-06 19:48:25 UTC
Created attachment 23903 [details]
reduced test case

The test case reduces to the following:

void __attribute__((naked)) f(void)
{
    int x = 0;
    g(&x);
}

It ICEs 4.4.5, 4.5.2, and 4.6.0, but not 4.3.5, 4.2.4, or 4.1.2.

I suspect it isn't valid to make recursive calls or take the address of local variables in naked functions.
Comment 3 Stephen Cleary 2011-07-26 15:56:40 UTC
(In reply to comment #2)
> The test case reduces to the following:
> void __attribute__((naked)) f(void)
> {
>     int x = 0;
>     g(&x);
> }
> It ICEs 4.4.5, 4.5.2, and 4.6.0, but not 4.3.5, 4.2.4, or 4.1.2.
> I suspect it isn't valid to make recursive calls or take the address of local
> variables in naked functions.

It is important to note, however, that the original test case does not take the address of a local variable in a naked function. The original test case is like this:

static void g(void);
void __attribute__((naked)) f(void)
{
    g();
}
void g(void)
{
    int x = 0;
    h(&x);
}

So this may be due to overzealous inlining.
Comment 4 Jeffrey A. Law 2015-08-03 19:35:03 UTC
Author: law
Date: Mon Aug  3 19:34:31 2015
New Revision: 226528

URL: https://gcc.gnu.org/viewcvs?rev=226528&root=gcc&view=rev
Log:
	PR middle-end/64744
	PR middle-end/48470
	PR middle-end/43404
	* cfgexpand.c (expand_one_var): Add check if stack is going to
	be used in naked function.
	* expr.c (expand_expr_addr_expr_1): Remove excess checking
	whether expression should not reside in MEM.
	* function.c (use_register_for_decl): Do not use registers for
	non-register things (volatile, float, BLKMode) in naked functions.

	PR middle-end/64744
	PR middle-end/48470
	PR middle-end/43404
	* gcc.target/arm/pr43404.c : New testcase.
	* gcc.target/arm/pr48470.c : New testcase.
	* gcc.target/arm/pr64744-1.c : New testcase.
	* gcc.target/arm/pr64744-2.c : New testcase.

Added:
    trunk/gcc/testsuite/gcc.target/arm/pr43404.c
    trunk/gcc/testsuite/gcc.target/arm/pr48470.c
    trunk/gcc/testsuite/gcc.target/arm/pr64744-1.c
    trunk/gcc/testsuite/gcc.target/arm/pr64744-2.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/cfgexpand.c
    trunk/gcc/expr.c
    trunk/gcc/function.c
    trunk/gcc/testsuite/ChangeLog
Comment 5 Jeffrey A. Law 2015-08-03 19:36:33 UTC
Fixed on the trunk.