diff options
author | Reid Kleckner <reid@kleckner.net> | 2014-12-03 21:00:21 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2014-12-03 21:00:21 +0000 |
commit | 8d58513da49ce3636afb3b6921dccd377b892ae5 (patch) | |
tree | 9200b83942772063268716df8fbaef6e653540cf /clang/lib/CodeGen/CGClass.cpp | |
parent | 1780d82f35cf8cbb78cca779c24c7bd36564b67e (diff) | |
download | llvm-8d58513da49ce3636afb3b6921dccd377b892ae5.zip llvm-8d58513da49ce3636afb3b6921dccd377b892ae5.tar.gz llvm-8d58513da49ce3636afb3b6921dccd377b892ae5.tar.bz2 |
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
Diffstat (limited to 'clang/lib/CodeGen/CGClass.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGClass.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp index 3957eb7..dd19471 100644 --- a/clang/lib/CodeGen/CGClass.cpp +++ b/clang/lib/CodeGen/CGClass.cpp @@ -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()); } |