Changeset View
Changeset View
Standalone View
Standalone View
clang/lib/CodeGen/CGClass.cpp
Show First 20 Lines • Show All 2,502 Lines • ▼ Show 20 Lines | void CodeGenFunction::InitializeVTablePointer(const VPtr &Vptr) { | ||||
if (!NonVirtualOffset.isZero() || VirtualOffset) | if (!NonVirtualOffset.isZero() || VirtualOffset) | ||||
VTableField = ApplyNonVirtualAndVirtualOffset( | VTableField = ApplyNonVirtualAndVirtualOffset( | ||||
*this, VTableField, NonVirtualOffset, VirtualOffset, Vptr.VTableClass, | *this, VTableField, NonVirtualOffset, VirtualOffset, Vptr.VTableClass, | ||||
Vptr.NearestVBase); | Vptr.NearestVBase); | ||||
// Finally, store the address point. Use the same LLVM types as the field to | // Finally, store the address point. Use the same LLVM types as the field to | ||||
// support optimization. | // support optimization. | ||||
unsigned GlobalsAS = CGM.getDataLayout().getDefaultGlobalsAddressSpace(); | |||||
unsigned ProgAS = CGM.getDataLayout().getProgramAddressSpace(); | |||||
llvm::Type *VTablePtrTy = | llvm::Type *VTablePtrTy = | ||||
llvm::FunctionType::get(CGM.Int32Ty, /*isVarArg=*/true) | llvm::FunctionType::get(CGM.Int32Ty, /*isVarArg=*/true) | ||||
->getPointerTo() | ->getPointerTo(ProgAS) | ||||
->getPointerTo(); | ->getPointerTo(GlobalsAS); | ||||
VTableField = Builder.CreateBitCast(VTableField, VTablePtrTy->getPointerTo()); | VTableField = Builder.CreatePointerBitCastOrAddrSpaceCast( | ||||
VTableAddressPoint = Builder.CreateBitCast(VTableAddressPoint, VTablePtrTy); | VTableField, VTablePtrTy->getPointerTo(GlobalsAS)); | ||||
VTableAddressPoint = Builder.CreatePointerBitCastOrAddrSpaceCast( | |||||
VTableAddressPoint, VTablePtrTy); | |||||
llvm::StoreInst *Store = Builder.CreateStore(VTableAddressPoint, VTableField); | llvm::StoreInst *Store = Builder.CreateStore(VTableAddressPoint, VTableField); | ||||
TBAAAccessInfo TBAAInfo = CGM.getTBAAVTablePtrAccessInfo(VTablePtrTy); | TBAAAccessInfo TBAAInfo = CGM.getTBAAVTablePtrAccessInfo(VTablePtrTy); | ||||
CGM.DecorateInstructionWithTBAA(Store, TBAAInfo); | CGM.DecorateInstructionWithTBAA(Store, TBAAInfo); | ||||
if (CGM.getCodeGenOpts().OptimizationLevel > 0 && | if (CGM.getCodeGenOpts().OptimizationLevel > 0 && | ||||
CGM.getCodeGenOpts().StrictVTablePointers) | CGM.getCodeGenOpts().StrictVTablePointers) | ||||
CGM.DecorateInstructionWithInvariantGroup(Store, Vptr.VTableClass); | CGM.DecorateInstructionWithInvariantGroup(Store, Vptr.VTableClass); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 443 Lines • Show Last 20 Lines |