[LLVMdev] VTable Method Index

Duncan Sands baldrick at free.fr
Fri Apr 20 00:40:02 PDT 2012


Hi Михаил,

> Virtual call translates into IR like this:
>
> %0 = bitcast %class.A* %call to i32 (%class.A*, i32)***
> %vtable = load i32 (%class.A*, i32)*** %0
> %vfn = getelementptr inbounds i32 (%class.A*, i32)** %vtable, i64 0
> %1 = load i32 (%class.A*, i32)** %vfn
>
> Is it possible to map pair [StructType, methodIndex(i64 0 in example)] into
> Function?

if the vtable is present in the IR module, and the optimizers can work out that
%0 is pointing to it, then yes.

Ciao, Duncan.



More information about the llvm-dev mailing list