From patchwork Wed Oct 14 15:59:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 530248 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 BDD2B141107 for ; Thu, 15 Oct 2015 03:00:30 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=ClQyeUq9; 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:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=l5/mAG1ZWqGPyjnh WNOU0hPUI1vjuLtuzfBO8fRLFPDwfT71xG/UlSkQbHqwRXO4QOSKuHdNt+36frad 6sRVAHa8teCx8KqtqCknaXMFPOX+tASrc72HD4QLjiF/o0S+F8urGQ0HHTiusHdA i2o34encI4OFLP7cLAvyJXA+1SQ= 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:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=dShJeTqdWwgWO+LcCyT0Jf PEkYU=; b=ClQyeUq9zlJVC2yURcpvqyZG9wM56hYco5IvESL5mGb1DyrBvinuNX +SV9RrQD99gUCEmRUJncG5eMf+wtNZZwIQ6thiWO8ZukXMKIgIbTb409jlnyRyy4 UQXN51sJFWXRRQ9zpT+IY0C27W9kn1PUr6gIpi2wMFH7946+MQS+I= Received: (qmail 100286 invoked by alias); 14 Oct 2015 16:00:20 -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 100257 invoked by uid 89); 14 Oct 2015 16:00:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL, BAYES_00, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 14 Oct 2015 16:00:12 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 1D48C279F56D for ; Wed, 14 Oct 2015 18:00:10 +0200 (CEST) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id AO1sWxz8ffIc for ; Wed, 14 Oct 2015 18:00:10 +0200 (CEST) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id EE758279F561 for ; Wed, 14 Oct 2015 18:00:09 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [patch] Minor adjustment to gimplify_addr_expr Date: Wed, 14 Oct 2015 17:59:03 +0200 Message-ID: <16609465.DasV8VXWIg@polaris> User-Agent: KMail/4.14.9 (Linux/3.16.7-24-desktop; KDE/4.14.9; x86_64; ; ) MIME-Version: 1.0 Hi, this is the regression of ACATS c37213k at -O2 with an upcoming change in the front-end of the Ada compiler: eric@polaris:~/gnat/gnat-head/native> gcc/gnat1 -quiet c37213k.adb -I /home/eric/gnat/bugs/support -O2 +===========================GNAT BUG DETECTED==============================+ | Pro 7.4.0w (20151014-60) (x86_64-suse-linux) GCC error: | | tree check: expected class 'expression', have | | 'exceptional' (ssa_name) in tree_operand_check, at tree.h:3431| | Error detected around c37213k.adb:95:37 It's recompute_tree_invariant_for_addr_expr receiving an SSA_NAME instead of an ADDR_EXPR when called from gimplify_addr_expr. The sequence is as follows: we start with this GIMPLE statement: *R.43_60 = c37213k.B_1.B_6.proc6.B_4.B_5.value (); [static-chain: &FRAME.60] [return slot optimization] Then IPA clones the function and turns the statement into: MEM[(struct c37213k__B_1__B_6__proc6__B_4__nrec *)R.43_46] = c37213k.B_1.B_6.proc6.B_4.B_5.value (); [static-chain: &FRAME.60] [return slot optimization] The 'value' function has been NRVed and contains: .builtin_memcpy (&, _9, _10); and gets inlined so the above statement is rewritten into: .builtin_memcpy (&MEM[(struct c37213k__B_1__B_6__proc6__B_4__nrec *)R.43_46], _174, _175); so gimplify_addr_expr is invoked on: &MEM[(struct c37213k__B_1__B_6__proc6__B_4__nrec *)R.43_46] and gets confused because it doesn't see that it's just R.43_46 (it would have seen it if the original INDIRECT_REF was still present in lieu of MEM_REF). Hence the attached fixlet. Tested on x86_64-suse-linux, OK for the mainline? 2015-10-14 Eric Botcazou * gimplify.c (gimplify_addr_expr) : New case. Index: gimplify.c =================================================================== --- gimplify.c (revision 228794) +++ gimplify.c (working copy) @@ -4984,6 +4984,12 @@ gimplify_addr_expr (tree *expr_p, gimple ret = GS_OK; break; + case MEM_REF: + if (integer_zerop (TREE_OPERAND (op0, 1))) + goto do_indirect_ref; + + /* ... fall through ... */ + default: /* If we see a call to a declared builtin or see its address being taken (we can unify those cases here) then we can mark