On Mon, Aug 27, 2018 at 10:43 AM Martin Liška <mli...@suse.cz> wrote:
>
> On 08/27/2018 09:56 AM, Richard Biener wrote:
> > On Mon, Aug 27, 2018 at 9:13 AM Martin Liška <mli...@suse.cz> wrote:
> >>
> >> Hi.
> >>
> >> There's updated version with notes that were discussed with Richi
> >> on IRC. As pointed out label_to_block can potentially lead to
> >> quadratic complexity, but it's not ambition of the patch to resolve
> >> that.
> >
> > Please don't
> >
> > @@ -3239,7 +3239,7 @@ expand_asm_stmt (gasm *stmt)
> >              may insert further instructions into the same basic block after
> >              asm goto and if we don't do this, insertion of instructions on
> >              the fallthru edge might misbehave.  See PR58670.  */
> > -         if (fallthru_bb && label_to_block_fn (cfun, label) == fallthru_bb)
> > +         if (fallthru_bb && label_to_block (label) == fallthru_bb)
> >             {
> >               if (fallthru_label == NULL_RTX)
> >                 fallthru_label = gen_label_rtx ();
> >
> > rather the label_to_block function should go away.  OK with removing any
> > such instances in the patch.
> >
> > Richard.
> >
> >> Martin
>
> Ok, I'm sending one more version where I completely removed label_to_block_fn.
> Richi, out of the modified function, which would be subject for introduction
> of a new argument (struct *function)?

Esp. gimple_switch_bb would be ... also, sorry for noticing so late,
gimple_switch_bb
awfully sounds like gimple_bb which means better call it
gimple_switch_label_bb ()?

Note doing both things in one patch (adding your wrappers) and cleaning up
label_to_block isn't necessary (but I have no issue with that).

So - may I ask you for a) change name to gimple_switch_label_bb b) add a
cfun argument to this function?

To your last question, it's most of the time easy to look up the call chain for
static functions and you'll find a function that is called with struct
function *.
When I(?) added label_to_block_fn I did so for the places I "cleaned up", so
it would be nice to not introduce cfun references where it's easy to avoid.
From a quick look important cases seem to be
 - set_switch_stmt_execution_predicate
 - find_taken_edge_switch_expr (and thus callers)
 - gimple_redirect_edge_and_branch
 - gimple_switch_label_bb

in most passes using cfun should be "easy" to avoid by passing down
the struct function arg from the pass execute() method but that's a bit
tedious and IMHO not too important.

You'll notice that in GIMPLE / CFG infrastructure one of the ugly facts
is that there's no way to go from a basic-block to the containing
struct function.

Thanks,
Richard.

>
> Martin

Reply via email to