From patchwork Fri Aug 6 12:58:44 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 61109 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 55A2BB6EEE for ; Fri, 6 Aug 2010 22:59:14 +1000 (EST) Received: (qmail 21849 invoked by alias); 6 Aug 2010 12:59:11 -0000 Received: (qmail 21840 invoked by uid 22791); 6 Aug 2010 12:59:11 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (212.99.106.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 06 Aug 2010 12:59:05 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 80AC5CB02C8 for ; Fri, 6 Aug 2010 14:59:03 +0200 (CEST) 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 9fmd7JcuNaAT for ; Fri, 6 Aug 2010 14:59:03 +0200 (CEST) Received: from adijon-256-1-135-251.w90-6.abo.wanadoo.fr (ADijon-256-1-135-251.w90-6.abo.wanadoo.fr [90.6.246.251]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id 31E51CB01E2 for ; Fri, 6 Aug 2010 14:59:03 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Do not build useless allocators Date: Fri, 6 Aug 2010 14:58:44 +0200 User-Agent: KMail/1.9.9 MIME-Version: 1.0 Message-Id: <201008061458.44429.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 When an object is too large to be allocated on the stack, gigi builds an allocator so that Storage_Error is raised at run time. It was doing that even for imported objects, which is useless since the allocator is ditched afterward for them. Fixed thusly, tested on x86-64-suse-linux, applied on the mainline. 2010-08-06 Eric Botcazou * gcc-interface/decl.c (gnat_to_gnu_entity) : Do not build an allocator for large imported objects. Index: gcc-interface/decl.c =================================================================== --- gcc-interface/decl.c (revision 162897) +++ gcc-interface/decl.c (working copy) @@ -1180,7 +1180,6 @@ gnat_to_gnu_entity (Entity_Id gnat_entit gnu_type = build_reference_type (gnu_type); gnu_size = NULL_TREE; used_by_ref = true; - const_flag = true; /* In case this was a aliased object whose nominal subtype is unconstrained, the pointer above will be a thin pointer and @@ -1194,7 +1193,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entit If we are elaborating a mutable object, tell build_allocator to ignore a possibly simpler size from the initializer, if any, as we must allocate the maximum possible size in this case. */ - if (definition) + if (definition && !imported_p) { tree gnu_alloc_type = TREE_TYPE (gnu_type); @@ -1217,14 +1216,14 @@ gnat_to_gnu_entity (Entity_Id gnat_entit } if (TREE_CODE (TYPE_SIZE_UNIT (gnu_alloc_type)) == INTEGER_CST - && TREE_OVERFLOW (TYPE_SIZE_UNIT (gnu_alloc_type)) - && !Is_Imported (gnat_entity)) + && TREE_OVERFLOW (TYPE_SIZE_UNIT (gnu_alloc_type))) post_error ("?`Storage_Error` will be raised at run time!", gnat_entity); gnu_expr = build_allocator (gnu_alloc_type, gnu_expr, gnu_type, Empty, Empty, gnat_entity, mutable_p); + const_flag = true; } else {