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

Luke Dalessandro luked at cs.rochester.edu
Tue Mar 24 12:16:09 PDT 2009


Mike Stump wrote:
> On Mar 24, 2009, at 10:22 AM, Luke Dalessandro wrote:
> 
>> I guess that alias analysis doesn't always "trust" casts, where if I  
>> manually
>> pushed back I would be assuming that the casts are correct?
> 
> Once all the pushing is in, one should be able to discover that the  
> casts all convert to the same type, and remove them as useless.  :-)

Right. I guess what I meant is that the cast might not have been 
generated by llvm-g++ but may be a user "lying" about the type of a 
function with a C cast for whatever reason. It could alias almost any 
global or anything that has its address taken. With a C++ vtable I know 
that the user never had access to the vtable and thus couldn't have done 
that.

I'm statically cloning and instrumenting call targets for my application 
(and doing runtime indirect branch target translation lookups), so it's 
really bad if I miss a target that I need. On the other hand I'd like to 
clone as few functions as possible. The most likely reason for an 
indirect call in what I get is C++ virtual calls, so disambiguating just 
these call sites would be helpful.

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.

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.

Luke

> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list