diff mbox series

Fix PR lto/81351

Message ID 1548470.apyJlh6za3@polaris
State New
Headers show
Series Fix PR lto/81351 | expand

Commit Message

Eric Botcazou Nov. 10, 2017, 12:10 p.m. UTC
Hi,

this is the EH breakage introduced in LTO mode on non-(x86 or Linux):
  https://gcc.gnu.org/ml/gcc-patches/2017-11/msg00771.html

As Jan explained, in the end it's only a matter of recording whether at least 
one function needs a FDE for EH in the compilation unit and, if so, generating 
the EH frame at the end.  That's why a couple of patches to that effect are 
attached, first a cleanup with no functional changes[*] and second the fix.

[*] modulo the dwarf2out_do_cfi_asm hunk, which seems to be another bug fix.

Tested (lightly for now) on x86-64/Linux and SPARC/Solaris, OK for mainline?


2017-11-10  Eric Botcazou  <ebotcazou@adacore.com>

	PR lto/81351
	* debug.h (dwarf2out_do_eh_frame): Declare.
	* dwarf2cfi.c (dwarf2out_do_eh_frame): New predicate.
	(dwarf2out_do_frame): Use it.
	(dwarf2out_do_cfi_asm): Likewise.
	* dwarf2out.c (dwarf2out_frame_finish): Likewise.
	(dwarf2out_assembly_start): Likewise.
	(dwarf2out_begin_prologue): Fix comment.
	* toplev.c (compile_file): Always call dwarf2out_frame_finish
	if the target needs either debug or unwind DWARF2 info.
	* lto-opts.c (lto_write_options): Do not save -fexceptions,
	-fnon-call-exceptions, -ffp-contract, -fmath-errno, -fsigned-zeros,
	-ftrapping-math, -ftrapv and -fwrapv.

	PR lto/81351
	* dwarf2out.c (do_eh_frame): New static variable.
	(dwarf2out_begin_prologue): Set it.
	(dwarf2out_frame_finish): Test it instead of dwarf2out_do_eh_frame.

Comments

Eric Botcazou Nov. 13, 2017, 12:20 p.m. UTC | #1
> 2017-11-10  Eric Botcazou  <ebotcazou@adacore.com>
> 
> 	PR lto/81351
> 	* debug.h (dwarf2out_do_eh_frame): Declare.
> 	* dwarf2cfi.c (dwarf2out_do_eh_frame): New predicate.
> 	(dwarf2out_do_frame): Use it.
> 	(dwarf2out_do_cfi_asm): Likewise.
> 	* dwarf2out.c (dwarf2out_frame_finish): Likewise.
> 	(dwarf2out_assembly_start): Likewise.
> 	(dwarf2out_begin_prologue): Fix comment.
> 	* toplev.c (compile_file): Always call dwarf2out_frame_finish
> 	if the target needs either debug or unwind DWARF2 info.
> 	* lto-opts.c (lto_write_options): Do not save -fexceptions,
> 	-fnon-call-exceptions, -ffp-contract, -fmath-errno, -fsigned-zeros,
> 	-ftrapping-math, -ftrapv and -fwrapv.
> 
> 	PR lto/81351
> 	* dwarf2out.c (do_eh_frame): New static variable.
> 	(dwarf2out_begin_prologue): Set it.
> 	(dwarf2out_frame_finish): Test it instead of dwarf2out_do_eh_frame.

Now bootstrapped/regtested on x86-64/Linux, SPARC64/Linux and SPARC/Solaris.
Jan Hubicka Nov. 13, 2017, 2:11 p.m. UTC | #2
> > 2017-11-10  Eric Botcazou  <ebotcazou@adacore.com>
> > 
> > 	PR lto/81351
> > 	* debug.h (dwarf2out_do_eh_frame): Declare.
> > 	* dwarf2cfi.c (dwarf2out_do_eh_frame): New predicate.
> > 	(dwarf2out_do_frame): Use it.
> > 	(dwarf2out_do_cfi_asm): Likewise.
> > 	* dwarf2out.c (dwarf2out_frame_finish): Likewise.
> > 	(dwarf2out_assembly_start): Likewise.
> > 	(dwarf2out_begin_prologue): Fix comment.
> > 	* toplev.c (compile_file): Always call dwarf2out_frame_finish
> > 	if the target needs either debug or unwind DWARF2 info.
> > 	* lto-opts.c (lto_write_options): Do not save -fexceptions,
> > 	-fnon-call-exceptions, -ffp-contract, -fmath-errno, -fsigned-zeros,
> > 	-ftrapping-math, -ftrapv and -fwrapv.
> > 
> > 	PR lto/81351
> > 	* dwarf2out.c (do_eh_frame): New static variable.
> > 	(dwarf2out_begin_prologue): Set it.
> > 	(dwarf2out_frame_finish): Test it instead of dwarf2out_do_eh_frame.
> 
> Now bootstrapped/regtested on x86-64/Linux, SPARC64/Linux and SPARC/Solaris.

Thank you for updating the patch!  It looks good to me, but I can't approve it.

Honza
> 
> -- 
> Eric Botcazou
Richard Biener Nov. 13, 2017, 2:19 p.m. UTC | #3
On Mon, Nov 13, 2017 at 3:11 PM, Jan Hubicka <hubicka@ucw.cz> wrote:
>> > 2017-11-10  Eric Botcazou  <ebotcazou@adacore.com>
>> >
>> >     PR lto/81351
>> >     * debug.h (dwarf2out_do_eh_frame): Declare.
>> >     * dwarf2cfi.c (dwarf2out_do_eh_frame): New predicate.
>> >     (dwarf2out_do_frame): Use it.
>> >     (dwarf2out_do_cfi_asm): Likewise.
>> >     * dwarf2out.c (dwarf2out_frame_finish): Likewise.
>> >     (dwarf2out_assembly_start): Likewise.
>> >     (dwarf2out_begin_prologue): Fix comment.
>> >     * toplev.c (compile_file): Always call dwarf2out_frame_finish
>> >     if the target needs either debug or unwind DWARF2 info.
>> >     * lto-opts.c (lto_write_options): Do not save -fexceptions,
>> >     -fnon-call-exceptions, -ffp-contract, -fmath-errno, -fsigned-zeros,
>> >     -ftrapping-math, -ftrapv and -fwrapv.
>> >
>> >     PR lto/81351
>> >     * dwarf2out.c (do_eh_frame): New static variable.
>> >     (dwarf2out_begin_prologue): Set it.
>> >     (dwarf2out_frame_finish): Test it instead of dwarf2out_do_eh_frame.
>>
>> Now bootstrapped/regtested on x86-64/Linux, SPARC64/Linux and SPARC/Solaris.
>
> Thank you for updating the patch!  It looks good to me, but I can't approve it.

Ok.

Richard.

> Honza
>>
>> --
>> Eric Botcazou
diff mbox series

Patch

--- dwarf2out.c.0	2017-11-10 13:02:25.103559148 +0100
+++ dwarf2out.c	2017-11-10 13:06:14.427951051 +0100
@@ -284,6 +284,9 @@  static void dwarf2out_note_section_used
    personality CFI.  */
 static GTY(()) rtx current_unit_personality;
 
+/* Whether an eh_frame section is required.  */
+static GTY(()) bool do_eh_frame = false;
+
 /* .debug_rnglists next index.  */
 static unsigned int rnglist_idx;
 
@@ -1063,6 +1066,10 @@  dwarf2out_begin_prologue (unsigned int l
   if (!do_frame)
     return;
 
+  /* Unlike the debug version, the EH version of frame unwind info is a per-
+     function setting so we need to record whether we need it for the unit.  */
+  do_eh_frame |= dwarf2out_do_eh_frame ();
+
   /* Cater to the various TARGET_ASM_OUTPUT_MI_THUNK implementations that
      emit insns as rtx but bypass the bulk of rest_of_compilation, which
      would include pass_dwarf2_frame.  If we've not created the FDE yet,
@@ -1179,7 +1186,7 @@  dwarf2out_frame_finish (void)
     output_call_frame_info (0);
 
   /* Output another copy for the unwinder.  */
-  if (dwarf2out_do_eh_frame ())
+  if (do_eh_frame)
     output_call_frame_info (1);
 }