From patchwork Tue Jan 4 08:56:32 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 77420 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]) by ozlabs.org (Postfix) with SMTP id A225BB7063 for ; Tue, 4 Jan 2011 19:58:53 +1100 (EST) Received: (qmail 14062 invoked by alias); 4 Jan 2011 08:58:52 -0000 Received: (qmail 14053 invoked by uid 22791); 4 Jan 2011 08:58:51 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (194.98.77.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 04 Jan 2011 08:58:43 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 82FCACB0277 for ; Tue, 4 Jan 2011 09:58:41 +0100 (CET) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 55YLUakVtAdK for ; Tue, 4 Jan 2011 09:58:41 +0100 (CET) Received: from [192.168.1.2] (bon31-9-83-155-120-49.fbx.proxad.net [83.155.120.49]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id 4F992CB022A for ; Tue, 4 Jan 2011 09:58:41 +0100 (CET) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Fix PR ada/47131 Date: Tue, 4 Jan 2011 09:56:32 +0100 User-Agent: KMail/1.9.9 MIME-Version: 1.0 Message-Id: <201101040956.32642.ebotcazou@adacore.com> 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 This is the failure of ACATS c34011b on SJLJ targets. We have this kludge in Identifier_to_gnu since the Tree-SSA transition: /* If we are in an exception handler, force this variable into memory to ensure optimization does not remove stores that appear redundant but are actually needed in case an exception occurs. ??? Note that we need not do this if the variable is declared within the handler, only if it is referenced in the handler and declared in an enclosing block, but we have no way of testing that right now. ??? We used to essentially set the TREE_ADDRESSABLE flag on the variable here, but it can now be removed by the Tree aliasing machinery if the address of the variable is never taken. All we can do is to make the variable volatile, which might incur the generation of temporaries just to access the memory in some circumstances. This can be avoided for variables of non-constant size because they are automatically allocated to memory. There might be no way of allocating a proper temporary for them in any case. We only do this for SJLJ though. */ if (VEC_last (tree, gnu_except_ptr_stack) && TREE_CODE (gnu_result) == VAR_DECL && TREE_CODE (DECL_SIZE_UNIT (gnu_result)) == INTEGER_CST) TREE_THIS_VOLATILE (gnu_result) = TREE_SIDE_EFFECTS (gnu_result) = 1; This turns out to be problematic with recent more stringent consistency checks because TREE_THIS_VOLATILE can be set late and thus not propagated in already built trees referencing the DECL. The volatile trick used here is consistent with the setjmp/longjmp semantics but we use __builtin_setjmp/__builtin_longjmp to implement the SJLJ scheme. Tested on i586-suse-linux in SJLJ configuration, applied on the mainline. 2011-01-04 Eric Botcazou PR ada/47131 * gcc-interface/trans.c (Identifier_to_gnu): In SJLJ mode, do not make variables that are referenced in exception handlers volatile. Index: gcc-interface/trans.c =================================================================== --- gcc-interface/trans.c (revision 168416) +++ gcc-interface/trans.c (working copy) @@ -6,7 +6,7 @@ * * * C Implementation File * * * - * Copyright (C) 1992-2010, Free Software Foundation, Inc. * + * Copyright (C) 1992-2011, Free Software Foundation, Inc. * * * * GNAT is free software; you can redistribute it and/or modify it under * * terms of the GNU General Public License as published by the Free Soft- * @@ -980,27 +980,6 @@ Identifier_to_gnu (Node_Id gnat_node, tr else gnu_result = gnat_to_gnu_entity (gnat_temp, NULL_TREE, 0); - /* If we are in an exception handler, force this variable into memory to - ensure optimization does not remove stores that appear redundant but are - actually needed in case an exception occurs. - - ??? Note that we need not do this if the variable is declared within the - handler, only if it is referenced in the handler and declared in an - enclosing block, but we have no way of testing that right now. - - ??? We used to essentially set the TREE_ADDRESSABLE flag on the variable - here, but it can now be removed by the Tree aliasing machinery if the - address of the variable is never taken. All we can do is to make the - variable volatile, which might incur the generation of temporaries just - to access the memory in some circumstances. This can be avoided for - variables of non-constant size because they are automatically allocated - to memory. There might be no way of allocating a proper temporary for - them in any case. We only do this for SJLJ though. */ - if (VEC_last (tree, gnu_except_ptr_stack) - && TREE_CODE (gnu_result) == VAR_DECL - && TREE_CODE (DECL_SIZE_UNIT (gnu_result)) == INTEGER_CST) - TREE_THIS_VOLATILE (gnu_result) = TREE_SIDE_EFFECTS (gnu_result) = 1; - /* Some objects (such as parameters passed by reference, globals of variable size, and renamed objects) actually represent the address of the object. In that case, we must do the dereference. Likewise,