[LLVMdev] C++ type erasure in llvm-g++

Mike Stump mrs at apple.com
Tue Mar 24 17:30:01 PDT 2009


On Mar 24, 2009, at 12:16 PM, Luke Dalessandro wrote:
> Right. I guess what I meant is that the cast might not have been
> generated by llvm-g++ but may be a user "lying"

Right.  If the type is the same, you know it isn't a lie, and you can  
do what you want.  If you `see' someone lying, well, within the  
confines of the language standard, we have ways of dealing with that.   
Basically, it is verbotten.  In practice, for a production compiler,  
you need to handle it reasonably (things like debuggers, JITs, libffi  
and the like).

> One thing I don't exactly understand is how I can push back through  
> the
> vtable pointer loads in order to distinguish different vtables. I  
> still
> need alias analysis for this... if I don't then the virtual function  
> at
> index 0 will likely have lots of different types.

index 0 for a given family of vtables will always have the same  
signature due to the language rules.  If they are different, it means  
the vtables is of a different family and for a particular vtable  
pointer, can never be pointed to as the types don't match.

> I think I really need to make this happen at a higher level where I  
> have a much better idea of the set of possible targets of a virtual  
> call.

That's just the set of possible values that a particular vtable  
pointer can have.  -fwhole-program or some such can explain what that  
set is (after one does up all the code I mean).  It is true that the  
front end also has this information, but it doesn't have the -fwhole- 
program bit to ensure it has the entire set.



More information about the llvm-dev mailing list