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

Mike Stump mrs at apple.com
Tue Mar 24 11:02:05 PDT 2009


On Mar 24, 2009, at 10:22 AM, Luke Dalessandro wrote:
> OK, so it's mainly a problem of becoming comfortable with the llvm-gcc
> internals that are affected and not a fundamental whole-compiler  
> design
> problem.

That's correct.

> So I can essentially rematerialize the vtable types by pushing things
> back through from the indirect calls in the program. Wouldn't existing
> alias analysis _do_ the same thing in a less specific manner?

Yes, it should, that it essentially what I was describing.  I can't  
make any claims about existing alias analysis, I thought there were  
large swaths missing.  The idea would be, that if you wrote C++ code  
in C, using an array of void* for the vtables, you could get the  
backend to figure it all out and raise things back up.  Kinda double  
the work than doing it safely to begin with.

> 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.  :-)



More information about the llvm-dev mailing list