CFG:
- Add 'LoopTarget' pointer field to CFGBlock. This records if the block is used
as the 'loop back' path back to the head of a loop.
- For ForStmt, encode the loop back target as the increment code.
Eli Friedman [Tue, 28 Apr 2009 00:51:18 +0000 (00:51 +0000)]
Get rid of some useless uses of NoExtensions. The philosophy here is
that if we're going to print an extension warning anyway,
there's no point to changing behavior based on NoExtensions: it will
only make error recovery worse.
Note that this doesn't cause any behavior change because NoExtensions
isn't used by the current front-end. I'm still considering what to do about
the remaining use of NoExtensions in IdentifierTable.cpp.
Chris Lattner [Mon, 27 Apr 2009 21:45:14 +0000 (21:45 +0000)]
Teach PCH that ASTContext is optional. Move -parse-noop and -Eonly (so far)
processing to after PCH is loaded. -Eonly and -parse-noop are close to working
with PCH now but are not quite there yet.
Douglas Gregor [Mon, 27 Apr 2009 20:06:05 +0000 (20:06 +0000)]
Add Sema::ExtVectorDecls and Sema::ObjCCategoryImpls to the PCH file. Since these vectors are very, very rarely used and, when used in headers, and even when used are relatively small, we load them eagerly.
Add two new checker-specific attributes: 'objc_ownership_release' and
'objc_ownership_cfrelease'. These are the 'release' equivalents of
'objc_ownership_retain' and 'objc_ownership_cfretain' respectively.
Douglas Gregor [Mon, 27 Apr 2009 18:38:38 +0000 (18:38 +0000)]
Implement caching of stat() calls for precompiled headers, which is
essentially the same thing we do with pretokenized headers. stat()
caching improves performance of the Cocoa-prefixed "Hello, World" by
45%.
Add new checker-specific attribute 'objc_ownership_cfretain'. This is the same
as 'objc_ownership_cfretain' except that the method acts like a CFRetain instead
of a [... retain] (important in GC modes). Checker support is wired up, but
currently only for Objective-C message expressions (not function calls).
Chris Lattner [Mon, 27 Apr 2009 07:35:58 +0000 (07:35 +0000)]
add an abbreviation for common PARM_VAR_DECL. All but 9 of the
parm var decls in leopard cocoa.h end up using this abbreviation,
which shrinks the bitcode file by about 50K: 7217736->7167120.
Before:
Block ID #12 (DECLS_BLOCK):
Num Instances: 1
Total Size: 2.23595e+07b/2.79494e+06B/698736W
% of file: 38.7233
Num SubBlocks: 0
Num Abbrevs: 0
Num Records: 139387
% Abbrev Recs: 0
After:
Block ID #12 (DECLS_BLOCK):
Num Instances: 1
Total Size: 2.02405e+07b/2.53006e+06B/632516W
% of file: 35.301
Num SubBlocks: 0
Num Abbrevs: 1
Num Records: 139387
% Abbrev Recs: 19.2902
Douglas Gregor [Mon, 27 Apr 2009 06:38:32 +0000 (06:38 +0000)]
Load most of the source manager's information lazily from the PCH
file. In particular, only eagerly load source location entries for
files and for the predefines buffer. Other buffers and
macro-instantiation source location entries are loaded lazily.
With the Cocoa-prefixed "Hello, World", we only load 815/26555 source
location entities. This halves the amount of user time we spend in
this "Hello, World" program with -fsyntax-only (down to .007s).
This optimization is part 1 of 2 for the source manager. This
eliminates most of the user time in loading a PCH file. We still spend
too much time initialize File structures (especially in the calls to
stat), so we need to either make the loading of source location
entries for files lazy or import the stat cache from the PTH
implementation.
Chris Lattner [Mon, 27 Apr 2009 01:46:12 +0000 (01:46 +0000)]
Change our silencing of C typedef redefinition handling to what we had
before r69391: typedef redefinition is an error by default, but if
*either* the old or new definition are from a system header, we silence
it.
Chris Lattner [Sun, 26 Apr 2009 22:26:21 +0000 (22:26 +0000)]
make llvm-bcanalyzer dump out PCH files symbolically. We should probably
eventually get an option to turn this off, but it is nice for looking at
statistics. For example, the types block now prints:
Block ID #11 (TYPES_BLOCK_ID):
Num Instances: 1
Total Size: 895100b/111888B/27971.9W
% of file: 1.55801
Num SubBlocks: 0
Num Abbrevs: 0
Num Records: 14899
% Abbrev Recs: 0
Douglas Gregor [Sun, 26 Apr 2009 22:20:50 +0000 (22:20 +0000)]
Some fixes for PCH (de-)serialization of Objective-C AST nodes:
- Deal with the Receiver/ClassInfo shared storage in ObjCMessageExpr
- Implement PCH support for ImplicitParamDecl
- Fix the handling of the body of an ObjCMethodDecl
- Several cast -> cast_or_null fixes
- Make Selector::getIdentifierInfoForSlot work for 1-argument, NULL
selectors.
- Make Selector::getAsString() work with NULL selectors.
- Fix the names of VisitObjCAtCatchStmt and VisitObjCAtFinallyStmt
in the PCH reader and writer; these were never getting called.
At this point, all of the pch-test tests pass for C and Objective-C.
Chris Lattner [Sun, 26 Apr 2009 18:22:24 +0000 (18:22 +0000)]
implement PR4077: [Linux kernel] inscrutable error on inline asm input/output constraint mismatch
Before we emitted:
$ clang t.c -S -m64
llvm: error: Unsupported asm: input constraint with a matching output constraint of incompatible type!
Now we produce:
$ clang t.c -S -m64
t.c:5:40: error: unsupported inline asm: input with type 'unsigned long' matching output with type 'int'
asm volatile("foo " : "=a" (a) :"0" (b));
~~~ ~^~
Douglas Gregor [Sun, 26 Apr 2009 03:52:11 +0000 (03:52 +0000)]
Simple little smoke-test script that tries to build PCH files and then
dump their contents for all of the compilable tests in Clang's
testsuite. All of the tests pass for C, but there are still many
failures for Objective-C.
Douglas Gregor [Sun, 26 Apr 2009 03:49:13 +0000 (03:49 +0000)]
When writing a PCH file, write multiple type and declaration blocks as
necessary and iterate until all types and declarations have been
written. This reduces the Cocoa.h PCH file size by about 4% (since we
don't write types we don't need), and fixes problems where writing a
declaration generates a new type.
This doesn't seem to have any impact on performance either way.
Douglas Gregor [Sun, 26 Apr 2009 02:02:08 +0000 (02:02 +0000)]
Add a new -ast-dump-full option that traverses the translation unit
declaration rather than printing through the HandleTopLevelDecl
action. Using this, one can deserialize an entire PCH file and dump
it.
Eli Friedman [Sun, 26 Apr 2009 01:30:08 +0000 (01:30 +0000)]
Correct the order of the parameters to CheckAssignmentConstraints in
cleanup attribute checking. The difference isn't normally visible, but it
can make a difference...
Daniel Dunbar [Sun, 26 Apr 2009 01:10:38 +0000 (01:10 +0000)]
Driver: Add -std-default= option.
- This can be used to supply a default value for -std=; the idea is
that this can be used in conjunction with CCC_ADD_ARGS or
QA_OVERRIDE_GCC3_OPTIONS to change the default without having to
modify the build system.
Douglas Gregor [Sun, 26 Apr 2009 00:37:38 +0000 (00:37 +0000)]
Another shot at switching PCH on by default, now that we've cleaned up some bugs and improved performance. Will be reverted after Mr. Speedy gets done with it
Anders Carlsson [Sun, 26 Apr 2009 00:34:20 +0000 (00:34 +0000)]
When calling the cleanup function specified by __attribute__((cleanup)), make sure to bitcast the argument so it has the same type as the first argument of the cleanup function. Fixes <rdar://problem/6827047>.
Douglas Gregor [Sun, 26 Apr 2009 00:07:37 +0000 (00:07 +0000)]
Don't read all of the records in the PCH file's preprocessor block,
most of which are ignored. Instead, move the __COUNTER__ value out to
a PCH-level record (since it is handled eagerly) and move the header
file information into the SourceManager block (which is also,
currently, loaded eagerly).
This results in another 17% performance improvement in the
Cocoa-prefixed "Hello, World" with PCH.
Douglas Gregor [Sat, 25 Apr 2009 23:30:02 +0000 (23:30 +0000)]
Lazily load the controlling macros for all of the headers known in the
PCH file. In the Cocoa-prefixed "Hello, World" benchmark, this takes
us from reading 503 identifiers down to 37 and from 470 macros down to
4. It also results in an 8% performance improvement.
Chris Lattner [Sat, 25 Apr 2009 23:19:45 +0000 (23:19 +0000)]
"This fixes message sends to super in a way that both works with real code and passes the test in the test suite. It also fixes a crash when using recent versions of GNU libobjc and compiling modules that do not contain any constant strings but do contain a declaration of the constant string class and possible some other corner cases (thanks to Pete French for providing me with a test case for that one)."
Chris Lattner [Sat, 25 Apr 2009 21:59:05 +0000 (21:59 +0000)]
fix PR4073 by making designated initializer checking code use
VerifyIntegerConstantExpression instead of isIntegerConstantExpr.
This makes it ext-warn but tolerate things that fold to a constant
but that are not valid i-c-e's.
There must be a bug in the i-c-e computation though, because it
doesn't catch this case even with pedantic.
This also switches the later code to use EvaluateAsInt which is
simpler and handles everything that evaluate does.
Douglas Gregor [Sat, 25 Apr 2009 21:21:38 +0000 (21:21 +0000)]
Optimize the loading of an identifier from a PCH file when given the
identifier's ID. In this case, we know where the identifier's entry is
located in the hash table (it starts right before the identifier
string itself), so skip the hash table lookup and read the entry
directly. The performance improvement here is, gain, hard to quantify,
but it's the right thing to do.