diff options
author | Anders Carlsson <andersca@mac.com> | 2009-12-05 21:28:12 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-12-05 21:28:12 +0000 |
commit | bb27d868ac3ca429bfe0f52c5f091f849368fff8 (patch) | |
tree | b5f0e55353b412a1cb14355bd56f5bb5ab63c0e7 /lib/CodeGen/CGCXX.cpp | |
parent | e40477cd57d5297ff5e4cc5e4515744c42a96ce2 (diff) |
CodeGenModule::GenerateVtable now returns a pointer directly to the vtable and not to the address point.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90676 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGCXX.cpp')
-rw-r--r-- | lib/CodeGen/CGCXX.cpp | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp index c536350ad4..a2674b82d1 100644 --- a/lib/CodeGen/CGCXX.cpp +++ b/lib/CodeGen/CGCXX.cpp @@ -1682,8 +1682,7 @@ void CodeGenFunction::EmitCtorPrologue(const CXXConstructorDecl *CD, const CXXRecordDecl *ClassDecl = CD->getParent(); // FIXME: Add vbase initialization - llvm::Value *LoadOfThis = 0; - + for (CXXConstructorDecl::init_const_iterator B = CD->init_begin(), E = CD->init_end(); B != E; ++B) { @@ -1705,15 +1704,21 @@ void CodeGenFunction::EmitCtorPrologue(const CXXConstructorDecl *CD, if (!ClassDecl->isDynamicClass()) return; - // Initialize the vtable pointer - if (!LoadOfThis) - LoadOfThis = LoadCXXThis(); + // Initialize the vtable pointer. + // FIXME: This needs to initialize secondary vtable pointers too. + llvm::Value *ThisPtr = LoadCXXThis(); - const llvm::Type *Int8PtrTy = llvm::Type::getInt8PtrTy(VMContext); + llvm::Constant *Vtable = CGM.getVtableInfo().getVtable(ClassDecl); + uint64_t AddressPoint = CGM.getVtableInfo().getVtableAddressPoint(ClassDecl); + + llvm::Value *VtableAddressPoint = + Builder.CreateConstInBoundsGEP2_64(Vtable, 0, AddressPoint); + llvm::Value *VtableField = - Builder.CreateBitCast(LoadOfThis, Int8PtrTy->getPointerTo()); - llvm::Value *vtable = CGM.getVtableInfo().getVtable(ClassDecl); - Builder.CreateStore(vtable, VtableField); + Builder.CreateBitCast(ThisPtr, + VtableAddressPoint->getType()->getPointerTo()); + + Builder.CreateStore(VtableAddressPoint, VtableField); } /// EmitDtorEpilogue - Emit all code that comes at the end of class's |