[cfe-commits] r124507 - in /cfe/trunk: lib/CodeGen/CGCXX.cpp lib/CodeGen/CGExprCXX.cpp lib/CodeGen/CGVTables.cpp test/CodeGenCXX/apple-kext-indirect-call-2.C

jahanian fjahanian at apple.com
Mon Jan 31 09:17:44 PST 2011


On Jan 31, 2011, at 7:26 AM, Douglas Gregor wrote:

> 
> On Jan 28, 2011, at 3:42 PM, Fariborz Jahanian wrote:
> 
>> Author: fjahanian
>> Date: Fri Jan 28 17:42:29 2011
>> New Revision: 124507
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=124507&view=rev
>> Log:
>> More work to support -fapple-kext regarding 
>> indirect vf calls and addition of extra entry
>> at bottom of vtbls.
>> 
>> Added:
>>    cfe/trunk/test/CodeGenCXX/apple-kext-indirect-call-2.C
>> Modified:
>>    cfe/trunk/lib/CodeGen/CGCXX.cpp
>>    cfe/trunk/lib/CodeGen/CGExprCXX.cpp
>>    cfe/trunk/lib/CodeGen/CGVTables.cpp
>> 
>> Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=124507&r1=124506&r2=124507&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGCXX.cpp Fri Jan 28 17:42:29 2011
>> @@ -329,7 +329,9 @@
>>   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);
> 
> Ah, I think I understand this now. We'll want to document what we're doing somewhere.

Yes. We have have the documentation of what -fapple-kext does after al pieces are known and are in place.

> 
>> Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=124507&r1=124506&r2=124507&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/CodeGen/CGVTables.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGVTables.cpp Fri Jan 28 17:42:29 2011
>> @@ -2758,7 +2758,14 @@
>> 
>>   // 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);
> 
> NumVTableComponents-1?

We are adding a null entry after all other entries. So, last entry is nullified.

- Fariborz
> 
> 	- Doug
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20110131/ddce6a76/attachment.html>


More information about the cfe-commits mailing list