Commit 629387a6 by Eric Botcazou Committed by Eric Botcazou

tree-eh.h (unsplit_eh_edges): Declare.

	* tree-eh.h (unsplit_eh_edges): Declare.
	* tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases.
	(unsplit_eh_edges): New function wrapping unsplit_all_eh.
	* gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h.
	(struct store_immediate_info): Add lp_nr field.
	(store_immediate_info::store_immediate_info): Add NR2 parameter and
	initialize lp_nr with it.
	(struct merged_store_group): Add lp_nr and only_constants fields.
	(merged_store_group::merged_store_group): Initialize them.
	(merged_store_group::can_be_merged_into): Deal with them.
	(pass_store_merging): Rename terminate_and_release_chain into
	terminate_and_process_chain.
	(pass_store_merging::terminate_and_process_all_chains): Adjust to above
	renaming and remove useless assertions.
	(pass_store_merging::terminate_all_aliasing_chains): Small tweak.
	(stmts_may_clobber_ref_p): Be prepared for different basic blocks.
	(imm_store_chain_info::coalesce_immediate_stores): Use only_constants
	instead of always recomputing it and compare lp_nr.
	(imm_store_chain_info::output_merged_store): If the group is in an
	active EH region, register new stores if they can throw.  Moreover,
	if the insertion has created new basic blocks, adjust the PHI nodes
	of the post landing pad.
	(imm_store_chain_info::output_merged_stores): If the original stores
	are in an active EH region, deregister them.
	(lhs_valid_for_store_merging_p): Prettify.
	(adjust_bit_pos): New function extracted from...
	(mem_valid_for_store_merging): ...here.  Use it for the base address
	and also for the offset if it is the addition of a constant.
	(lp_nr_for_store): New function.
	(pass_store_merging::process_store): Change return type to bool.
	Call lp_nr_for_store to initialize the store info.  Propagate the
	return status of various called functions to the return value.
	(store_valid_for_store_merging_p): New predicate.
	(enum basic_block_status): New enumeration.
	(get_status_for_store_merging): New function.
	(pass_store_merging::execute): If the function can throw and catch
	non-call exceptions, unsplit the EH edges on entry and clean up the
	CFG on exit if something changed.  Call get_status_for_store_merging
	for every basic block and keep the chains open across basic blocks
	when possible.  Terminate and process open chains at the end, if any.

From-SVN: r276459
parent ea4b29d5
2019-10-02 Eric Botcazou <ebotcazou@adacore.com>
* tree-eh.h (unsplit_eh_edges): Declare.
* tree-eh.c (maybe_remove_unreachable_handlers): Detect more cases.
(unsplit_eh_edges): New function wrapping unsplit_all_eh.
* gimple-ssa-store-merging.c: Include cfganal.h cfgcleanup.h except.h.
(struct store_immediate_info): Add lp_nr field.
(store_immediate_info::store_immediate_info): Add NR2 parameter and
initialize lp_nr with it.
(struct merged_store_group): Add lp_nr and only_constants fields.
(merged_store_group::merged_store_group): Initialize them.
(merged_store_group::can_be_merged_into): Deal with them.
(pass_store_merging): Rename terminate_and_release_chain into
terminate_and_process_chain.
(pass_store_merging::terminate_and_process_all_chains): Adjust to above
renaming and remove useless assertions.
(pass_store_merging::terminate_all_aliasing_chains): Small tweak.
(stmts_may_clobber_ref_p): Be prepared for different basic blocks.
(imm_store_chain_info::coalesce_immediate_stores): Use only_constants
instead of always recomputing it and compare lp_nr.
(imm_store_chain_info::output_merged_store): If the group is in an
active EH region, register new stores if they can throw. Moreover,
if the insertion has created new basic blocks, adjust the PHI nodes
of the post landing pad.
(imm_store_chain_info::output_merged_stores): If the original stores
are in an active EH region, deregister them.
(lhs_valid_for_store_merging_p): Prettify.
(adjust_bit_pos): New function extracted from...
(mem_valid_for_store_merging): ...here. Use it for the base address
and also for the offset if it is the addition of a constant.
(lp_nr_for_store): New function.
(pass_store_merging::process_store): Change return type to bool.
Call lp_nr_for_store to initialize the store info. Propagate the
return status of various called functions to the return value.
(store_valid_for_store_merging_p): New predicate.
(enum basic_block_status): New enumeration.
(get_status_for_store_merging): New function.
(pass_store_merging::execute): If the function can throw and catch
non-call exceptions, unsplit the EH edges on entry and clean up the
CFG on exit if something changed. Call get_status_for_store_merging
for every basic block and keep the chains open across basic blocks
when possible. Terminate and process open chains at the end, if any.
2019-10-02 Richard Sandiford <richard.sandiford@arm.com>
* reginfo.c (globalize_reg): Fix shadowed variable in
......
2019-10-02 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/opt82.adb: New test.
* gnat.dg/opt82_pkg.ads: New helper.
2019-10-02 Richard Sandiford <richard.sandiford@arm.com>
* gcc.target/mips/call-clobbered-3.c: Remove skip for -Os.
......
-- { dg-do compile }
-- { dg-options "-O2 -fdump-tree-optimized" }
with Opt82_Pkg; use Opt82_Pkg;
procedure Opt82 (R : access Rec) is
begin
R.A := 'A';
R.B := 'B';
R.C := 'C';
R.D := 'D';
exception
when Storage_Error => R.A := 'E';
end;
-- { dg-final { scan-tree-dump "= 1145258561|= 1094861636" "optimized" } }
package Opt82_Pkg is
type Rec is record
A, B, C, D : Character;
end record;
end Opt82_Pkg;
......@@ -4040,15 +4040,14 @@ maybe_remove_unreachable_handlers (void)
if (cfun->eh == NULL)
return;
FOR_EACH_VEC_SAFE_ELT (cfun->eh->lp_array, i, lp)
if (lp && lp->post_landing_pad)
if (lp
&& (lp->post_landing_pad == NULL_TREE
|| label_to_block (cfun, lp->post_landing_pad) == NULL))
{
if (label_to_block (cfun, lp->post_landing_pad) == NULL)
{
remove_unreachable_handlers ();
return;
}
remove_unreachable_handlers ();
return;
}
}
......@@ -4211,6 +4210,27 @@ unsplit_all_eh (void)
return changed;
}
/* Wrapper around unsplit_all_eh that makes it usable everywhere. */
void
unsplit_eh_edges (void)
{
bool changed;
/* unsplit_all_eh can die looking up unreachable landing pads. */
maybe_remove_unreachable_handlers ();
changed = unsplit_all_eh ();
/* If EH edges have been unsplit, delete unreachable forwarder blocks. */
if (changed)
{
free_dominance_info (CDI_DOMINATORS);
free_dominance_info (CDI_POST_DOMINATORS);
delete_unreachable_blocks ();
}
}
/* A subroutine of cleanup_empty_eh. Redirect all EH edges incoming
to OLD_BB to NEW_BB; return true on success, false on failure.
......
......@@ -50,6 +50,7 @@ extern bool maybe_duplicate_eh_stmt_fn (struct function *, gimple *,
hash_map<void *, void *> *, int);
extern bool maybe_duplicate_eh_stmt (gimple *, gimple *);
extern void maybe_remove_unreachable_handlers (void);
extern void unsplit_eh_edges (void);
extern bool verify_eh_edges (gimple *);
extern bool verify_eh_dispatch_edge (geh_dispatch *);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment