This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [tcb] Value Range Propagation
Andrew> Thanks, Diego! I really wanted this in order to get bounds check
Andrew> elimination working for Java. I'll see if it does that.
Diego> I wouldn't be surprised if it needs a little tweaking. I will be
Diego> evaluating this and elimination of redundant mudflap instrumentation
Diego> in the next few days.
I gave it a try today and it does not eliminate java bounds. I think
the problem is due to the way we use a cast to unsigned to implement
the actual bounds check.
Take a look at the appended example. It is analogous to the situation
with java arrays. If you compile it as is, the dead __cxa_throw call
will not be removed. If you define WORK_WORK_WORK, the dead call will
be removed.
Tom
// Define this to see it work.
// #define WORK_WORK_WORK
#ifdef WORK_WORK_WORK
#define ORIG unsigned int
#define CAST
#else
#define ORIG int
#define CAST (unsigned)
#endif
struct array
{
const ORIG len;
int *data;
};
extern void call (ORIG);
void doit (array *a)
{
for (ORIG i = 0; i < a->len; ++i)
{
if (CAST (i) >= CAST (a->len))
throw 5;
call (a->data[i]);
}
}