From patchwork Wed Apr 22 07:41:38 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: 463605 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 15C68140152 for ; Wed, 22 Apr 2015 17:41:55 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=XoCyyGUB; dkim-adsp=none (unprotected policy); 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 :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=xlbuZIfp/RC0pn8jcbsl3VuTVIYdzUwAxQGlhKoKvGB+vr 3VYYz+Rr/OMm7WubY6WqgGluMcI6xJtRW8cug614vUZHP14i3rsP0yFlpLvW+DUN Vi2YkPfPAs6UQVsFmJdx7UhRWfQ8BLFbomNHVZSr/dU6v68nboZWTtxOAV67k= 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:subject:content-type; s= default; bh=SOD2dpVoNxRTPWkjxa8CXW9gEhc=; b=XoCyyGUBIHSPR84mujlZ C9kzCo6OVfGBW5rt7zGBJA10k+/E40Ah0ibX86yN/3QwECa9ah5MXXYy1OZ2Qp0Z sh/epmM8oisFx5nBT2PDiO+ohcCNDZUOtcNyNg70eIeZxj1IDAglGQ8wg2Gu1nsj ufdMs5O3NPU+0FpX8KwlFzA= Received: (qmail 5711 invoked by alias); 22 Apr 2015 07:41:47 -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 5700 invoked by uid 89); 22 Apr 2015 07:41:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 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; Wed, 22 Apr 2015 07:41:45 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1YkpHx-0003x5-To from Tom_deVries@mentor.com for gcc-patches@gcc.gnu.org; Wed, 22 Apr 2015 00:41:42 -0700 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.3.224.2; Wed, 22 Apr 2015 08:41:40 +0100 Message-ID: <553750B2.8010209@mentor.com> Date: Wed, 22 Apr 2015 09:41:38 +0200 From: Tom de Vries User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: GCC Patches Subject: [PATCH][PR65823] Fix va_arg ap_copy nop detection Hi, this patch fixes PR65823. The problem is a verify_gimple ICE during compilation of gcc.c-torture/execute/stdarg-2.c for arm at -O0/-O1: ... In function 'f3': src/gcc/testsuite/gcc.c-torture/execute/stdarg-2.c:61:1: error: incorrect sharing of tree nodes aps[4] # .MEM_5 = VDEF <.MEM_11> aps[4] = aps[4]; ... Before gimplification, f3 looks like this in the original dump: ... struct va_list aps[10]; struct va_list aps[10]; __builtin_va_start ((struct &) (struct *) &aps[4], i); x = VA_ARG_EXPR ; __builtin_va_end ((struct &) (struct *) &aps[4]); ... After gimplification, it looks like: ... f3 (int i) { long intD.5 x.0D.4231; struct va_listD.4222 apsD.4227[10]; try { # USE = anything # CLB = anything __builtin_va_startD.1052 (&apsD.4227[4], 0); # USE = anything # CLB = anything x.0D.4231 = VA_ARG (&apsD.4227[4], 0B); apsD.4227[4] = apsD.4227[4]; xD.4223 = x.0D.4231; # USE = anything # CLB = anything __builtin_va_endD.1051 (&apsD.4227[4]); } finally { apsD.4227 = {CLOBBER}; } } ... The nop 'apsD.4227[4] = apsD.4227[4]' introduced during gimplification is not meant to be there. There is already a test 'TREE_OPERAND (ap, 0) != TREE_OPERAND (ap_copy, 0))' in gimplify_modify_expr to prevent this nop: ... /* When gimplifying the &ap argument of va_arg, we might end up with ap.1 = ap va_arg (&ap.1, 0B) We need to assign ap.1 back to ap, otherwise va_arg has no effect on ap. */ if (ap != NULL_TREE && TREE_CODE (ap) == ADDR_EXPR && TREE_CODE (ap_copy) == ADDR_EXPR && TREE_OPERAND (ap, 0) != TREE_OPERAND (ap_copy, 0)) gimplify_assign (TREE_OPERAND (ap, 0), TREE_OPERAND (ap_copy, 0), pre_p); ... But the test is a pointer equality test, and it fails in this case. The patches fixes the problem by using operand_equal_p to do the equality test. Bootstrapped and reg-tested on x86_64. Did minimal non-bootstrap build on arm and reg-tested. OK for trunk? Thanks, - Tom Fix va_arg ap_copy nop detection 2015-04-22 Tom de Vries PR tree-optimization/65823 * gimplify.c (gimplify_modify_expr): Use operand_equal_p to test for equality between ap_copy and ap. --- gcc/gimplify.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 0a8ef84..c68bd47 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -4792,7 +4792,7 @@ gimplify_modify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, if (ap != NULL_TREE && TREE_CODE (ap) == ADDR_EXPR && TREE_CODE (ap_copy) == ADDR_EXPR - && TREE_OPERAND (ap, 0) != TREE_OPERAND (ap_copy, 0)) + && !operand_equal_p (TREE_OPERAND (ap, 0), TREE_OPERAND (ap_copy, 0), 0)) gimplify_assign (TREE_OPERAND (ap, 0), TREE_OPERAND (ap_copy, 0), pre_p); if (want_value) -- 1.9.1