}
llvm::Value *
-CodeGenFunction::GetAddressOfBaseClass(llvm::Value *Value,
- const CXXRecordDecl *Class,
- const CXXRecordDecl *BaseClass,
- bool NullCheckValue) {
+CodeGenFunction::OldGetAddressOfBaseClass(llvm::Value *Value,
+ const CXXRecordDecl *Class,
+ const CXXRecordDecl *BaseClass) {
QualType BTy =
getContext().getCanonicalType(
getContext().getTypeDeclType(BaseClass));
return Builder.CreateBitCast(Value, BasePtrTy);
}
- llvm::BasicBlock *CastNull = 0;
- llvm::BasicBlock *CastNotNull = 0;
- llvm::BasicBlock *CastEnd = 0;
-
- if (NullCheckValue) {
- CastNull = createBasicBlock("cast.null");
- CastNotNull = createBasicBlock("cast.notnull");
- CastEnd = createBasicBlock("cast.end");
-
- llvm::Value *IsNull =
- Builder.CreateICmpEQ(Value,
- llvm::Constant::getNullValue(Value->getType()));
- Builder.CreateCondBr(IsNull, CastNull, CastNotNull);
- EmitBlock(CastNotNull);
- }
-
llvm::Value *VirtualOffset = 0;
if (VBase)
// Cast back.
Value = Builder.CreateBitCast(Value, BasePtrTy);
-
- if (NullCheckValue) {
- Builder.CreateBr(CastEnd);
- EmitBlock(CastNull);
- Builder.CreateBr(CastEnd);
- EmitBlock(CastEnd);
-
- llvm::PHINode *PHI = Builder.CreatePHI(Value->getType());
- PHI->reserveOperandSpace(2);
- PHI->addIncoming(Value, CastNotNull);
- PHI->addIncoming(llvm::Constant::getNullValue(Value->getType()),
- CastNull);
- Value = PHI;
- }
-
return Value;
}
CXXCtorType CtorType = Ctor_Complete;
if (ClassDecl) {
- Dest = GetAddressOfBaseClass(Dest, ClassDecl, BaseClassDecl,
- /*NullCheckValue=*/false);
- Src = GetAddressOfBaseClass(Src, ClassDecl, BaseClassDecl,
- /*NullCheckValue=*/false);
+ Dest = OldGetAddressOfBaseClass(Dest, ClassDecl, BaseClassDecl);
+ Src = OldGetAddressOfBaseClass(Src, ClassDecl, BaseClassDecl);
// We want to call the base constructor.
CtorType = Ctor_Base;
const CXXRecordDecl *BaseClassDecl,
QualType Ty) {
if (ClassDecl) {
- Dest = GetAddressOfBaseClass(Dest, ClassDecl, BaseClassDecl,
- /*NullCheckValue=*/false);
- Src = GetAddressOfBaseClass(Src, ClassDecl, BaseClassDecl,
- /*NullCheckValue=*/false);
+ Dest = OldGetAddressOfBaseClass(Dest, ClassDecl, BaseClassDecl);
+ Src = OldGetAddressOfBaseClass(Src, ClassDecl, BaseClassDecl);
}
if (BaseClassDecl->hasTrivialCopyAssignment()) {
EmitAggregateCopy(Dest, Src, Ty);
continue;
const CXXDestructorDecl *D = BaseClassDecl->getDestructor(getContext());
- llvm::Value *V = GetAddressOfBaseClass(LoadCXXThis(),
- ClassDecl, BaseClassDecl,
- /*NullCheckValue=*/false);
+ llvm::Value *V = OldGetAddressOfBaseClass(LoadCXXThis(),
+ ClassDecl, BaseClassDecl);
EmitCXXDestructorCall(D, Dtor_Base, V);
}
}
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 = GetAddressOfBaseClass(LoadCXXThis(), VTableClass, RD,
- /*NullCheckValue=*/false);
+ VTableField = OldGetAddressOfBaseClass(LoadCXXThis(), VTableClass, RD);
} else {
const llvm::Type *Int8PtrTy = llvm::Type::getInt8PtrTy(CGM.getLLVMContext());
bool IsVirtual,
const CXXRecordDecl *Derived,
const CXXRecordDecl *Base);
-
+
+ llvm::Value *OldGetAddressOfBaseClass(llvm::Value *Value,
+ const CXXRecordDecl *ClassDecl,
+ const CXXRecordDecl *BaseClassDecl);
+
/// GetAddressOfBaseClass - This function will add the necessary delta to the
/// load of 'this' and returns address of the base class.
- llvm::Value *GetAddressOfBaseClass(llvm::Value *Value,
- const CXXRecordDecl *ClassDecl,
- const CXXRecordDecl *BaseClassDecl,
- bool NullCheckValue);
llvm::Value *GetAddressOfBaseClass(llvm::Value *Value,
const CXXRecordDecl *ClassDecl,
const CXXBaseSpecifierArray &BasePath,