Bug 24665 - [4.0/4.1 Regression] internal compiler error: get_indirect_ref_operands
Summary: [4.0/4.1 Regression] internal compiler error: get_indirect_ref_operands
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.0.2
: P1 normal
Target Milestone: 4.0.3
Assignee: Richard Henderson
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2005-11-04 04:46 UTC by Darin Johnson
Modified: 2005-11-20 19:06 UTC (History)
3 users (show)

See Also:
Host:
Target: *-*-*
Build:
Known to work: 3.4.0 4.2.0
Known to fail: 4.0.3 4.1.0 4.0.0
Last reconfirmed: 2005-11-19 22:05:55


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Darin Johnson 2005-11-04 04:46:17 UTC
I get an internal compiler error when compiling the code below.  The compiler error goes away if the "-fno-tree-ccp" is added to the command line.  The exact error message is:

gccbug.cpp: In constructor 'Controller_t::Controller_t()':
gccbug.cpp:41: internal compiler error: in get_indirect_ref_operands, at tree-ssa-operands.c:1453

This is not a duplicate of #21167.  That patch already appears to be in 4.0.2.

The "-v" option gives this configuration:
Using built-in specs.
Target: powerpc-603e-eabi
Configured with: /c/GCC/src/gcc-4.0.2/configure --target=powerpc-603e-eabi --prefix=/c/GCC/powerpc-603e-eabi --with-headers=/c/GCC/powerpc-603e-eabi/powerpc-603e-eabi/include --with-local-prefix=/c/GCC/powerpc-603e-eabi/powerpc-603e-eabi --with-newlib --with-cpu=603e --enable-cxx-flags=-mcpu=603e --disable-multilib --with-dwarf2 --enable-libstdcxx-debug --disable-c-mbchar --disable-nls --disable-threads --enable-symvers=gnu --enable-__cxa_atexit --enable-languages=c,c++ --disable-shared --enable-c99 --enable-long-long --with-dwarf2
Thread model: single
gcc version 4.0.2
 /c/gcc/powerpc-603e-eabi/bin/../libexec/gcc/powerpc-603e-eabi/4.0.2/cc1plus.exe -quiet -v -iprefix /c/gcc/powerpc-603e-eabi/bin/../lib/gcc/powerpc-603e-eabi/4.0.2/ gccbug.cpp -quiet -dumpbase gccbug.cpp -mcpu=603e -auxbase gccbug -O2 -version -o /c/DOCUME~1/djohnson/LOCALS~1/Temp/cckcPKQy.s

The exact code that generates this error is:
------------------
// Compile with -O2.
// compiler error goes away if "-fno-tree-ccp" is added

typedef unsigned long uint32_t;

// compiler error goes away if "const" is removed
typedef volatile uint32_t* const hwreg_t;

struct RegisterLayout
{
    uint32_t intmask;
};

struct Controller_t
{
public:
    Controller_t();

    inline void
    disableInterrupt()
    {
        *mpMaskRegister = 0;
    };

    static hwreg_t mpMaskRegister;
};

extern char SimulatedRegisters[];

// compiler error goes away if "volatile" is remove
#define	MACHINE                                                         \
    (reinterpret_cast<volatile RegisterLayout*>(SimulatedRegisters))

hwreg_t Controller_t::mpMaskRegister = &MACHINE->intmask;

Controller_t::Controller_t()
{      
    disableInterrupt();
}
Comment 1 Andrew Pinski 2005-11-04 05:06:42 UTC
Confirmed, reduced testcase as far as I can get it (and is willing to try at this point):
typedef unsigned long uint32_t;
typedef volatile uint32_t* const hwreg_t;
struct RegisterLayout
{
    uint32_t intmask;
};
struct Controller_t
{
    Controller_t();
    inline void
    disableInterrupt()
    {
        *mpMaskRegister = 0;
    };
    static hwreg_t mpMaskRegister;
};
extern char SimulatedRegisters[];
hwreg_t Controller_t::mpMaskRegister = &(reinterpret_cast<volatile RegisterLayout*>(SimulatedRegisters))->intmask;
Controller_t::Controller_t()
{
    disableInterrupt();
}
Comment 2 Janis Johnson 2005-11-04 20:19:05 UTC
A regression hunt identified the following patch:

http://gcc.gnu.org/viewcvs?view=rev&rev=89280

r89280 | rth | 2004-10-19 17:24:46 +0000 (Tue, 19 Oct 2004) | 4 lines
                                                                                
        PR middle-end/17885
        * tree.c (recompute_tree_invarant_for_addr_expr): Always poll address
        of INDIRECT_REF.
Comment 3 Andrew Pinski 2005-11-05 20:30:13 UTC
Something is not gimplifing an expression:
*(struct RegisterLayoutD.2065 *) (charD.3 *) &SimulatedRegistersD.2082
------
#   SimulatedRegistersD.2082_6 = V_MAY_DEF <SimulatedRegistersD.2082_5>;
((struct RegisterLayoutD.2065 *) (charD.3 *) &SimulatedRegistersD.2082)->intmaskD.2067 = 0


CCP it looks like.
Comment 4 Andrew Pinski 2005-11-05 20:34:11 UTC
Lattice value changed to CONSTANT &((struct RegisterLayout *) (char *) &SimulatedRegisters)->intmask.  Adding SSA edges to worklist.

Substituing values and folding statements

Folded statement: mpMaskRegister.0_4 = mpMaskRegister;
            into: mpMaskRegister.0_4 = &((struct RegisterLayout *) (char *) &SimulatedRegisters)->intmask;
Comment 5 Mark Mitchell 2005-11-19 01:39:38 UTC
Showstopper.
Comment 6 Richard Henderson 2005-11-20 05:37:13 UTC
Subject: Bug 24665

Author: rth
Date: Sun Nov 20 05:37:08 2005
New Revision: 107244

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=107244
Log:
        PR tree-opt/24665
        * tree-gimple.c (is_gimple_id): Export.
        * tree-gimple.h (is_gimple_id): Declare.
        * tree-ssa-ccp.c (ccp_decl_initial_min_invariant): New.
        (get_default_value): Use it.
        (maybe_fold_stmt_indirect): Likewise.

Added:
    trunk/gcc/testsuite/g++.dg/opt/pr24665.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/tree-gimple.c
    trunk/gcc/tree-gimple.h
    trunk/gcc/tree-ssa-ccp.c

Comment 7 Richard Henderson 2005-11-20 19:04:02 UTC
Subject: Bug 24665

Author: rth
Date: Sun Nov 20 19:03:53 2005
New Revision: 107259

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=107259
Log:
        PR tree-opt/24665
        * tree-gimple.c (is_gimple_id): Export.
        * tree-gimple.h (is_gimple_id): Declare.
        * tree-ssa-ccp.c (ccp_decl_initial_min_invariant): New.
        (get_default_value): Use it.
        (maybe_fold_stmt_indirect): Likewise.

Added:
    branches/gcc-4_0-branch/gcc/testsuite/g++.dg/opt/pr24665.C
      - copied unchanged from r107245, trunk/gcc/testsuite/g++.dg/opt/pr24665.C
Modified:
    branches/gcc-4_0-branch/gcc/ChangeLog
    branches/gcc-4_0-branch/gcc/tree-gimple.c
    branches/gcc-4_0-branch/gcc/tree-gimple.h
    branches/gcc-4_0-branch/gcc/tree-ssa-ccp.c

Comment 8 Richard Henderson 2005-11-20 19:05:46 UTC
Subject: Bug 24665

Author: rth
Date: Sun Nov 20 19:05:43 2005
New Revision: 107260

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=107260
Log:
        PR tree-opt/24665
        * tree-gimple.c (is_gimple_id): Export.
        * tree-gimple.h (is_gimple_id): Declare.
        * tree-ssa-ccp.c (ccp_decl_initial_min_invariant): New.
        (get_default_value): Use it.
        (maybe_fold_stmt_indirect): Likewise.

Added:
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/opt/pr24665.C
      - copied unchanged from r107244, trunk/gcc/testsuite/g++.dg/opt/pr24665.C
Modified:
    branches/gcc-4_1-branch/gcc/ChangeLog
    branches/gcc-4_1-branch/gcc/tree-gimple.c
    branches/gcc-4_1-branch/gcc/tree-gimple.h
    branches/gcc-4_1-branch/gcc/tree-ssa-ccp.c

Comment 9 Richard Henderson 2005-11-20 19:06:51 UTC
Fixed.