Workaround for a GDB bug for -flto -freorder-blocks-and-partition -g (PR debug/81155)

Message ID 20180112155227.GC2063@tucnak
State New
Headers show
Series
  • Workaround for a GDB bug for -flto -freorder-blocks-and-partition -g (PR debug/81155)
Related show

Commit Message

Jakub Jelinek Jan. 12, 2018, 3:52 p.m.
Hi!

The LTO debug changes create a DW_TAG_subprogram in main in one spot and
a small DW_TAG_subprogram that has DW_AT_abstract_origin to that +
DW_AT_ranges when doing hot/cold partitioning.  Unfortunately, it seems GDB
in that case doesn't read the DIE in the initial debug info read, as
read_partial_die only handles DW_AT_{low,high}_pc.

The following patch is an ugly workaround for that, I hope most of
real-world programs don't have most of the performance sensitive code
directly in main and so disabling hot/cold partitioning for main if in lto
might be acceptable.

Bootstrapped/regtested on x86_64-linux and i686-linux, fixes:
-FAIL: gcc.dg/guality/pr43051-1.c   -O2 -flto -fno-use-linker-plugin -flto-partition=none  line 34 c == &a[0]
-FAIL: gcc.dg/guality/pr43051-1.c   -O2 -flto -fno-use-linker-plugin -flto-partition=none  line 36 e == &a[1]
-FAIL: gcc.dg/guality/pr43051-1.c   -O2 -flto -fno-use-linker-plugin -flto-partition=none  line 39 c == &a[0]
-FAIL: gcc.dg/guality/pr43051-1.c   -O2 -flto -fno-use-linker-plugin -flto-partition=none  line 41 e == &a[1]
-FAIL: gcc.dg/guality/pr43051-1.c   -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects  line 34 c == &a[0]
-FAIL: gcc.dg/guality/pr43051-1.c   -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects  line 36 e == &a[1]
-FAIL: gcc.dg/guality/pr43051-1.c   -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects  line 39 c == &a[0]
-FAIL: gcc.dg/guality/pr43051-1.c   -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects  line 41 e == &a[1]
-FAIL: gcc.dg/guality/pr45882.c   -O2 -flto -fno-use-linker-plugin -flto-partition=none  line 16 b == 7
-FAIL: gcc.dg/guality/pr45882.c   -O2 -flto -fno-use-linker-plugin -flto-partition=none  line 16 c == 11
-FAIL: gcc.dg/guality/pr45882.c   -O2 -flto -fno-use-linker-plugin -flto-partition=none  line 16 d == 112
-FAIL: gcc.dg/guality/pr45882.c   -O2 -flto -fno-use-linker-plugin -flto-partition=none  line 16 e == 142
-FAIL: gcc.dg/guality/pr45882.c   -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects  line 16 b == 7
-FAIL: gcc.dg/guality/pr45882.c   -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects  line 16 c == 11
Ok for trunk?

2018-01-12  Jakub Jelinek  <jakub@redhat.com>

	PR debug/81155
	* bb-reorder.c (pass_partition_blocks::gate): In lto don't partition
	main to workaround a bug in GDB.


	Jakub

Comments

Richard Biener Jan. 12, 2018, 4:46 p.m. | #1
On January 12, 2018 4:52:27 PM GMT+01:00, Jakub Jelinek <jakub@redhat.com> wrote:
>Hi!
>
>The LTO debug changes create a DW_TAG_subprogram in main in one spot
>and
>a small DW_TAG_subprogram that has DW_AT_abstract_origin to that +
>DW_AT_ranges when doing hot/cold partitioning.  Unfortunately, it seems
>GDB
>in that case doesn't read the DIE in the initial debug info read, as
>read_partial_die only handles DW_AT_{low,high}_pc.
>
>The following patch is an ugly workaround for that, I hope most of
>real-world programs don't have most of the performance sensitive code
>directly in main and so disabling hot/cold partitioning for main if in
>lto
>might be acceptable.
>
>Bootstrapped/regtested on x86_64-linux and i686-linux, fixes:
>-FAIL: gcc.dg/guality/pr43051-1.c   -O2 -flto -fno-use-linker-plugin
>-flto-partition=none  line 34 c == &a[0]
>-FAIL: gcc.dg/guality/pr43051-1.c   -O2 -flto -fno-use-linker-plugin
>-flto-partition=none  line 36 e == &a[1]
>-FAIL: gcc.dg/guality/pr43051-1.c   -O2 -flto -fno-use-linker-plugin
>-flto-partition=none  line 39 c == &a[0]
>-FAIL: gcc.dg/guality/pr43051-1.c   -O2 -flto -fno-use-linker-plugin
>-flto-partition=none  line 41 e == &a[1]
>-FAIL: gcc.dg/guality/pr43051-1.c   -O2 -flto -fuse-linker-plugin
>-fno-fat-lto-objects  line 34 c == &a[0]
>-FAIL: gcc.dg/guality/pr43051-1.c   -O2 -flto -fuse-linker-plugin
>-fno-fat-lto-objects  line 36 e == &a[1]
>-FAIL: gcc.dg/guality/pr43051-1.c   -O2 -flto -fuse-linker-plugin
>-fno-fat-lto-objects  line 39 c == &a[0]
>-FAIL: gcc.dg/guality/pr43051-1.c   -O2 -flto -fuse-linker-plugin
>-fno-fat-lto-objects  line 41 e == &a[1]
>-FAIL: gcc.dg/guality/pr45882.c   -O2 -flto -fno-use-linker-plugin
>-flto-partition=none  line 16 b == 7
>-FAIL: gcc.dg/guality/pr45882.c   -O2 -flto -fno-use-linker-plugin
>-flto-partition=none  line 16 c == 11
>-FAIL: gcc.dg/guality/pr45882.c   -O2 -flto -fno-use-linker-plugin
>-flto-partition=none  line 16 d == 112
>-FAIL: gcc.dg/guality/pr45882.c   -O2 -flto -fno-use-linker-plugin
>-flto-partition=none  line 16 e == 142
>-FAIL: gcc.dg/guality/pr45882.c   -O2 -flto -fuse-linker-plugin
>-fno-fat-lto-objects  line 16 b == 7
>-FAIL: gcc.dg/guality/pr45882.c   -O2 -flto -fuse-linker-plugin
>-fno-fat-lto-objects  line 16 c == 11
>Ok for trunk?

OK. 

Hopefully this can be fixed in gdb for the upcoming release. 

Richard. 

>2018-01-12  Jakub Jelinek  <jakub@redhat.com>
>
>	PR debug/81155
>	* bb-reorder.c (pass_partition_blocks::gate): In lto don't partition
>	main to workaround a bug in GDB.
>
>--- gcc/bb-reorder.c.jj	2018-01-10 17:08:56.074912734 +0100
>+++ gcc/bb-reorder.c	2018-01-12 11:52:00.936332511 +0100
>@@ -2873,7 +2873,10 @@ pass_partition_blocks::gate (function *f
> 	     we are going to omit the reordering.  */
> 	  && optimize_function_for_speed_p (fun)
> 	  && !DECL_COMDAT_GROUP (current_function_decl)
>-	  && !lookup_attribute ("section", DECL_ATTRIBUTES (fun->decl)));
>+	  && !lookup_attribute ("section", DECL_ATTRIBUTES (fun->decl))
>+	  /* Workaround a bug in GDB where read_partial_die doesn't cope
>+	     with DIEs with DW_AT_ranges, see PR81115.  */
>+	  && !(in_lto_p && MAIN_NAME_P (DECL_NAME (fun->decl))));
> }
> 
> unsigned
>
>	Jakub

Patch

--- gcc/bb-reorder.c.jj	2018-01-10 17:08:56.074912734 +0100
+++ gcc/bb-reorder.c	2018-01-12 11:52:00.936332511 +0100
@@ -2873,7 +2873,10 @@  pass_partition_blocks::gate (function *f
 	     we are going to omit the reordering.  */
 	  && optimize_function_for_speed_p (fun)
 	  && !DECL_COMDAT_GROUP (current_function_decl)
-	  && !lookup_attribute ("section", DECL_ATTRIBUTES (fun->decl)));
+	  && !lookup_attribute ("section", DECL_ATTRIBUTES (fun->decl))
+	  /* Workaround a bug in GDB where read_partial_die doesn't cope
+	     with DIEs with DW_AT_ranges, see PR81115.  */
+	  && !(in_lto_p && MAIN_NAME_P (DECL_NAME (fun->decl))));
 }
 
 unsigned