From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 128779 invoked by alias); 11 Feb 2018 15:29:15 -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 128765 invoked by uid 89); 11 Feb 2018 15:29:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 11 Feb 2018 15:29:12 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B5CBC356F6; Sun, 11 Feb 2018 15:29:10 +0000 (UTC) Received: from freie.home (ovpn04.gateway.prod.ext.phx2.redhat.com [10.5.9.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2EE7560BE7; Sun, 11 Feb 2018 15:29:09 +0000 (UTC) Received: from livre (livre.home [172.31.160.2]) by freie.home (8.15.2/8.15.2) with ESMTP id w1BFShsq013429; Sun, 11 Feb 2018 13:28:44 -0200 From: Alexandre Oliva To: Jeff Law Cc: Joseph Myers , Alan Modra , Jakub Jelinek , Jason Merrill , Richard Biener , GCC Patches Subject: Re: [SFN+LVU+IEPM v4 9/9] [IEPM] Introduce inline entry point markers References: <20171110023448.28164-9-aoliva@redhat.com> <20180124171232.GG2063@tucnak> <20180209035334.GF3846@bubble.grove.modra.org> <6e28e34e-681d-bebb-d815-569eee148de5@redhat.com> <56fdb94e-85ac-935c-786c-30795b119373@redhat.com> Date: Sun, 11 Feb 2018 15:29:00 -0000 In-Reply-To: (Jeff Law's message of "Sat, 10 Feb 2018 11:19:09 -0700") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2018-02/txt/msg00599.txt.bz2 On Feb 10, 2018, Jeff Law wrote: >> Ports call final_scan_insn with seen == NULL, and then >> maybe_output_next_view crashes because it assumes it's >> non-NULL. Oops. Fixed. > A bit icky. But OK. Thanks. Testing revealed some ports had already introduced their own 'seen' variables passed to final_scan_insn recursive calls, so I adjusted them, and the comments to the wrapper to indicate ports should not do that. Here's what I checked in. [LVU] deal with md final_scan_insn Ports call final_scan_insn with seen == NULL, and then maybe_output_next_view crashes because it assumes it's non-NULL. Oops. Fixed. for gcc/ChangeLog * final.c (final_scan_insn_1): Renamed from... (final_scan_insn): ... this. New wrapper, to recover seen from the outermost call in recursive ones. * config/sparc/sparc.c (output_return): Drop seen from call. (output_sibcall): Likewise. * config/visium/visium.c (output_branch): Likewise. --- gcc/config/sparc/sparc.c | 6 ++---- gcc/config/visium/visium.c | 3 +-- gcc/final.c | 36 +++++++++++++++++++++++++++++++++--- 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c index 48669f177652..7126b57ba011 100644 --- a/gcc/config/sparc/sparc.c +++ b/gcc/config/sparc/sparc.c @@ -6422,7 +6422,6 @@ output_return (rtx_insn *insn) { rtx_insn *delay; rtx pat; - int seen; delay = NEXT_INSN (insn); gcc_assert (delay); @@ -6442,7 +6441,7 @@ output_return (rtx_insn *insn) Make sure to output its source location first. */ PATTERN (delay) = gen_blockage (); INSN_CODE (delay) = -1; - final_scan_insn (delay, asm_out_file, optimize, 0, &seen); + final_scan_insn (delay, asm_out_file, optimize, 0, NULL); INSN_LOCATION (delay) = UNKNOWN_LOCATION; output_restore (pat); @@ -6503,7 +6502,6 @@ output_sibcall (rtx_insn *insn, rtx call_operand) { rtx_insn *delay; rtx pat; - int seen; delay = NEXT_INSN (insn); gcc_assert (delay); @@ -6514,7 +6512,7 @@ output_sibcall (rtx_insn *insn, rtx call_operand) Make sure to output its source location first. */ PATTERN (delay) = gen_blockage (); INSN_CODE (delay) = -1; - final_scan_insn (delay, asm_out_file, optimize, 0, &seen); + final_scan_insn (delay, asm_out_file, optimize, 0, NULL); INSN_LOCATION (delay) = UNKNOWN_LOCATION; output_restore (pat); diff --git a/gcc/config/visium/visium.c b/gcc/config/visium/visium.c index 8751156c4065..106cdaf9e3f9 100644 --- a/gcc/config/visium/visium.c +++ b/gcc/config/visium/visium.c @@ -3094,10 +3094,9 @@ output_branch (rtx label, const char *cond, rtx_insn *insn) if (final_sequence) { rtx_insn *delay = NEXT_INSN (insn); - int seen; gcc_assert (delay); - final_scan_insn (delay, asm_out_file, optimize, 0, &seen); + final_scan_insn (delay, asm_out_file, optimize, 0, NULL); PATTERN (delay) = gen_blockage (); INSN_CODE (delay) = -1; } diff --git a/gcc/final.c b/gcc/final.c index 99a7cadd7c9f..cbebbfdf5b07 100644 --- a/gcc/final.c +++ b/gcc/final.c @@ -2236,9 +2236,9 @@ asm_show_source (const char *filename, int linenum) debug information. We force the emission of a line note after both NOTE_INSN_PROLOGUE_END and NOTE_INSN_FUNCTION_BEG. */ -rtx_insn * -final_scan_insn (rtx_insn *insn, FILE *file, int optimize_p ATTRIBUTE_UNUSED, - int nopeepholes ATTRIBUTE_UNUSED, int *seen) +static rtx_insn * +final_scan_insn_1 (rtx_insn *insn, FILE *file, int optimize_p ATTRIBUTE_UNUSED, + int nopeepholes ATTRIBUTE_UNUSED, int *seen) { #if HAVE_cc0 rtx set; @@ -3189,6 +3189,36 @@ final_scan_insn (rtx_insn *insn, FILE *file, int optimize_p ATTRIBUTE_UNUSED, } return NEXT_INSN (insn); } + +/* This is a wrapper around final_scan_insn_1 that allows ports to + call it recursively without a known value for SEEN. The value is + saved at the outermost call, and recovered for recursive calls. + Recursive calls MUST pass NULL, or the same pointer if they can + otherwise get to it. */ + +rtx_insn * +final_scan_insn (rtx_insn *insn, FILE *file, int optimize_p, + int nopeepholes, int *seen) +{ + static int *enclosing_seen; + static int recursion_counter; + + gcc_assert (seen || recursion_counter); + gcc_assert (!recursion_counter || !seen || seen == enclosing_seen); + + if (!recursion_counter++) + enclosing_seen = seen; + else if (!seen) + seen = enclosing_seen; + + rtx_insn *ret = final_scan_insn_1 (insn, file, optimize_p, nopeepholes, seen); + + if (!--recursion_counter) + enclosing_seen = NULL; + + return ret; +} + /* Return whether a source line note needs to be emitted before INSN. Sets IS_STMT to TRUE if the line should be marked as a possible -- Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/ You must be the change you wish to see in the world. -- Gandhi Be Free! -- http://FSFLA.org/ FSF Latin America board member Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer