summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGCXX.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-12-05 21:28:12 +0000
committerAnders Carlsson <andersca@mac.com>2009-12-05 21:28:12 +0000
commitb3f54b748da3b90abaad12e3556b07bc33ee6f51 (patch)
tree33e29b15cfd3230b4092422d78344afc406732f6 /clang/lib/CodeGen/CGCXX.cpp
parenta95d4c51dcfa404423862dfe292f96ec0a6fbc2b (diff)
downloadbcm5719-llvm-b3f54b748da3b90abaad12e3556b07bc33ee6f51.tar.gz
bcm5719-llvm-b3f54b748da3b90abaad12e3556b07bc33ee6f51.zip
CodeGenModule::GenerateVtable now returns a pointer directly to the vtable and not to the address point.
llvm-svn: 90676
Diffstat (limited to 'clang/lib/CodeGen/CGCXX.cpp')
-rw-r--r--clang/lib/CodeGen/CGCXX.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/clang/lib/CodeGen/CGCXX.cpp b/clang/lib/CodeGen/CGCXX.cpp
index c536350ad4b..a2674b82d1b 100644
--- a/clang/lib/CodeGen/CGCXX.cpp
+++ b/clang/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
OpenPOWER on IntegriCloud