Re: [PATCH][2/2] early LTO debug, main part

2017-09-21 Thread Jakub Jelinek
On Thu, Sep 21, 2017 at 04:29:34PM +0200, Pierre-Marie de Rodat wrote:
> On 09/20/2017 08:08 PM, Jeff Law wrote:
> > > As for general DWARF5 testing, I think best coverage is GDB (say guality
> > > testing with -gdwarf-5), I think GDB 8.0 should have the needed support.
> > > I'll try to install it (am only at 7.12.1 right now) and try to do some
> > > testing.
> > > What about Pierre-Marie's work to be able to use python to parse and
> > check dwarf output?
> 
> I’m not sure from reading the thread what is to be tested, here. Is it just
> the presence of the .debug_line_str section? (in which case for once just
> scanning the .s sounds enough) Or is it rather about checking that objdump
> (or alike) can properly parse the line table?

The latter, basically verify that a line info (and also location info etc.)
consumer can grok the DWARF5 stuff.  And for that IMNSHO we really need a
consumer that follows the spec and complains if it is wrong.

Jakub


Re: [PATCH][2/2] early LTO debug, main part

2017-09-21 Thread Pierre-Marie de Rodat

On 09/20/2017 08:08 PM, Jeff Law wrote:

As for general DWARF5 testing, I think best coverage is GDB (say guality
testing with -gdwarf-5), I think GDB 8.0 should have the needed support.
I'll try to install it (am only at 7.12.1 right now) and try to do some
testing.

> What about Pierre-Marie's work to be able to use python to parse and
check dwarf output?


I’m not sure from reading the thread what is to be tested, here. Is it 
just the presence of the .debug_line_str section? (in which case for 
once just scanning the .s sounds enough) Or is it rather about checking 
that objdump (or alike) can properly parse the line table?


--
Pierre-Marie de Rodat


Re: [PATCH][2/2] early LTO debug, main part

2017-09-20 Thread Jeff Law
On 09/20/2017 02:31 AM, Jakub Jelinek wrote:
> On Wed, Sep 20, 2017 at 10:20:03AM +0200, Richard Biener wrote:
>> Anyway, I did a quick LTO bootstrap with your patch and it seems
>> to work fine.
>>
>> Can you add a testcase verifying -gdwarf-5 works ok (properly
>> emitting a debug_line_str section?).
> 
> I'm afraid I can't.  We don't have a command line switch for
> DWARF2_ASM_LINE_DEBUG_INFO, it is something tested solely at configure time
> (I've noticed this because my working directory for whatever reason
> (many hundreds of reconfigures) doesn't have this defined), and we actually 
> emit
> proper DWARF5 .debug_line{,_str} only in that case; when using .file
> directives, it is waiting for missing binutils support.
> 
> Perhaps we should add -fno-dwarf2-loc-asm to force emitting .debug_line*
> by gcc?
> 
> As for general DWARF5 testing, I think best coverage is GDB (say guality
> testing with -gdwarf-5), I think GDB 8.0 should have the needed support.
> I'll try to install it (am only at 7.12.1 right now) and try to do some
> testing.
What about Pierre-Marie's work to be able to use python to parse and
check dwarf output?

jeff


Re: [PATCH][2/2] early LTO debug, main part

2017-09-20 Thread Jakub Jelinek
On Wed, Sep 20, 2017 at 10:20:03AM +0200, Richard Biener wrote:
> Anyway, I did a quick LTO bootstrap with your patch and it seems
> to work fine.
> 
> Can you add a testcase verifying -gdwarf-5 works ok (properly
> emitting a debug_line_str section?).

I'm afraid I can't.  We don't have a command line switch for
DWARF2_ASM_LINE_DEBUG_INFO, it is something tested solely at configure time
(I've noticed this because my working directory for whatever reason
(many hundreds of reconfigures) doesn't have this defined), and we actually emit
proper DWARF5 .debug_line{,_str} only in that case; when using .file
directives, it is waiting for missing binutils support.

Perhaps we should add -fno-dwarf2-loc-asm to force emitting .debug_line*
by gcc?

As for general DWARF5 testing, I think best coverage is GDB (say guality
testing with -gdwarf-5), I think GDB 8.0 should have the needed support.
I'll try to install it (am only at 7.12.1 right now) and try to do some
testing.

Jakub


Re: [PATCH][2/2] early LTO debug, main part

2017-09-20 Thread Richard Biener
On Tue, 19 Sep 2017, Jakub Jelinek wrote:

> On Tue, Sep 19, 2017 at 05:24:14PM +0200, Jakub Jelinek wrote:
> > These changes broke DWARF-5 support.  E.g. in gcc-7 and before this change
> > there was:

Sorry for the breakage I had to manually merge conflicts in this
part quite a few times since the 1.5 years the patch was under review.
Appearantly there's no testsuite coverage for this when testing with
default flags (nor is there any coverage for -gsplit-dwarf btw...).

> Here is a fix, make check-g++ RUNTESTFLAGS=dwarf2.exp now passes again
> even with !DWARF2_ASM_LINE_DEBUG_INFO compiler.  Haven't tried LTO (except
> for what is in make check).  Bootstrapped/regtested on x86_64-linux and
> i686-linux, ok for trunk?
> 
> 2017-09-19  Jakub Jelinek  
> 
>   * dwarf2out.c (DEBUG_LTO_DWO_INFO_SECTION): Reorder defines.
>   (DEBUG_LTO_ABBREV_SECTION): Likewise.
>   (DEBUG_LTO_MACINFO_SECTION): Likewise.
>   (DEBUG_MACRO_SECTION): Likewise.
>   (DEBUG_LTO_MACRO_SECTION): Likewise.
>   (DEBUG_STR_DWO_SECTION): Likewise.
>   (DEBUG_LTO_STR_DWO_SECTION): Likewise.
>   (DEBUG_LTO_LINE_SECTION): Drop .dwo suffix from the name.

I think this has .dwo because similar to DWO this section can
be dropped (it's only "fake" because for some reason we do have
to have a line section).

Anyway, I did a quick LTO bootstrap with your patch and it seems
to work fine.

Can you add a testcase verifying -gdwarf-5 works ok (properly
emitting a debug_line_str section?).

Ok with that change.

Thanks and sorry for the breakage,
Richard.

>   (DEBUG_LTO_DWO_LINE_SECTION): Define.
>   (DEBUG_LTO_LINE_STR_SECTION): Define.
>   (init_sections_and_labels): Initialize debug_line_str_section
>   variable.  Initialize debug_loc_section for -gdwarf-5 to
>   DEBUG_LOCLISTS_SECTION.  Formatting fixes.
> 
> --- gcc/dwarf2out.c.jj2017-09-19 16:51:16.0 +0200
> +++ gcc/dwarf2out.c   2017-09-19 18:07:51.348919965 +0200
> @@ -3702,24 +3702,24 @@ new_addr_loc_descr (rtx addr, enum dtpre
>  #ifndef DEBUG_DWO_INFO_SECTION
>  #define DEBUG_DWO_INFO_SECTION ".debug_info.dwo"
>  #endif
> -#ifndef DEBUG_LTO_DWO_INFO_SECTION
> -#define DEBUG_LTO_DWO_INFO_SECTION ".gnu.debuglto_.debug_info.dwo"
> -#endif
>  #ifndef DEBUG_LTO_INFO_SECTION
>  #define DEBUG_LTO_INFO_SECTION   ".gnu.debuglto_.debug_info"
>  #endif
> +#ifndef DEBUG_LTO_DWO_INFO_SECTION
> +#define DEBUG_LTO_DWO_INFO_SECTION ".gnu.debuglto_.debug_info.dwo"
> +#endif
>  #ifndef DEBUG_ABBREV_SECTION
>  #define DEBUG_ABBREV_SECTION ".debug_abbrev"
>  #endif
> +#ifndef DEBUG_LTO_ABBREV_SECTION
> +#define DEBUG_LTO_ABBREV_SECTION ".gnu.debuglto_.debug_abbrev"
> +#endif
>  #ifndef DEBUG_DWO_ABBREV_SECTION
>  #define DEBUG_DWO_ABBREV_SECTION ".debug_abbrev.dwo"
>  #endif
>  #ifndef DEBUG_LTO_DWO_ABBREV_SECTION
>  #define DEBUG_LTO_DWO_ABBREV_SECTION ".gnu.debuglto_.debug_abbrev.dwo"
>  #endif
> -#ifndef DEBUG_LTO_ABBREV_SECTION
> -#define DEBUG_LTO_ABBREV_SECTION ".gnu.debuglto_.debug_abbrev"
> -#endif
>  #ifndef DEBUG_ARANGES_SECTION
>  #define DEBUG_ARANGES_SECTION".debug_aranges"
>  #endif
> @@ -3729,35 +3729,38 @@ new_addr_loc_descr (rtx addr, enum dtpre
>  #ifndef DEBUG_MACINFO_SECTION
>  #define DEBUG_MACINFO_SECTION ".debug_macinfo"
>  #endif
> +#ifndef DEBUG_LTO_MACINFO_SECTION
> +#define DEBUG_LTO_MACINFO_SECTION  ".gnu.debuglto_.debug_macinfo"
> +#endif
>  #ifndef DEBUG_DWO_MACINFO_SECTION
>  #define DEBUG_DWO_MACINFO_SECTION  ".debug_macinfo.dwo"
>  #endif
>  #ifndef DEBUG_LTO_DWO_MACINFO_SECTION
>  #define DEBUG_LTO_DWO_MACINFO_SECTION  ".gnu.debuglto_.debug_macinfo.dwo"
>  #endif
> -#ifndef DEBUG_LTO_MACINFO_SECTION
> -#define DEBUG_LTO_MACINFO_SECTION  ".gnu.debuglto_.debug_macinfo"
> +#ifndef DEBUG_MACRO_SECTION
> +#define DEBUG_MACRO_SECTION  ".debug_macro"
> +#endif
> +#ifndef DEBUG_LTO_MACRO_SECTION
> +#define DEBUG_LTO_MACRO_SECTION ".gnu.debuglto_.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  ".debug_macro"
> -#endif
>  #ifndef DEBUG_LTO_DWO_MACRO_SECTION
>  #define DEBUG_LTO_DWO_MACRO_SECTION".gnu.debuglto_.debug_macro.dwo"
>  #endif
> -#ifndef DEBUG_LTO_MACRO_SECTION
> -#define DEBUG_LTO_MACRO_SECTION ".gnu.debuglto_.debug_macro"
> -#endif
>  #ifndef DEBUG_LINE_SECTION
>  #define DEBUG_LINE_SECTION   ".debug_line"
>  #endif
> +#ifndef DEBUG_LTO_LINE_SECTION
> +#define DEBUG_LTO_LINE_SECTION ".gnu.debuglto_.debug_line"
> +#endif
>  #ifndef DEBUG_DWO_LINE_SECTION
>  #define DEBUG_DWO_LINE_SECTION ".debug_line.dwo"
>  #endif
> -#ifndef DEBUG_LTO_LINE_SECTION
> -#define DEBUG_LTO_LINE_SECTION ".gnu.debuglto_.debug_line.dwo"
> +#ifndef DEBUG_LTO_DWO_LINE_SECTION
> +#define DEBUG_LTO_DWO_LINE_SECTION ".gnu.debuglto_.debug_line.dwo"
>  #endif
>  #ifndef DEBUG_LOC_SECTION
>  #define DEBUG_LOC_SECTION".debug_loc"
> @@ -3790,18 

Re: [PATCH][2/2] early LTO debug, main part

2017-09-19 Thread Jakub Jelinek
On Tue, Sep 19, 2017 at 05:24:14PM +0200, Jakub Jelinek wrote:
> These changes broke DWARF-5 support.  E.g. in gcc-7 and before this change
> there was:

Here is a fix, make check-g++ RUNTESTFLAGS=dwarf2.exp now passes again
even with !DWARF2_ASM_LINE_DEBUG_INFO compiler.  Haven't tried LTO (except
for what is in make check).  Bootstrapped/regtested on x86_64-linux and
i686-linux, ok for trunk?

2017-09-19  Jakub Jelinek  

* dwarf2out.c (DEBUG_LTO_DWO_INFO_SECTION): Reorder defines.
(DEBUG_LTO_ABBREV_SECTION): Likewise.
(DEBUG_LTO_MACINFO_SECTION): Likewise.
(DEBUG_MACRO_SECTION): Likewise.
(DEBUG_LTO_MACRO_SECTION): Likewise.
(DEBUG_STR_DWO_SECTION): Likewise.
(DEBUG_LTO_STR_DWO_SECTION): Likewise.
(DEBUG_LTO_LINE_SECTION): Drop .dwo suffix from the name.
(DEBUG_LTO_DWO_LINE_SECTION): Define.
(DEBUG_LTO_LINE_STR_SECTION): Define.
(init_sections_and_labels): Initialize debug_line_str_section
variable.  Initialize debug_loc_section for -gdwarf-5 to
DEBUG_LOCLISTS_SECTION.  Formatting fixes.

--- gcc/dwarf2out.c.jj  2017-09-19 16:51:16.0 +0200
+++ gcc/dwarf2out.c 2017-09-19 18:07:51.348919965 +0200
@@ -3702,24 +3702,24 @@ new_addr_loc_descr (rtx addr, enum dtpre
 #ifndef DEBUG_DWO_INFO_SECTION
 #define DEBUG_DWO_INFO_SECTION ".debug_info.dwo"
 #endif
-#ifndef DEBUG_LTO_DWO_INFO_SECTION
-#define DEBUG_LTO_DWO_INFO_SECTION ".gnu.debuglto_.debug_info.dwo"
-#endif
 #ifndef DEBUG_LTO_INFO_SECTION
 #define DEBUG_LTO_INFO_SECTION ".gnu.debuglto_.debug_info"
 #endif
+#ifndef DEBUG_LTO_DWO_INFO_SECTION
+#define DEBUG_LTO_DWO_INFO_SECTION ".gnu.debuglto_.debug_info.dwo"
+#endif
 #ifndef DEBUG_ABBREV_SECTION
 #define DEBUG_ABBREV_SECTION   ".debug_abbrev"
 #endif
+#ifndef DEBUG_LTO_ABBREV_SECTION
+#define DEBUG_LTO_ABBREV_SECTION ".gnu.debuglto_.debug_abbrev"
+#endif
 #ifndef DEBUG_DWO_ABBREV_SECTION
 #define DEBUG_DWO_ABBREV_SECTION ".debug_abbrev.dwo"
 #endif
 #ifndef DEBUG_LTO_DWO_ABBREV_SECTION
 #define DEBUG_LTO_DWO_ABBREV_SECTION ".gnu.debuglto_.debug_abbrev.dwo"
 #endif
-#ifndef DEBUG_LTO_ABBREV_SECTION
-#define DEBUG_LTO_ABBREV_SECTION ".gnu.debuglto_.debug_abbrev"
-#endif
 #ifndef DEBUG_ARANGES_SECTION
 #define DEBUG_ARANGES_SECTION  ".debug_aranges"
 #endif
@@ -3729,35 +3729,38 @@ new_addr_loc_descr (rtx addr, enum dtpre
 #ifndef DEBUG_MACINFO_SECTION
 #define DEBUG_MACINFO_SECTION ".debug_macinfo"
 #endif
+#ifndef DEBUG_LTO_MACINFO_SECTION
+#define DEBUG_LTO_MACINFO_SECTION  ".gnu.debuglto_.debug_macinfo"
+#endif
 #ifndef DEBUG_DWO_MACINFO_SECTION
 #define DEBUG_DWO_MACINFO_SECTION  ".debug_macinfo.dwo"
 #endif
 #ifndef DEBUG_LTO_DWO_MACINFO_SECTION
 #define DEBUG_LTO_DWO_MACINFO_SECTION  ".gnu.debuglto_.debug_macinfo.dwo"
 #endif
-#ifndef DEBUG_LTO_MACINFO_SECTION
-#define DEBUG_LTO_MACINFO_SECTION  ".gnu.debuglto_.debug_macinfo"
+#ifndef DEBUG_MACRO_SECTION
+#define DEBUG_MACRO_SECTION".debug_macro"
+#endif
+#ifndef DEBUG_LTO_MACRO_SECTION
+#define DEBUG_LTO_MACRO_SECTION ".gnu.debuglto_.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".debug_macro"
-#endif
 #ifndef DEBUG_LTO_DWO_MACRO_SECTION
 #define DEBUG_LTO_DWO_MACRO_SECTION".gnu.debuglto_.debug_macro.dwo"
 #endif
-#ifndef DEBUG_LTO_MACRO_SECTION
-#define DEBUG_LTO_MACRO_SECTION ".gnu.debuglto_.debug_macro"
-#endif
 #ifndef DEBUG_LINE_SECTION
 #define DEBUG_LINE_SECTION ".debug_line"
 #endif
+#ifndef DEBUG_LTO_LINE_SECTION
+#define DEBUG_LTO_LINE_SECTION ".gnu.debuglto_.debug_line"
+#endif
 #ifndef DEBUG_DWO_LINE_SECTION
 #define DEBUG_DWO_LINE_SECTION ".debug_line.dwo"
 #endif
-#ifndef DEBUG_LTO_LINE_SECTION
-#define DEBUG_LTO_LINE_SECTION ".gnu.debuglto_.debug_line.dwo"
+#ifndef DEBUG_LTO_DWO_LINE_SECTION
+#define DEBUG_LTO_DWO_LINE_SECTION ".gnu.debuglto_.debug_line.dwo"
 #endif
 #ifndef DEBUG_LOC_SECTION
 #define DEBUG_LOC_SECTION  ".debug_loc"
@@ -3790,18 +3793,18 @@ new_addr_loc_descr (rtx addr, enum dtpre
 #ifndef DEBUG_LTO_DWO_STR_OFFSETS_SECTION
 #define DEBUG_LTO_DWO_STR_OFFSETS_SECTION 
".gnu.debuglto_.debug_str_offsets.dwo"
 #endif
-#ifndef DEBUG_STR_DWO_SECTION
-#define DEBUG_STR_DWO_SECTION   ".debug_str.dwo"
-#endif
-#ifndef DEBUG_LTO_STR_DWO_SECTION
-#define DEBUG_LTO_STR_DWO_SECTION ".gnu.debuglto_.debug_str.dwo"
-#endif
 #ifndef DEBUG_STR_SECTION
 #define DEBUG_STR_SECTION  ".debug_str"
 #endif
 #ifndef DEBUG_LTO_STR_SECTION
 #define DEBUG_LTO_STR_SECTION ".gnu.debuglto_.debug_str"
 #endif
+#ifndef DEBUG_STR_DWO_SECTION
+#define DEBUG_STR_DWO_SECTION   ".debug_str.dwo"
+#endif
+#ifndef DEBUG_LTO_STR_DWO_SECTION
+#define DEBUG_LTO_STR_DWO_SECTION ".gnu.debuglto_.debug_str.dwo"
+#endif
 #ifndef DEBUG_RANGES_SECTION
 #define DEBUG_RANGES_SECTION   ".debug_ranges"
 #endif
@@ -3811,6 +3814,9 @@ new_addr_loc_descr (rtx addr, enum dtpre
 

Re: [PATCH][2/2] early LTO debug, main part

2017-09-19 Thread Jakub Jelinek
On Fri, Aug 04, 2017 at 02:21:29PM +0200, Richard Biener wrote:
> ! /* Initialize the various sections and labels for dwarf output.  */
>   
>   static void
> ! init_sections_and_labels (void)

...

These changes broke DWARF-5 support.  E.g. in gcc-7 and before this change
there was:

> !   if (!dwarf_split_debug_info)
>   {
...
> !   debug_loc_section = get_section (dwarf_version >= 5
> !? DEBUG_LOCLISTS_SECTION
> !: DEBUG_LOC_SECTION,
> !SECTION_DEBUG, NULL);

the above which would use .debug_loclists section for debug_loc_section
instead of .debug_loc for -gdwarf-5, because that is what DWARF-5 requires
and the section content is ABI incompatible.  But current trunk does
> !   debug_loc_section = get_section (DEBUG_LOC_SECTION,
> !SECTION_DEBUG, NULL);
only, so the DWARF-5 content is emitted into .debug_loc section.

Or, there used to be:

> !   if (!dwarf_split_debug_info && !DWARF2_ASM_LINE_DEBUG_INFO)
> ! debug_line_str_section = get_section (DEBUG_LINE_STR_SECTION,
> !   DEBUG_STR_SECTION_FLAGS, NULL);

which has no replacement at all, debug_line_str_hash is NULL and
so !DWARF2_ASM_LINE_DEBUG_INFO compiler ICEs on pretty much all
-gdwarf-5, because it can't emit the strings into that section.

Do you have rough time when you wrote changes to these functions (so that
I could diff init_sections_and_labels changes in between that date and
before your LTO debug changes and find out what needs to be double checked
besides those two)?

I presume we'll need some name for a LTO .debug_loclists variant.

Also, seeing:

#ifndef DEBUG_LINE_SECTION
#define DEBUG_LINE_SECTION  ".debug_line"
#endif
#ifndef DEBUG_DWO_LINE_SECTION
#define DEBUG_DWO_LINE_SECTION ".debug_line.dwo"
#endif
#ifndef DEBUG_LTO_LINE_SECTION
#define DEBUG_LTO_LINE_SECTION ".gnu.debuglto_.debug_line.dwo"
#endif

that looks like a pasto, , I'd expect the last one, since it doesn't have
DWO_ in the name, to be just .gnu.debuglto_.debug_line .

Jakub


Re: [PATCH][2/2] early LTO debug, main part

2017-08-22 Thread Richard Biener
On Tue, 22 Aug 2017, Szabolcs Nagy wrote:

> On 22/08/17 11:17, Richard Biener wrote:
> > On Tue, 22 Aug 2017, Szabolcs Nagy wrote:
> >> on aarch64_be-none-elf i see
> >>
> >> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 (test for excess errors)
> >> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -O (test for excess errors)
> >> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -O3 (test for excess errors)
> >> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -g1 (test for excess errors)
> >> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -g1 -O (test for excess 
> >> errors)
> >> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -g1 -O3 (test for excess 
> >> errors)
> >> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -g3 (test for excess errors)
> >> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -g3 -O (test for excess 
> >> errors)
> >> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -g3 -O3 (test for excess 
> >> errors)
> >> PASS->FAIL: gcc.dg/lto/20090914-1 
> >> c_lto_20090914-1_0.o-c_lto_20090914-1_0.o link, -flto
> >> PASS->FAIL: gcc.dg/lto/20100426 c_lto_20100426_0.o-c_lto_20100426_0.o 
> >> link, -r -nostdlib -flto -g
> >> PASS->FAIL: gcc.dg/lto/20111207-2 
> >> c_lto_20111207-2_0.o-c_lto_20111207-2_0.o link,  -g -O -flto
> >> PASS->FAIL: gcc.dg/lto/20111213-1 
> >> c_lto_20111213-1_0.o-c_lto_20111213-1_0.o link,  -flto -g
> >> PASS->FAIL: gcc.dg/lto/pr51572-1 c_lto_pr51572-1_0.o-c_lto_pr51572-1_0.o 
> >> link,  -flto -g
> >> PASS->FAIL: gcc.dg/lto/pr53470 c_lto_pr53470_0.o-c_lto_pr53470_0.o link,  
> >> -flto -g
> >> PASS->FAIL: gcc.dg/lto/pr59323 c_lto_pr59323_0.o-c_lto_pr59323_0.o link,  
> >> -O2 -g -flto
> >> PASS->FAIL: gcc.dg/lto/pr59323-2 c_lto_pr59323-2_0.o-c_lto_pr59323-2_0.o 
> >> link,  -O2 -g -flto
> >> PASS->FAIL: gcc.dg/pr43557-1.c (test for excess errors)
> >>
> >> linking seems to fail with
> >>
> >> /tmp/ccqAb1Wfdebugobjtem: file not recognized: Bad value
> >> collect2: error: ld returned 1 exit status
> >> lto-wrapper: fatal error: B/gcc/xgcc returned 1 exit status
> >> compilation terminated.
> >> P/aarch64_be-none-elf/bin/ld: error: lto-wrapper failed
> >> collect2: error: ld returned 1 exit status
> >> compiler exited with status 1
> > 
> > Can you file a bugreport please?  Can you investigate a bit, I suspect
> > a simple int main() {} and ./xgcc -B. -flto -g t.c fails the same way.
> > With -save-temps -v you should be able to inspect the generated
> > debugobj with readelf.
> > 
> 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81925
> 
> i could not figure much out, readelf could parse lto1 input
> but printed errors on the final link command input.
> 
> > Is this a native compiler or a cross-compiler?  [I suspect endianess
> > issues somewhere?]
> 
> cross compiler (from aarch64-linux-gnu to aarch64_be-none-elf)

I am testing the following fix (verified with a cross), will apply
as obvious if that succeeds.

Richard.

2017-08-22  Richard Biener  

PR lto/81925
* simple-object-elf.c (simple_object_elf_write_shdr): Adjust
type of sh_addralign and sh_entsize and properly write
sh_entsize as Elf_Addr.
(simple_object_elf_write_to_file): Read sh_entsize as Elf_Addr.

Index: libiberty/simple-object-elf.c
===
--- libiberty/simple-object-elf.c   (revision 251273)
+++ libiberty/simple-object-elf.c   (working copy)
@@ -830,8 +830,8 @@ simple_object_elf_write_shdr (simple_obj
  off_t sh_addr,
  unsigned int sh_offset, unsigned int sh_size,
  unsigned int sh_link, unsigned int sh_info,
- unsigned int sh_addralign,
- unsigned int sh_entsize,
+ size_t sh_addralign,
+ size_t sh_entsize,
  const char **errmsg, int *err)
 {
   struct simple_object_elf_attributes *attrs =
@@ -858,7 +858,7 @@ simple_object_elf_write_shdr (simple_obj
   ELF_SET_FIELD (fns, cl, Shdr, buf, sh_link, Elf_Word, sh_link);
   ELF_SET_FIELD (fns, cl, Shdr, buf, sh_info, Elf_Word, sh_info);
   ELF_SET_FIELD (fns, cl, Shdr, buf, sh_addralign, Elf_Addr, sh_addralign);
-  ELF_SET_FIELD (fns, cl, Shdr, buf, sh_entsize, Elf_Word, sh_entsize);
+  ELF_SET_FIELD (fns, cl, Shdr, buf, sh_entsize, Elf_Addr, sh_entsize);
 
   return simple_object_internal_write (descriptor, offset, buf, shdr_size,
   errmsg, err);
@@ -948,8 +948,8 @@ simple_object_elf_write_to_file (simple_
   off_t sh_addr = 0;
   unsigned int sh_link = 0;
   unsigned int sh_info = 0;
-  unsigned int sh_addralign = 1U << section->align;
-  unsigned int sh_entsize = 0;
+  size_t sh_addralign = 1U << section->align;
+  size_t sh_entsize = 0;
   if (eow->shdrs)
{
  sh_type = ELF_FETCH_FIELD (attrs->type_functions, attrs->ei_class, 

Re: [PATCH][2/2] early LTO debug, main part

2017-08-22 Thread Szabolcs Nagy
On 22/08/17 11:17, Richard Biener wrote:
> On Tue, 22 Aug 2017, Szabolcs Nagy wrote:
>> on aarch64_be-none-elf i see
>>
>> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 (test for excess errors)
>> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -O (test for excess errors)
>> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -O3 (test for excess errors)
>> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -g1 (test for excess errors)
>> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -g1 -O (test for excess 
>> errors)
>> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -g1 -O3 (test for excess 
>> errors)
>> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -g3 (test for excess errors)
>> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -g3 -O (test for excess 
>> errors)
>> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -g3 -O3 (test for excess 
>> errors)
>> PASS->FAIL: gcc.dg/lto/20090914-1 c_lto_20090914-1_0.o-c_lto_20090914-1_0.o 
>> link, -flto
>> PASS->FAIL: gcc.dg/lto/20100426 c_lto_20100426_0.o-c_lto_20100426_0.o link, 
>> -r -nostdlib -flto -g
>> PASS->FAIL: gcc.dg/lto/20111207-2 c_lto_20111207-2_0.o-c_lto_20111207-2_0.o 
>> link,  -g -O -flto
>> PASS->FAIL: gcc.dg/lto/20111213-1 c_lto_20111213-1_0.o-c_lto_20111213-1_0.o 
>> link,  -flto -g
>> PASS->FAIL: gcc.dg/lto/pr51572-1 c_lto_pr51572-1_0.o-c_lto_pr51572-1_0.o 
>> link,  -flto -g
>> PASS->FAIL: gcc.dg/lto/pr53470 c_lto_pr53470_0.o-c_lto_pr53470_0.o link,  
>> -flto -g
>> PASS->FAIL: gcc.dg/lto/pr59323 c_lto_pr59323_0.o-c_lto_pr59323_0.o link,  
>> -O2 -g -flto
>> PASS->FAIL: gcc.dg/lto/pr59323-2 c_lto_pr59323-2_0.o-c_lto_pr59323-2_0.o 
>> link,  -O2 -g -flto
>> PASS->FAIL: gcc.dg/pr43557-1.c (test for excess errors)
>>
>> linking seems to fail with
>>
>> /tmp/ccqAb1Wfdebugobjtem: file not recognized: Bad value
>> collect2: error: ld returned 1 exit status
>> lto-wrapper: fatal error: B/gcc/xgcc returned 1 exit status
>> compilation terminated.
>> P/aarch64_be-none-elf/bin/ld: error: lto-wrapper failed
>> collect2: error: ld returned 1 exit status
>> compiler exited with status 1
> 
> Can you file a bugreport please?  Can you investigate a bit, I suspect
> a simple int main() {} and ./xgcc -B. -flto -g t.c fails the same way.
> With -save-temps -v you should be able to inspect the generated
> debugobj with readelf.
> 

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81925

i could not figure much out, readelf could parse lto1 input
but printed errors on the final link command input.

> Is this a native compiler or a cross-compiler?  [I suspect endianess
> issues somewhere?]

cross compiler (from aarch64-linux-gnu to aarch64_be-none-elf)



Re: [PATCH][2/2] early LTO debug, main part

2017-08-22 Thread Richard Biener
On Tue, 22 Aug 2017, Szabolcs Nagy wrote:

> On 04/08/17 13:21, Richard Biener wrote:
> > On Thu, 3 Aug 2017, Jason Merrill wrote:
> >> OK if testing passes.
> > 
> > Thanks.  Meanwhile testing passed.
> > 
> > Bootstrapped and tested on x86_64-unknown-linux-gnu, LTO bootstrapped
> > on x86_64-unknown-linux-gnu (both all languages).  I've successfully
> > built SPEC CPU 2006 with -flto -g (provides reasonable Fortran coverage).
> > I've successfully ran the GCC testsuite with -flto -g which shows lots
> > of FAILs but doesn't regress in any unexpected ways compared to before
> > the patches.
> > 
> > I'll ping Ian about the simple-object part again and will apply
> > earliest at Aug 14th.
> > 
> > Richard.
> > 
> 
> on aarch64_be-none-elf i see
> 
> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 (test for excess errors)
> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -O (test for excess errors)
> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -O3 (test for excess errors)
> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -g1 (test for excess errors)
> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -g1 -O (test for excess errors)
> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -g1 -O3 (test for excess 
> errors)
> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -g3 (test for excess errors)
> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -g3 -O (test for excess errors)
> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -g3 -O3 (test for excess 
> errors)
> PASS->FAIL: gcc.dg/lto/20090914-1 c_lto_20090914-1_0.o-c_lto_20090914-1_0.o 
> link, -flto
> PASS->FAIL: gcc.dg/lto/20100426 c_lto_20100426_0.o-c_lto_20100426_0.o link, 
> -r -nostdlib -flto -g
> PASS->FAIL: gcc.dg/lto/20111207-2 c_lto_20111207-2_0.o-c_lto_20111207-2_0.o 
> link,  -g -O -flto
> PASS->FAIL: gcc.dg/lto/20111213-1 c_lto_20111213-1_0.o-c_lto_20111213-1_0.o 
> link,  -flto -g
> PASS->FAIL: gcc.dg/lto/pr51572-1 c_lto_pr51572-1_0.o-c_lto_pr51572-1_0.o 
> link,  -flto -g
> PASS->FAIL: gcc.dg/lto/pr53470 c_lto_pr53470_0.o-c_lto_pr53470_0.o link,  
> -flto -g
> PASS->FAIL: gcc.dg/lto/pr59323 c_lto_pr59323_0.o-c_lto_pr59323_0.o link,  -O2 
> -g -flto
> PASS->FAIL: gcc.dg/lto/pr59323-2 c_lto_pr59323-2_0.o-c_lto_pr59323-2_0.o 
> link,  -O2 -g -flto
> PASS->FAIL: gcc.dg/pr43557-1.c (test for excess errors)
> 
> linking seems to fail with
> 
> /tmp/ccqAb1Wfdebugobjtem: file not recognized: Bad value
> collect2: error: ld returned 1 exit status
> lto-wrapper: fatal error: B/gcc/xgcc returned 1 exit status
> compilation terminated.
> P/aarch64_be-none-elf/bin/ld: error: lto-wrapper failed
> collect2: error: ld returned 1 exit status
> compiler exited with status 1

Can you file a bugreport please?  Can you investigate a bit, I suspect
a simple int main() {} and ./xgcc -B. -flto -g t.c fails the same way.
With -save-temps -v you should be able to inspect the generated
debugobj with readelf.

Is this a native compiler or a cross-compiler?  [I suspect endianess
issues somewhere?]

Thanks,
Richard.

> similar regressions on g++ tests:
> 
> PASS->FAIL: g++.dg/lto/20101010-4 cp_lto_20101010-4_0.o-cp_lto_20101010-4_0.o 
> link,  -std=c++0x -flto -g -r
> -nostdlib
> PASS->FAIL: g++.dg/lto/20101015-2 cp_lto_20101015-2_0.o-cp_lto_20101015-2_0.o 
> link,  -g -flto
> PASS->FAIL: g++.dg/lto/pr42987 cp_lto_pr42987_0.o-cp_lto_pr42987_1.o link,  
> -flto -flto-partition=none -g
> PASS->FAIL: g++.dg/lto/pr42987 cp_lto_pr42987_0.o-cp_lto_pr42987_1.o link,  
> -flto -g
> PASS->FAIL: g++.dg/lto/pr48207 cp_lto_pr48207_0.o-cp_lto_pr48207_0.o link,  
> -flto -g
> PASS->FAIL: g++.dg/lto/pr48207-2 cp_lto_pr48207-2_0.o-cp_lto_pr48207-2_0.o 
> link,  -flto -g
> PASS->FAIL: g++.dg/lto/pr48207-3 cp_lto_pr48207-3_0.o-cp_lto_pr48207-3_0.o 
> link,  -flto -g
> PASS->FAIL: g++.dg/lto/pr48354-1 cp_lto_pr48354-1_0.o-cp_lto_pr48354-1_0.o 
> link,  -g -flto
> PASS->FAIL: g++.dg/lto/pr48508-1 cp_lto_pr48508-1_0.o-cp_lto_pr48508-1_1.o 
> link,  -g -O2 -flto
> -flto-partition=none
> PASS->FAIL: g++.dg/lto/pr51564-1 cp_lto_pr51564-1_0.o-cp_lto_pr51564-1_0.o 
> link,  -flto -g
> PASS->FAIL: g++.dg/lto/pr51567-1 cp_lto_pr51567-1_0.o-cp_lto_pr51567-1_0.o 
> link,  -flto -g
> PASS->FAIL: g++.dg/lto/pr51572-2 cp_lto_pr51572-2_0.o-cp_lto_pr51572-2_0.o 
> link,  -g -flto
> PASS->FAIL: g++.dg/lto/pr51573-1 cp_lto_pr51573-1_0.o-cp_lto_pr51573-1_0.o 
> link,  -flto -g
> PASS->FAIL: g++.dg/lto/pr51650-1 cp_lto_pr51650-1_0.o-cp_lto_pr51650-1_0.o 
> link,  -flto -g
> PASS->FAIL: g++.dg/lto/pr51650-2 cp_lto_pr51650-2_0.o-cp_lto_pr51650-2_0.o 
> link,  -flto -g
> PASS->FAIL: g++.dg/lto/pr51650-3 cp_lto_pr51650-3_0.o-cp_lto_pr51650-3_0.o 
> link,  -flto -g
> PASS->FAIL: g++.dg/lto/pr52605 cp_lto_pr52605_0.o-cp_lto_pr52605_0.o link, 
> -flto -g
> PASS->FAIL: g++.dg/lto/pr53470 cp_lto_pr53470_0.o-cp_lto_pr53470_0.o link,  
> -g -flto
> PASS->FAIL: g++.dg/lto/pr65193 cp_lto_pr65193_0.o-cp_lto_pr65193_0.o link, 
> -fPIC -r -nostdlib -flto -O2 -g
> PASS->FAIL: g++.dg/lto/pr65316 cp_lto_pr65316_0.o-cp_lto_pr65316_1.o 

Re: [PATCH][2/2] early LTO debug, main part

2017-08-22 Thread Szabolcs Nagy
On 04/08/17 13:21, Richard Biener wrote:
> On Thu, 3 Aug 2017, Jason Merrill wrote:
>> OK if testing passes.
> 
> Thanks.  Meanwhile testing passed.
> 
> Bootstrapped and tested on x86_64-unknown-linux-gnu, LTO bootstrapped
> on x86_64-unknown-linux-gnu (both all languages).  I've successfully
> built SPEC CPU 2006 with -flto -g (provides reasonable Fortran coverage).
> I've successfully ran the GCC testsuite with -flto -g which shows lots
> of FAILs but doesn't regress in any unexpected ways compared to before
> the patches.
> 
> I'll ping Ian about the simple-object part again and will apply
> earliest at Aug 14th.
> 
> Richard.
> 

on aarch64_be-none-elf i see

PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 (test for excess errors)
PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -O (test for excess errors)
PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -O3 (test for excess errors)
PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -g1 (test for excess errors)
PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -g1 -O (test for excess errors)
PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -g1 -O3 (test for excess errors)
PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -g3 (test for excess errors)
PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -g3 -O (test for excess errors)
PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -g3 -O3 (test for excess errors)
PASS->FAIL: gcc.dg/lto/20090914-1 c_lto_20090914-1_0.o-c_lto_20090914-1_0.o 
link, -flto
PASS->FAIL: gcc.dg/lto/20100426 c_lto_20100426_0.o-c_lto_20100426_0.o link, -r 
-nostdlib -flto -g
PASS->FAIL: gcc.dg/lto/20111207-2 c_lto_20111207-2_0.o-c_lto_20111207-2_0.o 
link,  -g -O -flto
PASS->FAIL: gcc.dg/lto/20111213-1 c_lto_20111213-1_0.o-c_lto_20111213-1_0.o 
link,  -flto -g
PASS->FAIL: gcc.dg/lto/pr51572-1 c_lto_pr51572-1_0.o-c_lto_pr51572-1_0.o link,  
-flto -g
PASS->FAIL: gcc.dg/lto/pr53470 c_lto_pr53470_0.o-c_lto_pr53470_0.o link,  -flto 
-g
PASS->FAIL: gcc.dg/lto/pr59323 c_lto_pr59323_0.o-c_lto_pr59323_0.o link,  -O2 
-g -flto
PASS->FAIL: gcc.dg/lto/pr59323-2 c_lto_pr59323-2_0.o-c_lto_pr59323-2_0.o link,  
-O2 -g -flto
PASS->FAIL: gcc.dg/pr43557-1.c (test for excess errors)

linking seems to fail with

/tmp/ccqAb1Wfdebugobjtem: file not recognized: Bad value
collect2: error: ld returned 1 exit status
lto-wrapper: fatal error: B/gcc/xgcc returned 1 exit status
compilation terminated.
P/aarch64_be-none-elf/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
compiler exited with status 1

similar regressions on g++ tests:

PASS->FAIL: g++.dg/lto/20101010-4 cp_lto_20101010-4_0.o-cp_lto_20101010-4_0.o 
link,  -std=c++0x -flto -g -r
-nostdlib
PASS->FAIL: g++.dg/lto/20101015-2 cp_lto_20101015-2_0.o-cp_lto_20101015-2_0.o 
link,  -g -flto
PASS->FAIL: g++.dg/lto/pr42987 cp_lto_pr42987_0.o-cp_lto_pr42987_1.o link,  
-flto -flto-partition=none -g
PASS->FAIL: g++.dg/lto/pr42987 cp_lto_pr42987_0.o-cp_lto_pr42987_1.o link,  
-flto -g
PASS->FAIL: g++.dg/lto/pr48207 cp_lto_pr48207_0.o-cp_lto_pr48207_0.o link,  
-flto -g
PASS->FAIL: g++.dg/lto/pr48207-2 cp_lto_pr48207-2_0.o-cp_lto_pr48207-2_0.o 
link,  -flto -g
PASS->FAIL: g++.dg/lto/pr48207-3 cp_lto_pr48207-3_0.o-cp_lto_pr48207-3_0.o 
link,  -flto -g
PASS->FAIL: g++.dg/lto/pr48354-1 cp_lto_pr48354-1_0.o-cp_lto_pr48354-1_0.o 
link,  -g -flto
PASS->FAIL: g++.dg/lto/pr48508-1 cp_lto_pr48508-1_0.o-cp_lto_pr48508-1_1.o 
link,  -g -O2 -flto
-flto-partition=none
PASS->FAIL: g++.dg/lto/pr51564-1 cp_lto_pr51564-1_0.o-cp_lto_pr51564-1_0.o 
link,  -flto -g
PASS->FAIL: g++.dg/lto/pr51567-1 cp_lto_pr51567-1_0.o-cp_lto_pr51567-1_0.o 
link,  -flto -g
PASS->FAIL: g++.dg/lto/pr51572-2 cp_lto_pr51572-2_0.o-cp_lto_pr51572-2_0.o 
link,  -g -flto
PASS->FAIL: g++.dg/lto/pr51573-1 cp_lto_pr51573-1_0.o-cp_lto_pr51573-1_0.o 
link,  -flto -g
PASS->FAIL: g++.dg/lto/pr51650-1 cp_lto_pr51650-1_0.o-cp_lto_pr51650-1_0.o 
link,  -flto -g
PASS->FAIL: g++.dg/lto/pr51650-2 cp_lto_pr51650-2_0.o-cp_lto_pr51650-2_0.o 
link,  -flto -g
PASS->FAIL: g++.dg/lto/pr51650-3 cp_lto_pr51650-3_0.o-cp_lto_pr51650-3_0.o 
link,  -flto -g
PASS->FAIL: g++.dg/lto/pr52605 cp_lto_pr52605_0.o-cp_lto_pr52605_0.o link, 
-flto -g
PASS->FAIL: g++.dg/lto/pr53470 cp_lto_pr53470_0.o-cp_lto_pr53470_0.o link,  -g 
-flto
PASS->FAIL: g++.dg/lto/pr65193 cp_lto_pr65193_0.o-cp_lto_pr65193_0.o link, 
-fPIC -r -nostdlib -flto -O2 -g
PASS->FAIL: g++.dg/lto/pr65316 cp_lto_pr65316_0.o-cp_lto_pr65316_1.o link,  
-flto -std=c++11 -g2
-fno-lto-odr-type-merging -O2
PASS->FAIL: g++.dg/lto/pr65549 cp_lto_pr65549_0.o-cp_lto_pr65549_0.o link,  
-std=gnu++14 -flto -g
PASS->FAIL: g++.dg/lto/pr65549 cp_lto_pr65549_0.o-cp_lto_pr65549_0.o link,  
-std=gnu++14 -flto -g -O2
-fno-inline -flto-partition=max
PASS->FAIL: g++.dg/lto/pr69077 cp_lto_pr69077_0.o-cp_lto_pr69077_1.o link,  -O3 
-g -flto
PASS->FAIL: g++.dg/lto/pr69137 cp_lto_pr69137_0.o-cp_lto_pr69137_0.o link,  
-std=c++11 -g -flto
PASS->FAIL: g++.dg/lto/pr79000 cp_lto_pr79000_0.o-cp_lto_pr79000_1.o link, 
-flto -g
NA->FAIL: 

Re: [PATCH][2/2] early LTO debug, main part

2017-08-04 Thread Richard Biener
On Thu, 3 Aug 2017, Jason Merrill wrote:

> On Thu, Aug 3, 2017 at 6:51 AM, Richard Biener  wrote:
> > On Wed, 2 Aug 2017, Jason Merrill wrote:
> >
> >> On Wed, Aug 2, 2017 at 6:35 AM, Richard Biener  wrote:
> >> > On Wed, 2 Aug 2017, Jason Merrill wrote:
> >> >
> >> >> On 05/19/2017 06:42 AM, Richard Biener wrote:
> >> >> > + /* ???  In some cases the C++ FE (at least) fails to
> >> >> > +set DECL_CONTEXT properly.  Simply globalize stuff
> >> >> > +in this case.  For example
> >> >> > +__dso_handle created via iostream line 74 col 25.  */
> >> >> > + parent = comp_unit_die ();
> >> >>
> >> >> I've now fixed __dso_handle, so that can be removed from the comment, 
> >> >> but it
> >> >> still makes sense to have this fall-back for the (permitted) case of 
> >> >> null
> >> >> DECL_CONTEXT.
> >> >
> >> > Adjusted the comment.
> >> >
> >> >> > +   /* ???  LANG issue - DW_TAG_module for fortran.  Either look
> >> >> > +at the input language (if we have enough DECL_CONTEXT to follow)
> >> >> > +or use a bit in tree_decl_with_vis to record the distinction.  */
> >> >>
> >> >> Sure, you should be able to look at TRANSLATION_UNIT_LANGUAGE.
> >> >
> >> > Yeah, the comment says we might be able to walk DECL_CONTEXT up to
> >> > a TRANSLATION_UNIT_DECL.  I've amended is_fortran similar to as I
> >> > amended is_cxx, providing an overload for a decl, factoring out common
> >> > code.  So this is now if (is_fortran (decl)) ... = new_die
> >> > (DW_TAG_module,...).
> >> >
> >> >> > ! /* ???  We cannot unconditionally output die_offset if
> >> >> > !non-zero - at least -feliminate-dwarf2-dups will
> >> >> > !create references to those DIEs via symbols.  And we
> >> >> > !do not clear its DIE offset after outputting it
> >> >> > !(and the label refers to the actual DIEs, not the
> >> >> > !DWARF CU unit header which is when using label + 
> >> >> > offset
> >> >> > !would be the correct thing to do).
> >> >>
> >> >> As in our previous discussion, I think -feliminate-dwarf2-dups can go 
> >> >> away
> >> >> now.  But this is a more general issue: die_offset has meant the offset 
> >> >> from
> >> >> the beginning of the CU, but if with_offset is set it means an offset 
> >> >> from
> >> >> die_symbol.  Since with_offset changes the meaning of die_symbol and
> >> >> die_offset, having different code here depending on that flag makes 
> >> >> sense.
> >> >>
> >> >> It seems likely that when -fEDD goes away, we will never again want to 
> >> >> do
> >> >> direct symbolic references to DIEs, in which case we could drop the 
> >> >> current
> >> >> meaning of die_symbol, and so we wouldn't need the with_offset flag.
> >> >
> >> > Yeah, I've been playing with a patch to remove -fEDD but it has conflicts
> >> > with the early LTO debug work and thus I wanted to postpone it until
> >> > after that goes in to avoid further churn.  I hope that's fine, it's
> >> > sth I'll tackle soon after this patch lands on trunk.
> >>
> >> Sure.
> >>
> >> >> > !   /* Don't output the symbol twice.  For LTO we want the label
> >> >> > !  on the section beginning, not on the actual DIE.  */
> >> >> > !   && (!flag_generate_lto
> >> >> > ! || die->die_tag != DW_TAG_compile_unit))
> >> >>
> >> >> I think this check should just be !with_offset; if that flag is set the 
> >> >> DIE
> >> >> doesn't actually have its own symbol.
> >> >
> >> > with_offset is set only during LTRANS phase for the DIEs refering to
> >> > the early DIEs via the CU label.  But the above is guarding the
> >> > early phase when we do not want to output that CU label twice.
> >> >
> >> > Can we revisit this check when -fEDD has gone away?
> >>
> >> Yes.
> >>
> >> >> > !   if (old_die
> >> >> > ! && (c = get_AT_ref (old_die, DW_AT_abstract_origin))
> >> >> > ! /* ???  In LTO all origin DIEs still refer to the early
> >> >> > !debug copy.  Detect that.  */
> >> >> > ! && get_AT (c, DW_AT_inline))
> >> >> ...
> >> >> > !   /* "Unwrap" the decls DIE which we put in the imported unit 
> >> >> > context.
> >> >> > !   ???  If we finish dwarf2out_function_decl refactoring we 
> >> >> > can
> >> >> > ! do this in a better way from the start and only lazily emit
> >> >> > ! the early DIE references.  */
> >> >>
> >> >> It seems like in gen_subprogram_die you deliberately avoid reusing the 
> >> >> DIE
> >> >> from dwarf2out_register_external_die (since it doesn't have 
> >> >> DW_AT_inline), and
> >> >> then in add_abstract_origin_attribute you need to look through that 
> >> >> redundant
> >> >> die.  Why not reuse it?
> >> >
> >> > What we're doing here is dealing with the case of an inlined
> >> > instance which is adjusted to point back to the early debug copy
> >> > directly than to the wrapping DIE (supposed to eventually 

Re: [PATCH][2/2] early LTO debug, main part

2017-08-03 Thread Jason Merrill
On Thu, Aug 3, 2017 at 6:51 AM, Richard Biener  wrote:
> On Wed, 2 Aug 2017, Jason Merrill wrote:
>
>> On Wed, Aug 2, 2017 at 6:35 AM, Richard Biener  wrote:
>> > On Wed, 2 Aug 2017, Jason Merrill wrote:
>> >
>> >> On 05/19/2017 06:42 AM, Richard Biener wrote:
>> >> > + /* ???  In some cases the C++ FE (at least) fails to
>> >> > +set DECL_CONTEXT properly.  Simply globalize stuff
>> >> > +in this case.  For example
>> >> > +__dso_handle created via iostream line 74 col 25.  */
>> >> > + parent = comp_unit_die ();
>> >>
>> >> I've now fixed __dso_handle, so that can be removed from the comment, but 
>> >> it
>> >> still makes sense to have this fall-back for the (permitted) case of null
>> >> DECL_CONTEXT.
>> >
>> > Adjusted the comment.
>> >
>> >> > +   /* ???  LANG issue - DW_TAG_module for fortran.  Either look
>> >> > +at the input language (if we have enough DECL_CONTEXT to follow)
>> >> > +or use a bit in tree_decl_with_vis to record the distinction.  */
>> >>
>> >> Sure, you should be able to look at TRANSLATION_UNIT_LANGUAGE.
>> >
>> > Yeah, the comment says we might be able to walk DECL_CONTEXT up to
>> > a TRANSLATION_UNIT_DECL.  I've amended is_fortran similar to as I
>> > amended is_cxx, providing an overload for a decl, factoring out common
>> > code.  So this is now if (is_fortran (decl)) ... = new_die
>> > (DW_TAG_module,...).
>> >
>> >> > ! /* ???  We cannot unconditionally output die_offset if
>> >> > !non-zero - at least -feliminate-dwarf2-dups will
>> >> > !create references to those DIEs via symbols.  And we
>> >> > !do not clear its DIE offset after outputting it
>> >> > !(and the label refers to the actual DIEs, not the
>> >> > !DWARF CU unit header which is when using label + offset
>> >> > !would be the correct thing to do).
>> >>
>> >> As in our previous discussion, I think -feliminate-dwarf2-dups can go away
>> >> now.  But this is a more general issue: die_offset has meant the offset 
>> >> from
>> >> the beginning of the CU, but if with_offset is set it means an offset from
>> >> die_symbol.  Since with_offset changes the meaning of die_symbol and
>> >> die_offset, having different code here depending on that flag makes sense.
>> >>
>> >> It seems likely that when -fEDD goes away, we will never again want to do
>> >> direct symbolic references to DIEs, in which case we could drop the 
>> >> current
>> >> meaning of die_symbol, and so we wouldn't need the with_offset flag.
>> >
>> > Yeah, I've been playing with a patch to remove -fEDD but it has conflicts
>> > with the early LTO debug work and thus I wanted to postpone it until
>> > after that goes in to avoid further churn.  I hope that's fine, it's
>> > sth I'll tackle soon after this patch lands on trunk.
>>
>> Sure.
>>
>> >> > !   /* Don't output the symbol twice.  For LTO we want the label
>> >> > !  on the section beginning, not on the actual DIE.  */
>> >> > !   && (!flag_generate_lto
>> >> > ! || die->die_tag != DW_TAG_compile_unit))
>> >>
>> >> I think this check should just be !with_offset; if that flag is set the 
>> >> DIE
>> >> doesn't actually have its own symbol.
>> >
>> > with_offset is set only during LTRANS phase for the DIEs refering to
>> > the early DIEs via the CU label.  But the above is guarding the
>> > early phase when we do not want to output that CU label twice.
>> >
>> > Can we revisit this check when -fEDD has gone away?
>>
>> Yes.
>>
>> >> > !   if (old_die
>> >> > ! && (c = get_AT_ref (old_die, DW_AT_abstract_origin))
>> >> > ! /* ???  In LTO all origin DIEs still refer to the early
>> >> > !debug copy.  Detect that.  */
>> >> > ! && get_AT (c, DW_AT_inline))
>> >> ...
>> >> > !   /* "Unwrap" the decls DIE which we put in the imported unit 
>> >> > context.
>> >> > !   ???  If we finish dwarf2out_function_decl refactoring we can
>> >> > ! do this in a better way from the start and only lazily emit
>> >> > ! the early DIE references.  */
>> >>
>> >> It seems like in gen_subprogram_die you deliberately avoid reusing the DIE
>> >> from dwarf2out_register_external_die (since it doesn't have 
>> >> DW_AT_inline), and
>> >> then in add_abstract_origin_attribute you need to look through that 
>> >> redundant
>> >> die.  Why not reuse it?
>> >
>> > What we're doing here is dealing with the case of an inlined
>> > instance which is adjusted to point back to the early debug copy
>> > directly than to the wrapping DIE (supposed to eventually contain
>> > the concrete instance).
>>
>> But we enter this block when we're emitting the concrete out-of-line
>> instance, and the DW_AT_inline check prevents us from using the
>> wrapping DIE for the out-of-line instance.
>>
>> The comment should really change "inlined instance" to "concrete
>> instance"; inlined 

Re: [PATCH][2/2] early LTO debug, main part

2017-08-03 Thread Richard Biener
On Wed, 2 Aug 2017, Jason Merrill wrote:

> On Wed, Aug 2, 2017 at 6:35 AM, Richard Biener  wrote:
> > On Wed, 2 Aug 2017, Jason Merrill wrote:
> >
> >> On 05/19/2017 06:42 AM, Richard Biener wrote:
> >> > + /* ???  In some cases the C++ FE (at least) fails to
> >> > +set DECL_CONTEXT properly.  Simply globalize stuff
> >> > +in this case.  For example
> >> > +__dso_handle created via iostream line 74 col 25.  */
> >> > + parent = comp_unit_die ();
> >>
> >> I've now fixed __dso_handle, so that can be removed from the comment, but 
> >> it
> >> still makes sense to have this fall-back for the (permitted) case of null
> >> DECL_CONTEXT.
> >
> > Adjusted the comment.
> >
> >> > +   /* ???  LANG issue - DW_TAG_module for fortran.  Either look
> >> > +at the input language (if we have enough DECL_CONTEXT to follow)
> >> > +or use a bit in tree_decl_with_vis to record the distinction.  */
> >>
> >> Sure, you should be able to look at TRANSLATION_UNIT_LANGUAGE.
> >
> > Yeah, the comment says we might be able to walk DECL_CONTEXT up to
> > a TRANSLATION_UNIT_DECL.  I've amended is_fortran similar to as I
> > amended is_cxx, providing an overload for a decl, factoring out common
> > code.  So this is now if (is_fortran (decl)) ... = new_die
> > (DW_TAG_module,...).
> >
> >> > ! /* ???  We cannot unconditionally output die_offset if
> >> > !non-zero - at least -feliminate-dwarf2-dups will
> >> > !create references to those DIEs via symbols.  And we
> >> > !do not clear its DIE offset after outputting it
> >> > !(and the label refers to the actual DIEs, not the
> >> > !DWARF CU unit header which is when using label + offset
> >> > !would be the correct thing to do).
> >>
> >> As in our previous discussion, I think -feliminate-dwarf2-dups can go away
> >> now.  But this is a more general issue: die_offset has meant the offset 
> >> from
> >> the beginning of the CU, but if with_offset is set it means an offset from
> >> die_symbol.  Since with_offset changes the meaning of die_symbol and
> >> die_offset, having different code here depending on that flag makes sense.
> >>
> >> It seems likely that when -fEDD goes away, we will never again want to do
> >> direct symbolic references to DIEs, in which case we could drop the current
> >> meaning of die_symbol, and so we wouldn't need the with_offset flag.
> >
> > Yeah, I've been playing with a patch to remove -fEDD but it has conflicts
> > with the early LTO debug work and thus I wanted to postpone it until
> > after that goes in to avoid further churn.  I hope that's fine, it's
> > sth I'll tackle soon after this patch lands on trunk.
> 
> Sure.
> 
> >> > !   /* Don't output the symbol twice.  For LTO we want the label
> >> > !  on the section beginning, not on the actual DIE.  */
> >> > !   && (!flag_generate_lto
> >> > ! || die->die_tag != DW_TAG_compile_unit))
> >>
> >> I think this check should just be !with_offset; if that flag is set the DIE
> >> doesn't actually have its own symbol.
> >
> > with_offset is set only during LTRANS phase for the DIEs refering to
> > the early DIEs via the CU label.  But the above is guarding the
> > early phase when we do not want to output that CU label twice.
> >
> > Can we revisit this check when -fEDD has gone away?
> 
> Yes.
> 
> >> > !   if (old_die
> >> > ! && (c = get_AT_ref (old_die, DW_AT_abstract_origin))
> >> > ! /* ???  In LTO all origin DIEs still refer to the early
> >> > !debug copy.  Detect that.  */
> >> > ! && get_AT (c, DW_AT_inline))
> >> ...
> >> > !   /* "Unwrap" the decls DIE which we put in the imported unit 
> >> > context.
> >> > !   ???  If we finish dwarf2out_function_decl refactoring we can
> >> > ! do this in a better way from the start and only lazily emit
> >> > ! the early DIE references.  */
> >>
> >> It seems like in gen_subprogram_die you deliberately avoid reusing the DIE
> >> from dwarf2out_register_external_die (since it doesn't have DW_AT_inline), 
> >> and
> >> then in add_abstract_origin_attribute you need to look through that 
> >> redundant
> >> die.  Why not reuse it?
> >
> > What we're doing here is dealing with the case of an inlined
> > instance which is adjusted to point back to the early debug copy
> > directly than to the wrapping DIE (supposed to eventually contain
> > the concrete instance).
> 
> But we enter this block when we're emitting the concrete out-of-line
> instance, and the DW_AT_inline check prevents us from using the
> wrapping DIE for the out-of-line instance.
> 
> The comment should really change "inlined instance" to "concrete
> instance"; inlined instances are handled in
> gen_inlined_subroutine_die.

You are right.  I suspect I got confused by the comment when looking
for a way to paper over the check_die ICE removing the check 

Re: [PATCH][2/2] early LTO debug, main part

2017-08-02 Thread Jason Merrill
On Wed, Aug 2, 2017 at 6:35 AM, Richard Biener  wrote:
> On Wed, 2 Aug 2017, Jason Merrill wrote:
>
>> On 05/19/2017 06:42 AM, Richard Biener wrote:
>> > + /* ???  In some cases the C++ FE (at least) fails to
>> > +set DECL_CONTEXT properly.  Simply globalize stuff
>> > +in this case.  For example
>> > +__dso_handle created via iostream line 74 col 25.  */
>> > + parent = comp_unit_die ();
>>
>> I've now fixed __dso_handle, so that can be removed from the comment, but it
>> still makes sense to have this fall-back for the (permitted) case of null
>> DECL_CONTEXT.
>
> Adjusted the comment.
>
>> > +   /* ???  LANG issue - DW_TAG_module for fortran.  Either look
>> > +at the input language (if we have enough DECL_CONTEXT to follow)
>> > +or use a bit in tree_decl_with_vis to record the distinction.  */
>>
>> Sure, you should be able to look at TRANSLATION_UNIT_LANGUAGE.
>
> Yeah, the comment says we might be able to walk DECL_CONTEXT up to
> a TRANSLATION_UNIT_DECL.  I've amended is_fortran similar to as I
> amended is_cxx, providing an overload for a decl, factoring out common
> code.  So this is now if (is_fortran (decl)) ... = new_die
> (DW_TAG_module,...).
>
>> > ! /* ???  We cannot unconditionally output die_offset if
>> > !non-zero - at least -feliminate-dwarf2-dups will
>> > !create references to those DIEs via symbols.  And we
>> > !do not clear its DIE offset after outputting it
>> > !(and the label refers to the actual DIEs, not the
>> > !DWARF CU unit header which is when using label + offset
>> > !would be the correct thing to do).
>>
>> As in our previous discussion, I think -feliminate-dwarf2-dups can go away
>> now.  But this is a more general issue: die_offset has meant the offset from
>> the beginning of the CU, but if with_offset is set it means an offset from
>> die_symbol.  Since with_offset changes the meaning of die_symbol and
>> die_offset, having different code here depending on that flag makes sense.
>>
>> It seems likely that when -fEDD goes away, we will never again want to do
>> direct symbolic references to DIEs, in which case we could drop the current
>> meaning of die_symbol, and so we wouldn't need the with_offset flag.
>
> Yeah, I've been playing with a patch to remove -fEDD but it has conflicts
> with the early LTO debug work and thus I wanted to postpone it until
> after that goes in to avoid further churn.  I hope that's fine, it's
> sth I'll tackle soon after this patch lands on trunk.

Sure.

>> > !   /* Don't output the symbol twice.  For LTO we want the label
>> > !  on the section beginning, not on the actual DIE.  */
>> > !   && (!flag_generate_lto
>> > ! || die->die_tag != DW_TAG_compile_unit))
>>
>> I think this check should just be !with_offset; if that flag is set the DIE
>> doesn't actually have its own symbol.
>
> with_offset is set only during LTRANS phase for the DIEs refering to
> the early DIEs via the CU label.  But the above is guarding the
> early phase when we do not want to output that CU label twice.
>
> Can we revisit this check when -fEDD has gone away?

Yes.

>> > !   if (old_die
>> > ! && (c = get_AT_ref (old_die, DW_AT_abstract_origin))
>> > ! /* ???  In LTO all origin DIEs still refer to the early
>> > !debug copy.  Detect that.  */
>> > ! && get_AT (c, DW_AT_inline))
>> ...
>> > !   /* "Unwrap" the decls DIE which we put in the imported unit 
>> > context.
>> > !   ???  If we finish dwarf2out_function_decl refactoring we can
>> > ! do this in a better way from the start and only lazily emit
>> > ! the early DIE references.  */
>>
>> It seems like in gen_subprogram_die you deliberately avoid reusing the DIE
>> from dwarf2out_register_external_die (since it doesn't have DW_AT_inline), 
>> and
>> then in add_abstract_origin_attribute you need to look through that redundant
>> die.  Why not reuse it?
>
> What we're doing here is dealing with the case of an inlined
> instance which is adjusted to point back to the early debug copy
> directly than to the wrapping DIE (supposed to eventually contain
> the concrete instance).

But we enter this block when we're emitting the concrete out-of-line
instance, and the DW_AT_inline check prevents us from using the
wrapping DIE for the out-of-line instance.

The comment should really change "inlined instance" to "concrete
instance"; inlined instances are handled in
gen_inlined_subroutine_die.

Jason


Re: [PATCH][2/2] early LTO debug, main part

2017-08-02 Thread Richard Biener
On Wed, 2 Aug 2017, Jason Merrill wrote:

> On 05/19/2017 06:42 AM, Richard Biener wrote:
> > + /* ???  In some cases the C++ FE (at least) fails to
> > +set DECL_CONTEXT properly.  Simply globalize stuff
> > +in this case.  For example
> > +__dso_handle created via iostream line 74 col 25.  */
> > + parent = comp_unit_die ();
> 
> I've now fixed __dso_handle, so that can be removed from the comment, but it
> still makes sense to have this fall-back for the (permitted) case of null
> DECL_CONTEXT.

Adjusted the comment.

> > +   /* ???  LANG issue - DW_TAG_module for fortran.  Either look
> > +at the input language (if we have enough DECL_CONTEXT to follow)
> > +or use a bit in tree_decl_with_vis to record the distinction.  */
> 
> Sure, you should be able to look at TRANSLATION_UNIT_LANGUAGE.

Yeah, the comment says we might be able to walk DECL_CONTEXT up to
a TRANSLATION_UNIT_DECL.  I've amended is_fortran similar to as I
amended is_cxx, providing an overload for a decl, factoring out common
code.  So this is now if (is_fortran (decl)) ... = new_die 
(DW_TAG_module,...).

> > ! /* ???  We cannot unconditionally output die_offset if
> > !non-zero - at least -feliminate-dwarf2-dups will
> > !create references to those DIEs via symbols.  And we
> > !do not clear its DIE offset after outputting it
> > !(and the label refers to the actual DIEs, not the
> > !DWARF CU unit header which is when using label + offset
> > !would be the correct thing to do).
> 
> As in our previous discussion, I think -feliminate-dwarf2-dups can go away
> now.  But this is a more general issue: die_offset has meant the offset from
> the beginning of the CU, but if with_offset is set it means an offset from
> die_symbol.  Since with_offset changes the meaning of die_symbol and
> die_offset, having different code here depending on that flag makes sense.
> 
> It seems likely that when -fEDD goes away, we will never again want to do
> direct symbolic references to DIEs, in which case we could drop the current
> meaning of die_symbol, and so we wouldn't need the with_offset flag.

Yeah, I've been playing with a patch to remove -fEDD but it has conflicts
with the early LTO debug work and thus I wanted to postpone it until
after that goes in to avoid further churn.  I hope that's fine, it's
sth I'll tackle soon after this patch lands on trunk.

> > !   unit_die->comdat_type_p = comdat_p;
> > ! }
> > ! ! static void
> > ! compute_section_prefix (dw_die_ref unit_die)
> > ! {
> > !   compute_section_prefix_1 (unit_die, true);
> > !   comdat_symbol_id = unit_die->die_id.die_symbol;
> > comdat_symbol_number = 0;
> >   }
> 
> Let's set the comdat_type_p flag in this function rather than add a parameter
> to the existing function.  And when -fEDD goes away, we don't need this entry
> point at all.
> 
> Also, for LTO debug, it seems you aren't actually using the symbol as a
> section prefix, so the name becomes inaccurate.  Maybe
> compute_comp_unit_symbol rather than compute_section_prefix_1?

Done.

> > +   /* For LTO cross unit DIE refs we want a symbol on the start of the
> > +  debuginfo section, not on the CU DIE.
> > +  ???  We could simply use the symbol as it would be output by
> > output_die
> > +  and account for the extra offset produced by the CU header which has
> > fixed
> > +  size.  OTOH it currently only supports linkonce globals which would
> > +  be less than ideal?.  */
> 
> I think the way you're doing it now is better than this alternative, since
> die_offset is relative to the beginning of the CU header.

Removed the ??? part of the comment.

> > !   /* Don't output the symbol twice.  For LTO we want the label
> > !  on the section beginning, not on the actual DIE.  */
> > !   && (!flag_generate_lto
> > ! || die->die_tag != DW_TAG_compile_unit))
> 
> I think this check should just be !with_offset; if that flag is set the DIE
> doesn't actually have its own symbol.

with_offset is set only during LTRANS phase for the DIEs refering to
the early DIEs via the CU label.  But the above is guarding the
early phase when we do not want to output that CU label twice.

Can we revisit this check when -fEDD has gone away?

> > !   if (old_die
> > ! && (c = get_AT_ref (old_die, DW_AT_abstract_origin))
> > ! /* ???  In LTO all origin DIEs still refer to the early
> > !debug copy.  Detect that.  */
> > ! && get_AT (c, DW_AT_inline))
> ...
> > !   /* "Unwrap" the decls DIE which we put in the imported unit context.
> > !   ???  If we finish dwarf2out_function_decl refactoring we can
> > ! do this in a better way from the start and only lazily emit
> > ! the early DIE references.  */
> 
> It seems like in gen_subprogram_die you deliberately avoid reusing the DIE
> from dwarf2out_register_external_die 

Re: [PATCH][2/2] early LTO debug, main part

2017-08-01 Thread Jason Merrill

On 05/19/2017 06:42 AM, Richard Biener wrote:

+ /* ???  In some cases the C++ FE (at least) fails to
+set DECL_CONTEXT properly.  Simply globalize stuff
+in this case.  For example
+__dso_handle created via iostream line 74 col 25.  */
+ parent = comp_unit_die ();


I've now fixed __dso_handle, so that can be removed from the comment, 
but it still makes sense to have this fall-back for the (permitted) case 
of null DECL_CONTEXT.



+   /* ???  LANG issue - DW_TAG_module for fortran.  Either look
+at the input language (if we have enough DECL_CONTEXT to follow)
+or use a bit in tree_decl_with_vis to record the distinction.  */


Sure, you should be able to look at TRANSLATION_UNIT_LANGUAGE.


! /* ???  We cannot unconditionally output die_offset if
!non-zero - at least -feliminate-dwarf2-dups will
!create references to those DIEs via symbols.  And we
!do not clear its DIE offset after outputting it
!(and the label refers to the actual DIEs, not the
!DWARF CU unit header which is when using label + offset
!would be the correct thing to do).


As in our previous discussion, I think -feliminate-dwarf2-dups can go 
away now.  But this is a more general issue: die_offset has meant the 
offset from the beginning of the CU, but if with_offset is set it means 
an offset from die_symbol.  Since with_offset changes the meaning of 
die_symbol and die_offset, having different code here depending on that 
flag makes sense.


It seems likely that when -fEDD goes away, we will never again want to 
do direct symbolic references to DIEs, in which case we could drop the 
current meaning of die_symbol, and so we wouldn't need the with_offset flag.



!   unit_die->comdat_type_p = comdat_p;
! }
! 
! static void

! compute_section_prefix (dw_die_ref unit_die)
! {
!   compute_section_prefix_1 (unit_die, true);
!   comdat_symbol_id = unit_die->die_id.die_symbol;
comdat_symbol_number = 0;
  }


Let's set the comdat_type_p flag in this function rather than add a 
parameter to the existing function.  And when -fEDD goes away, we don't 
need this entry point at all.


Also, for LTO debug, it seems you aren't actually using the symbol as a 
section prefix, so the name becomes inaccurate.  Maybe 
compute_comp_unit_symbol rather than compute_section_prefix_1?



+   /* For LTO cross unit DIE refs we want a symbol on the start of the
+  debuginfo section, not on the CU DIE.
+  ???  We could simply use the symbol as it would be output by output_die
+  and account for the extra offset produced by the CU header which has 
fixed
+  size.  OTOH it currently only supports linkonce globals which would
+  be less than ideal?.  */


I think the way you're doing it now is better than this alternative, 
since die_offset is relative to the beginning of the CU header.



!   /* Don't output the symbol twice.  For LTO we want the label
!  on the section beginning, not on the actual DIE.  */
!   && (!flag_generate_lto
! || die->die_tag != DW_TAG_compile_unit))


I think this check should just be !with_offset; if that flag is set the 
DIE doesn't actually have its own symbol.



!   if (old_die
! && (c = get_AT_ref (old_die, DW_AT_abstract_origin))
! /* ???  In LTO all origin DIEs still refer to the early
!debug copy.  Detect that.  */
! && get_AT (c, DW_AT_inline))

...

!   /* "Unwrap" the decls DIE which we put in the imported unit context.
!   ???  If we finish dwarf2out_function_decl refactoring we can
! do this in a better way from the start and only lazily emit
! the early DIE references.  */


It seems like in gen_subprogram_die you deliberately avoid reusing the 
DIE from dwarf2out_register_external_die (since it doesn't have 
DW_AT_inline), and then in add_abstract_origin_attribute you need to 
look through that redundant die.  Why not reuse it?



! /* ???  In LTO we do not see any of the location attributes.  */
!  && ((DECL_ARTIFICIAL (decl) || in_lto_p)


Perhaps get_AT_ref (old_die, DW_AT_abstract_origin) instead of in_lto_p?

And you don't need the added parentheses here.


 if (parm_die && parm_die->die_parent != context_die)
{
! /* ???  The DIE parent is the "abstract" copy and the context_die
!is the specification "copy".  */
! if (!DECL_ABSTRACT_P (node) && !in_lto_p)


And a bit below in the current source,

  /* FIXME: Reuse DIE even with a differing context.   
   
 This can happen when calling  
 

Re: [PATCH][2/2] early LTO debug, main part

2017-07-04 Thread Richard Biener
On Tue, 20 Jun 2017, Richard Biener wrote:

> On Wed, 7 Jun 2017, Richard Biener wrote:
> 
> > On Fri, 19 May 2017, Richard Biener wrote:
> > 
> > > 
> > > This is a repost of the main part of the early LTO debug support.
> > > The only changes relative to the last post is in the dwarf2out.c
> > > pieces due to Jasons review and Jakubs introduction of
> > > DW_OP_GNU_variable_value.
> > > 
> > > I've also adjusted testcases for fallout (the asan backtraces do
> > > give files / line numbers because libbacktrace doesn't understand
> > > the DWARF) plus added a -flto run over the libstdc++ pretty printer
> > > testsuite -- after all the goal was to make those work with LTO,
> > > and they now nicely do.
> > > 
> > > [LTO-]bootstrapped and tested on x86_64-unknown-linux-gnu.
> > > 
> > > I've also tested with -flto -g and compared to before the patch and
> > > the outcome doesn't contain any surprises.
> > > 
> > > I've also ran the gdb testsuite with no differences (but I guess
> > > it doesn't exercise LTO).
> > > 
> > > I've also built SPEC 2k6 with -flto -g.
> > > 
> > > I've also debugged optimized LTO bootstrapped cc1 a bit - not that
> > > debugging (LTO) optimized cc1 is a pleasant experience, but at least
> > > gdb doesn't crash.
> > > 
> > > Ok for trunk?
> > 
> > Ping.
> 
> Ping^2.

Ping^3.

> > > Both darwin and mingw maintainers were not concerned about LTO with -g
> > > being broken for them.
> > > 
> > > This patch allows us to go forward with freeing more stuff after
> > > the frontend finished, in particular remove LTO streaming of a lot
> > > of type information that is referenced from trees (and, as a first
> > > step, enable free-lang-data for non-LTO compiles).
> > > 
> > > Thanks,
> > > Richard.
> > > 
> > > 2017-05-19  Richard Biener  
> > > 
> > > * debug.h (struct gcc_debug_hooks): Add die_ref_for_decl and
> > > register_external_die hooks.
> > > (debug_false_tree_charstarstar_uhwistar): Declare.
> > > (debug_nothing_tree_charstar_uhwi): Likewise.
> > > * debug.c (do_nothing_debug_hooks): Adjust.
> > > (debug_false_tree_charstarstar_uhwistar): New do nothing.
> > > (debug_nothing_tree_charstar_uhwi): Likewise.
> > > * dbxout.c (dbx_debug_hooks): Adjust.
> > > (xcoff_debug_hooks): Likewise.
> > > * sdbout.c (sdb_debug_hooks): Likewise.
> > > * vmsdbgout.c (vmsdbg_debug_hooks): Likewise.
> > > 
> > > * dwarf2out.c (macinfo_label_base): New global.
> > >   (dwarf2out_register_external_die): New function for the
> > >   register_external_die hook.
> > > (dwarf2out_die_ref_for_decl): Likewise for die_ref_for_decl.
> > > (dwarf2_debug_hooks): Use them.
> > > (dwarf2_lineno_debug_hooks): Adjust.
> > > (struct die_struct): Add with_offset flag.
> > > (DEBUG_LTO_DWO_INFO_SECTION, DEBUG_LTO_INFO_SECTION,
> > > DEBUG_LTO_DWO_ABBREV_SECTION, DEBUG_LTO_ABBREV_SECTION,
> > > DEBUG_LTO_DWO_MACINFO_SECTION, DEBUG_LTO_MACINFO_SECTION,
> > > DEBUG_LTO_DWO_MACRO_SECTION, DEBUG_LTO_MACRO_SECTION,
> > > DEBUG_LTO_LINE_SECTION, DEBUG_LTO_DWO_STR_OFFSETS_SECTION,
> > > DEBUG_LTO_STR_DWO_SECTION, DEBUG_STR_LTO_SECTION): New macros
> > > defining section names for the early LTO debug variants.
> > >   (reset_indirect_string): New helper.
> > > (add_AT_external_die_ref): Helper for 
> > > dwarf2out_register_external_die.
> > > (print_dw_val): Add support for offsetted symbol references.
> > > (compute_section_prefix_1): Split out worker to distinguish
> > > the comdat from the LTO case.
> > > (compute_section_prefix): Wrap old comdat case here.
> > > (output_die): Skip DIE symbol output for the LTO added one.
> > > Handle DIE symbol references with offset.
> > > (output_comp_unit): Guard section name mangling properly.
> > > For LTO debug sections emit a symbol at the section beginning
> > > which we use to refer to its DIEs.
> > > (add_abstract_origin_attribute): For DIEs registered via
> > > dwarf2out_register_external_die directly refer to the early
> > > DIE rather than indirectly through the shadow one we created.
> > > (gen_array_type_die): When generating early LTO debug do
> > > not emit DW_AT_string_length.
> > > (gen_formal_parameter_die): Do not re-create DIEs for PARM_DECLs
> > > late when in LTO.
> > > (gen_subprogram_die): Adjust the check for whether we face
> > > a concrete instance DIE for an inline we can reuse for the
> > > late LTO case.  Likewise avoid another specification DIE
> > > for early built declarations/definitions for the late LTO case.
> > > (gen_variable_die): Add type references for late duplicated VLA 
> > > dies
> > > when in late LTO.
> > > (gen_inlined_subroutine_die): Do not call 
> 

Re: [PATCH][2/2] early LTO debug, main part

2017-06-20 Thread Richard Biener
On Wed, 7 Jun 2017, Richard Biener wrote:

> On Fri, 19 May 2017, Richard Biener wrote:
> 
> > 
> > This is a repost of the main part of the early LTO debug support.
> > The only changes relative to the last post is in the dwarf2out.c
> > pieces due to Jasons review and Jakubs introduction of
> > DW_OP_GNU_variable_value.
> > 
> > I've also adjusted testcases for fallout (the asan backtraces do
> > give files / line numbers because libbacktrace doesn't understand
> > the DWARF) plus added a -flto run over the libstdc++ pretty printer
> > testsuite -- after all the goal was to make those work with LTO,
> > and they now nicely do.
> > 
> > [LTO-]bootstrapped and tested on x86_64-unknown-linux-gnu.
> > 
> > I've also tested with -flto -g and compared to before the patch and
> > the outcome doesn't contain any surprises.
> > 
> > I've also ran the gdb testsuite with no differences (but I guess
> > it doesn't exercise LTO).
> > 
> > I've also built SPEC 2k6 with -flto -g.
> > 
> > I've also debugged optimized LTO bootstrapped cc1 a bit - not that
> > debugging (LTO) optimized cc1 is a pleasant experience, but at least
> > gdb doesn't crash.
> > 
> > Ok for trunk?
> 
> Ping.

Ping^2.

> > Both darwin and mingw maintainers were not concerned about LTO with -g
> > being broken for them.
> > 
> > This patch allows us to go forward with freeing more stuff after
> > the frontend finished, in particular remove LTO streaming of a lot
> > of type information that is referenced from trees (and, as a first
> > step, enable free-lang-data for non-LTO compiles).
> > 
> > Thanks,
> > Richard.
> > 
> > 2017-05-19  Richard Biener  
> > 
> > * debug.h (struct gcc_debug_hooks): Add die_ref_for_decl and
> > register_external_die hooks.
> > (debug_false_tree_charstarstar_uhwistar): Declare.
> > (debug_nothing_tree_charstar_uhwi): Likewise.
> > * debug.c (do_nothing_debug_hooks): Adjust.
> > (debug_false_tree_charstarstar_uhwistar): New do nothing.
> > (debug_nothing_tree_charstar_uhwi): Likewise.
> > * dbxout.c (dbx_debug_hooks): Adjust.
> > (xcoff_debug_hooks): Likewise.
> > * sdbout.c (sdb_debug_hooks): Likewise.
> > * vmsdbgout.c (vmsdbg_debug_hooks): Likewise.
> > 
> > * dwarf2out.c (macinfo_label_base): New global.
> > (dwarf2out_register_external_die): New function for the
> > register_external_die hook.
> > (dwarf2out_die_ref_for_decl): Likewise for die_ref_for_decl.
> > (dwarf2_debug_hooks): Use them.
> > (dwarf2_lineno_debug_hooks): Adjust.
> > (struct die_struct): Add with_offset flag.
> > (DEBUG_LTO_DWO_INFO_SECTION, DEBUG_LTO_INFO_SECTION,
> > DEBUG_LTO_DWO_ABBREV_SECTION, DEBUG_LTO_ABBREV_SECTION,
> > DEBUG_LTO_DWO_MACINFO_SECTION, DEBUG_LTO_MACINFO_SECTION,
> > DEBUG_LTO_DWO_MACRO_SECTION, DEBUG_LTO_MACRO_SECTION,
> > DEBUG_LTO_LINE_SECTION, DEBUG_LTO_DWO_STR_OFFSETS_SECTION,
> > DEBUG_LTO_STR_DWO_SECTION, DEBUG_STR_LTO_SECTION): New macros
> > defining section names for the early LTO debug variants.
> > (reset_indirect_string): New helper.
> > (add_AT_external_die_ref): Helper for 
> > dwarf2out_register_external_die.
> > (print_dw_val): Add support for offsetted symbol references.
> > (compute_section_prefix_1): Split out worker to distinguish
> > the comdat from the LTO case.
> > (compute_section_prefix): Wrap old comdat case here.
> > (output_die): Skip DIE symbol output for the LTO added one.
> > Handle DIE symbol references with offset.
> > (output_comp_unit): Guard section name mangling properly.
> > For LTO debug sections emit a symbol at the section beginning
> > which we use to refer to its DIEs.
> > (add_abstract_origin_attribute): For DIEs registered via
> > dwarf2out_register_external_die directly refer to the early
> > DIE rather than indirectly through the shadow one we created.
> > (gen_array_type_die): When generating early LTO debug do
> > not emit DW_AT_string_length.
> > (gen_formal_parameter_die): Do not re-create DIEs for PARM_DECLs
> > late when in LTO.
> > (gen_subprogram_die): Adjust the check for whether we face
> > a concrete instance DIE for an inline we can reuse for the
> > late LTO case.  Likewise avoid another specification DIE
> > for early built declarations/definitions for the late LTO case.
> > (gen_variable_die): Add type references for late duplicated VLA dies
> > when in late LTO.
> > (gen_inlined_subroutine_die): Do not call 
> > dwarf2out_abstract_function,
> > we have the abstract instance already.
> > (process_scope_var): Adjust decl DIE contexts in LTO which
> > first puts them in limbo.
> > (gen_decl_die): Do not generate type DIEs late 

Re: [PATCH][2/2] early LTO debug, main part

2017-06-07 Thread Richard Biener
On Fri, 19 May 2017, Richard Biener wrote:

> 
> This is a repost of the main part of the early LTO debug support.
> The only changes relative to the last post is in the dwarf2out.c
> pieces due to Jasons review and Jakubs introduction of
> DW_OP_GNU_variable_value.
> 
> I've also adjusted testcases for fallout (the asan backtraces do
> give files / line numbers because libbacktrace doesn't understand
> the DWARF) plus added a -flto run over the libstdc++ pretty printer
> testsuite -- after all the goal was to make those work with LTO,
> and they now nicely do.
> 
> [LTO-]bootstrapped and tested on x86_64-unknown-linux-gnu.
> 
> I've also tested with -flto -g and compared to before the patch and
> the outcome doesn't contain any surprises.
> 
> I've also ran the gdb testsuite with no differences (but I guess
> it doesn't exercise LTO).
> 
> I've also built SPEC 2k6 with -flto -g.
> 
> I've also debugged optimized LTO bootstrapped cc1 a bit - not that
> debugging (LTO) optimized cc1 is a pleasant experience, but at least
> gdb doesn't crash.
> 
> Ok for trunk?

Ping.

> Both darwin and mingw maintainers were not concerned about LTO with -g
> being broken for them.
> 
> This patch allows us to go forward with freeing more stuff after
> the frontend finished, in particular remove LTO streaming of a lot
> of type information that is referenced from trees (and, as a first
> step, enable free-lang-data for non-LTO compiles).
> 
> Thanks,
> Richard.
> 
> 2017-05-19  Richard Biener  
> 
> * debug.h (struct gcc_debug_hooks): Add die_ref_for_decl and
> register_external_die hooks.
> (debug_false_tree_charstarstar_uhwistar): Declare.
> (debug_nothing_tree_charstar_uhwi): Likewise.
> * debug.c (do_nothing_debug_hooks): Adjust.
> (debug_false_tree_charstarstar_uhwistar): New do nothing.
> (debug_nothing_tree_charstar_uhwi): Likewise.
> * dbxout.c (dbx_debug_hooks): Adjust.
> (xcoff_debug_hooks): Likewise.
> * sdbout.c (sdb_debug_hooks): Likewise.
> * vmsdbgout.c (vmsdbg_debug_hooks): Likewise.
> 
> * dwarf2out.c (macinfo_label_base): New global.
>   (dwarf2out_register_external_die): New function for the
>   register_external_die hook.
> (dwarf2out_die_ref_for_decl): Likewise for die_ref_for_decl.
> (dwarf2_debug_hooks): Use them.
> (dwarf2_lineno_debug_hooks): Adjust.
> (struct die_struct): Add with_offset flag.
> (DEBUG_LTO_DWO_INFO_SECTION, DEBUG_LTO_INFO_SECTION,
> DEBUG_LTO_DWO_ABBREV_SECTION, DEBUG_LTO_ABBREV_SECTION,
> DEBUG_LTO_DWO_MACINFO_SECTION, DEBUG_LTO_MACINFO_SECTION,
> DEBUG_LTO_DWO_MACRO_SECTION, DEBUG_LTO_MACRO_SECTION,
> DEBUG_LTO_LINE_SECTION, DEBUG_LTO_DWO_STR_OFFSETS_SECTION,
> DEBUG_LTO_STR_DWO_SECTION, DEBUG_STR_LTO_SECTION): New macros
> defining section names for the early LTO debug variants.
>   (reset_indirect_string): New helper.
> (add_AT_external_die_ref): Helper for dwarf2out_register_external_die.
> (print_dw_val): Add support for offsetted symbol references.
> (compute_section_prefix_1): Split out worker to distinguish
> the comdat from the LTO case.
> (compute_section_prefix): Wrap old comdat case here.
> (output_die): Skip DIE symbol output for the LTO added one.
> Handle DIE symbol references with offset.
> (output_comp_unit): Guard section name mangling properly.
> For LTO debug sections emit a symbol at the section beginning
> which we use to refer to its DIEs.
> (add_abstract_origin_attribute): For DIEs registered via
> dwarf2out_register_external_die directly refer to the early
> DIE rather than indirectly through the shadow one we created.
> (gen_array_type_die): When generating early LTO debug do
> not emit DW_AT_string_length.
> (gen_formal_parameter_die): Do not re-create DIEs for PARM_DECLs
> late when in LTO.
> (gen_subprogram_die): Adjust the check for whether we face
> a concrete instance DIE for an inline we can reuse for the
> late LTO case.  Likewise avoid another specification DIE
> for early built declarations/definitions for the late LTO case.
> (gen_variable_die): Add type references for late duplicated VLA dies
> when in late LTO.
> (gen_inlined_subroutine_die): Do not call dwarf2out_abstract_function,
> we have the abstract instance already.
> (process_scope_var): Adjust decl DIE contexts in LTO which
> first puts them in limbo.
> (gen_decl_die): Do not generate type DIEs late apart from
> types for VLAs or for decls we do not yet have a DIE.
> (dwarf2out_early_global_decl): Make sure to create DIEs
> for abstract instances of a decl first.
> (dwarf2out_late_global_decl): Adjust comment.
> 

[PATCH][2/2] early LTO debug, main part

2017-05-19 Thread Richard Biener

This is a repost of the main part of the early LTO debug support.
The only changes relative to the last post is in the dwarf2out.c
pieces due to Jasons review and Jakubs introduction of
DW_OP_GNU_variable_value.

I've also adjusted testcases for fallout (the asan backtraces do
give files / line numbers because libbacktrace doesn't understand
the DWARF) plus added a -flto run over the libstdc++ pretty printer
testsuite -- after all the goal was to make those work with LTO,
and they now nicely do.

[LTO-]bootstrapped and tested on x86_64-unknown-linux-gnu.

I've also tested with -flto -g and compared to before the patch and
the outcome doesn't contain any surprises.

I've also ran the gdb testsuite with no differences (but I guess
it doesn't exercise LTO).

I've also built SPEC 2k6 with -flto -g.

I've also debugged optimized LTO bootstrapped cc1 a bit - not that
debugging (LTO) optimized cc1 is a pleasant experience, but at least
gdb doesn't crash.

Ok for trunk?

Both darwin and mingw maintainers were not concerned about LTO with -g
being broken for them.

This patch allows us to go forward with freeing more stuff after
the frontend finished, in particular remove LTO streaming of a lot
of type information that is referenced from trees (and, as a first
step, enable free-lang-data for non-LTO compiles).

Thanks,
Richard.

2017-05-19  Richard Biener  

* debug.h (struct gcc_debug_hooks): Add die_ref_for_decl and
register_external_die hooks.
(debug_false_tree_charstarstar_uhwistar): Declare.
(debug_nothing_tree_charstar_uhwi): Likewise.
* debug.c (do_nothing_debug_hooks): Adjust.
(debug_false_tree_charstarstar_uhwistar): New do nothing.
(debug_nothing_tree_charstar_uhwi): Likewise.
* dbxout.c (dbx_debug_hooks): Adjust.
(xcoff_debug_hooks): Likewise.
* sdbout.c (sdb_debug_hooks): Likewise.
* vmsdbgout.c (vmsdbg_debug_hooks): Likewise.

* dwarf2out.c (macinfo_label_base): New global.
(dwarf2out_register_external_die): New function for the
register_external_die hook.
(dwarf2out_die_ref_for_decl): Likewise for die_ref_for_decl.
(dwarf2_debug_hooks): Use them.
(dwarf2_lineno_debug_hooks): Adjust.
(struct die_struct): Add with_offset flag.
(DEBUG_LTO_DWO_INFO_SECTION, DEBUG_LTO_INFO_SECTION,
DEBUG_LTO_DWO_ABBREV_SECTION, DEBUG_LTO_ABBREV_SECTION,
DEBUG_LTO_DWO_MACINFO_SECTION, DEBUG_LTO_MACINFO_SECTION,
DEBUG_LTO_DWO_MACRO_SECTION, DEBUG_LTO_MACRO_SECTION,
DEBUG_LTO_LINE_SECTION, DEBUG_LTO_DWO_STR_OFFSETS_SECTION,
DEBUG_LTO_STR_DWO_SECTION, DEBUG_STR_LTO_SECTION): New macros
defining section names for the early LTO debug variants.
(reset_indirect_string): New helper.
(add_AT_external_die_ref): Helper for dwarf2out_register_external_die.
(print_dw_val): Add support for offsetted symbol references.
(compute_section_prefix_1): Split out worker to distinguish
the comdat from the LTO case.
(compute_section_prefix): Wrap old comdat case here.
(output_die): Skip DIE symbol output for the LTO added one.
Handle DIE symbol references with offset.
(output_comp_unit): Guard section name mangling properly.
For LTO debug sections emit a symbol at the section beginning
which we use to refer to its DIEs.
(add_abstract_origin_attribute): For DIEs registered via
dwarf2out_register_external_die directly refer to the early
DIE rather than indirectly through the shadow one we created.
(gen_array_type_die): When generating early LTO debug do
not emit DW_AT_string_length.
(gen_formal_parameter_die): Do not re-create DIEs for PARM_DECLs
late when in LTO.
(gen_subprogram_die): Adjust the check for whether we face
a concrete instance DIE for an inline we can reuse for the
late LTO case.  Likewise avoid another specification DIE
for early built declarations/definitions for the late LTO case.
(gen_variable_die): Add type references for late duplicated VLA dies
when in late LTO.
(gen_inlined_subroutine_die): Do not call dwarf2out_abstract_function,
we have the abstract instance already.
(process_scope_var): Adjust decl DIE contexts in LTO which
first puts them in limbo.
(gen_decl_die): Do not generate type DIEs late apart from
types for VLAs or for decls we do not yet have a DIE.
(dwarf2out_early_global_decl): Make sure to create DIEs
for abstract instances of a decl first.
(dwarf2out_late_global_decl): Adjust comment.
(output_macinfo_op): With multiple macro sections use
macinfo_label_base to distinguish labels.
(output_macinfo): Likewise.  Update macinfo_label_base.
Pass in the line info label.
(note_variable_value_in_expr): 

Re: [PING][PATCH][2/2] Early LTO debug -- main part

2017-05-19 Thread Richard Biener
Late response now that I'm finished refreshing the patches.

On Mon, Nov 28, 2016 at 6:20 PM, Jason Merrill  wrote:
> On Thu, Nov 24, 2016 at 8:50 AM, Richard Biener  wrote:
>>> > +  /* ???  We can't annotate types late, but for LTO we may not
>>> > +generate a location early either (gfortran.dg/save_5.f90).
>>> > +The proper way is to handle it like VLAs though it is told
>>> > +that DW_AT_string_length does not support this.  */
>>>
>>> I think go ahead and handle it like VLAs, this is an obvious generalization
>>> and should go into the spec soon enough.  This can happen later.
>>
>> Ok, note that VLAs are now handled by re-emitting types late to avoid
>> some guality regressions.  With inlining VLA types also get copied
>> so we'd need to re-design how we handle them a bit.
>> I'll see what the DWARF people come up with.
>
> Does the discussion in
> https://sourceware.org/bugzilla/show_bug.cgi?id=20426 cover the issue?

This covers the VLA issue, yes.  With the DW_OP_GNU_variable_value extension
we might be able to handle those better though gdb still lacks support.

For the Fortran case quoted above it might be possible to use
DW_OP_GNU_variable_value
as well but I'll leave that for followup improvements (handling it
"like VLAs" without
this extension isn't possible Jakub told me).

I've removed the reference to VLAs in the comment, added a -flto -g variant of
save_5.f90 to the testsuite and refer to that.

>
>>> > + /* ???  This all (and above) should probably be simply
>>> > +a ! early_dwarf check somehow.  */
>>> > +  && ((DECL_ARTIFICIAL (decl) || in_lto_p)
>>> >|| (get_AT_file (old_die, DW_AT_decl_file) == file_index
>>> >&& (get_AT_unsigned (old_die, DW_AT_decl_line)
>>> >== (unsigned) s.line
>>>
>>> Why doesn't the existing source position check handle the LTO case? Also the
>>> extra parens aren't necessary.
>>
>> Because in LTRANS we do not see those attributes anymore but they are
>> present in the early created DIEs.
>
> Ah, OK.  But the comment seems wrong, since we go through here in
> early dwarf for local class methods.

Changed the comment to

/* ???  In LTO we do not see any of the location attributes.  */

>>> > +init_sections_and_labels (bool early_lto_debug)
>>>
>>> You're changing this function to do the same thing in four slightly 
>>> different
>>> ways rather than two.  I'd rather control each piece as appropriate; we 
>>> ought
>>> to make SECTION_DEBUG or SECTION_DEBUG|SECTION_EXCLUDE a local variable, and
>>> select between *_SECTION and the DWO variant at each statement rather than 
>>> in
>>> different blocks.
>>
>> Note that the section names change between LTO, LTO_DWO, DWO and
>> regular section names.  It's basically modeled after what we have now
>> which switches between regular and DWO section names.  We might
>> be able to refactor this with a new array
>>
>> enum section_kind { NORMAL, DWO, LTO, LTO_DWO };
>> char **section_names[section_kind][] = { { DEBUG_INFO_SECTION, ... },
>> { DEBUG_DWO_INFO_SECTION, ... },
>> { DEBUG_LTO_INFO_SECTION, ... },
>> { DEBUG_LTO_DWO_INFO_SECTION, .. } };
>>
>> would you prefer that?
>
> That sounds better, thanks.

I tried a few variants but they all end up even more awkward ...

Given the ugliness is isolated in init_sections_and_labels I think
keeping it the
way it is is best.

Updated patches posted separately (I posted the diff to the previous
state already).

Thanks,
Richard.

>
> Jason


Re: [PING][PATCH][2/2] Early LTO debug -- main part

2016-11-28 Thread Jason Merrill
On Thu, Nov 24, 2016 at 8:50 AM, Richard Biener  wrote:
>> > +  /* ???  We can't annotate types late, but for LTO we may not
>> > +generate a location early either (gfortran.dg/save_5.f90).
>> > +The proper way is to handle it like VLAs though it is told
>> > +that DW_AT_string_length does not support this.  */
>>
>> I think go ahead and handle it like VLAs, this is an obvious generalization
>> and should go into the spec soon enough.  This can happen later.
>
> Ok, note that VLAs are now handled by re-emitting types late to avoid
> some guality regressions.  With inlining VLA types also get copied
> so we'd need to re-design how we handle them a bit.
> I'll see what the DWARF people come up with.

Does the discussion in
https://sourceware.org/bugzilla/show_bug.cgi?id=20426 cover the issue?

>> > + /* ???  This all (and above) should probably be simply
>> > +a ! early_dwarf check somehow.  */
>> > +  && ((DECL_ARTIFICIAL (decl) || in_lto_p)
>> >|| (get_AT_file (old_die, DW_AT_decl_file) == file_index
>> >&& (get_AT_unsigned (old_die, DW_AT_decl_line)
>> >== (unsigned) s.line
>>
>> Why doesn't the existing source position check handle the LTO case? Also the
>> extra parens aren't necessary.
>
> Because in LTRANS we do not see those attributes anymore but they are
> present in the early created DIEs.

Ah, OK.  But the comment seems wrong, since we go through here in
early dwarf for local class methods.

>> > +init_sections_and_labels (bool early_lto_debug)
>>
>> You're changing this function to do the same thing in four slightly different
>> ways rather than two.  I'd rather control each piece as appropriate; we ought
>> to make SECTION_DEBUG or SECTION_DEBUG|SECTION_EXCLUDE a local variable, and
>> select between *_SECTION and the DWO variant at each statement rather than in
>> different blocks.
>
> Note that the section names change between LTO, LTO_DWO, DWO and
> regular section names.  It's basically modeled after what we have now
> which switches between regular and DWO section names.  We might
> be able to refactor this with a new array
>
> enum section_kind { NORMAL, DWO, LTO, LTO_DWO };
> char **section_names[section_kind][] = { { DEBUG_INFO_SECTION, ... },
> { DEBUG_DWO_INFO_SECTION, ... },
> { DEBUG_LTO_INFO_SECTION, ... },
> { DEBUG_LTO_DWO_INFO_SECTION, .. } };
>
> would you prefer that?

That sounds better, thanks.

Jason


Re: [PING][PATCH][2/2] Early LTO debug -- main part

2016-11-24 Thread Richard Biener
On Thu, 24 Nov 2016, Richard Biener wrote:

> On Tue, 22 Nov 2016, Jason Merrill wrote:
> 
> > On 11/11/2016 03:06 AM, Richard Biener wrote:
> > > +/* ???  In some cases the C++ FE (at least) fails to
> > > +   set DECL_CONTEXT properly.  Simply globalize stuff
> > > +   in this case.  For example
> > > +   __dso_handle created via iostream line 74 col 25.  */
> > 
> > The comment for DECL_CONTEXT says that a VAR_DECL can have 'NULL_TREE or a
> > TRANSLATION_UNIT_DECL if the given decl has "file scope"'
> > 
> > So this doesn't seem like a FE bug.
> 
> True - though with LTO we rely on all entities be associated with
> a TRANSLATION_UNIT_DECL (well, "rely" only in terms of how debuginfo
> is emitted with or without this patch).  It should be easy to fix this
> up in the LTO streamer though.
> 
> > > +   /* ???  We cannot unconditionally output die_offset if
> > > +  non-zero - at least -feliminate-dwarf2-dups will
> > > +  create references to those DIEs via symbols.  And we
> > > +  do not clear its DIE offset after outputting it
> > > +  (and the label refers to the actual DIEs, not the
> > > +  DWARF CU unit header which is when using label + offset
> > > +  would be the correct thing to do).
> > 
> > I'd be happy to remove or disable -feliminate-dwarf2-dups at this point, 
> > since
> > it's already useless for C++ without reimplementation.
> 
> Ok, I'd favor removal in that case, I'll see to that independently
> of this patch.
> 
> > > +  /* "Unwrap" the decls DIE which we put in the imported unit 
> > > context.
> > > +  ???  If we finish dwarf2out_function_decl refactoring we can
> > > +   do this in a better way from the start and only lazily emit
> > > +   the early DIE references.  */
> > 
> > Can you elaborate more on the refactoring?  dwarf2out_function_decl is 
> > already
> > very small, I'm guessing you mean gen_subprogram_die?
> 
> Yes, refactor gen_subprogram_die into the early part and the part needed
> by dwarf2out_function_decl.
> 
> > > +  /* ???  We can't annotate types late, but for LTO we may not
> > > +  generate a location early either (gfortran.dg/save_5.f90).
> > > +  The proper way is to handle it like VLAs though it is told
> > > +  that DW_AT_string_length does not support this.  */
> > 
> > I think go ahead and handle it like VLAs, this is an obvious generalization
> > and should go into the spec soon enough.  This can happen later.
> 
> Ok, note that VLAs are now handled by re-emitting types late to avoid
> some guality regressions.  With inlining VLA types also get copied
> so we'd need to re-design how we handle them a bit.  I'll see what
> the DWARF people come up with.
> 
> > > +   /* ???  This all (and above) should probably be simply
> > > +  a ! early_dwarf check somehow.  */
> > > +&& ((DECL_ARTIFICIAL (decl) || in_lto_p)
> > >  || (get_AT_file (old_die, DW_AT_decl_file) == file_index
> > >  && (get_AT_unsigned (old_die, DW_AT_decl_line)
> > >  == (unsigned) s.line
> > 
> > Why doesn't the existing source position check handle the LTO case? Also the
> > extra parens aren't necessary.
> 
> Because in LTRANS we do not see those attributes anymore but they are
> present in the early created DIEs.  The LTRANS old_die looks basically 
> like
> 
>DW_TAG_subprogram
>  DW_AT_abstract_origin : 
> 
> refactoring gen_subprogram might also help here (I tried this three
> times alrady but it quickly becomes unwieldly).
> 
> > >/* If we're emitting an out-of-line copy of an inline function,
> > >emit info for the abstract instance and set up to refer to it.  */
> > > +  /* ???  We have output an abstract instance early already and
> > > + could just re-use that.  This is how LTO treats all functions
> > > +  for example.  */
> > 
> > Isn't this what you do now?
> 
> Yes.  dwarf2out_abstract_function only sets DW_AT_inline after the patch.
> I'll adjust the comment to
> 
>   /* If we're emitting a possibly inlined function emit it as
>  abstract instance.  */
> 
> > 
> > > +  /* Avoid generating stray type DIEs during late dwarf dumping.
> > > + All types have been dumped early.  */
> > > +  if (! (decl ? lookup_decl_die (decl) : NULL)
> > 
> > Why do you still want to gen_type_die if decl_or_origin is origin?
> 
> Probably an oversight on my side -- will change.
> 
> > > +init_sections_and_labels (bool early_lto_debug)
> > 
> > You're changing this function to do the same thing in four slightly 
> > different
> > ways rather than two.  I'd rather control each piece as appropriate; we 
> > ought
> > to make SECTION_DEBUG or SECTION_DEBUG|SECTION_EXCLUDE a local variable, and
> > select between *_SECTION and the DWO variant at each statement rather than 
> > in
> > different blocks.
> 
> Note that the section names change between LTO, LTO_DWO, DWO and 
> regular 

Re: [PING][PATCH][2/2] Early LTO debug -- main part

2016-11-24 Thread Richard Biener
On Tue, 22 Nov 2016, Jason Merrill wrote:

> On 11/11/2016 03:06 AM, Richard Biener wrote:
> > +/* ???  In some cases the C++ FE (at least) fails to
> > +   set DECL_CONTEXT properly.  Simply globalize stuff
> > +   in this case.  For example
> > +   __dso_handle created via iostream line 74 col 25.  */
> 
> The comment for DECL_CONTEXT says that a VAR_DECL can have 'NULL_TREE or a
> TRANSLATION_UNIT_DECL if the given decl has "file scope"'
> 
> So this doesn't seem like a FE bug.

True - though with LTO we rely on all entities be associated with
a TRANSLATION_UNIT_DECL (well, "rely" only in terms of how debuginfo
is emitted with or without this patch).  It should be easy to fix this
up in the LTO streamer though.

> > + /* ???  We cannot unconditionally output die_offset if
> > +non-zero - at least -feliminate-dwarf2-dups will
> > +create references to those DIEs via symbols.  And we
> > +do not clear its DIE offset after outputting it
> > +(and the label refers to the actual DIEs, not the
> > +DWARF CU unit header which is when using label + offset
> > +would be the correct thing to do).
> 
> I'd be happy to remove or disable -feliminate-dwarf2-dups at this point, since
> it's already useless for C++ without reimplementation.

Ok, I'd favor removal in that case, I'll see to that independently
of this patch.

> > +  /* "Unwrap" the decls DIE which we put in the imported unit context.
> > +  ???  If we finish dwarf2out_function_decl refactoring we can
> > + do this in a better way from the start and only lazily emit
> > + the early DIE references.  */
> 
> Can you elaborate more on the refactoring?  dwarf2out_function_decl is already
> very small, I'm guessing you mean gen_subprogram_die?

Yes, refactor gen_subprogram_die into the early part and the part needed
by dwarf2out_function_decl.

> > +  /* ???  We can't annotate types late, but for LTO we may not
> > +generate a location early either (gfortran.dg/save_5.f90).
> > +The proper way is to handle it like VLAs though it is told
> > +that DW_AT_string_length does not support this.  */
> 
> I think go ahead and handle it like VLAs, this is an obvious generalization
> and should go into the spec soon enough.  This can happen later.

Ok, note that VLAs are now handled by re-emitting types late to avoid
some guality regressions.  With inlining VLA types also get copied
so we'd need to re-design how we handle them a bit.  I'll see what
the DWARF people come up with.

> > + /* ???  This all (and above) should probably be simply
> > +a ! early_dwarf check somehow.  */
> > +  && ((DECL_ARTIFICIAL (decl) || in_lto_p)
> >|| (get_AT_file (old_die, DW_AT_decl_file) == file_index
> >&& (get_AT_unsigned (old_die, DW_AT_decl_line)
> >== (unsigned) s.line
> 
> Why doesn't the existing source position check handle the LTO case? Also the
> extra parens aren't necessary.

Because in LTRANS we do not see those attributes anymore but they are
present in the early created DIEs.  The LTRANS old_die looks basically 
like

   DW_TAG_subprogram
 DW_AT_abstract_origin : 

refactoring gen_subprogram might also help here (I tried this three
times alrady but it quickly becomes unwieldly).

> >/* If we're emitting an out-of-line copy of an inline function,
> >  emit info for the abstract instance and set up to refer to it.  */
> > +  /* ???  We have output an abstract instance early already and
> > + could just re-use that.  This is how LTO treats all functions
> > +for example.  */
> 
> Isn't this what you do now?

Yes.  dwarf2out_abstract_function only sets DW_AT_inline after the patch.
I'll adjust the comment to

  /* If we're emitting a possibly inlined function emit it as
 abstract instance.  */

> 
> > +  /* Avoid generating stray type DIEs during late dwarf dumping.
> > + All types have been dumped early.  */
> > +  if (! (decl ? lookup_decl_die (decl) : NULL)
> 
> Why do you still want to gen_type_die if decl_or_origin is origin?

Probably an oversight on my side -- will change.

> > +init_sections_and_labels (bool early_lto_debug)
> 
> You're changing this function to do the same thing in four slightly different
> ways rather than two.  I'd rather control each piece as appropriate; we ought
> to make SECTION_DEBUG or SECTION_DEBUG|SECTION_EXCLUDE a local variable, and
> select between *_SECTION and the DWO variant at each statement rather than in
> different blocks.

Note that the section names change between LTO, LTO_DWO, DWO and 
regular section names.  It's basically modeled after what we have now
which switches between regular and DWO section names.  We might
be able to refactor this with a new array

enum section_kind { NORMAL, DWO, LTO, LTO_DWO };
char **section_names[section_kind][] = 

Re: [PING][PATCH][2/2] Early LTO debug -- main part

2016-11-22 Thread Jason Merrill

On 11/11/2016 03:06 AM, Richard Biener wrote:

+/* ???  In some cases the C++ FE (at least) fails to
+   set DECL_CONTEXT properly.  Simply globalize stuff
+   in this case.  For example
+   __dso_handle created via iostream line 74 col 25.  */


The comment for DECL_CONTEXT says that a VAR_DECL can have 'NULL_TREE or 
a TRANSLATION_UNIT_DECL if the given decl has "file scope"'


So this doesn't seem like a FE bug.


+ /* ???  We cannot unconditionally output die_offset if
+non-zero - at least -feliminate-dwarf2-dups will
+create references to those DIEs via symbols.  And we
+do not clear its DIE offset after outputting it
+(and the label refers to the actual DIEs, not the
+DWARF CU unit header which is when using label + offset
+would be the correct thing to do).


I'd be happy to remove or disable -feliminate-dwarf2-dups at this point, 
since it's already useless for C++ without reimplementation.



+  /* "Unwrap" the decls DIE which we put in the imported unit context.
+  ???  If we finish dwarf2out_function_decl refactoring we can
+ do this in a better way from the start and only lazily emit
+ the early DIE references.  */


Can you elaborate more on the refactoring?  dwarf2out_function_decl is 
already very small, I'm guessing you mean gen_subprogram_die?



+  /* ???  We can't annotate types late, but for LTO we may not
+generate a location early either (gfortran.dg/save_5.f90).
+The proper way is to handle it like VLAs though it is told
+that DW_AT_string_length does not support this.  */


I think go ahead and handle it like VLAs, this is an obvious 
generalization and should go into the spec soon enough.  This can happen 
later.



+ /* ???  This all (and above) should probably be simply
+a ! early_dwarf check somehow.  */
+  && ((DECL_ARTIFICIAL (decl) || in_lto_p)
   || (get_AT_file (old_die, DW_AT_decl_file) == file_index
   && (get_AT_unsigned (old_die, DW_AT_decl_line)
   == (unsigned) s.line


Why doesn't the existing source position check handle the LTO case? 
Also the extra parens aren't necessary.



   /* If we're emitting an out-of-line copy of an inline function,
 emit info for the abstract instance and set up to refer to it.  */
+  /* ???  We have output an abstract instance early already and
+ could just re-use that.  This is how LTO treats all functions
+for example.  */


Isn't this what you do now?


+  /* Avoid generating stray type DIEs during late dwarf dumping.
+ All types have been dumped early.  */
+  if (! (decl ? lookup_decl_die (decl) : NULL)


Why do you still want to gen_type_die if decl_or_origin is origin?


+init_sections_and_labels (bool early_lto_debug)


You're changing this function to do the same thing in four slightly 
different ways rather than two.  I'd rather control each piece as 
appropriate; we ought to make SECTION_DEBUG or 
SECTION_DEBUG|SECTION_EXCLUDE a local variable, and select between 
*_SECTION and the DWO variant at each statement rather than in different 
blocks.



+  /* Remove DW_AT_macro from the early output.  */
+  if (have_macinfo)
+   remove_AT (comp_unit_die (),
+  dwarf_strict ? DW_AT_macro_info : DW_AT_GNU_macros);


This will need adjustment for Jakub's DWARF 5 work.  Please make the 
choice of AT value a macro.



+  /* ???  Mostly duplicated from dwarf2out_finish.  */


:(

Jason



[PING][PATCH][2/2] Early LTO debug -- main part

2016-11-11 Thread Richard Biener
On Fri, 21 Oct 2016, Richard Biener wrote:

> 
> This is the main part of the early LTO debug support.  The main parts
> of the changes are to dwarf2out.c where most of the changes are related
> to the fact that we eventually have to output debug info twice, once
> for the early LTO part and once for the fat part of the object file.
> 
> Bootstrapped and tested on x86_64-unknown-linux-gnu with ASAN and TSAN
> extra FAILs (see PR78063, a libbacktrace missing feature or libsanitizer
> being too pessimistic).  There's an extra
> 
> XPASS: gcc.dg/guality/inline-params.c   -O2 -flto -fuse-linker-plugin 
> -fno-fat-lto-objects  execution test
> 
> the previously reported extra VLA guality FAILs are gone.
> 
> I've compared testresults with -flto -g added for all languages and
> only see expected differences (libstdc++ pretty printers now work,
> most scan-assembler-times debug testcases fail because we have everything
> twice now).
> 
> See https://gcc.gnu.org/ml/gcc-patches/2016-08/msg01842.html for
> the last posting of this patch which has a high-level overview of
> Early LTO debug.  You may want to refer to the slides I presented
> at the GNU Cauldron as well.

I have refreshed the patch after the DWARF5 changes, re-LTO-bootstrapped
and retested (also comparing -g -flto with/without the patch) with no
changes in results.  Patch [1/2] still applies without changes.

Thanks,
Richard.

2016-10-21  Richard Biener  

* debug.h (struct gcc_debug_hooks): Add die_ref_for_decl and
register_external_die hooks.
(debug_false_tree_charstarstar_uhwistar): Declare.
(debug_nothing_tree_charstar_uhwi): Likewise.
* debug.c (do_nothing_debug_hooks): Adjust.
(debug_false_tree_charstarstar_uhwistar): New do nothing.
(debug_nothing_tree_charstar_uhwi): Likewise.
* dbxout.c (dbx_debug_hooks): Adjust.
(xcoff_debug_hooks): Likewise.
* sdbout.c (sdb_debug_hooks): Likewise.
* vmsdbgout.c (vmsdbg_debug_hooks): Likewise.

* dwarf2out.c (macinfo_label_base): New global.
(dwarf2out_register_external_die): New function for the
register_external_die hook.
(dwarf2out_die_ref_for_decl): Likewise for die_ref_for_decl.
(dwarf2_debug_hooks): Use them.
(dwarf2_lineno_debug_hooks): Adjust.
(struct die_struct): Add with_offset flag.
(DEBUG_LTO_DWO_INFO_SECTION, DEBUG_LTO_INFO_SECTION,
DEBUG_LTO_DWO_ABBREV_SECTION, DEBUG_LTO_ABBREV_SECTION,
DEBUG_LTO_DWO_MACINFO_SECTION, DEBUG_LTO_MACINFO_SECTION,
DEBUG_LTO_DWO_MACRO_SECTION, DEBUG_LTO_MACRO_SECTION,
DEBUG_LTO_LINE_SECTION, DEBUG_LTO_DWO_STR_OFFSETS_SECTION,
DEBUG_LTO_STR_DWO_SECTION, DEBUG_STR_LTO_SECTION): New macros
defining section names for the early LTO debug variants.
(reset_indirect_string): New helper.
(add_AT_external_die_ref): Helper for dwarf2out_register_external_die.
(print_dw_val): Add support for offsetted symbol references.
(compute_section_prefix_1): Split out worker to distinguish
the comdat from the LTO case.
(compute_section_prefix): Wrap old comdat case here.
(output_die): Skip DIE symbol output for the LTO added one.
Handle DIE symbol references with offset.
(output_comp_unit): Guard section name mangling properly.
For LTO debug sections emit a symbol at the section beginning
which we use to refer to its DIEs.
(add_abstract_origin_attribute): For DIEs registered via
dwarf2out_register_external_die directly refer to the early
DIE rather than indirectly through the shadow one we created.
(gen_array_type_die): When generating early LTO debug do
not emit DW_AT_string_length.
(gen_formal_parameter_die): Do not re-create DIEs for PARM_DECLs
late when in LTO.
(gen_subprogram_die): Adjust the check for whether we face
a concrete instance DIE for an inline we can reuse for the
late LTO case.  Likewise avoid another specification DIE
for early built declarations/definitions for the late LTO case.
(gen_variable_die): Add type references for late duplicated VLA dies
when in late LTO.
(gen_inlined_subroutine_die): Do not call dwarf2out_abstract_function,
we have the abstract instance already.
(process_scope_var): Adjust decl DIE contexts in LTO which
first puts them in limbo.
(gen_decl_die): Do not generate type DIEs late apart from
types for VLAs or for decls we do not yet have a DIE.
(dwarf2out_early_global_decl): Make sure to create DIEs
for abstract instances of a decl first.
(dwarf2out_late_global_decl): Adjust comment.
(output_macinfo_op): With multiple macro sections use
macinfo_label_base to distinguish labels.
(output_macinfo): Likewise.  Update macinfo_label_base.
Pass in 

[PATCH][2/2] Early LTO debug -- main part

2016-10-21 Thread Richard Biener

This is the main part of the early LTO debug support.  The main parts
of the changes are to dwarf2out.c where most of the changes are related
to the fact that we eventually have to output debug info twice, once
for the early LTO part and once for the fat part of the object file.

Bootstrapped and tested on x86_64-unknown-linux-gnu with ASAN and TSAN
extra FAILs (see PR78063, a libbacktrace missing feature or libsanitizer
being too pessimistic).  There's an extra

XPASS: gcc.dg/guality/inline-params.c   -O2 -flto -fuse-linker-plugin 
-fno-fat-lto-objects  execution test

the previously reported extra VLA guality FAILs are gone.

I've compared testresults with -flto -g added for all languages and
only see expected differences (libstdc++ pretty printers now work,
most scan-assembler-times debug testcases fail because we have everything
twice now).

See https://gcc.gnu.org/ml/gcc-patches/2016-08/msg01842.html for
the last posting of this patch which has a high-level overview of
Early LTO debug.  You may want to refer to the slides I presented
at the GNU Cauldron as well.

Thanks,
Richard.

2016-10-21  Richard Biener  

* debug.h (struct gcc_debug_hooks): Add die_ref_for_decl and
register_external_die hooks.
(debug_false_tree_charstarstar_uhwistar): Declare.
(debug_nothing_tree_charstar_uhwi): Likewise.
* debug.c (do_nothing_debug_hooks): Adjust.
(debug_false_tree_charstarstar_uhwistar): New do nothing.
(debug_nothing_tree_charstar_uhwi): Likewise.
* dbxout.c (dbx_debug_hooks): Adjust.
(xcoff_debug_hooks): Likewise.
* sdbout.c (sdb_debug_hooks): Likewise.
* vmsdbgout.c (vmsdbg_debug_hooks): Likewise.

* dwarf2out.c (macinfo_label_base): New global.
(dwarf2out_register_external_die): New function for the
register_external_die hook.
(dwarf2out_die_ref_for_decl): Likewise for die_ref_for_decl.
(dwarf2_debug_hooks): Use them.
(dwarf2_lineno_debug_hooks): Adjust.
(struct die_struct): Add with_offset flag.
(DEBUG_LTO_DWO_INFO_SECTION, DEBUG_LTO_INFO_SECTION,
DEBUG_LTO_DWO_ABBREV_SECTION, DEBUG_LTO_ABBREV_SECTION,
DEBUG_LTO_DWO_MACINFO_SECTION, DEBUG_LTO_MACINFO_SECTION,
DEBUG_LTO_DWO_MACRO_SECTION, DEBUG_LTO_MACRO_SECTION,
DEBUG_LTO_LINE_SECTION, DEBUG_LTO_DWO_STR_OFFSETS_SECTION,
DEBUG_LTO_STR_DWO_SECTION, DEBUG_STR_LTO_SECTION): New macros
defining section names for the early LTO debug variants.
(reset_indirect_string): New helper.
(add_AT_external_die_ref): Helper for dwarf2out_register_external_die.
(print_dw_val): Add support for offsetted symbol references.
(compute_section_prefix_1): Split out worker to distinguish
the comdat from the LTO case.
(compute_section_prefix): Wrap old comdat case here.
(output_die): Skip DIE symbol output for the LTO added one.
Handle DIE symbol references with offset.
(output_comp_unit): Guard section name mangling properly.
For LTO debug sections emit a symbol at the section beginning
which we use to refer to its DIEs.
(add_abstract_origin_attribute): For DIEs registered via
dwarf2out_register_external_die directly refer to the early
DIE rather than indirectly through the shadow one we created.
(gen_array_type_die): When generating early LTO debug do
not emit DW_AT_string_length.
(gen_formal_parameter_die): Do not re-create DIEs for PARM_DECLs
late when in LTO.
(gen_subprogram_die): Adjust the check for whether we face
a concrete instance DIE for an inline we can reuse for the
late LTO case.  Likewise avoid another specification DIE
for early built declarations/definitions for the late LTO case.
(gen_variable_die): Add type references for late duplicated VLA dies
when in late LTO.
(gen_inlined_subroutine_die): Do not call dwarf2out_abstract_function,
we have the abstract instance already.
(process_scope_var): Adjust decl DIE contexts in LTO which
first puts them in limbo.
(gen_decl_die): Do not generate type DIEs late apart from
types for VLAs or for decls we do not yet have a DIE.
(dwarf2out_early_global_decl): Make sure to create DIEs
for abstract instances of a decl first.
(dwarf2out_late_global_decl): Adjust comment.
(output_macinfo_op): With multiple macro sections use
macinfo_label_base to distinguish labels.
(output_macinfo): Likewise.  Update macinfo_label_base.
Pass in the line info label.
(init_sections_and_labels): Add early LTO debug flag parameter
and generate different sections and names if set.  Add generation
counter for the labels so we can have multiple of them.
(reset_dies): Helper to allow DIEs to be output multiple times.