From patchwork Fri Jul 11 13:01:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schmidt X-Patchwork-Id: 369158 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 2383A1400DD for ; Fri, 11 Jul 2014 23:02:41 +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 :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=n23+cNU5HwH1zhyij6WFRLv54WfOWfVrWNXC1QPgByRbaP 4n+QSWOSMn+S6VKU2crTy5jDKoOBHbKU0yOXcokD6D33pAHUGUw5I1NoTKCpxB4t ObWog6UvOcc9zkIX+1Hu8lBzSRU49u4dG7TlmR2oz28ekS1pBEH6sbaw4nWX4= 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 :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=SKiY0xvRqlsWXiTQH1G4GL4J8t4=; b=iCkwUxKHS6uceytWixYU cUKAXLh482rK4PsyIXAJwaie7RtlLHw2A2GVEuuxdPd4x6wsM+ToWbPnExyP73Rj njOIOwASgjzYlgeeKwuA0xgp2Z+b3Bfvm91ivitb86RhpDkaSDp7S/s7y10rISda wL2SMJc1UM+kaIESBNdku8w= Received: (qmail 15909 invoked by alias); 11 Jul 2014 13:02:33 -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 15874 invoked by uid 89); 11 Jul 2014 13:02:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, FROM_12LTRDOM autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 11 Jul 2014 13:02:27 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1X5aT0-0001wo-2Q from Bernd_Schmidt@mentor.com for gcc-patches@gcc.gnu.org; Fri, 11 Jul 2014 06:02:22 -0700 Received: from SVR-IES-FEM-02.mgc.mentorg.com ([137.202.0.106]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Fri, 11 Jul 2014 06:02:21 -0700 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-02.mgc.mentorg.com (137.202.0.106) with Microsoft SMTP Server id 14.2.247.3; Fri, 11 Jul 2014 14:02:19 +0100 Message-ID: <53BFE018.8060409@codesourcery.com> Date: Fri, 11 Jul 2014 15:01:12 +0200 From: Bernd Schmidt User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: GCC Patches Subject: Change an assignment to an assert in varpool I noticed that we set node->definition = true in varpool_assemble_decl. The surrounding code suggests that we should only ever get there if definition is already true, so I changed it to an assert. The question is interesting for some modifications I'm making for ptx (which requires declarations for external variables in the assembly). The only thing that was tripped by the assert was a variable created by asan. AFAICT the problem there is that asan calls varpool_assemble_decl when it should be calling varpool_finalize_decl. Bootstrapped and tested on x86_64-linux, ok? Bernd * asan.c (asan_finish_file): Use varpool_finalize_decl instead of varpool_assemble_decl. * varpool.c (varpool_assemble_decl): Assert that node->definition is true. diff --git a/gcc/asan.c b/gcc/asan.c index b9a4a91..0d78634 100644 --- a/gcc/asan.c +++ b/gcc/asan.c @@ -2595,7 +2595,7 @@ asan_finish_file (void) TREE_CONSTANT (ctor) = 1; TREE_STATIC (ctor) = 1; DECL_INITIAL (var) = ctor; - varpool_assemble_decl (varpool_node_for_decl (var)); + varpool_finalize_decl (var); fn = builtin_decl_implicit (BUILT_IN_ASAN_REGISTER_GLOBALS); tree gcount_tree = build_int_cst (pointer_sized_int_node, gcount); diff --git a/gcc/varpool.c b/gcc/varpool.c index 79f07bf..a72fb22 100644 --- a/gcc/varpool.c +++ b/gcc/varpool.c @@ -473,7 +473,7 @@ varpool_assemble_decl (varpool_node *node) { assemble_variable (decl, 0, 1, 0); gcc_assert (TREE_ASM_WRITTEN (decl)); - node->definition = true; + gcc_assert (node->definition); assemble_aliases (node); return true; }