diff options
author | Piotr Padlewski <prazek@google.com> | 2015-09-09 22:20:28 +0000 |
---|---|---|
committer | Piotr Padlewski <prazek@google.com> | 2015-09-09 22:20:28 +0000 |
commit | 255652e828ea84957f76d6719436e34ece09605d (patch) | |
tree | fd7ccd2736929fe411a932a9a07928d386b400f2 /clang/lib/CodeGen/CodeGenFunction.h | |
parent | 66ef16b2890e57d4cc94e4ebf902a9ed741e8c26 (diff) | |
download | llvm-255652e828ea84957f76d6719436e34ece09605d.zip llvm-255652e828ea84957f76d6719436e34ece09605d.tar.gz llvm-255652e828ea84957f76d6719436e34ece09605d.tar.bz2 |
Generating assumption loads of vptr after ctor call (fixed)
Generating call assume(icmp %vtable, %global_vtable) after constructor
call for devirtualization purposes.
For more info go to:
http://lists.llvm.org/pipermail/cfe-dev/2015-July/044227.html
Edit:
Fixed version because of PR24479.
After this patch got reverted because of ScalarEvolution bug (D12719)
Merged after John McCall big patch (Added Address).
http://reviews.llvm.org/D11859
llvm-svn: 247199
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.h')
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.h | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index 3925932..3411272 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -1354,21 +1354,27 @@ public: void EmitInitializerForField(FieldDecl *Field, LValue LHS, Expr *Init, ArrayRef<VarDecl *> ArrayIndexes); - /// InitializeVTablePointer - Initialize the vtable pointer of the given - /// subobject. - /// - void InitializeVTablePointer(BaseSubobject Base, - const CXXRecordDecl *NearestVBase, - CharUnits OffsetFromNearestVBase, - const CXXRecordDecl *VTableClass); + /// Struct with all informations about dynamic [sub]class needed to set vptr. + struct VPtr { + BaseSubobject Base; + const CXXRecordDecl *NearestVBase; + CharUnits OffsetFromNearestVBase; + const CXXRecordDecl *VTableClass; + }; + + /// Initialize the vtable pointer of the given subobject. + void InitializeVTablePointer(const VPtr &vptr); + + typedef llvm::SmallVector<VPtr, 4> VPtrsVector; typedef llvm::SmallPtrSet<const CXXRecordDecl *, 4> VisitedVirtualBasesSetTy; - void InitializeVTablePointers(BaseSubobject Base, - const CXXRecordDecl *NearestVBase, - CharUnits OffsetFromNearestVBase, - bool BaseIsNonVirtualPrimaryBase, - const CXXRecordDecl *VTableClass, - VisitedVirtualBasesSetTy& VBases); + VPtrsVector getVTablePointers(const CXXRecordDecl *VTableClass); + + void getVTablePointers(BaseSubobject Base, const CXXRecordDecl *NearestVBase, + CharUnits OffsetFromNearestVBase, + bool BaseIsNonVirtualPrimaryBase, + const CXXRecordDecl *VTableClass, + VisitedVirtualBasesSetTy &VBases, VPtrsVector &vptrs); void InitializeVTablePointers(const CXXRecordDecl *ClassDecl); @@ -1836,10 +1842,18 @@ public: // they are substantially the same. void EmitDelegatingCXXConstructorCall(const CXXConstructorDecl *Ctor, const FunctionArgList &Args); + void EmitCXXConstructorCall(const CXXConstructorDecl *D, CXXCtorType Type, bool ForVirtualBase, bool Delegating, Address This, const CXXConstructExpr *E); + /// Emit assumption load for all bases. Requires to be be called only on + /// most-derived class and not under construction of the object. + void EmitVTableAssumptionLoads(const CXXRecordDecl *ClassDecl, Address This); + + /// Emit assumption that vptr load == global vtable. + void EmitVTableAssumptionLoad(const VPtr &vptr, Address This); + void EmitSynthesizedCXXCopyCtorCall(const CXXConstructorDecl *D, Address This, Address Src, const CXXConstructExpr *E); |