From patchwork Tue Jul 20 16:36:14 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Unbreak ia64 bootstrap (PR debug/45006) Date: Tue, 20 Jul 2010 06:36:14 -0000 From: Jakub Jelinek X-Patchwork-Id: 59346 Message-Id: <20100720163614.GF19172@tyan-ft48-01.lab.bos.redhat.com> To: Richard Guenther Cc: gcc-patches@gcc.gnu.org Hi! My PR45003 fix apparently broke IA-64 bootstrap, because there FUNCTION_DECLs have DECL_MODE DImode, while TYPE_MODE of FUNCTION_TYPE is TImode. Guess that's related to fn descriptors. The following patch is an attempt to fix that. For FUNCTION_DECLs, I don't see how SIGN_EXTEND/ZERO_EXTEND on the MEM would be ever useful, FUNCTION_DECLs ought to appear in DEBUG stmts only inside of ADDR_EXPR where the MEM is not used anyway and we just use the address. The adjust_mode path isn't hit just for unary expressions (PAREN_EXPR/NOP_EXPR/CONVERT_EXPR), but also for decls and SSA_NAMEs. The latter ones of course don't have TREE_OPERAND (exp, 0), while usually the modes ought to match, it is IMHO better to try to be cautious. Either of the hunks should fix the ICE, though without the first hunk we just won't be able to emit useful debug info (as ADDR_EXPR will return NULL on ia64 then), and without the second hunk we risk we hit similar ICE later on. Ok for trunk? 2010-07-20 Jakub Jelinek PR debug/45006 * cfgexpand.c (expand_debug_expr): Don't go through adjust_mode path for FUNCTION_DECLs. Only look at TYPE_UNSIGNED of operand's type if exp is tcc_unary class tree. Jakub --- gcc/cfgexpand.c.jj 2010-07-20 12:12:14.000000000 +0200 +++ gcc/cfgexpand.c 2010-07-20 18:06:13.000000000 +0200 @@ -2369,7 +2369,10 @@ expand_debug_expr (tree exp) below would ICE. While it is likely a FE bug, try to be robust here. See PR43166. */ || mode == BLKmode - || (mode == VOIDmode && GET_MODE (op0) != VOIDmode)) + || (mode == VOIDmode && GET_MODE (op0) != VOIDmode) + /* On some targets DECL_MODE of a FUNCTION_DECL is + different from TYPE_MODE of its type. */ + || (TREE_CODE (exp) == FUNCTION_DECL && MEM_P (op0))) { gcc_assert (MEM_P (op0)); op0 = adjust_address_nv (op0, mode, 0); @@ -2427,7 +2430,9 @@ expand_debug_expr (tree exp) op0 = simplify_gen_subreg (mode, op0, inner_mode, subreg_lowpart_offset (mode, inner_mode)); - else if (TYPE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0)))) + else if (TREE_CODE_CLASS (TREE_CODE (exp)) == tcc_unary + ? TYPE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0))) + : unsignedp) op0 = gen_rtx_ZERO_EXTEND (mode, op0); else op0 = gen_rtx_SIGN_EXTEND (mode, op0);