diff options
| author | Anders Carlsson <andersca@mac.com> | 2010-05-03 00:29:58 +0000 |
|---|---|---|
| committer | Anders Carlsson <andersca@mac.com> | 2010-05-03 00:29:58 +0000 |
| commit | c58fb552f327a7af1806b8e8f7fabfd7503023b6 (patch) | |
| tree | d7ae370be263523b26f8c457a286bdfac2c6a42c /clang/lib/CodeGen | |
| parent | c4d0d0fed195742e5a315bdd5d1d7bc65264a26c (diff) | |
| download | bcm5719-llvm-c58fb552f327a7af1806b8e8f7fabfd7503023b6.tar.gz bcm5719-llvm-c58fb552f327a7af1806b8e8f7fabfd7503023b6.zip | |
Get rid of the last caller of OldGetAddressOfBaseClass.
llvm-svn: 102888
Diffstat (limited to 'clang/lib/CodeGen')
| -rw-r--r-- | clang/lib/CodeGen/CGClass.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp index d76279a54e9..a070b7f55e9 100644 --- a/clang/lib/CodeGen/CGClass.cpp +++ b/clang/lib/CodeGen/CGClass.cpp @@ -1402,19 +1402,27 @@ CodeGenFunction::InitializeVTablePointer(BaseSubobject Base, } // Compute where to store the address point. - llvm::Value *VTableField; + llvm::Value *VirtualOffset = 0; + uint64_t NonVirtualOffset = 0; if (CodeGenVTables::needsVTTParameter(CurGD) && NearestVBase) { // We need to use the virtual base offset offset because the virtual base // might have a different offset in the most derived class. - VTableField = OldGetAddressOfBaseClass(LoadCXXThis(), VTableClass, RD); + VirtualOffset = GetVirtualBaseClassOffset(LoadCXXThis(), VTableClass, + NearestVBase); + NonVirtualOffset = OffsetFromNearestVBase / 8; } else { - const llvm::Type *Int8PtrTy = llvm::Type::getInt8PtrTy(CGM.getLLVMContext()); - - VTableField = Builder.CreateBitCast(LoadCXXThis(), Int8PtrTy); - VTableField = - Builder.CreateConstInBoundsGEP1_64(VTableField, Base.getBaseOffset() / 8); + // We can just use the base offset in the complete class. + NonVirtualOffset = Base.getBaseOffset() / 8; } + + // Apply the offsets. + llvm::Value *VTableField = LoadCXXThis(); + + if (NonVirtualOffset || VirtualOffset) + VTableField = ApplyNonVirtualAndVirtualOffset(*this, VTableField, + NonVirtualOffset, + VirtualOffset); // Finally, store the address point. const llvm::Type *AddressPointPtrTy = @@ -1471,7 +1479,7 @@ CodeGenFunction::InitializeVTablePointers(BaseSubobject Base, BaseOffset = Base.getBaseOffset() + Layout.getBaseClassOffset(BaseDecl); BaseOffsetFromNearestVBase = - BaseOffsetFromNearestVBase + Layout.getBaseClassOffset(BaseDecl); + OffsetFromNearestVBase + Layout.getBaseClassOffset(BaseDecl); BaseDeclIsNonVirtualPrimaryBase = Layout.getPrimaryBase() == BaseDecl; } |

