From patchwork Sat Mar 24 20:25:17 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Steven Bosscher X-Patchwork-Id: 148541 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 97642B6EE7 for ; Sun, 25 Mar 2012 07:25:37 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1333225538; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:Received:Date:Message-ID:Subject:From:To: Content-Type:Content-Transfer-Encoding:Mailing-List:Precedence: List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=j6SzX8nmgkJg1QUDMv4ZPchczh0=; b=BQmEqLfleFOewLe 9pwRb1qMlaYYvK6H4LKxzpMfQ8eZLY5etwXhjhwW6u0amLcGrhFpNmiqRK/ZMmej Tnc0ezXg9+4ixoWkRHllrVun2yX/hOvilvSl6oM2hIgyEQ7nqorzaq9HygA/C2gz AWEmGjLtUEcp11dC01kDtbErRdUk= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:MIME-Version:Received:Received:Date:Message-ID:Subject:From:To:Content-Type:Content-Transfer-Encoding:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=mXmUlgwoghHWPaWfbCjMSVv5OvpNG8sEkXh3C7HKP8JAWbC6D8IOMdHAK3i5Cs tuowNq6yEtnrZdK4ghhgBTNN5oOCorOfufUXKTD5N3Yhb08G/hBo+g+AqBGB8Spy iZIbE+iUffdNGMxj1wTTcmzcNhpR+TsdBAoGvRWhOUcx8=; Received: (qmail 21626 invoked by alias); 24 Mar 2012 20:25:32 -0000 Received: (qmail 21615 invoked by uid 22791); 24 Mar 2012 20:25:31 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-gy0-f175.google.com (HELO mail-gy0-f175.google.com) (209.85.160.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 24 Mar 2012 20:25:17 +0000 Received: by ghbz2 with SMTP id z2so3540955ghb.20 for ; Sat, 24 Mar 2012 13:25:17 -0700 (PDT) MIME-Version: 1.0 Received: by 10.100.83.11 with SMTP id g11mr5061051anb.75.1332620717319; Sat, 24 Mar 2012 13:25:17 -0700 (PDT) Received: by 10.100.146.5 with HTTP; Sat, 24 Mar 2012 13:25:17 -0700 (PDT) Date: Sat, 24 Mar 2012 21:25:17 +0100 Message-ID: Subject: [patch] Assert assemble_external is only called during or after expanding to RTL From: Steven Bosscher To: GCC Patches , Diego Novillo X-IsSubscribed: yes 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 Hello, This patch tightens the conditions on when assemble_external() may be called. It also removes a comment that "most platforms do not define ASM_OUTPUT_EXTERNAL", because hasn't been true since r119764 added a definition of ASM_OUTPUT_EXTERNAL to elfos.h. This is the first step toward addressing PR17982 on the trunk for GCC 4.8. The next step is to change pending_assemble_externals to pending_assemble_visibility, and fold assemble_external_real() back into assemble_external. But first, this patch. I don't think this is very risky, because GCC now always works in unit-at-a-time mode. But I think it would be good to have this on the trunk for a week or so before proceeding. Bootstrapped & tested on x86_64-unknown-linux-gnu. OK for trunk? Ciao! Steven        * varasm.c (assemble_external): Assert this function is only called        during or after expanding to RTL. Index: varasm.c =================================================================== --- varasm.c    (revision 185762) +++ varasm.c    (working copy) @@ -2166,12 +2166,18 @@ static GTY(()) tree weak_decls;  void  assemble_external (tree decl ATTRIBUTE_UNUSED)  { -  /* Because most platforms do not define ASM_OUTPUT_EXTERNAL, the -     main body of this code is only rarely exercised.  To provide some -     testing, on all platforms, we make sure that the ASM_OUT_FILE is -     open.  If it's not, we should not be calling this function.  */ +  /*  Make sure that the ASM_OUT_FILE is open. +      If it's not, we should not be calling this function.  */   gcc_assert (asm_out_file); +  /* This function should only be called if we are expanding, or have +     expanded, to RTL. +     Ideally, only final.c would be calling this function, but it is +     not clear whether that would break things somehow.  See PR 17982 +     for further discussion.  */ +  gcc_assert (cgraph_state == CGRAPH_STATE_EXPANSION +              || cgraph_state == CGRAPH_STATE_FINISHED); +   if (!DECL_P (decl) || !DECL_EXTERNAL (decl) || !TREE_PUBLIC (decl))     return;