[cfe-dev] Patch for ContextDecl

Chris Lattner clattner at apple.com
Mon Apr 7 23:22:24 PDT 2008


On Apr 7, 2008, at 7:03 PM, Argiris Kirtzidis wrote:
>>>> That is a 6.1% slowdown on carbon.h and 4% slowdown on Cocoa.h.    
>>>> The number on this machine are very stable, three consecutive  
>>>> runs all produced the same timings.  While I really would like to  
>>>> have the cleanup, I don't think the cost is worth it.  When  
>>>> coming from a .i file (to reduce syscall/preprocessor overhead)  
>>>> the slowdown is 8.4% for carbon.h (0.119s -> 0.129s).
>>>>
>>>> What do you think?  If you want, I can provide you with a .i file  
>>>> of cocoa.h or carbon.h.
>>> Yes, that would be great! I wanted to test on something but  
>>> couldn't find something appropriate.
>>
>> Here ya go:
>>
>> http://nondot.org/sabre/misc
>>
>> -Chris
>
> Can you try again with the attached patch ?

I'm seeing lots of 'make test' errors with this patch.  I updated it  
to work with Doug's recent patch, here's what I'm using:

-------------- next part --------------
A non-text attachment was scrubbed...
Name: id-decl-map2.patch
Type: application/octet-stream
Size: 11060 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20080407/a7b36b6f/attachment.obj>
-------------- next part --------------




Steve and I were talking about this and came up with a potentially  
interesting refinement to your approach.  The observation we make is  
that shadowing of decls is actually really really rare in practice. It  
would be interesting to see stats, but I bet only a very small  
percentage of identifiers every have a scope chain with length > 1.

To take advantage of this, you could abuse the FETokenInfo a bit :),  
like we do in the 'Selector' class: if the field is null, it obviously  
doesn't point to anything.  If non-null and the low bit is clear, you  
could treat it as a pointer to a single unshadowed decl node.  If non- 
null with the low bit set, you could treat it as a pointer to the  
IdDeclInfo.

This would keep the common case (no shadowing) extraordinarily cheap,  
while allowing graceful fallback when there is shadowing.  What do you  
think?

-Chris


More information about the cfe-dev mailing list