Douglas Gregor [Tue, 28 Apr 2009 21:18:29 +0000 (21:18 +0000)]
Implement a minor space optimization for the PCH identifier table,
which eliminates the storage for IdentifierInfo in the "uninteresting
identifier" cases. Sadly, this only brought back 7k of the 500k we
lost :(
Douglas Gregor [Tue, 28 Apr 2009 20:33:11 +0000 (20:33 +0000)]
Implement checking for macro definitions that occur on the command
line when using a PCH that were not provided when building the PCH
file. If those names were used as identifiers somewhere in the PCH
file, reject the PCH file.
Douglas Gregor [Tue, 28 Apr 2009 20:01:51 +0000 (20:01 +0000)]
Revert r70075 and r70078, which reorganized the PCH on-disk hash table
for identifiers to separate "interesting" from "uninteresting"
identifiers. However, to cope with compiler invocations where the
predefines buffers mismatch, we need to be able to search the complete
identifier table. Cocoa.h.pch is now about 500k larger that it used to
be :(
Daniel Dunbar [Tue, 28 Apr 2009 19:38:45 +0000 (19:38 +0000)]
With -ccc-pch-is-pch, always treat precompiled inputs as PCH,
regardless of extension.
- Otherwise we can't expect that just plugging in -ccc-pch-is-pch
will work.
Douglas Gregor [Tue, 28 Apr 2009 18:58:38 +0000 (18:58 +0000)]
Allow some differences between the predefines buffer used to build a
PCH file and the predefines buffer used when including the PCH
file. We (explicitly) detect conflicting macro definitions (rejecting
the PCH file) and about missing macro definitions (they'll be
automatically pulled from the PCH file anyway).
We're missing some checking to make sure that new macro definitions
won't have any impact on the PCH file itself (e.g., #define'ing an
identifier that the PCH file used).
ccc-analyzer: Don't automatically generate 'Parser Rejects' files anymore. The
frontend is far enough along that most discrepancies between Clang and GCC are
(at least for C and Objective-C) are intentional. We also now have codegen to
test the frontend.
Douglas Gregor [Tue, 28 Apr 2009 06:37:30 +0000 (06:37 +0000)]
Improve compatibility with GCC regarding inline semantics in GNU89
mode and in the presence of __gnu_inline__ attributes. This should fix
both PR3989 and PR4069.
As part of this, we now keep track of all of the attributes attached
to each declaration even after we've performed declaration
merging. This fixes PR3264.
Eli Friedman [Tue, 28 Apr 2009 03:13:54 +0000 (03:13 +0000)]
Simplify the scheme used for keywords, and change the classification
scheme to be more useful.
The new scheme introduces a set of categories that should be more
readable, and also reflects what we want to consider as an extension
more accurately. Specifically, it makes the "what is a keyword"
determination accurately reflect whether the keyword is a GNU or
Microsoft extension.
I also introduced separate flags for keyword aliases; this is useful
because the classification of the aliases is mostly unrelated to the
classification of the original keyword.
This patch treats anything that's in the implementation
namespace (prefixed with "__", or "_X" where "X" is any upper-case
letter) as a keyword without marking it as an extension. This is
consistent with the standards in that an implementation is allowed to define
arbitrary extensions in the implementation namespace without violating
the standard. This gets rid of all the nasty "extension used" warnings
for stuff like __attribute__ in -pedantic mode. We still warn for
extensions outside of the the implementation namespace, like typeof.
If someone wants to implement -Wextensions or something like that, we
could add additional information to the keyword table.
This also removes processing for the unused "Boolean" language option;
such an extension isn't supported on any other C implementation, so I
don't see any point to adding it.
The changes to test/CodeGen/inline.c are required because previously, we
weren't actually disabling the "inline" keyword in -std=c89 mode.
I'll remove Boolean and NoExtensions from LangOptions in a follow-up
commit.
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));
~~~ ~^~