Need advice on bounds checking approaches

Greg McGary gkm@eng.ascend.com
Fri Mar 24 12:28:00 GMT 2000


Joern Rennecke <amylaar@cygnus.co.uk> writes:

> > Question: with the above plan, is there a way to provide a default
> > expansion of the "check_bounds" pattern into primitive RTL
> > (comparisons, conditional branches and call to abort) for those
> > targets that don't define an insn for "check_bounds"?
> 
> You can use HAVE_check_bounds to test if a "check_bounds" pattern has been
> defined in the md file.  If it is defined, you can use gen_check_bounds
> to generate this pattern.  The expander might fail (e.g. because the
> target can implement the bounds checking insn only for a particular
> cpu_, in which case you get a zero return value from gen_check_bounds.

I am aware of HAVE_check_bounds.  Unfortunately, it doesn't do what I
want.  If HAVE_check_bounds, I could generate "check_bounds", and if
! HAVE_check_bounds, I could generate the primitive RTL (compares +
conditional branches + abort).  If ! HAVE_check_bounds, then I lose
the ability to conveniently optimize away redundant checks, and my
basic blocks get sliced up by the presence of extra branches.

What I want is to always generate check_bounds insns, always optimize
away redundant checks the same way, and then provide a default
*expansion* if the MD doesn't define one.

Is that feasible, or am I dreaming?

Greg


More information about the Gcc mailing list