From patchwork Fri Sep 17 11:04:44 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 65057 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 521B0B6F10 for ; Fri, 17 Sep 2010 21:04:57 +1000 (EST) Received: (qmail 8048 invoked by alias); 17 Sep 2010 11:04:53 -0000 Received: (qmail 8037 invoked by uid 22791); 17 Sep 2010 11:04:52 -0000 X-SWARE-Spam-Status: No, hits=-5.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from cantor.suse.de (HELO mx1.suse.de) (195.135.220.2) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 17 Sep 2010 11:04:46 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.suse.de (Postfix) with ESMTP id 6F4CB5362F; Fri, 17 Sep 2010 13:04:44 +0200 (CEST) Date: Fri, 17 Sep 2010 13:04:44 +0200 (CEST) From: Richard Guenther To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com Subject: [PATCH][1/2] Crude debug language selection for LTO Message-ID: User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 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 This implements choosing a better DW_AT_language for LTO produced debug information. It still keeps a single DW_TAG_compile_unit, so it will work perfectly only for a single source language. This first patch tries to avoid using the global comp_unit_die where easily possible. Bootstrapped and tested on x86_64-unknown-linux-gnu, ok? Thanks, Richard. 2010-09-17 Richard Guenther * dwarf2out.c (is_cu_die): New function. (add_pubtype): Use it. (gen_subprogram_die): Likewise. (gen_struct_or_union_type_die): Likewise. (dwarf2out_finish): Likewise. Index: gcc/dwarf2out.c =================================================================== --- gcc/dwarf2out.c (revision 164364) +++ gcc/dwarf2out.c (working copy) @@ -9496,6 +9496,14 @@ is_symbol_die (dw_die_ref c) || c->die_tag == DW_TAG_module); } +/* Returns true iff C is a compile-unit DIE. */ + +static inline bool +is_cu_die (dw_die_ref c) +{ + return c->die_tag == DW_TAG_compile_unit; +} + static char * gen_internal_sym (const char *prefix) { @@ -11343,7 +11351,7 @@ add_pubtype (tree decl, dw_die_ref die) e.name = NULL; if ((TREE_PUBLIC (decl) - || die->die_parent == comp_unit_die) + || is_cu_die (die->die_parent)) && (die->die_tag == DW_TAG_typedef || COMPLETE_TYPE_P (decl))) { e.die = die; @@ -18729,7 +18737,7 @@ gen_subprogram_die (tree decl, dw_die_re instances of inlines, since the spec requires the out-of-line copy to have the same parent. For local class methods, this doesn't apply; we just use the old DIE. */ - if ((old_die->die_parent == comp_unit_die || context_die == NULL) + if ((is_cu_die (old_die->die_parent) || context_die == NULL) && (DECL_ARTIFICIAL (decl) || (get_AT_file (old_die, DW_AT_decl_file) == file_index && (get_AT_unsigned (old_die, DW_AT_decl_line) @@ -19740,7 +19748,7 @@ gen_struct_or_union_type_die (tree type, scope_die = scope_die_for (type, context_die); - if (! type_die || (nested && scope_die == comp_unit_die)) + if (! type_die || (nested && is_cu_die (scope_die))) /* First occurrence of type or toplevel definition of nested class. */ { dw_die_ref old_die = type_die; @@ -22366,7 +22378,7 @@ dwarf2out_finish (const char *filename) if (origin) add_child_die (origin->die_parent, die); - else if (die == comp_unit_die) + else if (is_cu_die (die)) ; else if (seen_error ()) /* It's OK to be confused by errors in the input. */