[cfe-commits] r78450 - in /cfe/trunk: include/clang/AST/Expr.h include/clang/AST/Stmt.h lib/AST/Stmt.cpp lib/Frontend/PCHReaderStmt.cpp lib/Sema/Sema.h lib/Sema/SemaTemplateInstantiateDecl.cpp lib/Sema/SemaTemplateInstantiateExpr.cpp

Daniel Dunbar daniel at zuster.org
Tue Aug 25 00:16:50 PDT 2009


On Wed, Aug 19, 2009 at 11:57 PM, Douglas Gregor<dgregor at apple.com> wrote:
>
> On Aug 19, 2009, at 11:42 PM, Chris Lattner wrote:
>
>> On Aug 7, 2009, at 6:41 PM, Douglas Gregor wrote:
>>> URL: http://llvm.org/viewvc/llvm-project?rev=78450&view=rev
>>> Log:
>>> Introduce reference counting for statements and expressions, using it
>>> to allow sharing of nodes. Simplifies some aspects of template
>>> instantiation, and fixes both PR3444 and <rdar://problem/6757457>.
>>
>> Yay for progress :)
>>
>>> +  /// \brief The statement class.
>>> +  const unsigned sClass : 8;
>>> +
>>> +  /// \brief The reference count for this statement.
>>> +  unsigned RefCount : 24;
>>
>> Random thought, do you ever expect to need more than 65536 ref
>> counts?  If not, shrinking the refcount to be an unsigned short
>> would lead to slightly more efficient generated code for some
>> operations.
>
> It's possible that a given template could get instantiated more than
> 65535 times in some crazy template metaprograms, which would cause a
> reference count of > 65535 for non-dependent expressions that occur in
> the template's definition. We're probably stuck with a 24-bit ref count.

In addition, the current scheme doesn't actually muck with the ref
count very frequently, so the ref counting code gen is probably a
non-issue.

 - Daniel




More information about the cfe-commits mailing list