From patchwork Mon Dec 9 22:24:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 299224 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id CBF7E2C00AC for ; Tue, 10 Dec 2013 09:25:15 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=lx0ju/1XhiptGl7OMGSoBwAZQ5peZOjvmAX07Bqtf76CJTPoCy SLPjhGk3GiA3FMB4TX0tq8UjOZyoPqabbsRvE6J6fhLPruIBYaXgbnQr9Hlq/NvK 2OfTphjM5sGWBg9hLTdNsBBCOL9qhnxmDOYna75GHGoUJRtdHVHlruRFk= 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:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=yll6GKcShoxAaC3G8xvtAxfuIgQ=; b=p89K3Za8N1NuwyGnJR8t IXYrUOtIJK15mMdmONGA9KAGz9zZUy/54jMF0h8yqyXfEMT/Y3KjA0fxomIivQwU 4NBgak5Uk3xDu5gKa+KsvsslrWp+34yC4bWPPLP4H/O4Lqq2CPl0kOo5zNXX6bSA fFrdEPaOQKMeN/SExd1ZBPk= Received: (qmail 6583 invoked by alias); 9 Dec 2013 22:25:08 -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 6569 invoked by uid 89); 9 Dec 2013 22:25:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.0 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from Unknown (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 09 Dec 2013 22:24:53 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rB9MOj2M021227 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 9 Dec 2013 17:24:45 -0500 Received: from redhat.com (ovpn-116-23.ams2.redhat.com [10.36.116.23]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id rB9MOfdd011225 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Mon, 9 Dec 2013 17:24:44 -0500 Date: Mon, 9 Dec 2013 23:24:41 +0100 From: Marek Polacek To: GCC Patches Cc: Richard Sandiford , Richard Biener , Jakub Jelinek Subject: [PATCH] Deal with promotions for internal functions (PR sanitizer/59399) Message-ID: <20131209222440.GL11710@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Back in April 2011, Richard S. submitted the implementation of internal functions [1]. It originally had this hunk of code: if (code == SSA_NAME && (g = SSA_NAME_DEF_STMT (ssa_name)) - && gimple_code (g) == GIMPLE_CALL) + && gimple_code (g) == GIMPLE_CALL + && !gimple_call_internal_p (g)) pmode = promote_function_mode (type, mode, &unsignedp, TREE_TYPE (TREE_TYPE (gimple_call_fn (g))), but the !gimple_call_internal_p (g) was turned into an assert. This patch turns the assert back into a condition. That's because I actually hit that assert with -fsanitize=signed-integer-overflow on PPC64, where we expand internal calls at expand time. On PPC64, integers are promoted to long when passed to a function, that is why the assert doesn't trigger on x86_64. There shouldn't be any harm in not calling promote_function_mode since internal functions do not result in a call instruction. I'm not attaching any new testcase, because that's not needed - we ICE on PPC64 with current testsuite. Regtested/bootstrapped on powerpc64-unknown-linux-gnu and x86_64-unknown-linux-gnu. Ok for trunk? [1] http://gcc.gnu.org/ml/gcc-patches/2011-04/msg00609.html 2013-12-09 Marek Polacek PR sanitizer/59399 * expr.c (expand_expr_real_1): Remove assert dealing with internal calls and turn that into a condition instead. Marek --- gcc/expr.c.mp2 2013-12-09 18:54:16.235624592 +0100 +++ gcc/expr.c 2013-12-09 18:55:03.580792572 +0100 @@ -9482,13 +9482,11 @@ expand_expr_real_1 (tree exp, rtx target the same mode we got when the variable was declared. */ if (code == SSA_NAME && (g = SSA_NAME_DEF_STMT (ssa_name)) - && gimple_code (g) == GIMPLE_CALL) - { - gcc_assert (!gimple_call_internal_p (g)); - pmode = promote_function_mode (type, mode, &unsignedp, - gimple_call_fntype (g), - 2); - } + && gimple_code (g) == GIMPLE_CALL + && !gimple_call_internal_p (g)) + pmode = promote_function_mode (type, mode, &unsignedp, + gimple_call_fntype (g), + 2); else pmode = promote_decl_mode (exp, &unsignedp); gcc_assert (GET_MODE (decl_rtl) == pmode);