[LLVMdev] [Help] How can we call an object's virtual function inside IR?

David Greene dag at cray.com
Tue Jan 5 09:33:43 PST 2010


On Tuesday 05 January 2010 04:59, Duncan Sands wrote:
> Hi Gyounghwa Kim, try pasting C++ code into http://llvm.org/demo/
> in order to see the LLVM IR that llvm-g++ turns it into.  That way
> you will see how this can be done.

LLVM has no direct support for class hierarchies, virtual functions,
templates or anything of that support.  It is very low-level.  The
frontend is responsible for implementing the C++ object model in
terms of LLVM constructs.  This the frontend will have to generate
vtables, indirect calls, etc. to implement virtual function calls.

This is all highly compiler-dependent.  Everyone does it a little
bit differently.  Using the llvm-g++ online demo as Duncan suggests
will show you how g++ implements this stuff.

                               -Dave



More information about the llvm-dev mailing list