[PATCH] Allow exceptions together with -freorder-blocks-and-partition

Jack Howarth howarth@bromo.med.uc.edu
Fri Oct 2 15:56:00 GMT 2009


On Thu, Aug 06, 2009 at 03:50:06PM -0700, Richard Henderson wrote:
> On 07/30/2009 08:40 AM, Jakub Jelinek wrote:
>> In theory without modifying personality
>> functions we could get away without those on i386 by using DW_EH_PE_sdata4
>> call site table format instead of the usual DW_EH_PE_uleb128 one
>> in hot/cold partitioned functions and use DW_EH_PE_pcrel encoded
>> __GLOBAL_OFFSET_TABLE__ LPStart and landing pads relative to that
>> (@GOTOFF).  But I have no idea how to optimize similarly e.g. on x86-64...
>
> It could technically be done with DW_EH_PE_sdata8 and GOTOFF64 relocs.
> Whether that size overhead is worth it or not is another question...
>
>> 	* dwarf2out.c (output_fde): When doing hot/cold partitioning, use
>> 	fde->dw_fde_begin as begin label instead of hot/cold label.
>> 	Use LLSDAC label instead of LLSDA for second section lsda.
>> 	(dwarf2out_do_cfi_startproc): Add SECOND argument.  Use LLSDAC
>> 	label instead of LLSDA if it is true.
>> 	(dwarf2out_begin_prologue, dwarf2out_switch_text_section): Adjust
>> 	callers.
>> 	* except.c (add_call_site, dw2_size_of_call_site_table): Add
>> 	SECTION argument.  Use it as index into crtl->eh.call_site_record
>> 	array.
>> 	(dw2_output_call_site_table): Likewise.  Add CS_FORMAT argument,
>> 	use it to determine how to print table entries instead of using
>> 	#ifdef HAVE_AS_LEB128.  For SECTION>  0 use hot resp. cold
>> 	label instead of normal begin label as base.
>> 	(sjlj_assign_call_site_values): Adjust add_call_site caller.
>> 	(convert_to_eh_region_ranges): When doing hot/cold partitioning,
>> 	ensure no EH range spans between sections and that landing pads
>> 	are always in the corresponding section.
>> 	(sjlj_size_of_call_site_table, sjlj_output_call_site_table): Adjust
>> 	for crtl->eh.call_site_record being an array rather than scalar.
>> 	(output_one_function_exception_table): New function, copied
>> 	from output_function_exception_table.  Adjust
>> 	dw2_size_of_call_site_table, dw2_output_call_site_table
>> 	callers.  For SECOND section use *C suffixed labels.
>> 	(output_function_exception_table): Call
>> 	output_one_function_exception_table and, when doing hot/cold
>> 	partitioning, also another time for the second section.
>> 	* opts.c: Include except.h.
>> 	(decode_options): Allow -freorder-blocks-and-partition with
>> 	exceptions, unless SJLJ or TARGET_UNWIND_INFO.
>> 	* Makefile.in (opts.o): Depend on $(EXCEPT_H).
>> 	* function.h (struct rtl_eh): Change call_site_record from
>> 	scalar into array of 2 elements.
>>
>> 	* g++.dg/tree-prof/partition1.C: New test.
>
> Ok.
>
>
> r~
>

Richard,
     The change in this patch...
 
      * opts.c: Include except.h.
      (decode_options): Allow -freorder-blocks-and-partition with
      exceptions, unless SJLJ or TARGET_UNWIND_INFO.

causes PR41313 on darwin since it modifies the logic for the conditionals 
described in the comments of opts.c...

  /* The optimization to partition hot and cold basic blocks into separate
     sections of the .o and executable files does not work (currently)
     with exception handling.  This is because there is no support for
     generating unwind info.  If flag_exceptions is turned on we need to
     turn off the partitioning optimization.  */

  /* If user requested unwind info, then turn off the partitioning
     optimization.  */

  /* If the target requested unwind info, then turn off the partitioning
     optimization with a different message.  Likewise, if the target does not
     support named sections.  */

that  seems to have been introduced starting at r108104. I am able to restore the
previous behavior on darwin which a change like...

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41313#c25

that avoids this part of r150553 on darwin. Do you have any suggestions
of a better way to fix for this? The current situation results in inappropriate
support for partitioning optimization on darwin which results in duplicate
.eh symbols that cause the partition1.C test case to fail.
                     Jack



More information about the Gcc-patches mailing list