From patchwork Wed Jul 21 11:48:08 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 59433 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 34FF0B70C6 for ; Wed, 21 Jul 2010 21:48:17 +1000 (EST) Received: (qmail 14498 invoked by alias); 21 Jul 2010 11:48:15 -0000 Received: (qmail 14477 invoked by uid 22791); 21 Jul 2010 11:48:14 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from nikam-dmz.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 21 Jul 2010 11:48:10 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 08FD29AC82C; Wed, 21 Jul 2010 13:48:08 +0200 (CEST) Date: Wed, 21 Jul 2010 13:48:08 +0200 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Fix ipa-pure-const ICE when mixing -O0 and -O2 LTO objects Message-ID: <20100721114807.GC10125@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) 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 Hi, this patch fixes ICE when building mozilla that mixes -O0 objects with -O2. We miss ipa-pure-const summary that was worked around by RIchard's patch. But his patch works only when function index ends up being after the vector of defined states. This patch makes it work always and also fixes memory corruption in remove_node_data. Bootstrapped/regtested x86_64-linux. WIll commit it later today if there are no complains. Honza * ipa-pure-const.c (varying_state): Brea out from ... (get_function_state): ... here; always return varying_state when state would be NULL otherwise. (remove_node_data): Do not free varying state. Index: ipa-pure-const.c =================================================================== --- ipa-pure-const.c (revision 162300) +++ ipa-pure-const.c (working copy) @@ -95,6 +95,11 @@ struct funct_state_d bool can_throw; }; +/* State used when we know nothing about function. */ +static struct funct_state_d varying_state + = { IPA_NEITHER, IPA_NEITHER, true, true, true }; + + typedef struct funct_state_d * funct_state; /* The storage of the funct_state is abstracted because there is the @@ -212,13 +217,12 @@ has_function_state (struct cgraph_node * static inline funct_state get_function_state (struct cgraph_node *node) { - static struct funct_state_d varying - = { IPA_NEITHER, IPA_NEITHER, true, true, true }; if (!funct_state_vec - || VEC_length (funct_state, funct_state_vec) <= (unsigned int)node->uid) + || VEC_length (funct_state, funct_state_vec) <= (unsigned int)node->uid + || !VEC_index (funct_state, funct_state_vec, node->uid)) /* We might want to put correct previously_known state into varying. */ - return &varying; - return VEC_index (funct_state, funct_state_vec, node->uid); + return &varying_state; + return VEC_index (funct_state, funct_state_vec, node->uid); } /* Set the function state S for NODE. */ @@ -860,7 +864,9 @@ remove_node_data (struct cgraph_node *no { if (has_function_state (node)) { - free (get_function_state (node)); + funct_state l = get_function_state (node); + if (l != &varying_state) + free (l); set_function_state (node, NULL); } }