summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2010-03-29 01:08:49 +0000
committerAnders Carlsson <andersca@mac.com>2010-03-29 01:08:49 +0000
commit5889027ccc55f68e3d00fdb144549fe71da14923 (patch)
treea06ccdd6ef66be92dc074124dc2e96ddacfb9947 /clang/lib/CodeGen
parent8baeaf0a267cd1a78e83691a740bb63ed575496a (diff)
downloadbcm5719-llvm-5889027ccc55f68e3d00fdb144549fe71da14923.tar.gz
bcm5719-llvm-5889027ccc55f68e3d00fdb144549fe71da14923.zip
Use construction vtables when needed. This is currently guarded by -fdump-vtable-layouts since it doesn't work 100% yet :)
llvm-svn: 99787
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGClass.cpp34
1 files changed, 29 insertions, 5 deletions
diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp
index 17802fc2010..4b5cffae853 100644
--- a/clang/lib/CodeGen/CGClass.cpp
+++ b/clang/lib/CodeGen/CGClass.cpp
@@ -1561,14 +1561,38 @@ CodeGenFunction::InitializeVTablePointer(BaseSubobject Base,
bool BaseIsMorallyVirtual,
llvm::Constant *VTable,
const CXXRecordDecl *VTableClass) {
+ const CXXRecordDecl *RD = Base.getBase();
+
// Compute the address point.
- const CodeGenVTables::AddrSubMap_t& AddressPoints =
- CGM.getVTables().getAddressPoints(VTableClass);
+ llvm::Value *VTableAddressPoint;
+
+ // FIXME: Always use the new vtable code once we know it works.
+ bool UseNewVTableCode = CGM.getLangOptions().DumpVtableLayouts;
+
+ // Check if we need to use a vtable from the VTT.
+ if (UseNewVTableCode && CodeGenVTables::needsVTTParameter(CurGD) &&
+ (RD->getNumVBases() || BaseIsMorallyVirtual)) {
+ // Get the secondary vpointer index.
+ uint64_t VirtualPointerIndex =
+ CGM.getVTables().getSecondaryVirtualPointerIndex(VTableClass, Base);
+
+ /// Load the VTT.
+ llvm::Value *VTT = LoadCXXVTT();
+ if (VirtualPointerIndex)
+ VTT = Builder.CreateConstInBoundsGEP1_64(VTT, VirtualPointerIndex);
+
+ // And load the address point from the VTT.
+ VTableAddressPoint = Builder.CreateLoad(VTT);
+ } else {
+ const CodeGenVTables::AddrSubMap_t& AddressPoints =
+ CGM.getVTables().getAddressPoints(VTableClass);
- uint64_t AddressPoint =
- AddressPoints.lookup(std::make_pair(Base.getBase(), Base.getBaseOffset()));
- llvm::Value *VTableAddressPoint =
+ uint64_t AddressPoint =
+ AddressPoints.lookup(std::make_pair(Base.getBase(),
+ Base.getBaseOffset()));
+ VTableAddressPoint =
Builder.CreateConstInBoundsGEP2_64(VTable, 0, AddressPoint);
+ }
// Compute where to store the address point.
const llvm::Type *Int8PtrTy = llvm::Type::getInt8PtrTy(CGM.getLLVMContext());
OpenPOWER on IntegriCloud