Hi,

> >> +static Value *StripBitCasts(Value *Val) {
> >
> > how about using IntrinsicInst::StripPointerCasts instead?
> 
> Done. Note that, although there's tantalizing GEP-0 handling in  
> StripPointerCasts, it's still not really possible to use gcroot  
> without bitcasts:

the reason for the GEP handling, is that if you have a constant
pointer P to a struct S for which the first field is of type T,
and you constant bitcast P to a T*, then the optimizers will turn
this into a GEP-0 instead of a bitcast.  Thus it is unwise to assume
you'll always see a bitcast - it might be that you get passed a
GEP instead.

>       %x_addr = alloca %class.Derived*
>       %tmp0 = getelementptr %x_addr, i32 0, i32 0  ; Invalid! But nice try...

If x_addr pointed to a global variable rather than a local variable, this (or
something like it) should be valid.  Just to be clear: I'm not suggesting that 
you
can get rid of bitcasts - I'm pointing out that in obscure circumstances you
may be passed a GEP rather than a bitcast, even if you always generate bitcasts
in the front-end.  So you need to handle that, eg by using StripPointerCasts.

Ciao,

Duncan.
_______________________________________________
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

Reply via email to