[cxx-conversion] RFC - Helper types for building GIMPLE

Steven Bosscher stevenb.gcc@gmail.com
Wed Mar 13 22:17:00 GMT 2013

On Wed, Mar 13, 2013 at 10:55 PM, Diego Novillo wrote:
> This patch adds an initial implementation for a new helper type for
> generating GIMPLE statements.

Great. I was just asking you about this on IRC - you not there - but
here's a patch. Great!

> For instance, in asan.c we generate the expression:
> (shadow != 0) & (base_addr & 7) + (size_in_bytes - 1)) >= shadow).
> with the following code:
> -----------------------------------------------------------------------------
>       gimple_builder_ssa gb(location);
>       t = gb.add (NE_EXPR, shadow, 0);
>       tree t1 = gb.add (BIT_AND_EXPR, base_addr, 7);
>       t1 = gb.add_type_cast (shadow_type, t1);
>       if (size_in_bytes > 1)
>         t1 = gb.add (PLUS_EXPR, t1, size_in_bytes - 1);
>       t1 = gb.add (GE_EXPR, t1, shadow);
>       t = gb.add (BIT_AND_EXPR, t, t1);
>       gb.insert_after (&gsi, GSI_NEW_STMT);
> -----------------------------------------------------------------------------

Much better than what GCC has now, although I had hoped it'd be
possible to build on the result of a previous expression without tree

> I expect to add more facilities to the builder.  Mainly, generation of
> control flow altering statements which will automatically reflect on
> the CFG.

What does your plan for this look like? Personally I'd prefer to keep
CFG modifications explicit, not hidden behind this builder. CFG
changes must be done with great care, to avoid invalidating associated
data (profile, dominator tree, etc.). I'm worried that if you hide
this behind a builder, it'll be more difficult to figure out where/how
the CFG is modified (a simple grep for CFG-modifying functions won't
do anymore).

> I do not think the helper should replace all code generation, but it
> should serve as a shorter/simpler way of generating GIMPLE IL in the
> common cases.

I'd like to convert the profiling code, if you'd accept patches for
that on the cxx-branch.

> Feedback welcome.  I would like to consider adding this facility when
> stage 1 opens.

Let's play with it a bit first on the CXX branch, and update
documentation like doc/gimple.texi :-)


More information about the Gcc-patches mailing list