From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21658 invoked by alias); 3 Aug 2014 13:57:29 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 21646 invoked by uid 89); 3 Aug 2014 13:57:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wg0-f41.google.com Received: from mail-wg0-f41.google.com (HELO mail-wg0-f41.google.com) (74.125.82.41) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sun, 03 Aug 2014 13:57:26 +0000 Received: by mail-wg0-f41.google.com with SMTP id z12so6552188wgg.24 for ; Sun, 03 Aug 2014 06:57:23 -0700 (PDT) X-Received: by 10.180.11.206 with SMTP id s14mr21625909wib.27.1407074243333; Sun, 03 Aug 2014 06:57:23 -0700 (PDT) Received: from localhost ([95.145.138.172]) by mx.google.com with ESMTPSA id bx2sm35997176wjb.47.2014.08.03.06.57.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Aug 2014 06:57:22 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, rdsandiford@googlemail.com Subject: [PATCH 13/50] cse.c:is_dead_debug_insn References: <87y4v5d77q.fsf@googlemail.com> Date: Sun, 03 Aug 2014 13:57:00 -0000 In-Reply-To: <87y4v5d77q.fsf@googlemail.com> (Richard Sandiford's message of "Sun, 03 Aug 2014 14:38:01 +0100") Message-ID: <87egwxbrr1.fsf@googlemail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2014-08/txt/msg00146.txt.bz2 gcc/ * cse.c (is_dead_reg): Change argument to const_rtx. (dead_debug_insn_data): Delete. (is_dead_debug_insn): Expand commentary. Turn from being a for_each_rtx callback to being a function that examines each subrtx itself. Take the fields of dead_debug_insn_data as argument. (delete_trivially_dead_insns): Update call accordingly. Index: gcc/cse.c =================================================================== --- gcc/cse.c 2014-08-03 11:25:23.456088077 +0100 +++ gcc/cse.c 2014-08-03 11:25:23.760091083 +0100 @@ -6783,7 +6783,7 @@ count_reg_usage (rtx x, int *counts, rtx /* Return true if X is a dead register. */ static inline int -is_dead_reg (rtx x, int *counts) +is_dead_reg (const_rtx x, int *counts) { return (REG_P (x) && REGNO (x) >= FIRST_PSEUDO_REGISTER @@ -6870,30 +6870,29 @@ count_stores (rtx x, const_rtx set ATTRI counts[REGNO (x)]++; } -struct dead_debug_insn_data -{ - int *counts; - rtx *replacements; - bool seen_repl; -}; - -/* Return if a DEBUG_INSN needs to be reset because some dead - pseudo doesn't have a replacement. Callback for for_each_rtx. */ +/* Return if DEBUG_INSN pattern PAT needs to be reset because some dead + pseudo doesn't have a replacement. COUNTS[X] is zero if register X + is dead and REPLACEMENTS[X] is null if it has no replacemenet. + Set *SEEN_REPL to true if we see a dead register that does have + a replacement. */ -static int -is_dead_debug_insn (rtx *loc, void *data) +static bool +is_dead_debug_insn (const_rtx pat, int *counts, rtx *replacements, + bool *seen_repl) { - rtx x = *loc; - struct dead_debug_insn_data *ddid = (struct dead_debug_insn_data *) data; - - if (is_dead_reg (x, ddid->counts)) + subrtx_iterator::array_type array; + FOR_EACH_SUBRTX (iter, array, pat, NONCONST) { - if (ddid->replacements && ddid->replacements[REGNO (x)] != NULL_RTX) - ddid->seen_repl = true; - else - return 1; + const_rtx x = *iter; + if (is_dead_reg (x, counts)) + { + if (replacements && replacements[REGNO (x)] != NULL_RTX) + *seen_repl = true; + else + return true; + } } - return 0; + return false; } /* Replace a dead pseudo in a DEBUG_INSN with replacement DEBUG_EXPR. @@ -7035,22 +7034,19 @@ delete_trivially_dead_insns (rtx insns, if (MAY_HAVE_DEBUG_INSNS) { - struct dead_debug_insn_data ddid; - ddid.counts = counts; - ddid.replacements = replacements; for (insn = get_last_insn (); insn; insn = PREV_INSN (insn)) if (DEBUG_INSN_P (insn)) { /* If this debug insn references a dead register that wasn't replaced with an DEBUG_EXPR, reset the DEBUG_INSN. */ - ddid.seen_repl = false; - if (for_each_rtx (&INSN_VAR_LOCATION_LOC (insn), - is_dead_debug_insn, &ddid)) + bool seen_repl = false; + if (is_dead_debug_insn (INSN_VAR_LOCATION_LOC (insn), + counts, replacements, &seen_repl)) { INSN_VAR_LOCATION_LOC (insn) = gen_rtx_UNKNOWN_VAR_LOC (); df_insn_rescan (insn); } - else if (ddid.seen_repl) + else if (seen_repl) { INSN_VAR_LOCATION_LOC (insn) = simplify_replace_fn_rtx (INSN_VAR_LOCATION_LOC (insn),