* [PATCH] Make split_block and create_basic_block type-safe
@ 2015-03-12 13:20 Richard Biener
2015-03-17 19:36 ` Jeff Law
2015-03-20 21:03 ` David Malcolm
0 siblings, 2 replies; 5+ messages in thread
From: Richard Biener @ 2015-03-12 13:20 UTC (permalink / raw)
To: gcc-patches; +Cc: Jakub Jelinek
After noticing tree-parloop.c passing crap to split_block (a tree
rather than a gimple or an rtx) I noticed those CFG functions simply
take void * pointers. The following patch fixes that and adds
two overloads, one for GIMPLE use and one for RTL use.
Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.
Ok at this stage?
Thanks,
Richard.
2015-03-12 Richard Biener <rguenther@suse.de>
* cfghooks.h (create_basic_block): Replace with two overloads
for RTL and GIMPLE.
(split_block): Likewise.
* cfghooks.c (split_block): Rename to ...
(split_block_1): ... this.
(split_block): Add two type-safe overloads for RTL and GIMPLE.
(split_block_after_labels): Call split_block_1.
(create_basic_block): Rename to ...
(create_basic_block_1): ... this.
(create_basic_block): Add two type-safe overloads for RTL and GIMPLE.
(create_empty_bb): Call create_basic_block_1.
* cfgrtl.c (fixup_fallthru_exit_predecessor): Use
split_block_after_labels.
* omp-low.c (expand_parallel_call): Likewise.
(expand_omp_target): Likewise.
(simd_clone_adjust): Likewise.
* tree-chkp.c (chkp_get_entry_block): Likewise.
* cgraphunit.c (init_lowered_empty_function): Use the GIMPLE
create_basic_block overload.
(cgraph_node::expand_thunk): Likewise.
* tree-cfg.c (make_blocks): Likewise.
(handle_abnormal_edges): Likewise.
* tree-inline.c (copy_bb): Likewise.
Index: gcc/cfghooks.c
===================================================================
--- gcc/cfghooks.c (revision 221379)
+++ gcc/cfghooks.c (working copy)
@@ -505,8 +505,8 @@ redirect_edge_and_branch_force (edge e,
the labels). If I is NULL, splits just after labels. The newly created edge
is returned. The new basic block is created just after the old one. */
-edge
-split_block (basic_block bb, void *i)
+static edge
+split_block_1 (basic_block bb, void *i)
{
basic_block new_bb;
edge res;
@@ -550,12 +550,24 @@ split_block (basic_block bb, void *i)
return res;
}
+edge
+split_block (basic_block bb, gimple i)
+{
+ return split_block_1 (bb, i);
+}
+
+edge
+split_block (basic_block bb, rtx i)
+{
+ return split_block_1 (bb, i);
+}
+
/* Splits block BB just after labels. The newly created edge is returned. */
edge
split_block_after_labels (basic_block bb)
{
- return split_block (bb, NULL);
+ return split_block_1 (bb, NULL);
}
/* Moves block BB immediately after block AFTER. Returns false if the
@@ -696,8 +708,8 @@ split_edge (edge e)
HEAD and END are the first and the last statement belonging
to the block. If both are NULL, an empty block is created. */
-basic_block
-create_basic_block (void *head, void *end, basic_block after)
+static basic_block
+create_basic_block_1 (void *head, void *end, basic_block after)
{
basic_block ret;
@@ -714,12 +726,25 @@ create_basic_block (void *head, void *en
return ret;
}
+basic_block
+create_basic_block (gimple_seq seq, basic_block after)
+{
+ return create_basic_block_1 (seq, NULL, after);
+}
+
+basic_block
+create_basic_block (rtx head, rtx end, basic_block after)
+{
+ return create_basic_block_1 (head, end, after);
+}
+
+
/* Creates an empty basic block just after basic block AFTER. */
basic_block
create_empty_bb (basic_block after)
{
- return create_basic_block (NULL, NULL, after);
+ return create_basic_block_1 (NULL, NULL, after);
}
/* Checks whether we may merge blocks BB1 and BB2. */
Index: gcc/cfghooks.h
===================================================================
--- gcc/cfghooks.h (revision 221379)
+++ gcc/cfghooks.h (working copy)
@@ -196,12 +196,14 @@ extern edge redirect_edge_succ_nodup (ed
extern bool can_remove_branch_p (const_edge);
extern void remove_branch (edge);
extern void remove_edge (edge);
-extern edge split_block (basic_block, void *);
+extern edge split_block (basic_block, rtx);
+extern edge split_block (basic_block, gimple);
extern edge split_block_after_labels (basic_block);
extern bool move_block_after (basic_block, basic_block);
extern void delete_basic_block (basic_block);
extern basic_block split_edge (edge);
-extern basic_block create_basic_block (void *, void *, basic_block);
+extern basic_block create_basic_block (rtx, rtx, basic_block);
+extern basic_block create_basic_block (gimple_seq, basic_block);
extern basic_block create_empty_bb (basic_block);
extern bool can_merge_blocks_p (basic_block, basic_block);
extern void merge_blocks (basic_block, basic_block);
Index: gcc/cfgrtl.c
===================================================================
--- gcc/cfgrtl.c (revision 221379)
+++ gcc/cfgrtl.c (working copy)
@@ -4047,7 +4047,7 @@ fixup_fallthru_exit_predecessor (void)
edge, we have to split that block. */
if (c == bb)
{
- bb = split_block (bb, NULL)->dest;
+ bb = split_block_after_labels (bb)->dest;
bb->aux = c->aux;
c->aux = bb;
BB_FOOTER (bb) = BB_FOOTER (c);
Index: gcc/cgraphunit.c
===================================================================
--- gcc/cgraphunit.c (revision 221379)
+++ gcc/cgraphunit.c (working copy)
@@ -1373,7 +1373,7 @@ init_lowered_empty_function (tree decl,
ENTRY_BLOCK_PTR_FOR_FN (cfun)->frequency = REG_BR_PROB_BASE;
EXIT_BLOCK_PTR_FOR_FN (cfun)->count = count;
EXIT_BLOCK_PTR_FOR_FN (cfun)->frequency = REG_BR_PROB_BASE;
- bb = create_basic_block (NULL, (void *) 0, ENTRY_BLOCK_PTR_FOR_FN (cfun));
+ bb = create_basic_block (NULL, ENTRY_BLOCK_PTR_FOR_FN (cfun));
bb->count = count;
bb->frequency = BB_FREQ_MAX;
e = make_edge (ENTRY_BLOCK_PTR_FOR_FN (cfun), bb, EDGE_FALLTHRU);
@@ -1710,13 +1710,13 @@ cgraph_node::expand_thunk (bool output_a
protect against NULL. We know there will be an
adjustment, because that's why we're emitting a
thunk. */
- then_bb = create_basic_block (NULL, (void *) 0, bb);
+ then_bb = create_basic_block (NULL, bb);
then_bb->count = count - count / 16;
then_bb->frequency = BB_FREQ_MAX - BB_FREQ_MAX / 16;
- return_bb = create_basic_block (NULL, (void *) 0, then_bb);
+ return_bb = create_basic_block (NULL, then_bb);
return_bb->count = count;
return_bb->frequency = BB_FREQ_MAX;
- else_bb = create_basic_block (NULL, (void *) 0, else_bb);
+ else_bb = create_basic_block (NULL, else_bb);
then_bb->count = count / 16;
then_bb->frequency = BB_FREQ_MAX / 16;
add_bb_to_loop (then_bb, bb->loop_father);
Index: gcc/omp-low.c
===================================================================
--- gcc/omp-low.c (revision 221379)
+++ gcc/omp-low.c (working copy)
@@ -4930,7 +4930,7 @@ expand_parallel_call (struct omp_region
tmp_join = tmp_var;
}
- e = split_block (bb, NULL);
+ e = split_block_after_labels (bb);
cond_bb = e->src;
bb = e->dest;
remove_edge (e);
@@ -9044,7 +9044,7 @@ expand_omp_target (struct omp_region *re
tmp_var = create_tmp_var (TREE_TYPE (device));
if (offloaded)
- e = split_block (new_bb, NULL);
+ e = split_block_after_labels (new_bb);
else
{
gsi = gsi_last_bb (new_bb);
@@ -13335,7 +13335,7 @@ simd_clone_adjust (struct cgraph_node *n
e = split_block (incr_bb, gsi_stmt (gsi));
basic_block latch_bb = e->dest;
basic_block new_exit_bb;
- new_exit_bb = split_block (latch_bb, NULL)->dest;
+ new_exit_bb = split_block_after_labels (latch_bb)->dest;
loop->latch = latch_bb;
redirect_edge_succ (FALLTHRU_EDGE (latch_bb), body_bb);
Index: gcc/tree-cfg.c
===================================================================
--- gcc/tree-cfg.c (revision 221379)
+++ gcc/tree-cfg.c (working copy)
@@ -541,7 +541,7 @@ make_blocks (gimple_seq seq)
{
if (!first_stmt_of_seq)
gsi_split_seq_before (&i, &seq);
- bb = create_basic_block (seq, NULL, bb);
+ bb = create_basic_block (seq, bb);
start_new_block = false;
}
@@ -739,7 +739,7 @@ handle_abnormal_edges (basic_block *disp
}
/* Create the dispatcher bb. */
- *dispatcher = create_basic_block (NULL, NULL, for_bb);
+ *dispatcher = create_basic_block (NULL, for_bb);
if (computed_goto)
{
/* Factor computed gotos into a common computed goto site. Also
Index: gcc/tree-chkp.c
===================================================================
--- gcc/tree-chkp.c (revision 221379)
+++ gcc/tree-chkp.c (working copy)
@@ -1042,7 +1042,8 @@ static basic_block
chkp_get_entry_block (void)
{
if (!entry_block)
- entry_block = split_block (ENTRY_BLOCK_PTR_FOR_FN (cfun), NULL)->dest;
+ entry_block
+ = split_block_after_labels (ENTRY_BLOCK_PTR_FOR_FN (cfun))->dest;
return entry_block;
}
Index: gcc/tree-inline.c
===================================================================
--- gcc/tree-inline.c (revision 221379)
+++ gcc/tree-inline.c (working copy)
@@ -1761,8 +1761,7 @@ copy_bb (copy_body_data *id, basic_block
/* create_basic_block() will append every new block to
basic_block_info automatically. */
- copy_basic_block = create_basic_block (NULL, (void *) 0,
- (basic_block) prev->aux);
+ copy_basic_block = create_basic_block (NULL, (basic_block) prev->aux);
copy_basic_block->count = apply_scale (bb->count, count_scale);
/* We are going to rebuild frequencies from scratch. These values
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Make split_block and create_basic_block type-safe
2015-03-12 13:20 [PATCH] Make split_block and create_basic_block type-safe Richard Biener
@ 2015-03-17 19:36 ` Jeff Law
2015-03-20 21:03 ` David Malcolm
1 sibling, 0 replies; 5+ messages in thread
From: Jeff Law @ 2015-03-17 19:36 UTC (permalink / raw)
To: Richard Biener, gcc-patches; +Cc: Jakub Jelinek
On 03/12/2015 07:20 AM, Richard Biener wrote:
>
> After noticing tree-parloop.c passing crap to split_block (a tree
> rather than a gimple or an rtx) I noticed those CFG functions simply
> take void * pointers. The following patch fixes that and adds
> two overloads, one for GIMPLE use and one for RTL use.
>
> Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.
>
> Ok at this stage?
>
> Thanks,
> Richard.
>
> 2015-03-12 Richard Biener <rguenther@suse.de>
>
> * cfghooks.h (create_basic_block): Replace with two overloads
> for RTL and GIMPLE.
> (split_block): Likewise.
> * cfghooks.c (split_block): Rename to ...
> (split_block_1): ... this.
> (split_block): Add two type-safe overloads for RTL and GIMPLE.
> (split_block_after_labels): Call split_block_1.
> (create_basic_block): Rename to ...
> (create_basic_block_1): ... this.
> (create_basic_block): Add two type-safe overloads for RTL and GIMPLE.
> (create_empty_bb): Call create_basic_block_1.
> * cfgrtl.c (fixup_fallthru_exit_predecessor): Use
> split_block_after_labels.
> * omp-low.c (expand_parallel_call): Likewise.
> (expand_omp_target): Likewise.
> (simd_clone_adjust): Likewise.
> * tree-chkp.c (chkp_get_entry_block): Likewise.
> * cgraphunit.c (init_lowered_empty_function): Use the GIMPLE
> create_basic_block overload.
> (cgraph_node::expand_thunk): Likewise.
> * tree-cfg.c (make_blocks): Likewise.
> (handle_abnormal_edges): Likewise.
> * tree-inline.c (copy_bb): Likewise.
Seems reasonable since it's very low risk and removes a difficult to
reproduce & diagnose compile-time issue.
But ultimately I think it's the release managers' call here.
Jeff
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Make split_block and create_basic_block type-safe
2015-03-12 13:20 [PATCH] Make split_block and create_basic_block type-safe Richard Biener
2015-03-17 19:36 ` Jeff Law
@ 2015-03-20 21:03 ` David Malcolm
2015-03-23 8:35 ` Richard Biener
1 sibling, 1 reply; 5+ messages in thread
From: David Malcolm @ 2015-03-20 21:03 UTC (permalink / raw)
To: Richard Biener; +Cc: gcc-patches, Jakub Jelinek
On Thu, 2015-03-12 at 14:20 +0100, Richard Biener wrote:
> After noticing tree-parloop.c passing crap to split_block (a tree
> rather than a gimple or an rtx) I noticed those CFG functions simply
> take void * pointers. The following patch fixes that and adds
> two overloads, one for GIMPLE use and one for RTL use.
>
> Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.
>
> Ok at this stage?
>
> Thanks,
> Richard.
>
> 2015-03-12 Richard Biener <rguenther@suse.de>
>
> * cfghooks.h (create_basic_block): Replace with two overloads
> for RTL and GIMPLE.
> (split_block): Likewise.
> * cfghooks.c (split_block): Rename to ...
> (split_block_1): ... this.
> (split_block): Add two type-safe overloads for RTL and GIMPLE.
> (split_block_after_labels): Call split_block_1.
> (create_basic_block): Rename to ...
> (create_basic_block_1): ... this.
> (create_basic_block): Add two type-safe overloads for RTL and GIMPLE.
> (create_empty_bb): Call create_basic_block_1.
> * cfgrtl.c (fixup_fallthru_exit_predecessor): Use
> split_block_after_labels.
> * omp-low.c (expand_parallel_call): Likewise.
> (expand_omp_target): Likewise.
> (simd_clone_adjust): Likewise.
> * tree-chkp.c (chkp_get_entry_block): Likewise.
> * cgraphunit.c (init_lowered_empty_function): Use the GIMPLE
> create_basic_block overload.
> (cgraph_node::expand_thunk): Likewise.
> * tree-cfg.c (make_blocks): Likewise.
> (handle_abnormal_edges): Likewise.
> * tree-inline.c (copy_bb): Likewise.
>
> Index: gcc/cfghooks.c
> ===================================================================
> --- gcc/cfghooks.c (revision 221379)
> +++ gcc/cfghooks.c (working copy)
[...snip...]
> +edge
> +split_block (basic_block bb, rtx i)
> +{
> + return split_block_1 (bb, i);
> +}
Possibly a dumb question, but could this take an rtx_insn * rather than
a plain rtx?
> +basic_block
> +create_basic_block (rtx head, rtx end, basic_block after)
> +{
> + return create_basic_block_1 (head, end, after);
> +}
Likewise for head and end... though I see a fix would be needed in
bfin.c:hwloop_optimize, at least.
> Index: gcc/cfghooks.h
> ===================================================================
> --- gcc/cfghooks.h (revision 221379)
> +++ gcc/cfghooks.h (working copy)
> -extern edge split_block (basic_block, void *);
> +extern edge split_block (basic_block, rtx);
(etc)
> -extern basic_block create_basic_block (void *, void *, basic_block);
> +extern basic_block create_basic_block (rtx, rtx, basic_block);
(etc)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Make split_block and create_basic_block type-safe
2015-03-20 21:03 ` David Malcolm
@ 2015-03-23 8:35 ` Richard Biener
2015-04-20 12:42 ` Richard Biener
0 siblings, 1 reply; 5+ messages in thread
From: Richard Biener @ 2015-03-23 8:35 UTC (permalink / raw)
To: David Malcolm; +Cc: gcc-patches, Jakub Jelinek
On Fri, 20 Mar 2015, David Malcolm wrote:
> On Thu, 2015-03-12 at 14:20 +0100, Richard Biener wrote:
> > After noticing tree-parloop.c passing crap to split_block (a tree
> > rather than a gimple or an rtx) I noticed those CFG functions simply
> > take void * pointers. The following patch fixes that and adds
> > two overloads, one for GIMPLE use and one for RTL use.
> >
> > Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.
> >
> > Ok at this stage?
> >
> > Thanks,
> > Richard.
> >
> > 2015-03-12 Richard Biener <rguenther@suse.de>
> >
> > * cfghooks.h (create_basic_block): Replace with two overloads
> > for RTL and GIMPLE.
> > (split_block): Likewise.
> > * cfghooks.c (split_block): Rename to ...
> > (split_block_1): ... this.
> > (split_block): Add two type-safe overloads for RTL and GIMPLE.
> > (split_block_after_labels): Call split_block_1.
> > (create_basic_block): Rename to ...
> > (create_basic_block_1): ... this.
> > (create_basic_block): Add two type-safe overloads for RTL and GIMPLE.
> > (create_empty_bb): Call create_basic_block_1.
> > * cfgrtl.c (fixup_fallthru_exit_predecessor): Use
> > split_block_after_labels.
> > * omp-low.c (expand_parallel_call): Likewise.
> > (expand_omp_target): Likewise.
> > (simd_clone_adjust): Likewise.
> > * tree-chkp.c (chkp_get_entry_block): Likewise.
> > * cgraphunit.c (init_lowered_empty_function): Use the GIMPLE
> > create_basic_block overload.
> > (cgraph_node::expand_thunk): Likewise.
> > * tree-cfg.c (make_blocks): Likewise.
> > (handle_abnormal_edges): Likewise.
> > * tree-inline.c (copy_bb): Likewise.
> >
> > Index: gcc/cfghooks.c
> > ===================================================================
> > --- gcc/cfghooks.c (revision 221379)
> > +++ gcc/cfghooks.c (working copy)
>
> [...snip...]
>
> > +edge
> > +split_block (basic_block bb, rtx i)
> > +{
> > + return split_block_1 (bb, i);
> > +}
>
> Possibly a dumb question, but could this take an rtx_insn * rather than
> a plain rtx?
Well, as you noted below...
> > +basic_block
> > +create_basic_block (rtx head, rtx end, basic_block after)
> > +{
> > + return create_basic_block_1 (head, end, after);
> > +}
>
> Likewise for head and end... though I see a fix would be needed in
> bfin.c:hwloop_optimize, at least.
...it would have required building all sorts of targets.
But sure, as this is now stage1 stuff I'll see to make it rtx_insns.
Richard.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Make split_block and create_basic_block type-safe
2015-03-23 8:35 ` Richard Biener
@ 2015-04-20 12:42 ` Richard Biener
0 siblings, 0 replies; 5+ messages in thread
From: Richard Biener @ 2015-04-20 12:42 UTC (permalink / raw)
To: David Malcolm; +Cc: gcc-patches, Jakub Jelinek
On Mon, 23 Mar 2015, Richard Biener wrote:
> On Fri, 20 Mar 2015, David Malcolm wrote:
>
> > On Thu, 2015-03-12 at 14:20 +0100, Richard Biener wrote:
> > > After noticing tree-parloop.c passing crap to split_block (a tree
> > > rather than a gimple or an rtx) I noticed those CFG functions simply
> > > take void * pointers. The following patch fixes that and adds
> > > two overloads, one for GIMPLE use and one for RTL use.
> > >
> > > Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.
> > >
> > > Ok at this stage?
> > >
> > > Thanks,
> > > Richard.
> > >
> > > 2015-03-12 Richard Biener <rguenther@suse.de>
> > >
> > > * cfghooks.h (create_basic_block): Replace with two overloads
> > > for RTL and GIMPLE.
> > > (split_block): Likewise.
> > > * cfghooks.c (split_block): Rename to ...
> > > (split_block_1): ... this.
> > > (split_block): Add two type-safe overloads for RTL and GIMPLE.
> > > (split_block_after_labels): Call split_block_1.
> > > (create_basic_block): Rename to ...
> > > (create_basic_block_1): ... this.
> > > (create_basic_block): Add two type-safe overloads for RTL and GIMPLE.
> > > (create_empty_bb): Call create_basic_block_1.
> > > * cfgrtl.c (fixup_fallthru_exit_predecessor): Use
> > > split_block_after_labels.
> > > * omp-low.c (expand_parallel_call): Likewise.
> > > (expand_omp_target): Likewise.
> > > (simd_clone_adjust): Likewise.
> > > * tree-chkp.c (chkp_get_entry_block): Likewise.
> > > * cgraphunit.c (init_lowered_empty_function): Use the GIMPLE
> > > create_basic_block overload.
> > > (cgraph_node::expand_thunk): Likewise.
> > > * tree-cfg.c (make_blocks): Likewise.
> > > (handle_abnormal_edges): Likewise.
> > > * tree-inline.c (copy_bb): Likewise.
> > >
> > > Index: gcc/cfghooks.c
> > > ===================================================================
> > > --- gcc/cfghooks.c (revision 221379)
> > > +++ gcc/cfghooks.c (working copy)
> >
> > [...snip...]
> >
> > > +edge
> > > +split_block (basic_block bb, rtx i)
> > > +{
> > > + return split_block_1 (bb, i);
> > > +}
> >
> > Possibly a dumb question, but could this take an rtx_insn * rather than
> > a plain rtx?
>
> Well, as you noted below...
>
> > > +basic_block
> > > +create_basic_block (rtx head, rtx end, basic_block after)
> > > +{
> > > + return create_basic_block_1 (head, end, after);
> > > +}
> >
> > Likewise for head and end... though I see a fix would be needed in
> > bfin.c:hwloop_optimize, at least.
>
> ...it would have required building all sorts of targets.
>
> But sure, as this is now stage1 stuff I'll see to make it rtx_insns.
Ick. Even bb-reorder.c isn't safe for that and stuff like
block_label () doesn't return a rtx_insn * either.
Thus I'll go for the original patch.
Thanks,
Richard.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-04-20 12:42 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-12 13:20 [PATCH] Make split_block and create_basic_block type-safe Richard Biener
2015-03-17 19:36 ` Jeff Law
2015-03-20 21:03 ` David Malcolm
2015-03-23 8:35 ` Richard Biener
2015-04-20 12:42 ` Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).