From patchwork Wed Apr 22 13:50:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 463669 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 51F201400B7 for ; Wed, 22 Apr 2015 23:51:07 +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=ofxhCkJT; 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 :mime-version:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; q=dns; s=default; b=YxNEJHpKJDGgAayZvT BfYOXYZx1FF4cz1Z8tT8LeYqZSxRvZUQl4gYI/mdDTmrnFZ95XvMfoIgZjDhktFr FtBY1MZl0BAET5yM/nPcaS0kaRTDjEUNf8Cbr9wj8GAXP19bLdTx+jRset9vg+uz xFcvP/0zP8/CyhNlcvAdteY+Y= 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 :mime-version:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; s=default; bh=yVvikF18IyJVk1MzeCp/mBTO C9A=; b=ofxhCkJTyJe735qBawaudf5ZUPAlt7TSyLq3qh5jlLF7oDVo3HcIGQ7L JHmWIbI8r/SrdVv2aDYOZMBHPFfLhDyWpvCtEM4wfXMuQ/2X1o7Bg5QlshxHrOOq drLvz7EKZ1a+hyIw+PLAf55E9gVCCnFaxe7j++8FXCa0aD+UJbw= Received: (qmail 52571 invoked by alias); 22 Apr 2015 13:50:59 -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 52561 invoked by uid 89); 22 Apr 2015 13:50:58 -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, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ob0-f177.google.com Received: from mail-ob0-f177.google.com (HELO mail-ob0-f177.google.com) (209.85.214.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 22 Apr 2015 13:50:57 +0000 Received: by obbeb7 with SMTP id eb7so170236664obb.3 for ; Wed, 22 Apr 2015 06:50:55 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.202.172.196 with SMTP id v187mr22192754oie.51.1429710655495; Wed, 22 Apr 2015 06:50:55 -0700 (PDT) Received: by 10.76.115.167 with HTTP; Wed, 22 Apr 2015 06:50:55 -0700 (PDT) In-Reply-To: <5537A438.5030803@mentor.com> References: <553750B2.8010209@mentor.com> <5537A438.5030803@mentor.com> Date: Wed, 22 Apr 2015 15:50:55 +0200 Message-ID: Subject: Re: [PATCH][PR65823] Fix va_arg ap_copy nop detection From: Richard Biener To: Tom de Vries Cc: GCC Patches X-IsSubscribed: yes On Wed, Apr 22, 2015 at 3:38 PM, Tom de Vries wrote: > On 22-04-15 10:06, Richard Biener wrote: >> >> On Wed, Apr 22, 2015 at 9:41 AM, Tom de Vries >> wrote: >>> >>> Hi, >>> >>> this patch fixes PR65823. >>> > > > >>> >>> 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? >> >> >> Hmm, ok for now. > > > Committed. > >> But I wonder if we can't fix things to not require that >> odd extra copy. > > > Agreed, that would be good. > >> In fact that we introduce ap.1 looks completely bogus to me > > > AFAICT, it's introduced by gimplify_arg ('&argp') because argp (a PARM_DECL) > is not addressable. > >> (and we don't in this case for arm). Note that the pointer compare >> obviously >> fails because we unshare the expression. >> >> So ... what breaks if we simply remove this odd "fixup"? >> > > [ Originally mentioned at https://gcc.gnu.org/ml/gcc/2015-02/msg00011.html . > ] > > I've committed gcc.target/x86_64/abi/callabi/vaarg-6.c specifically as a > minimal version of this problem. > > If we remove the ap_copy fixup, at original we have: > ... > ;; Function do_cpy2 (null) > { > char * e; > > char * e; > e = VA_ARG_EXPR ; > e = VA_ARG_EXPR ; > if (e != b) > { > abort (); > } > } > ... > > and after gimplify we have: > ... > do_cpy2 (char * argp) > { > char * argp.1; > char * argp.2; > char * b.3; > char * e; > > argp.1 = argp; > e = VA_ARG (&argp.1, 0B); > argp.2 = argp; > e = VA_ARG (&argp.2, 0B); > b.3 = b; > if (e != b.3) goto ; else goto ; > : > abort (); > : > } > ... > > The second VA_ARG uses &argp.2, which is a copy of argp, which is unmodified > by the first VA_ARG. > > > Using attached _proof-of-concept_ patch, I get callabi.exp working without > the ap_copy, still at the cost of one 'argp.1 = argp' copy though: > ... > do_cpy2 (char * argp) > { > char * argp.1; > char * b.2; > char * e; > > argp.1 = argp; > e = VA_ARG (&argp.1, 0B); > e = VA_ARG (&argp.1, 0B); > b.2 = b; > if (e != b.2) goto ; else goto ; > : > abort (); > : > } > ... > > But perhaps there's an easier way? Hum, simply pre-approved with removing the kludge. Thanks, Richard. > Thanks, > - Tom Index: gcc/gimplify.c =================================================================== --- gcc/gimplify.c (revision 222320) +++ gcc/gimplify.c (working copy) @@ -9419,6 +9419,7 @@ gimplify_va_arg_expr (tree *expr_p, gimp } /* Transform a VA_ARG_EXPR into an VA_ARG internal function. */ + mark_addressable (valist); ap = build_fold_addr_expr_loc (loc, valist); tag = build_int_cst (build_pointer_type (type), 0); *expr_p = build_call_expr_internal_loc (loc, IFN_VA_ARG, type, 2, ap, tag);