From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14331 invoked by alias); 26 Jul 2002 17:16:15 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 14321 invoked from network); 26 Jul 2002 17:16:14 -0000 Received: from unknown (HELO igw3.watson.ibm.com) (198.81.209.18) by sources.redhat.com with SMTP; 26 Jul 2002 17:16:14 -0000 Received: from sp1n293en1.watson.ibm.com (sp1n293en1.watson.ibm.com [9.2.112.57]) by igw3.watson.ibm.com (8.11.4/8.11.4) with ESMTP id g6QHG6C02750; Fri, 26 Jul 2002 13:16:06 -0400 Received: from makai.watson.ibm.com (makai.watson.ibm.com [9.2.216.144]) by sp1n293en1.watson.ibm.com (8.11.4/8.11.4) with ESMTP id g6QHG6H30640; Fri, 26 Jul 2002 13:16:06 -0400 Received: from watson.ibm.com (localhost [127.0.0.1]) by makai.watson.ibm.com (AIX4.3/8.9.3/8.9.3/01-10-2000) with ESMTP id NAA21234; Fri, 26 Jul 2002 13:16:04 -0400 Message-Id: <200207261716.NAA21234@makai.watson.ibm.com> To: Richard Henderson cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Re: thread-local storage: c front end and generic backend patch References: <20020711103818.A12613@redhat.com> Date: Fri, 26 Jul 2002 11:08:00 -0000 From: David Edelsohn X-SW-Source: 2002-07/txt/msg01570.txt.bz2 >>>>> Richard Henderson writes: > Hmm. Ok. I can see why I made the change -- COMMON does not > make sense without PUBLIC. I'll adjust assemble_variable and > its subroutines to compensate. I think this actually stems from the question of what DECL_COMMON means. tree.h says: /* Nonzero for a given ..._DECL node means that this node should be put in .common, if possible. If a DECL_INITIAL is given, and it is not error_mark_node, then the decl cannot be put in .common. */ #define DECL_COMMON(NODE) (DECL_CHECK (NODE)->decl.common_flag) Is ".common" all common or only global common? The change to c-decl.c testing TREE_PUBLIC implies that DECL_COMMON only means global common. This means that GCC has no way to mark a decl as local common, other than uninitialized and not public. And, currently, GCC only *emits* local common if the the target also supports ASM_OUTPUT_BSS. There is no connection between a target supporting local common and supporting BSS, so the logic has been confused somewhere. Two apparent solutions are: 1) Either DECL_COMMON should mean any common, in which case it should not depend on TREE_PUBLIC(decl) and c-decl should be fixed. 2) Or, DECL_COMMON only means global common, in which case varasm.c:assemble_variable() should test ASM_EMIT_BSS and, if not defined, avoid invoking asm_emit_uninitialized() for the *one* case it is required: uninitialized, public symbol that is not common. I have implemented option 2 above and submit it for review. As I say in the comment, it seems that it would be cleaner to localize the test to asm_emit_uninitialized and return failure instead of spreading the test across two functions and aborting if called the wrong way. David * varasm.c (assemble_variable): Narrow test for uninitialized without BSS target support. Index: varasm.c =================================================================== RCS file: /cvs/gcc/egcs/gcc/varasm.c,v retrieving revision 1.296 diff -c -p -r1.296 varasm.c *** varasm.c 26 Jun 2002 15:16:01 -0000 1.296 --- varasm.c 26 Jul 2002 16:47:51 -0000 *************** assemble_variable (decl, top_level, at_e *** 1598,1604 **** in .bss, then we have to use .data. */ /* ??? We should handle .bss via select_section mechanisms rather than via special target hooks. That would eliminate this special case. */ ! else if (!DECL_COMMON (decl)) ; #endif else if (DECL_INITIAL (decl) == 0 --- 1598,1606 ---- in .bss, then we have to use .data. */ /* ??? We should handle .bss via select_section mechanisms rather than via special target hooks. That would eliminate this special case. */ ! /* Duplicate BSS test in asm_emit_uninitialized instead of having it ! return success or failure for that case. Shrug. */ ! else if (TREE_PUBLIC (decl) && !DECL_COMMON (decl)) ; #endif else if (DECL_INITIAL (decl) == 0