llvm/lib
Chris Lattner b89e071aea Factor some code to handle "load (constantexpr cast foo)" just like
"load (cast foo)".  This allows us to compile C++ code like this:

class Bclass {
  public: virtual int operator()() { return 666; }
};

class Dclass: public Bclass {
  public: virtual int operator()() { return 667; }
} ;

int main(int argc, char** argv) {
  Dclass x;
  return x();
}

Into this:

int %main(int %argc, sbyte** %argv) {
entry:
        call void %__main( )
        ret int 667
}

Instead of this:

int %main(int %argc, sbyte** %argv) {
entry:
        %x = alloca "struct.std::bad_typeid"            ; <"struct.std::bad_typeid"*> [#uses=3]
        call void %__main( )
        %tmp.1.i.i = getelementptr "struct.std::bad_typeid"* %x, uint 0, uint 0, uint 0         ; <int (...)***> [#uses=1]
        store int (...)** getelementptr ([3 x int (...)*]*  %vtable for Bclass, int 0, long 2), int (...)*** %tmp.1.i.i
        %tmp.3.i = getelementptr "struct.std::bad_typeid"* %x, int 0, uint 0, uint 0            ; <int (...)***> [#uses=1]
        store int (...)** getelementptr ([3 x int (...)*]*  %vtable for Dclass, int 0, long 2), int (...)*** %tmp.3.i
        %tmp.5 = load int ("struct.std::bad_typeid"*)** cast (int (...)** getelementptr ([3 x int (...)*]*  %vtable for Dclass, int 0, long 2) to int
("struct.std::bad_typeid"*)**)          ; <int ("struct.std::bad_typeid"*)*> [#uses=1]
        %tmp.6 = call int %tmp.5( "struct.std::bad_typeid"* %x )                ; <int> [#uses=1]
	ret int %tmp.6
        ret int 0
}

In order words, we now resolve the virtual function call.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14783 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-13 01:49:43 +00:00
..
Analysis Disable some code that isn't helping matters 2004-07-08 07:25:51 +00:00
Archive Add #include <iostream> which is needed now that Value.h doesn't include it 2004-07-04 11:01:27 +00:00
AsmParser Don't call Type::setName() 2004-07-09 16:43:55 +00:00
Bytecode Fix unused var warning 2004-07-12 20:29:52 +00:00
CodeGen Add checks to ensure that there are no unreachable blocks in the function 2004-07-09 16:44:37 +00:00
Debugger Add #include <iostream> since Value.h does not #include it any more. 2004-07-04 12:19:56 +00:00
ExecutionEngine The cleanup is done. Update comment. 2004-07-11 08:24:02 +00:00
Linker - #include <iostream> since its not in Value.h any more. 2004-07-04 11:52:49 +00:00
Support Implicitly getting a new option by linking to support.o instead of support.a 2004-07-11 01:04:33 +00:00
Target Correctly load FP constants out of the constant pool. 2004-07-12 23:49:47 +00:00
Transforms Factor some code to handle "load (constantexpr cast foo)" just like 2004-07-13 01:49:43 +00:00
VMCore implement new helper method 2004-07-12 20:35:11 +00:00
Makefile CBackend is no longer here 2004-02-13 23:29:37 +00:00