Steve Naroff [Tue, 27 Jan 2009 22:08:43 +0000 (22:08 +0000)]
Convert types over to placement new() that takes an ASTContext.
Also changed FunctionTypeProto to be allocated with 8-byte alignment (noticed by Doug). I couldn't think of any reason to allocate on 16-byte boundaries. If anyone remembers why we were doing this, let me know!
Steve Naroff [Tue, 27 Jan 2009 21:25:57 +0000 (21:25 +0000)]
Remove many references to ASTContext::getAllocator(), replacing them with calls to the recently added placement new (which uses ASTContext's allocator for memory). Also added ASTContext::Deallocate().
This will simplify runtime replacement of ASTContext's allocator. Keeping the allocator private (and removing getAllocator() entirely) is also goodness.
Chris Lattner [Tue, 27 Jan 2009 18:30:58 +0000 (18:30 +0000)]
Split the single monolithic DiagnosticKinds.def file into one
.def file for each library. This means that adding a diagnostic
to sema doesn't require all the other libraries to be rebuilt.
Ted Kremenek [Tue, 27 Jan 2009 18:29:03 +0000 (18:29 +0000)]
Fix bug in BasicStore::getLValueElement where if the base of an array subscript expression was an ElementRegion we stacked another ElementRegion on top of that.
Chris Lattner [Tue, 27 Jan 2009 18:08:34 +0000 (18:08 +0000)]
add a new "getPreferredTypeAlign" method to return the preferred alignment
of a type. The implementation is currently something of a hack, but is
sufficient for now and allows clients to be built on it.
Chris Lattner [Tue, 27 Jan 2009 07:57:44 +0000 (07:57 +0000)]
Introduce a new PresumedLoc class to represent the concept of a location
as reported to the user and as manipulated by #line. This is what __FILE__,
__INCLUDE_LEVEL__, diagnostics and other things should follow (but not
dependency generation!).
This patch also includes several cleanups along the way:
- SourceLocation now has a dump method, and several other places
that did similar things now use it.
- I cleaned up some code in AnalysisConsumer, but it should probably be
simplified further now that NamedDecl is better.
- TextDiagnosticPrinter is now simplified and cleaned up a bit.
This patch is a prerequisite for #line, but does not actually provide
any #line functionality.
Ted Kremenek [Tue, 27 Jan 2009 01:53:39 +0000 (01:53 +0000)]
PathDiagnostics:
- Add the distinction between the 'bug type' and the 'bug description'
HTMLDiagnostics:
- Output the bug type field as HTML comments
scan-build:
- Use the bug type field instead of the bug description for the HTML table.
- Radar filing now automatically picks up the bug description in the title (addresses <rdar://problem/6265970>)
Ted Kremenek [Tue, 27 Jan 2009 00:01:05 +0000 (00:01 +0000)]
PTH: Use Token::setLiteralData() to directly store a pointer to cached spelling data in the PTH file. This removes a ton of code for looking up spellings using sourcelocations in the PTH file. This simplifies both PTH-generation and reading.
Performance impact for -fsyntax-only on Cocoa.h (with Cocoa.h in the PTH file):
- PTH generation time improves by 5%
- PTH reading improves by 0.3%.
Douglas Gregor [Mon, 26 Jan 2009 22:44:13 +0000 (22:44 +0000)]
Some micro-optimizations for DISABLE_SMART_POINTERS:
- When it's safe, ActionResult uses the low bit of the pointer for
the "invalid" flag rather than a separate "bool" value. This keeps
GCC from generating some truly awful code, for a > 3x speedup in the
result-passing microbenchmark.
- When DISABLE_SMART_POINTERS is defined, store an ActionResult
within ASTOwningResult rather than an ASTOwningPtr. Brings the
performance benefits of the above to smart pointers with
DISABLE_SMART_POINTERS defined.
Sadly, these micro-benchmark performance improvements don't seem to
make much of a difference on Cocoa.h right now. However, they're
harmless and might help with future optimizations.
Chris Lattner [Mon, 26 Jan 2009 22:24:27 +0000 (22:24 +0000)]
Fix a bug I introduced in my changes, which caused MeasureTokenLength
to crash when given an instantiation location. Thanks to Fariborz for
the testcase.
Ted Kremenek [Mon, 26 Jan 2009 21:43:14 +0000 (21:43 +0000)]
Embed the offset of the PTH table inside the prologue of the PTH file. This will help improve gradual versioning of PTH files instead of relying that the PTH table is at a fixed offset.
Chris Lattner [Mon, 26 Jan 2009 20:24:53 +0000 (20:24 +0000)]
remove my hacks that aggressively threw away multiple
instantiation history in an effort to speed up c99-intconst-1.c.
Now that multiple nested instantiations are allowed, we just
make them and don't pay the cost of lookups. With the other
changes that went in before this, reverting this is actually
a speedup for c99-intconst-1.c, speeding it up from 1.96s to 1.80s,
and preserves much better loc info.
Chris Lattner [Mon, 26 Jan 2009 20:08:26 +0000 (20:08 +0000)]
now that everything properly handles multiply instantiated
source locations, allow creation of them. We can now say that
a token was instantiated here, then here, then here.
Chris Lattner [Mon, 26 Jan 2009 19:41:58 +0000 (19:41 +0000)]
fix a negated conditional in getDecomposedInstantiationLocSlowCase,
which I think is rdar://6527005, and make getDecomposedSpellingLocSlowCase
handle nested spelling locations.
Chris Lattner [Mon, 26 Jan 2009 19:29:26 +0000 (19:29 +0000)]
This change refactors some of the low-level lexer interfaces a bit.
Token now has a class of kinds for "literals", which include
numeric constants, strings, etc. These tokens can optionally have
a pointer to the start of the token in the lexer buffer. This
makes it faster to get spelling and do other gymnastics, because we
don't have to go through source locations.
This change is performance neutral, but will make other changes
more feasible down the road.
Chris Lattner [Mon, 26 Jan 2009 06:49:09 +0000 (06:49 +0000)]
Bitmangle file characteristic bits into the low bits of
the content cache pointer. This saves 105876 bytes on
cocoa.h because it shrinks the SLocEntry union, which
we have a big array of. It would be nice to use
PointerIntPair here, but we can't because it is in a
union.
Chris Lattner [Mon, 26 Jan 2009 04:33:10 +0000 (04:33 +0000)]
eagerly resolve the spelling locations of macro argument preexpansions.
This reduces fsyntax-only time on c99-intconst-1.c from 2.43s down to
2.01s (20%), reducing the number of fileid lookups from 2529040 linear
and 64771121 binary to 5625902 linear and 4151182 binary.
This knocks getFileID down to only 4.6% of compile time on this testcase.
At this point, malloc/free is over 35% of compile time, primarily allocating
MacroArgs objects and their argument preexpansion vectors.
I don't feel like malloc avoiding right now, so I'm just going to call
this good.
Chris Lattner [Mon, 26 Jan 2009 04:06:48 +0000 (04:06 +0000)]
Eagerly resolve the spelling location of the tokens in a definition
of a macro. Since these tokens may themselves be from macro
expansions, we need to resolve down to the spelling loc when the
macro ends up being instantiated. Instead of resolving this for
each token expanded from the macro definition, just do it once when
the macro is defined. This speeds up clang on c99-intconst-1.c from
2.66s to 2.43s (9.5%), reducing the FileID lookups from 407244 linear and 114175649 binary to 2529040 linear and 64771121 binary.
Chris Lattner [Mon, 26 Jan 2009 03:46:22 +0000 (03:46 +0000)]
Only resolve a macro's instantiation loc once per macro, instead of once
per token lexed from it. This speeds up clang on c99-intconst-1.c from
the GCC testsuite from 3.64s to 2.66s (36%). This reduces the number of
binary search FileID lookups from 251570522 to 114175649 on this testcase.
Eli Friedman [Sun, 25 Jan 2009 02:32:41 +0000 (02:32 +0000)]
Rename Expr::isConstantExpr to Expr::isConstantInitializer; this more
accurately states what the function is trying to do and how it is
different from Expr::isEvaluatable. Also get rid of a parameter that is both
unused and inaccurate.
Eli Friedman [Sun, 25 Jan 2009 01:54:01 +0000 (01:54 +0000)]
Make the constant folder aware of
__builtin___CFStringMakeConstantString. (We get into trouble in
GenerateStaticBlockVarDecl if the constant folder isn't accurate.)
Eli Friedman [Sat, 24 Jan 2009 23:09:00 +0000 (23:09 +0000)]
PR3062: statement expressions should be illegal at file scope. I don't
think this has any significant effects at the moment, but it could
matter if we start constant-folding statement expressions like gcc does.
Chris Lattner [Sat, 24 Jan 2009 21:53:27 +0000 (21:53 +0000)]
add initial support for the gcc "alignof(decl) is the alignment of the decl
not the type" semantics. This can definitely be improved, but is better than
what we had.