From patchwork Tue May 12 11:45:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 471271 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 F1423140187 for ; Tue, 12 May 2015 21:45:50 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=rk18D/C4; 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:cc:subject:references :in-reply-to:content-type; q=dns; s=default; b=Ck9u0OekjoqbJmTBC WOMNX1TanrqG9hWv3nkmidaleaUsIAHDzNHgT/89REzmRRUAd02maTGoknlkqxDt 3x5n2g839WUJiYFZC9ieEly86ATSHzSDnVxrqlIIRaa+jTCXdxw7SXLou4LWe28r 7k3PN3jBYYg5AIcMdijkl1jh6g= 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=7WRyGW+spI13JqZ0skSlx1T 5FMg=; b=rk18D/C4EulwAMGWnWfCWCOh9FLdGWYfmDYUJwWjp/pf3Ml2gRvTql4 YhU//RA9nLr/zAshubc9sHFBfYE9+TU/xMYB99Een5gdQAWW99ncJtIg1RPdUbmc J+P7kJbYTR0MSmU8+3OW+V9PGWdNP+ZbrDrDzjbMF2RXk+c+jpqA= Received: (qmail 32807 invoked by alias); 12 May 2015 11:45:41 -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 32782 invoked by uid 89); 12 May 2015 11:45:40 -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; Tue, 12 May 2015 11:45:36 +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 1Ys8cu-0001DQ-UC from Tom_deVries@mentor.com ; Tue, 12 May 2015 04:45:33 -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; Tue, 12 May 2015 12:45:22 +0100 Message-ID: <5551E7CF.9060304@mentor.com> Date: Tue, 12 May 2015 13:45:19 +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: Richard Biener CC: GCC Patches Subject: Re: [PATCH][PR66010] Don't take address of ap unless necessary References: <554D0BE4.8090305@mentor.com> <5550C7DA.6070406@mentor.com> <5551D014.3040205@mentor.com> In-Reply-To: <5551D014.3040205@mentor.com> On 12-05-15 12:04, Tom de Vries wrote: > Committed with comments below added. Hmm, this causes an ice for s390 in gcc.dg/tree-ssa/stdarg-2.c: ... gimplification failed: &ap sizes-gimplified BLK size unit size align 32 symtab 0 alias set -1 canonical type 0x7f132f46b9d8 domain context pointer_to_this > unsigned SI size unit size align 32 symtab 0 alias set -1 canonical type 0x7f132f55f2a0> arg 0 addressable used BLK file stdarg-2.c line 32 col 11 size unit size align 32 context > stdarg-2.c:35:15> stdarg-2.c: In function ‘f2’: stdarg-2.c:35:15: internal compiler error: gimplification failed res = f2_1 (ap); ^ 0xad3d02 gimplify_expr(tree_node**, gimple_statement_base**, gimple_statement_base**, bool (*)(tree_node*), int) /home/vries/gcc_versions/devel/devel3/src/gcc/gimplify.c:8856 0xad5762 gimplify_va_arg_internal(tree_node*, tree_node*, gimple_statement_base**, gimple_statement_base**) /home/vries/gcc_versions/devel/devel3/src/gcc/gimplify.c:9326 0x10a3349 expand_ifn_va_arg_1 /home/vries/gcc_versions/devel/devel3/src/gcc/tree-stdarg.c:1062 0x10a3596 expand_ifn_va_arg /home/vries/gcc_versions/devel/devel3/src/gcc/tree-stdarg.c:1122 0x10a36d3 execute /home/vries/gcc_versions/devel/devel3/src/gcc/tree-stdarg.c:1174 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See for instructions. ... Attached patch is a tentative fix. I'll bootstrap and reg-test on x86_64. Thanks, - Tom diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 322d0ba..4846478 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -9302,32 +9302,6 @@ dummy_object (tree type) return build2 (MEM_REF, type, t, t); } -/* Call the target expander for evaluating a va_arg call of VALIST - and TYPE. */ - -tree -gimplify_va_arg_internal (tree valist, tree type, gimple_seq *pre_p, - gimple_seq *post_p) -{ - tree have_va_type = TREE_TYPE (valist); - tree cano_type = targetm.canonical_va_list_type (have_va_type); - - if (cano_type != NULL_TREE) - have_va_type = cano_type; - - /* Make it easier for the backends by protecting the valist argument - from multiple evaluations. */ - if (TREE_CODE (have_va_type) == ARRAY_TYPE) - { - gcc_assert (TREE_CODE (TREE_TYPE (valist)) != ARRAY_TYPE); - gimplify_expr (&valist, pre_p, post_p, is_gimple_val, fb_rvalue); - } - else - gimplify_expr (&valist, pre_p, post_p, is_gimple_min_lval, fb_lvalue); - - return targetm.gimplify_va_arg_expr (valist, type, pre_p, post_p); -} - /* Gimplify __builtin_va_arg, aka VA_ARG_EXPR, which is not really a builtin function, but a very special sort of operator. */ diff --git a/gcc/gimplify.h b/gcc/gimplify.h index 83bf525..615925c 100644 --- a/gcc/gimplify.h +++ b/gcc/gimplify.h @@ -82,7 +82,6 @@ extern void gimplify_function_tree (tree); extern enum gimplify_status gimplify_va_arg_expr (tree *, gimple_seq *, gimple_seq *); gimple gimplify_assign (tree, tree, gimple_seq *); -extern tree gimplify_va_arg_internal (tree, tree, gimple_seq *, gimple_seq *); /* Return true if gimplify_one_sizepos doesn't need to gimplify expr (when in TYPE_SIZE{,_UNIT} and similar type/decl size/bitsize diff --git a/gcc/tree-stdarg.c b/gcc/tree-stdarg.c index 3bede7e..f8ff70a 100644 --- a/gcc/tree-stdarg.c +++ b/gcc/tree-stdarg.c @@ -1059,7 +1059,14 @@ expand_ifn_va_arg_1 (function *fun) push_gimplify_context (false); - expr = gimplify_va_arg_internal (ap, type, &pre, &post); + /* Make it easier for the backends by protecting the valist argument + from multiple evaluations. */ + if (do_deref == integer_one_node) + gimplify_expr (&ap, &pre, &post, is_gimple_min_lval, fb_lvalue); + else + gimplify_expr (&ap, &pre, &post, is_gimple_val, fb_rvalue); + + expr = targetm.gimplify_va_arg_expr (ap, type, &pre, &post); lhs = gimple_call_lhs (stmt); if (lhs != NULL_TREE)