From patchwork Sat Apr 2 08:15:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 89432 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id D1534B6F91 for ; Sat, 2 Apr 2011 19:15:45 +1100 (EST) Received: (qmail 29687 invoked by alias); 2 Apr 2011 08:15:34 -0000 Received: (qmail 29663 invoked by uid 22791); 2 Apr 2011 08:15:31 -0000 X-SWARE-Spam-Status: No, hits=-3.1 required=5.0 tests=AWL, BAYES_00, MEDICAL_SUBJECT, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 02 Apr 2011 08:15:26 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p328FP8g002223 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sat, 2 Apr 2011 04:15:25 -0400 Received: from freie.oliva.athome.lsd.ic.unicamp.br (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p328FNjh011391 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sat, 2 Apr 2011 04:15:25 -0400 Received: from livre.localdomain (livre-to-gw.oliva.athome.lsd.ic.unicamp.br [172.31.160.19]) by freie.oliva.athome.lsd.ic.unicamp.br (8.14.4/8.14.4) with ESMTP id p328FKE5007889 for ; Sat, 2 Apr 2011 05:15:21 -0300 Received: from livre.localdomain (aoliva@localhost.localdomain [127.0.0.1]) by livre.localdomain (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id p328FHIW030062; Sat, 2 Apr 2011 05:15:17 -0300 Received: (from aoliva@localhost) by livre.localdomain (8.14.3/8.14.3/Submit) id p328FFAj030060; Sat, 2 Apr 2011 05:15:15 -0300 From: Alexandre Oliva To: gcc-patches@gcc.gnu.org Subject: [PR debug/47590] rework md option overriding to delay var-tracking Date: Sat, 02 Apr 2011 05:15:15 -0300 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Some targets delayed the var-tracking pass to run it after machine-specific transformations. The introduction of option saving and restoring broke this, because the machine-specific overriding took place too late for it to be saved, so, after compiling a function that used a different set of options, we'd restore incorrect flags, running var-tracking at the wrong time. This patch fixes the handling of this option so that it takes place at the right time. It does not, however, support per-function overriding of -fvar-tracking; I'm not sure how to implement that with the current framework. Suggestions? Meanwhile, is this ok to install? I believe it should be applied to trunk and 4.6 as well. Although I've only tested it myself on trunk, and on platforms that were not affected, a comment in the bug report indicates it was tested (on trunk?) on one of the affected platforms. for gcc/ChangeLog from Alexandre Oliva PR debug/47590 * config/bfin/bfin.c (output_file_start): Move flag_var_tracking overriding... (bfin_option_override): ... here. * config/ia64/ia64.c (ia64_file_start): Likewise... (ia64_option_override): ... ditto. * config/spu/spu.c (asm_file_start): Likewise... (spu_option_override): ... ditto. * config/picochip/picochip.c (picochip_asm_file_start): Likewise... (picochip_option_override): ... ditto. Split previous code into... (picochip_override_options_after_change): ... this new function. (TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE): Use the latter. Index: gcc/config/bfin/bfin.c =================================================================== --- gcc/config/bfin/bfin.c.orig 2011-03-27 09:15:56.000000000 -0300 +++ gcc/config/bfin/bfin.c 2011-03-31 03:58:54.968115465 -0300 @@ -343,13 +343,6 @@ output_file_start (void) FILE *file = asm_out_file; int i; - /* Variable tracking should be run after all optimizations which change order - of insns. It also needs a valid CFG. This can't be done in - bfin_option_override, because flag_var_tracking is finalized after - that. */ - bfin_flag_var_tracking = flag_var_tracking; - flag_var_tracking = 0; - fprintf (file, ".file \"%s\";\n", input_filename); for (i = 0; arg_regs[i] >= 0; i++) @@ -2723,6 +2716,13 @@ bfin_option_override (void) bfin_flag_schedule_insns2 = flag_schedule_insns_after_reload; flag_schedule_insns_after_reload = 0; + /* Variable tracking should be run after all optimizations which change order + of insns. It also needs a valid CFG. This can't be done in + bfin_option_override, because flag_var_tracking is finalized after + that. */ + bfin_flag_var_tracking = flag_var_tracking; + flag_var_tracking = 0; + init_machine_status = bfin_init_machine_status; } Index: gcc/config/ia64/ia64.c =================================================================== --- gcc/config/ia64/ia64.c.orig 2011-03-31 03:58:25.493054332 -0300 +++ gcc/config/ia64/ia64.c 2011-03-31 03:58:55.176115781 -0300 @@ -2391,13 +2391,6 @@ ia64_expand_atomic_op (enum rtx_code cod static void ia64_file_start (void) { - /* Variable tracking should be run after all optimizations which change order - of insns. It also needs a valid CFG. This can't be done in - ia64_option_override, because flag_var_tracking is finalized after - that. */ - ia64_flag_var_tracking = flag_var_tracking; - flag_var_tracking = 0; - default_file_start (); emit_safe_across_calls (); } @@ -5722,6 +5715,13 @@ ia64_option_override (void) if (TARGET_ABI_OPEN_VMS) flag_no_common = 1; + /* Variable tracking should be run after all optimizations which change order + of insns. It also needs a valid CFG. This can't be done in + ia64_option_override, because flag_var_tracking is finalized after + that. */ + ia64_flag_var_tracking = flag_var_tracking; + flag_var_tracking = 0; + ia64_override_options_after_change(); } Index: gcc/config/picochip/picochip.c =================================================================== --- gcc/config/picochip/picochip.c.orig 2011-03-27 09:15:33.000000000 -0300 +++ gcc/config/picochip/picochip.c 2011-03-31 03:58:55.242115880 -0300 @@ -127,6 +127,7 @@ picochip_asm_named_section (const char * static rtx picochip_static_chain (const_tree, bool); static void picochip_option_override (void); +static void picochip_override_options_after_change (void); /* Lookup table mapping a register number to the earliest containing class. Used by REGNO_REG_CLASS. */ @@ -335,7 +336,7 @@ static const struct default_options pico #define TARGET_OPTION_OVERRIDE picochip_option_override #undef TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE -#define TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE picochip_option_override +#define TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE picochip_override_options_after_change #undef TARGET_OPTION_OPTIMIZATION_TABLE #define TARGET_OPTION_OPTIMIZATION_TABLE picochip_option_optimization_table @@ -356,14 +357,29 @@ picochip_return_in_memory(const_tree typ return ((unsigned HOST_WIDE_INT) int_size_in_bytes (type) > 4); } -/* Allow some options to be overriden. In particular, the 2nd - scheduling pass option is switched off, and a machine dependent - reorganisation ensures that it is run later on, after the second - jump optimisation. */ +/* Allow some options to be overriden. */ static void picochip_option_override (void) { + /* Variable tracking should be run after all optimizations which change order + of insns. It also needs a valid CFG. This can't be done in + picochip_option_override, because flag_var_tracking is finalized after + that. */ + picochip_flag_var_tracking = flag_var_tracking; + flag_var_tracking = 0; + + picochip_override_options_after_change (); +} + +/* Allow some options to be overriden after a configuration change. + In particular, the 2nd scheduling pass option is switched off, and + a machine dependent reorganisation ensures that it is run later on, + after the second jump optimisation. */ + +static void +picochip_override_options_after_change (void) +{ /* If we are optimizing for stack, dont let inliner to inline functions that could potentially increase stack size.*/ if (flag_conserve_stack) @@ -461,7 +477,6 @@ picochip_option_override (void) error ("invalid mul type specified (%s) - expected mac, mul or none", picochip_mul_type_string); } - } @@ -1813,13 +1828,6 @@ picochip_asm_file_start (void) fprintf (asm_out_file, "// Has multiply: Yes (Mac unit)\n"); else fprintf (asm_out_file, "// Has multiply: No\n"); - - /* Variable tracking should be run after all optimizations which change order - of insns. It also needs a valid CFG. This can't be done in - picochip_option_override, because flag_var_tracking is finalized after - that. */ - picochip_flag_var_tracking = flag_var_tracking; - flag_var_tracking = 0; } /* Output the end of an ASM file. */ Index: gcc/config/spu/spu.c =================================================================== --- gcc/config/spu/spu.c.orig 2011-03-27 09:15:57.000000000 -0300 +++ gcc/config/spu/spu.c 2011-03-31 03:58:55.331116013 -0300 @@ -573,6 +573,19 @@ spu_option_override (void) } REAL_MODE_FORMAT (SFmode) = &spu_single_format; + + /* Variable tracking should be run after all optimizations which + change order of insns. It also needs a valid CFG. Therefore, + *if* we make nontrivial changes in machine-dependent reorg, + run variable tracking after those. However, if we do not run + our machine-dependent reorg pass, we must still run the normal + variable tracking pass (or else we will ICE in final since + debug insns have not been removed). */ + if (TARGET_BRANCH_HINTS && optimize) + { + spu_flag_var_tracking = flag_var_tracking; + flag_var_tracking = 0; + } } /* Handle an attribute requiring a FUNCTION_DECL; arguments as in @@ -7052,19 +7065,6 @@ spu_libgcc_shift_count_mode (void) static void asm_file_start (void) { - /* Variable tracking should be run after all optimizations which - change order of insns. It also needs a valid CFG. Therefore, - *if* we make nontrivial changes in machine-dependent reorg, - run variable tracking after those. However, if we do not run - our machine-dependent reorg pass, we must still run the normal - variable tracking pass (or else we will ICE in final since - debug insns have not been removed). */ - if (TARGET_BRANCH_HINTS && optimize) - { - spu_flag_var_tracking = flag_var_tracking; - flag_var_tracking = 0; - } - default_file_start (); }