From patchwork Mon Mar 7 11:26:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 592909 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 6C8C81402A0 for ; Mon, 7 Mar 2016 22:26:31 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=wEWC1R6U; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=pn7kYEFg53efnuMz1 S20fTJ5PqqL8KSSOm16i9d3+F2GRrHCpDwFnssrH5Z9MEYtg1YSP2ZZKdO3YVzvS ikXEWN5s4P5aKJvwJ7HfOPE+K3VPNQVgtk1+9ZQUQDEVVVQ6/+ZOX93HfqWtqPU1 2RLL7rcg0M9rxizyjaCplZV/H4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=TF2eGH19Wch1K5y6b/pV9C/ OiC4=; b=wEWC1R6UI9BZ810bed377Dv/gbuSPSG2QRqo/tV0ODmOWDgvVJTJMhN ExhzkPwYnOpU8058OsjL0lmaIlrZO9nBlz9tclpI3viyAg/FrWAX+2s4gBlbjANk hP+k2Y2J2pvbGsCLd6e1603E41AZtKzJxI4eram1cvigEgKIdKPg= Received: (qmail 13875 invoked by alias); 7 Mar 2016 11:26:24 -0000 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 Received: (qmail 13863 invoked by uid 89); 7 Mar 2016 11:26:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 07 Mar 2016 11:26:21 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-03.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1actIm-0002k2-Md from Tom_deVries@mentor.com ; Mon, 07 Mar 2016 03:26:16 -0800 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-03.mgc.mentorg.com (137.202.0.108) with Microsoft SMTP Server id 14.3.224.2; Mon, 7 Mar 2016 11:26:15 +0000 Subject: Re: [PATCH] Skip ubsan internal fns in tail-merge To: Jakub Jelinek References: <1c507aae804089fe39102391ff554d51a20ba391.1436450591.git.mliska@suse.cz> <20150709141312.GS10247@tucnak.redhat.com> <559E9481.70505@redhat.com> <20150709154153.GV10247@tucnak.redhat.com> <559EA345.6070105@redhat.com> <55A02707.6000505@redhat.com> <56DD4E9A.3030009@mentor.com> <20160307100155.GS3017@tucnak.redhat.com> CC: Jeff Law , Richard Biener , mliska , GCC Patches From: Tom de Vries Message-ID: <56DD6552.1030105@mentor.com> Date: Mon, 7 Mar 2016 12:26:10 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <20160307100155.GS3017@tucnak.redhat.com> On 07/03/16 11:01, Jakub Jelinek wrote: > On Mon, Mar 07, 2016 at 10:49:14AM +0100, Tom de Vries wrote: >> This patch implements that. >> >> Should the asan internal function (ASAN_CHECK) be handled in the same way, >> as suggested here ( https://gcc.gnu.org/ml/gcc-patches/2015-07/msg00776.html >> )? >> >> OK for stage4 trunk if bootstrap and reg-test succeeds? > > Please certainly add ASAN_CHECK to the list. Done. > Perhaps more precise would be to allow merging them, but only if > gimple_location (stmt1) == gimple_location (stmt2). > Done. > Also, I wonder why you need to check both stmts individually, wouldn't it be > better (both for the is_tm_ending and the ubsan/asan internal calls) to > first call gimple_equal_p and only if it says the two are equal, check > is_tm_ending (only on one stmt, if they are equal, then I hope is_tm_ending > is necessarily equal for both), and similarly for the ubsan/asan ifns > compare the gimple_location? > Done. OK for stage4 trunk if bootstrap and reg-test succeeds? Thanks, - Tom Skip ubsan/asan internal fns with different location in tail-merge 2016-03-07 Tom de Vries PR tree-optimization/70116 * tree-ssa-tail-merge.c (merge_stmts_p): New function, factored out of ... (find_duplicate): ... here. Move merge_stmts_p test to after gimple_equal_p test. (merge_stmts_p): Return false for ubsan/asan internal functions with different gimple_location. --- gcc/tree-ssa-tail-merge.c | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/gcc/tree-ssa-tail-merge.c b/gcc/tree-ssa-tail-merge.c index 5d32790..13ea4fe 100644 --- a/gcc/tree-ssa-tail-merge.c +++ b/gcc/tree-ssa-tail-merge.c @@ -1207,6 +1207,39 @@ gsi_advance_bw_nondebug_nonlocal (gimple_stmt_iterator *gsi, tree *vuse, } } +/* Return true if equal (in the sense of gimple_equal_p) statements STMT1 and + STMT2 are allowed to be merged. */ + +static bool +merge_stmts_p (gimple *stmt1, gimple *stmt2) +{ + /* What could be better than this here is to blacklist the bb + containing the stmt, when encountering the stmt f.i. in + same_succ_hash. */ + if (is_tm_ending (stmt1)) + return false; + + if (is_gimple_call (stmt1) + && gimple_call_internal_p (stmt1)) + { + switch (gimple_call_internal_fn (stmt1)) + { + case IFN_UBSAN_NULL: + case IFN_UBSAN_BOUNDS: + case IFN_UBSAN_VPTR: + case IFN_UBSAN_CHECK_ADD: + case IFN_UBSAN_CHECK_SUB: + case IFN_UBSAN_CHECK_MUL: + case IFN_UBSAN_OBJECT_SIZE: + case IFN_ASAN_CHECK: + return gimple_location (stmt1) == gimple_location (stmt2); + default: + break; + } + + return true; +} + /* Determines whether BB1 and BB2 (members of same_succ) are duplicates. If so, clusters them. */ @@ -1226,14 +1259,10 @@ find_duplicate (same_succ *same_succ, basic_block bb1, basic_block bb2) gimple *stmt1 = gsi_stmt (gsi1); gimple *stmt2 = gsi_stmt (gsi2); - /* What could be better than this here is to blacklist the bb - containing the stmt, when encountering the stmt f.i. in - same_succ_hash. */ - if (is_tm_ending (stmt1) - || is_tm_ending (stmt2)) + if (!gimple_equal_p (same_succ, stmt1, stmt2)) return; - if (!gimple_equal_p (same_succ, stmt1, stmt2)) + if (!merge_stmts_p (stmt1, stmt2)) return; gsi_prev_nondebug (&gsi1);