On Thu, 19 Feb 2015, Marek Polacek wrote:
> On Thu, Feb 19, 2015 at 01:48:58PM +0100, Jakub Jelinek wrote:
> > On Thu, Feb 19, 2015 at 01:41:05PM +0100, Richard Biener wrote:
> > > I hope we can get rid of this again (which needs re-writing of all
> > > targets va-arg gimplification hooks... - we are in need of some
> > > generic diamond/triangle CFG pattern builders anyway).
> >
> > We already have some in asan.c - create_cond_insert_point - perhaps
> > it isn't best named and could use some changes to be generally usable.
>
> Yeah, create_cond_insert_point is used in ubsan.c many times, and
> there's nothing *san specific in it.
It's also quite low-level. I'm more looking for sth like
val = gimple_build_cond_value (EQ_EXPR, comp_lhs, comp_rhs,
true_value, true_gimple_seq,
false_value, false_gimple_seq);
which then returns a simplified value (in case all is optimizable
to a constant for example) or produces
if (comp_lhs == comp_rhs)
true_gimple_seq;
else
false_gimple_seq;
val = PHI <true_value, false_value>
so basically allows you to build the true/false values with
gimple_build (or force_gimple_operand for legacy code) and
constructs the diamond/triangle and a PHI together with the
controlling predicate.
Richard.