Hi there, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61330. There will be an ICE in gcc trunk for targets support section anchor optimization when compiling this case(like arm and mips). This looks like an old bug which is exposed by recent patch.
In make_decl_rtl, when you declare register type incorrectly like "register int *a asm("unknown register");", the compiler will raise an error messge but doesn't return directly. It will continue to run into the rtx generation code for general variable declaration and generate a wrong rtx:(symbol_ref:SI...). So I just remove the else condition which used to be the rtx generation part for correctly declared register type, and let all the register type declaration(no matter it declared correct or not) go through it and generate the same type of rtx:(reg:SI...). gcc/ChangeLog: 2014-07-29 Tony Wang tony.w...@arm.com * gcc/varasm.c (make_decl_rtl): Remove the else condition for properly declared static register variables. diff --git a/gcc/varasm.c b/gcc/varasm.c index 819ec26..a6fae0c 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -1333,45 +1333,42 @@ make_decl_rtl (tree decl) error ("register specified for %q+D isn%'t suitable for data type", decl); /* Now handle properly declared static register variables. */ - else - { - int nregs; + int nregs; - if (DECL_INITIAL (decl) != 0 && TREE_STATIC (decl)) - { - DECL_INITIAL (decl) = 0; - error ("global register variable has initial value"); - } - if (TREE_THIS_VOLATILE (decl)) - warning (OPT_Wvolatile_register_var, - "optimization may eliminate reads and/or " - "writes to register variables"); + if (DECL_INITIAL (decl) != 0 && TREE_STATIC (decl)) + { + DECL_INITIAL (decl) = 0; + error ("global register variable has initial value"); + } + if (TREE_THIS_VOLATILE (decl)) + warning (OPT_Wvolatile_register_var, + "optimization may eliminate reads and/or " + "writes to register variables"); - /* If the user specified one of the eliminables registers here, - e.g., FRAME_POINTER_REGNUM, we don't want to get this variable - confused with that register and be eliminated. This usage is - somewhat suspect... */ + /* If the user specified one of the eliminables registers here, + e.g., FRAME_POINTER_REGNUM, we don't want to get this variable + confused with that register and be eliminated. This usage is + somewhat suspect... */ - SET_DECL_RTL (decl, gen_rtx_raw_REG (mode, reg_number)); - ORIGINAL_REGNO (DECL_RTL (decl)) = reg_number; - REG_USERVAR_P (DECL_RTL (decl)) = 1; + SET_DECL_RTL (decl, gen_rtx_raw_REG (mode, reg_number)); + ORIGINAL_REGNO (DECL_RTL (decl)) = reg_number; + REG_USERVAR_P (DECL_RTL (decl)) = 1; - if (TREE_STATIC (decl)) - { - /* Make this register global, so not usable for anything - else. */ + if (TREE_STATIC (decl)) + { + /* Make this register global, so not usable for anything + else. */ #ifdef ASM_DECLARE_REGISTER_GLOBAL - name = IDENTIFIER_POINTER (DECL_NAME (decl)); - ASM_DECLARE_REGISTER_GLOBAL (asm_out_file, decl, reg_number, name); + name = IDENTIFIER_POINTER (DECL_NAME (decl)); + ASM_DECLARE_REGISTER_GLOBAL (asm_out_file, decl, reg_number, + name); #endif - nregs = hard_regno_nregs[reg_number][mode]; - while (nregs > 0) - globalize_reg (decl, reg_number + --nregs); - } + nregs = hard_regno_nregs[reg_number][mode]; + while (nregs > 0) + globalize_reg (decl, reg_number + --nregs); + } - /* As a register variable, it has no section. */ - return; - } + /* As a register variable, it has no section. */ + return; } /* Now handle ordinary static variables and functions (in memory). Also handle vars declared register invalidly. */ BR, Tony
920507.diff
Description: Binary data