From patchwork Sat May 4 05:55:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 241428 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 4F3AF2C00B5 for ; Sat, 4 May 2013 15:55:28 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=W7PCxCP2ZO4YdJ2xR dlia8uvaXq+uk7rLzx6LouddLUjYXC/bLcD45ugMjTT37rGOgCr049ckjEblYwfR ZCvIMDYvUxKgDlnOzPGc6BACit6KSr9D7b4LUi8niYgOaogIHN4EWDuM/Z6a5/Yv eC835ALHj6MlnKr9Ix7eokv5Fg= 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:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=default; bh=aSV/VTlWgC/ZyzyTuXgJZ6q 3/x8=; b=V7Nu67rpUPpNOgoBPLHAHgliacM2+l9UP/yBlAYn/PPfErQiwzSJrnI 7WHaS1Ow09+PcbpAcqrjG8HSfLkN61jR35dZE/VF5ibcsQYWOWRdtY6DCIBglWCp sN3lr2tRT3YpZ6bf0AOsM2hPttKIKwjk7+W4t2FCveLnagSYJItk= Received: (qmail 16609 invoked by alias); 4 May 2013 05:55:21 -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 16580 invoked by uid 89); 4 May 2013 05:55:15 -0000 X-Spam-SWARE-Status: No, score=-0.7 required=5.0 tests=AWL, BAYES_20, FREEMAIL_FROM, KAM_STOCKGEN, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, SPF_PASS, TW_IB autolearn=no version=3.3.1 Received: from mail-pa0-f54.google.com (HELO mail-pa0-f54.google.com) (209.85.220.54) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Sat, 04 May 2013 05:55:14 +0000 Received: by mail-pa0-f54.google.com with SMTP id kx1so1250400pab.41 for ; Fri, 03 May 2013 22:55:13 -0700 (PDT) X-Received: by 10.68.220.106 with SMTP id pv10mr17148792pbc.52.1367646912747; Fri, 03 May 2013 22:55:12 -0700 (PDT) Received: from bubble.grove.modra.org ([101.166.26.37]) by mx.google.com with ESMTPSA id k2sm15865495pat.7.2013.05.03.22.55.09 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 03 May 2013 22:55:11 -0700 (PDT) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id 5FB59EA2C6B; Sat, 4 May 2013 15:25:05 +0930 (CST) Date: Sat, 4 May 2013 15:25:05 +0930 From: Alan Modra To: Jakub Jelinek Cc: Andrew Haley , Tom Tromey , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Fix array sizes created by Java FE (PR libgcj/57074) Message-ID: <20130504055505.GT5221@bubble.grove.modra.org> Mail-Followup-To: Jakub Jelinek , Andrew Haley , Tom Tromey , gcc-patches@gcc.gnu.org References: <20130503171015.GD28963@tucnak.redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20130503171015.GD28963@tucnak.redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) I believe the real problem here is in place_block_symbol() and output_object_block(). If DECL_INITIAL is given for an array, then shouldn't we be taking the size from the initializer? This patch fixes that problem, and ensures that we get an assembler error if placement in the block changes. I've bootstrapped with Jakub's java change, and the libjava failures are gone. However, the checking code shows up failures in gcc.c-torture/execute/20010924-1.c with "attempt to move .org backwards". This isn't exactly a regression as previously we generated bad code silently, but clearly more work is needed to teach place_block_symbol() how to size variables properly, or else something is going wrong elsewhere in the compiler.. PR libcgj/57074 * varasm.c (place_block_symbol): Use DECL_INITIAL size for variables if available. (output_object_block): Likewise. Use .org for each item in section anchor block rather than padding. Index: gcc/varasm.c =================================================================== --- gcc/varasm.c (revision 198274) +++ gcc/varasm.c (working copy) @@ -6979,7 +6989,11 @@ { decl = SYMBOL_REF_DECL (symbol); alignment = DECL_ALIGN (decl); - size = tree_low_cst (DECL_SIZE_UNIT (decl), 1); + if (DECL_INITIAL (decl) + && DECL_INITIAL (decl) != error_mark_node) + size = int_size_in_bytes (TREE_TYPE (DECL_INITIAL (decl))); + else + size = tree_low_cst (DECL_SIZE_UNIT (decl), 1); if (flag_asan && asan_protect_global (decl)) { size += asan_red_zone_size (size); @@ -7095,6 +7109,10 @@ HOST_WIDE_INT offset; tree decl; rtx symbol; +#if HAVE_GNU_AS + static int labelno; + char buf[30]; +#endif if (!block->objects) return; @@ -7104,6 +7122,12 @@ switch_to_section (block->sect); assemble_align (block->alignment); +#if HAVE_GNU_AS + ASM_GENERATE_INTERNAL_LABEL (buf, "LANCB", labelno); + ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, buf); + ++labelno; +#endif + /* Define the values of all anchors relative to the current section position. */ FOR_EACH_VEC_SAFE_ELT (block->anchors, i, symbol) @@ -7114,7 +7138,14 @@ FOR_EACH_VEC_ELT (*block->objects, i, symbol) { /* Move to the object's offset, padding with zeros if necessary. */ +#if HAVE_GNU_AS + fprintf (asm_out_file, "\t.org "); + assemble_name_raw (asm_out_file, buf); + fprintf (asm_out_file, "+" HOST_WIDE_INT_PRINT_DEC "\n", + SYMBOL_REF_BLOCK_OFFSET (symbol)); +#else assemble_zeros (SYMBOL_REF_BLOCK_OFFSET (symbol) - offset); +#endif offset = SYMBOL_REF_BLOCK_OFFSET (symbol); if (CONSTANT_POOL_ADDRESS_P (symbol)) { @@ -7144,7 +7175,11 @@ HOST_WIDE_INT size; decl = SYMBOL_REF_DECL (symbol); assemble_variable_contents (decl, XSTR (symbol, 0), false); - size = tree_low_cst (DECL_SIZE_UNIT (decl), 1); + if (DECL_INITIAL (decl) + && DECL_INITIAL (decl) != error_mark_node) + size = int_size_in_bytes (TREE_TYPE (DECL_INITIAL (decl))); + else + size = tree_low_cst (DECL_SIZE_UNIT (decl), 1); offset += size; if (flag_asan && asan_protect_global (decl)) {