From patchwork Wed Jan 14 12:15:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 428953 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 7DEC314027C for ; Wed, 14 Jan 2015 23:18:34 +1100 (AEDT) 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=RyqK6rDC26JLZlqz CwrVBn1JzWotEkSecfrtqvZAhmyYlrHCtsoJvLg4CFavxFVPMHzj7Noh1SuNneWC JeaP+UR8cQKTujrl3NxXE0KNz5OReTVkftDr8ifmpvKN7/+rds1ZUcJD7v3Cm6kb IFiLOVtDnZvwYegcJATClyaZ98Q= 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=stahSbdarY26dWxLFvKVpu LIdeE=; b=TAQcNoCjRNT7RjQQWD2DApZhnmX/t1RoabwFKFrqQoy7bp3sn/6Gzj 9A1LDEy/4R9fJxOGX2dXbcm6mVkqlvx97bL3VXj7tJ7FdFFm49mvpc+uz5iKKV6n VB/Nlxqy0yeWtI8FOrKl5+0sbkaE50kTqSKPuuse3rV5DRktI2+tk= Received: (qmail 32741 invoked by alias); 14 Jan 2015 12:18:26 -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 32703 invoked by uid 89); 14 Jan 2015 12:18:25 -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, RCVD_IN_DNSWL_NONE autolearn=ham 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 Jan 2015 12:18:20 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 2697828EFDF2 for ; Wed, 14 Jan 2015 13:18:17 +0100 (CET) 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 glWCCkUAmRKE for ; Wed, 14 Jan 2015 13:18:17 +0100 (CET) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id F1EAA28E4EA1 for ; Wed, 14 Jan 2015 13:18:16 +0100 (CET) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [PATCH] Dissociate MEM_EXPR so that it is not marked as addressable Date: Wed, 14 Jan 2015 13:15:14 +0100 Message-ID: <9293879.LMQFIBm6Yn@polaris> User-Agent: KMail/4.7.2 (Linux/3.1.10-1.29-desktop; KDE/4.7.2; x86_64; ; ) MIME-Version: 1.0 Hi, this is a follow-up to https://gcc.gnu.org/ml/gcc-patches/2012-03/msg01890.html where Martin was fixing an Ada bootstrap failure on SPARC64. After some discussion between Martin, Richard B. and me, the initial proposal evolved into a tweak to be applied to the existing call to set_mem_attributes in the normal_inner_ref case of expand_expr_real_1, first to avoid it and eventually to call it on the type instead of the expression. That was an oversight on my side, since the type is that of the expression and not that of the value spilled onto the stack, so it may not always be seen as having an alias set conflicting with that of the expression in Ada, e.g. if the expression is a an ARRAY_REF of a VCE to an array with a non-aliased component, see the attached testcase. So the patch reverts the change and instead clears MEM_EXPR in the problematic case, as first proposed by Martin. Bootstrapped/regtested on x86_64-suse-linux, OK for mainline and 4.9 branch? 2015-01-14 Eric Botcazou * expr.c (expand_expr_real_1) : Use the expression to set the memory attributes in all cases but clear MEM_EXPR if need be. 2015-01-14 Eric Botcazou * testsuite/gnat.dg/opt47.adb: New test. Index: expr.c =================================================================== --- expr.c (revision 219578) +++ expr.c (working copy) @@ -10137,7 +10137,7 @@ expand_expr_real_1 (tree exp, rtx target tree tem = get_inner_reference (exp, &bitsize, &bitpos, &offset, &mode1, &unsignedp, &volatilep, true); rtx orig_op0, memloc; - bool mem_attrs_from_type = false; + bool clear_mem_expr = false; /* If we got back the original object, something is wrong. Perhaps we are evaluating an expression too early. In any event, don't @@ -10233,7 +10233,7 @@ expand_expr_real_1 (tree exp, rtx target memloc = assign_temp (TREE_TYPE (tem), 1, 1); emit_move_insn (memloc, op0); op0 = memloc; - mem_attrs_from_type = true; + clear_mem_expr = true; } if (offset) @@ -10417,17 +10417,17 @@ expand_expr_real_1 (tree exp, rtx target if (op0 == orig_op0) op0 = copy_rtx (op0); - /* If op0 is a temporary because of forcing to memory, pass only the - type to set_mem_attributes so that the original expression is never - marked as ADDRESSABLE through MEM_EXPR of the temporary. */ - if (mem_attrs_from_type) - set_mem_attributes (op0, type, 0); - else - set_mem_attributes (op0, exp, 0); + set_mem_attributes (op0, exp, 0); if (REG_P (XEXP (op0, 0))) mark_reg_pointer (XEXP (op0, 0), MEM_ALIGN (op0)); + /* If op0 is a temporary because the original expressions was forced + to memory, clear MEM_EXPR so that the original expression cannot + be marked as addressable through MEM_EXPR of the temporary. */ + if (clear_mem_expr) + set_mem_expr (op0, NULL_TREE); + MEM_VOLATILE_P (op0) |= volatilep; if (mode == mode1 || mode1 == BLKmode || mode1 == tmode || modifier == EXPAND_CONST_ADDRESS