diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2011-01-28 23:42:29 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2011-01-28 23:42:29 +0000 |
commit | a50e33eb0ff7b73d44aebce88de3732583a7e960 (patch) | |
tree | 24cf4825a3d316cacc20462de14338d9470fd88c /lib | |
parent | 28dadd6c88e0b93b1b99edd460548625359786b7 (diff) |
More work to support -fapple-kext regarding
indirect vf calls and addition of extra entry
at bottom of vtbls.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124507 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CodeGen/CGCXX.cpp | 4 | ||||
-rw-r--r-- | lib/CodeGen/CGExprCXX.cpp | 1 | ||||
-rw-r--r-- | lib/CodeGen/CGVTables.cpp | 7 |
3 files changed, 11 insertions, 1 deletions
diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp index b6381de027..c9c95883c7 100644 --- a/lib/CodeGen/CGCXX.cpp +++ b/lib/CodeGen/CGCXX.cpp @@ -329,7 +329,9 @@ CodeGenFunction::BuildAppleKextVirtualCall(const CXXMethodDecl *MD, assert(VTable && "BuildVirtualCall = kext vtbl pointer is null"); MD = MD->getCanonicalDecl(); uint64_t VTableIndex = CGM.getVTables().getMethodVTableIndex(MD); - VTableIndex += 2; + uint64_t AddressPoint = + CGM.getVTables().getAddressPoint(BaseSubobject(RD, 0), RD); + VTableIndex += AddressPoint; llvm::Value *VFuncPtr = CGF.Builder.CreateConstInBoundsGEP1_64(VTable, VTableIndex, "vfnkxt"); return CGF.Builder.CreateLoad(VFuncPtr); diff --git a/lib/CodeGen/CGExprCXX.cpp b/lib/CodeGen/CGExprCXX.cpp index 513d80be0b..03b90e2587 100644 --- a/lib/CodeGen/CGExprCXX.cpp +++ b/lib/CodeGen/CGExprCXX.cpp @@ -195,6 +195,7 @@ RValue CodeGenFunction::EmitCXXMemberCallExpr(const CXXMemberCallExpr *CE, Callee = BuildVirtualCall(MD, This, Ty); } else { if (getContext().getLangOptions().AppleKext && + MD->isVirtual() && ME->hasQualifier()) Callee = BuildAppleKextVirtualCall(MD, ME->getQualifier(), This, Ty); else diff --git a/lib/CodeGen/CGVTables.cpp b/lib/CodeGen/CGVTables.cpp index ff65e583bb..5df3ac52b5 100644 --- a/lib/CodeGen/CGVTables.cpp +++ b/lib/CodeGen/CGVTables.cpp @@ -2758,7 +2758,14 @@ void CodeGenVTables::ComputeVTableRelatedInformation(const CXXRecordDecl *RD, // Add the VTable layout. uint64_t NumVTableComponents = Builder.getNumVTableComponents(); + // -fapple-kext adds an extra entry at end of vtbl. + bool IsAppleKext = CGM.getContext().getLangOptions().AppleKext; + if (IsAppleKext) + NumVTableComponents += 1; + uint64_t *LayoutData = new uint64_t[NumVTableComponents + 1]; + if (IsAppleKext) + LayoutData[NumVTableComponents] = 0; Entry.setPointer(LayoutData); // Store the number of components. |