Cast vtable address points to i32 (...)** to enable more globalopt
We currently use i32 (...)** as the type of the vptr field in the LLVM struct type. LLVM's GlobalOpt prefers any bitcasts to be on the side of the data being stored rather than on the pointer being stored to. Reviewers: majnemer Differential Revision: http://reviews.llvm.org/D5916 llvm-svn: 223267
This commit is contained in:
@@ -1982,10 +1982,14 @@ CodeGenFunction::InitializeVTablePointer(BaseSubobject Base,
|
||||
NonVirtualOffset,
|
||||
VirtualOffset);
|
||||
|
||||
// Finally, store the address point.
|
||||
llvm::Type *AddressPointPtrTy =
|
||||
VTableAddressPoint->getType()->getPointerTo();
|
||||
VTableField = Builder.CreateBitCast(VTableField, AddressPointPtrTy);
|
||||
// Finally, store the address point. Use the same LLVM types as the field to
|
||||
// support optimization.
|
||||
llvm::Type *VTablePtrTy =
|
||||
llvm::FunctionType::get(CGM.Int32Ty, /*isVarArg=*/true)
|
||||
->getPointerTo()
|
||||
->getPointerTo();
|
||||
VTableField = Builder.CreateBitCast(VTableField, VTablePtrTy->getPointerTo());
|
||||
VTableAddressPoint = Builder.CreateBitCast(VTableAddressPoint, VTablePtrTy);
|
||||
llvm::StoreInst *Store = Builder.CreateStore(VTableAddressPoint, VTableField);
|
||||
CGM.DecorateInstruction(Store, CGM.getTBAAInfoForVTablePtr());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user