From patchwork Thu Feb 19 11:07:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 441573 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 508721400F1 for ; Thu, 19 Feb 2015 22:08:05 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; q=dns; s=default; b=F6Va01a+bLE+3sVsZ i7QMSrPgRjbzVGvWWalWi2Cfna1sDTmr1DNn2GOPvrywgblSV5sc08yjimDLdQwn i7yOxYL8EHFgUNtG5yMYFIwH3GHjIULGp2UKEQ2hPoSuyCEpmr90qbClvwoQWteY pgmW0PHhHrK8XprKTyddxSMvMs= 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 :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; s=default; bh=ge/LiGsv05+JyMecWDNWyWs 8ut8=; b=borunbZTKHHtFdO+qZ6cmXgbZ8vxzKzEMZ0gZp+wAP7Sb/YslBUAqvw o0gvBiK7ygpcljUM7uH0/VETs2XPj0ELGoISJFjtM1ZmChYe5hVdDTws179sQ8pN urILZqNC4eFcWxi6NmIIbmk1PIrfbbLpmckinE3k90al/NAga5eU= Received: (qmail 3852 invoked by alias); 19 Feb 2015 11:07:57 -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 3836 invoked by uid 89); 19 Feb 2015 11:07:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 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; Thu, 19 Feb 2015 11:07:55 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-02.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1YOOxT-0006Xu-TU from Tom_deVries@mentor.com ; Thu, 19 Feb 2015 03:07:52 -0800 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-02.mgc.mentorg.com (137.202.0.106) with Microsoft SMTP Server id 14.3.224.2; Thu, 19 Feb 2015 11:07:50 +0000 Message-ID: <54E5C403.7050606@mentor.com> Date: Thu, 19 Feb 2015 12:07:47 +0100 From: Tom de Vries User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Jakub Jelinek , Richard Biener CC: GCC Patches , Michael Matz Subject: [PATCH][4/5] Handle internal_fn in operand_equal_p References: <54E5BB06.2080102@mentor.com> In-Reply-To: <54E5BB06.2080102@mentor.com> On 19-02-15 11:29, Tom de Vries wrote: > Hi, > > I'm posting this patch series for stage1: > - 0001-Disable-lang_hooks.gimplify_expr-in-free_lang_data.patch > - 0002-Add-gimple_find_sub_bbs.patch > - 0003-Factor-optimize_va_list_gpr_fpr_size-out-of-pass_std.patch > - 0004-Handle-internal_fn-in-operand_equal_p.patch > - 0005-Postpone-expanding-va_arg-until-pass_stdarg.patch > > The patch series - based on Michael's initial patch - postpones expanding va_arg > until pass_stdarg, which makes pass_stdarg more robust. > > Bootstrapped and reg-tested on x86_64 using all languages, with unix/ and > unix/-m32 testing. > > I'll post the patches in reply to this email. > This patch adds handling of internal functions in operand_equal_p. I ran into a situation here in operand_equal_p where it segfaulted on the internal function IFN_VA_ARG, because the CALL_EXPR_FN of an internal function is NULL, and operand_equal_p does not expect NULL arguments: ... case CALL_EXPR: /* If the CALL_EXPRs call different functions, then they clearly can not be equal. */ if (! operand_equal_p (CALL_EXPR_FN (arg0), CALL_EXPR_FN (arg1), flags)) return 0; ... This patch fixes that by testing if CALL_EXPR_FN is NULL. OK for stage1? Thanks, - Tom 2015-02-17 Tom de Vries * fold-const.c (operand_equal_p): Handle INTERNAL_FNs. --- gcc/fold-const.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 8377120..fbf76d0 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -3032,6 +3032,11 @@ operand_equal_p (const_tree arg0, const_tree arg1, unsigned int flags) switch (TREE_CODE (arg0)) { case CALL_EXPR: + /* Handle internal_fns conservatively. */ + if (CALL_EXPR_FN (arg0) == NULL_TREE + || CALL_EXPR_FN (arg1) == NULL_TREE) + return 0; + /* If the CALL_EXPRs call different functions, then they clearly can not be equal. */ if (! operand_equal_p (CALL_EXPR_FN (arg0), CALL_EXPR_FN (arg1), -- 1.9.1