From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 64961 invoked by alias); 23 Sep 2016 18:06:27 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 64948 invoked by uid 89); 23 Sep 2016 18:06:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM autolearn=no version=3.3.2 spammy=XNEWVEC, xnewvec, refactoring, Terminate X-HELO: mail-oi0-f49.google.com Received: from mail-oi0-f49.google.com (HELO mail-oi0-f49.google.com) (209.85.218.49) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 23 Sep 2016 18:06:16 +0000 Received: by mail-oi0-f49.google.com with SMTP id r126so143249533oib.0 for ; Fri, 23 Sep 2016 11:06:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=gvA22PpXFjx3YuYbej4elVdIUb2d8AaUpSPt5RToWFU=; b=i3EdTl4Vzy8JD3wClI/Ov1VGGxXCtEq/88j4bTnbDnSqhcwWWz+4BUStogwr8016Rq vGL5XxRYifqwBLamaCPY9yHHUOrSxCuHkfYmm6xbw2490yeyA59eQDyHdO3YRgQi/ote rjL8E7AklzjMBnBfKfdsVYZM3BrbAMWzv3yFSWy7CUWVBCtPFYUsdTRd/hp0B5dHl4Oq cG/ITY24P3EIAauy8LQNy1Ggcg1RaUDWO7ENiXmFxMI3Co5XPU3WN1mvNdUs5R7aCTLa mhKVoywMh1VcpcRpKm4cu+fPtjjvC9pvoQgU2CwC3B3gAbUsbe4FymaEFoiDJXz/K9SJ AIKA== X-Gm-Message-State: AE9vXwNLX0bigRUi+mRRII5Zy6krIUHNc4NSrAMDQ6LEVweSBbtQiRH665YBinQ1Y9NH6DcDvuJNP0nqEoHEkI1K X-Received: by 10.202.192.69 with SMTP id q66mr12675622oif.52.1474653974564; Fri, 23 Sep 2016 11:06:14 -0700 (PDT) MIME-Version: 1.0 Received: by 10.182.105.167 with HTTP; Fri, 23 Sep 2016 11:05:53 -0700 (PDT) In-Reply-To: References: From: Jason Merrill Date: Fri, 23 Sep 2016 19:37:00 -0000 Message-ID: Subject: Re: [PATCH] Refactor section/label init for early LTO debug To: Richard Biener Cc: gcc-patches List Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2016-09/txt/msg01734.txt.bz2 OK. On Wed, Sep 21, 2016 at 9:19 AM, Richard Biener wrote: > > The following patch ports a refactoring of section/label in it from > the early LTO debug work to trunk. For early LTO debug we need to > be able to emit two sets of debug infos into two sets of different > sections - early LTO into .gnu.debuglto_ prefixed sections and > regular (early + late) debug for the FAT part of the object. > > Thus this preparation splits out the section and label generation > from dwarf2out_init moving the text section related stuff to > dwarf2out_assembly_start and the rest to a new function > init_sections_and_labels which is now called only before we start > outputting dwarf (in dwarf2out_finish). It also removes some > dwarf_split_debug_info checks from the macro section name defines > (in the end I'll have up to four variants - regular, regular LTO, > DWO, DWO LTO). > > And it removes an unused function. > > Bootstrapped on x86_64-unknown-linux-gnu, testing in progress. I've > also bootstrapped with -O2 -g3 to exercise the .debug_macro path. > > Ok? > > Just noticed that DEBUG_STR_OFFSETS_SECTION needs similar massaging > for its dwarf_split_debug_info condition - will followup as obvious > if this one is approved. > > Thanks, > Richard. > > 2016-09-21 Richard Biener > > * dwarf2out.c (stripattributes): Remove unused function. > (DEBUG_NORM_MACINFO_SECTION): Rename to DEBUG_MACINFO_SECTION. > Push dwarf_split_debug_info handling into init_sections_and_labels. > (DEBUG_NORM_MACRO_SECTION): Likewise to DEBUG_MACRO_SECTION. > (DEBUG_MACRO_SECTION_FLAGS): Remove. > (debug_macinfo_section_name): New global. > (output_macinfo): Use debug_macinfo_section_name. > (init_sections_and_labels): Split out section and label generation > from dwarf2out_init. Set debug_macinfo_section_name. > (dwarf2out_init): Move text section label generation and emission > to ... > (dwarf2out_assembly_start): ... here. > (dwarf2out_finish): Call init_sections_and_labels before DWARF > output starts. > > Index: gcc/dwarf2out.c > =================================================================== > --- gcc/dwarf2out.c (revision 240303) > +++ gcc/dwarf2out.c (working copy) > @@ -159,6 +159,7 @@ static GTY(()) section *debug_skeleton_a > static GTY(()) section *debug_aranges_section; > static GTY(()) section *debug_addr_section; > static GTY(()) section *debug_macinfo_section; > +static const char *debug_macinfo_section_name; > static GTY(()) section *debug_line_section; > static GTY(()) section *debug_skeleton_line_section; > static GTY(()) section *debug_loc_section; > @@ -265,7 +266,6 @@ static GTY(()) dw_die_ref decltype_auto_ > > /* Forward declarations for functions defined in this file. */ > > -static char *stripattributes (const char *); > static void output_call_frame_info (int); > static void dwarf2out_note_section_used (void); > > @@ -410,24 +410,6 @@ should_emit_struct_debug (tree type, enu > return DUMP_GSTRUCT (type, usage, criterion, generic, false, false); > } > > -/* Return a pointer to a copy of the section string name S with all > - attributes stripped off, and an asterisk prepended (for assemble_name). */ > - > -static inline char * > -stripattributes (const char *s) > -{ > - char *stripped = XNEWVEC (char, strlen (s) + 2); > - char *p = stripped; > - > - *p++ = '*'; > - > - while (*s && *s != ',') > - *p++ = *s++; > - > - *p = '\0'; > - return stripped; > -} > - > /* Switch [BACK] to eh_frame_section. If we don't have an eh_frame_section, > switch to the data section instead, and write out a synthetic start label > for collect2 the first time around. */ > @@ -3514,27 +3496,17 @@ new_addr_loc_descr (rtx addr, enum dtpre > #ifndef DEBUG_ADDR_SECTION > #define DEBUG_ADDR_SECTION ".debug_addr" > #endif > -#ifndef DEBUG_NORM_MACINFO_SECTION > -#define DEBUG_NORM_MACINFO_SECTION ".debug_macinfo" > +#ifndef DEBUG_MACINFO_SECTION > +#define DEBUG_MACINFO_SECTION ".debug_macinfo" > #endif > #ifndef DEBUG_DWO_MACINFO_SECTION > #define DEBUG_DWO_MACINFO_SECTION ".debug_macinfo.dwo" > #endif > -#ifndef DEBUG_MACINFO_SECTION > -#define DEBUG_MACINFO_SECTION \ > - (!dwarf_split_debug_info \ > - ? (DEBUG_NORM_MACINFO_SECTION) : (DEBUG_DWO_MACINFO_SECTION)) > -#endif > -#ifndef DEBUG_NORM_MACRO_SECTION > -#define DEBUG_NORM_MACRO_SECTION ".debug_macro" > -#endif > #ifndef DEBUG_DWO_MACRO_SECTION > #define DEBUG_DWO_MACRO_SECTION ".debug_macro.dwo" > #endif > #ifndef DEBUG_MACRO_SECTION > -#define DEBUG_MACRO_SECTION \ > - (!dwarf_split_debug_info \ > - ? (DEBUG_NORM_MACRO_SECTION) : (DEBUG_DWO_MACRO_SECTION)) > +#define DEBUG_MACRO_SECTION ".debug_macro" > #endif > #ifndef DEBUG_LINE_SECTION > #define DEBUG_LINE_SECTION ".debug_line" > @@ -3580,10 +3552,6 @@ new_addr_loc_descr (rtx addr, enum dtpre > #define TEXT_SECTION_NAME ".text" > #endif > > -/* Section flags for .debug_macinfo/.debug_macro section. */ > -#define DEBUG_MACRO_SECTION_FLAGS \ > - (dwarf_split_debug_info ? SECTION_DEBUG | SECTION_EXCLUDE : SECTION_DEBUG) > - > /* Section flags for .debug_str section. */ > #define DEBUG_STR_SECTION_FLAGS \ > (HAVE_GAS_SHF_MERGE && flag_merge_debug_strings \ > @@ -25520,7 +25488,7 @@ output_macinfo (void) > tree comdat_key = get_identifier (ref->info); > /* Terminate the previous .debug_macinfo section. */ > dw2_asm_output_data (1, 0, "End compilation unit"); > - targetm.asm_out.named_section (DEBUG_MACRO_SECTION, > + targetm.asm_out.named_section (debug_macinfo_section_name, > SECTION_DEBUG > | SECTION_LINKONCE, > comdat_key); > @@ -25548,53 +25516,11 @@ output_macinfo (void) > } > } > > -/* Set up for Dwarf output at the start of compilation. */ > +/* Initialize the various sections and labels for dwarf output. */ > > static void > -dwarf2out_init (const char *filename ATTRIBUTE_UNUSED) > +init_sections_and_labels (void) > { > - /* This option is currently broken, see (PR53118 and PR46102). */ > - if (flag_eliminate_dwarf2_dups > - && strstr (lang_hooks.name, "C++")) > - { > - warning (0, "-feliminate-dwarf2-dups is broken for C++, ignoring"); > - flag_eliminate_dwarf2_dups = 0; > - } > - > - /* Allocate the file_table. */ > - file_table = hash_table::create_ggc (50); > - > -#ifndef DWARF2_LINENO_DEBUGGING_INFO > - /* Allocate the decl_die_table. */ > - decl_die_table = hash_table::create_ggc (10); > - > - /* Allocate the decl_loc_table. */ > - decl_loc_table = hash_table::create_ggc (10); > - > - /* Allocate the cached_dw_loc_list_table. */ > - cached_dw_loc_list_table = hash_table::create_ggc (10); > - > - /* Allocate the initial hunk of the decl_scope_table. */ > - vec_alloc (decl_scope_table, 256); > - > - /* Allocate the initial hunk of the abbrev_die_table. */ > - abbrev_die_table = ggc_cleared_vec_alloc > - (ABBREV_DIE_TABLE_INCREMENT); > - abbrev_die_table_allocated = ABBREV_DIE_TABLE_INCREMENT; > - /* Zero-th entry is allocated, but unused. */ > - abbrev_die_table_in_use = 1; > - > - /* Allocate the dwarf_proc_stack_usage_map. */ > - dwarf_proc_stack_usage_map = new hash_map; > - > - /* Allocate the pubtypes and pubnames vectors. */ > - vec_alloc (pubname_table, 32); > - vec_alloc (pubtype_table, 32); > - > - vec_alloc (incomplete_types, 64); > - > - vec_alloc (used_rtx_array, 32); > - > if (!dwarf_split_debug_info) > { > debug_info_section = get_section (DEBUG_INFO_SECTION, > @@ -25603,6 +25529,10 @@ dwarf2out_init (const char *filename ATT > SECTION_DEBUG, NULL); > debug_loc_section = get_section (DEBUG_LOC_SECTION, > SECTION_DEBUG, NULL); > + debug_macinfo_section_name > + = dwarf_strict ? DEBUG_MACINFO_SECTION : DEBUG_MACRO_SECTION; > + debug_macinfo_section = get_section (debug_macinfo_section_name, > + SECTION_DEBUG, NULL); > } > else > { > @@ -25623,8 +25553,8 @@ dwarf2out_init (const char *filename ATT > /* Somewhat confusing detail: The skeleton_[abbrev|info] sections stay in > the main .o, but the skeleton_line goes into the split off dwo. */ > debug_skeleton_line_section > - = get_section (DEBUG_DWO_LINE_SECTION, > - SECTION_DEBUG | SECTION_EXCLUDE, NULL); > + = get_section (DEBUG_DWO_LINE_SECTION, > + SECTION_DEBUG | SECTION_EXCLUDE, NULL); > ASM_GENERATE_INTERNAL_LABEL (debug_skeleton_line_section_label, > DEBUG_SKELETON_LINE_SECTION_LABEL, 0); > debug_str_offsets_section = get_section (DEBUG_STR_OFFSETS_SECTION, > @@ -25636,13 +25566,14 @@ dwarf2out_init (const char *filename ATT > SECTION_DEBUG | SECTION_EXCLUDE, NULL); > debug_str_dwo_section = get_section (DEBUG_STR_DWO_SECTION, > DEBUG_STR_DWO_SECTION_FLAGS, NULL); > + debug_macinfo_section_name > + = dwarf_strict ? DEBUG_DWO_MACINFO_SECTION : DEBUG_DWO_MACRO_SECTION; > + debug_macinfo_section = get_section (debug_macinfo_section_name, > + SECTION_DEBUG | SECTION_EXCLUDE, > + NULL); > } > debug_aranges_section = get_section (DEBUG_ARANGES_SECTION, > SECTION_DEBUG, NULL); > - debug_macinfo_section = get_section (dwarf_strict > - ? DEBUG_MACINFO_SECTION > - : DEBUG_MACRO_SECTION, > - DEBUG_MACRO_SECTION_FLAGS, NULL); > debug_line_section = get_section (DEBUG_LINE_SECTION, > SECTION_DEBUG, NULL); > debug_pubnames_section = get_section (DEBUG_PUBNAMES_SECTION, > @@ -25656,14 +25587,8 @@ dwarf2out_init (const char *filename ATT > debug_frame_section = get_section (DEBUG_FRAME_SECTION, > SECTION_DEBUG, NULL); > > - ASM_GENERATE_INTERNAL_LABEL (text_end_label, TEXT_END_LABEL, 0); > ASM_GENERATE_INTERNAL_LABEL (abbrev_section_label, > DEBUG_ABBREV_SECTION_LABEL, 0); > - ASM_GENERATE_INTERNAL_LABEL (text_section_label, TEXT_SECTION_LABEL, 0); > - ASM_GENERATE_INTERNAL_LABEL (cold_text_section_label, > - COLD_TEXT_SECTION_LABEL, 0); > - ASM_GENERATE_INTERNAL_LABEL (cold_end_label, COLD_END_LABEL, 0); > - > ASM_GENERATE_INTERNAL_LABEL (debug_info_section_label, > DEBUG_INFO_SECTION_LABEL, 0); > ASM_GENERATE_INTERNAL_LABEL (debug_line_section_label, > @@ -25677,12 +25602,57 @@ dwarf2out_init (const char *filename ATT > ? DEBUG_MACINFO_SECTION_LABEL > : DEBUG_MACRO_SECTION_LABEL, 0); > ASM_GENERATE_INTERNAL_LABEL (loc_section_label, DEBUG_LOC_SECTION_LABEL, 0); > +} > + > +/* Set up for Dwarf output at the start of compilation. */ > + > +static void > +dwarf2out_init (const char *filename ATTRIBUTE_UNUSED) > +{ > + /* This option is currently broken, see (PR53118 and PR46102). */ > + if (flag_eliminate_dwarf2_dups > + && strstr (lang_hooks.name, "C++")) > + { > + warning (0, "-feliminate-dwarf2-dups is broken for C++, ignoring"); > + flag_eliminate_dwarf2_dups = 0; > + } > + > + /* Allocate the file_table. */ > + file_table = hash_table::create_ggc (50); > + > +#ifndef DWARF2_LINENO_DEBUGGING_INFO > + /* Allocate the decl_die_table. */ > + decl_die_table = hash_table::create_ggc (10); > + > + /* Allocate the decl_loc_table. */ > + decl_loc_table = hash_table::create_ggc (10); > + > + /* Allocate the cached_dw_loc_list_table. */ > + cached_dw_loc_list_table = hash_table::create_ggc (10); > + > + /* Allocate the initial hunk of the decl_scope_table. */ > + vec_alloc (decl_scope_table, 256); > + > + /* Allocate the initial hunk of the abbrev_die_table. */ > + abbrev_die_table = ggc_cleared_vec_alloc > + (ABBREV_DIE_TABLE_INCREMENT); > + abbrev_die_table_allocated = ABBREV_DIE_TABLE_INCREMENT; > + /* Zero-th entry is allocated, but unused. */ > + abbrev_die_table_in_use = 1; > + > + /* Allocate the dwarf_proc_stack_usage_map. */ > + dwarf_proc_stack_usage_map = new hash_map; > + > + /* Allocate the pubtypes and pubnames vectors. */ > + vec_alloc (pubname_table, 32); > + vec_alloc (pubtype_table, 32); > + > + vec_alloc (incomplete_types, 64); > + > + vec_alloc (used_rtx_array, 32); > > if (debug_info_level >= DINFO_LEVEL_VERBOSE) > vec_alloc (macinfo_table, 64); > - > - switch_to_section (text_section); > - ASM_OUTPUT_LABEL (asm_out_file, text_section_label); > #endif > > /* Make sure the line number table for .text always exists. */ > @@ -25705,6 +25675,17 @@ dwarf2out_init (const char *filename ATT > static void > dwarf2out_assembly_start (void) > { > +#ifndef DWARF2_LINENO_DEBUGGING_INFO > + ASM_GENERATE_INTERNAL_LABEL (text_section_label, TEXT_SECTION_LABEL, 0); > + ASM_GENERATE_INTERNAL_LABEL (text_end_label, TEXT_END_LABEL, 0); > + ASM_GENERATE_INTERNAL_LABEL (cold_text_section_label, > + COLD_TEXT_SECTION_LABEL, 0); > + ASM_GENERATE_INTERNAL_LABEL (cold_end_label, COLD_END_LABEL, 0); > + > + switch_to_section (text_section); > + ASM_OUTPUT_LABEL (asm_out_file, text_section_label); > +#endif > + > if (HAVE_GAS_CFI_SECTIONS_DIRECTIVE > && dwarf2out_do_cfi_asm () > && (!(flag_unwind_tables || flag_exceptions) > @@ -27858,6 +27839,9 @@ dwarf2out_finish (const char *) > if (flag_eliminate_dwarf2_dups) > break_out_includes (comp_unit_die ()); > > + /* Initialize sections and labels used for actual assembler output. */ > + init_sections_and_labels (); > + > /* Traverse the DIE's and add sibling attributes to those DIE's that > have children. */ > add_sibling_attributes (comp_unit_die ());