Commit Graph

20125 Commits

Author SHA1 Message Date
Bruno Cardoso Lopes 129b4cc9ec Revert x86_64 ABI changes until I have time to check the items raised by Eli.
llvm-svn: 134765
2011-07-08 22:57:35 +00:00
Jakub Staszak d2cf2cbae9 Introduce __builtin_expect() intrinsic support.
llvm-svn: 134761
2011-07-08 22:45:14 +00:00
Bruno Cardoso Lopes 308d7423a9 Add support for AVX 256-bit in the x86_64 ABI (as in the 0.99.5 draft)
llvm-svn: 134754
2011-07-08 22:18:40 +00:00
Cameron Zwarich ae7bc98710 Add codegen support for the fma/fmal/fmaf builtins.
llvm-svn: 134743
2011-07-08 21:39:34 +00:00
Benjamin Kramer 581f48f583 Initialize all the AnalysisBasedWarnings statistics to zero.
Found by valgrind.

llvm-svn: 134733
2011-07-08 20:38:53 +00:00
Benjamin Kramer 65cc1074f3 Remove unused variable.
llvm-svn: 134731
2011-07-08 20:20:17 +00:00
Eli Friedman f7ca26a077 Fix up dependency file name printing to more closely match that of gcc, including fixing a nasty recent regression that could make us print "/foo.h" with a command-line including "-I ./".
rdar://problem/9734352

llvm-svn: 134728
2011-07-08 20:17:28 +00:00
Fariborz Jahanian f2913401fc objc++-arc: more diagnosis of converting a weak-unavailable
object to a __weak object type. // rdar://9732636

llvm-svn: 134706
2011-07-08 17:41:42 +00:00
Douglas Gregor 6336f29669 Teach CXXUnresolvedConstructExpr when it should be an
lvalue/xvalue/rvalue, rather than just (incorrectly) assuming it's an
lvalue. Fixes PR10285 / <rdar://problem/9743926>.

llvm-svn: 134700
2011-07-08 15:50:43 +00:00
Chandler Carruth a532863131 Make the worklist in the uninitialized values checker actually a queue.
Previously, despite the names 'enqueue' and 'dequeue', it behaved as
a stack and visited blocks in a LIFO fashion. This interacts badly with
extremely broad CFGs *inside* of a loop (such as a large switch inside
a state machine) where every block updates a different variable.

When encountering such a CFG, the checker visited blocks in essentially
a "depth first" order due to the stack-like behavior of the work list.
Combined with each block updating a different variable, the saturation
logic of the checker caused it to re-traverse blocks [1,N-1] of the
broad CFG inside the loop after traversing block N. These re-traversals
were to propagate the variable values derived from block N. Assuming
approximately the same number of variables as inner blocks exist, the
end result is O(N^2) updates. By making this a queue, we also make the
traversal essentially "breadth-first" across each of the N inner blocks
of the loop. Then all of this state is propagated around to all N inner
blocks of the loop. The result is O(N) updates.

The truth is in the numbers:
Before, gcc.c:   96409 block visits  (max: 61546,   avg: 591)
After,  gcc.c:   69958 block visits  (max: 33090,   avg: 429)
Before, PR10183: 2540494 block vists (max: 2536495, avg: 37360)
After,  PR10183: 137803 block visits (max: 134406,  avg: 2026)

The nearly 20x reduction in work for PR10183 corresponds to a roughly
100x speedup in compile time.

I've tested it on all the code I can get my hands on, and I've seen no
slowdowns due to this change. Where I've collected stats, the ammount of
work done is on average less. I'll also commit shortly some synthetic
test cases useful in analyzing the performance of CFG-based warnings.

Submitting this based on Doug's feedback that post-commit review should
be good. Ted, please review! Hopefully this helps compile times until
then.

llvm-svn: 134697
2011-07-08 11:19:06 +00:00
Evan Cheng 491f56d41e Fix a FIXME in clang ARM driver that was exposed as a bug with ARM backend
change.

Previously clang was passing the following feature strings to the ARM backend
when CPU is cortex-a8: +neon,-vfp2,-vfp3

This used to work because -vfp2,-vfp3 had no effect after +neon. Now that the
features are controlled by individual bits (with implied hierarchy), the net
effect is all three features will be turned off.

llvm-svn: 134691
2011-07-08 06:40:11 +00:00
Francois Pichet 3a44e43d40 Random cleanup:
- fix a comment.
- Remove an unnecessary { } block.

llvm-svn: 134690
2011-07-08 06:21:47 +00:00
Chandler Carruth 904cb14225 Remove a no-op break after a return, and correct one of the most
confusing indentations I've seen recently... Just noticed these while
making a change elsewhere.

No functionality changed.

llvm-svn: 134685
2011-07-08 04:59:44 +00:00
Chandler Carruth c5c3b0a25b Minor style cleanup.
Original patch by John Freeman, some style tweaks by me.

llvm-svn: 134683
2011-07-08 04:28:55 +00:00
Chandler Carruth 8ae50ad064 Tweak formatting.
llvm-svn: 134675
2011-07-08 01:04:24 +00:00
Chandler Carruth 2536c072f7 Switch the token-paste source locations inside of function style macro
argument expansion to use the macro argument source locations as well.
Add a few tests to exercise this. There is still a bit more work needed
here though.

llvm-svn: 134674
2011-07-08 01:04:21 +00:00
Chandler Carruth 402bb38823 Keep track of which source locations are part of a macro argument
instantiation and improve diagnostics which are stem from macro
arguments to trace the argument itself back through the layers of macro
expansion.

This requires some tricky handling of the source locations, as the
argument appears to be expanded in the opposite direction from the
surrounding macro. This patch provides helper routines that encapsulate
the logic and explain the reasoning behind how we step through macros
during diagnostic printing.

This fixes the rest of the test cases originially in PR9279, and later
split out into PR10214 and PR10215.

There is still some more work we can do here to improve the macro
backtrace, but those will follow as separate patches.

llvm-svn: 134660
2011-07-07 23:56:36 +00:00
Fariborz Jahanian 7fcce6829d objc++-arc: diagnose assignment/cast of a weak-unavailable
object to a __weak object/type. // rdar://9732636.
One item is yet todo.

llvm-svn: 134655
2011-07-07 23:04:17 +00:00
Eric Christopher 0c912c5f9b Fix a typo in the fpsr register and add the fpcr register.
Fixes PR10299 and rdar://9740322

llvm-svn: 134654
2011-07-07 22:55:26 +00:00
Jonathan D. Turner f8c3ccdeae Remove BoostCon-specific code from Clang. FWIW, I'm a fan of things like this living in a separate branch.
llvm-svn: 134649
2011-07-07 22:40:15 +00:00
Argyrios Kyrtzidis 61c58f7f43 Move SourceManager::isAt[Start/End]OfMacroInstantiation functions to the Lexer, since they depend on it now.
llvm-svn: 134644
2011-07-07 21:54:45 +00:00
Bill Wendling e367f387af Layout the code for trapping arithmetic so that the overflow case comes after
the normal case.

Before, for this:

$ cat t.c
int test(int x) { return x * 2; }

We would get this:

   addl  %edi, %edi
   jno   LBB0_2
## BB#1:                                ## %overflow
   ud2
LBB0_2:                                 ## %nooverflow
   movl    %edi, %eax
   popq    %rbp
   ret

Now we get this:

   addl   %edi, %edi
   jo     LBB0_2
## BB#1:                                ## %nooverflow
   movl                                 %edi, %eax
   popq                                 %rbp
   ret
LBB0_2:                                 ## %overflow
   ud2

<rdar://problem/8283919>

llvm-svn: 134642
2011-07-07 21:13:10 +00:00
Cameron Zwarich be652e6a24 r134634 causes a failure on MultiSource/Benchmarks/Olden/bh with TEST=nightly,
so roll it out.

llvm-svn: 134638
2011-07-07 21:03:28 +00:00
Nick Lewycky d755e6ac48 A redeclaration of an inline method in C99 mode should trigger emission of that
function. Fixes PR10233!

llvm-svn: 134634
2011-07-07 20:25:10 +00:00
Fariborz Jahanian 6f472e803b objc-arc: diagnose assignment/cast of a weak-unavailable
object to a __weak object/type. // rdar://9732636.
This is objc side of things. objc++ side tbd.

llvm-svn: 134624
2011-07-07 18:55:47 +00:00
Argyrios Kyrtzidis dccf6e1948 Turn hashhash into tok::unkwown when it comes from expanding an argument, per Chris' suggestion.
llvm-svn: 134621
2011-07-07 18:04:47 +00:00
Joerg Sonnenberger c46e3ce58c FreeBSD gets FreeBSD target, just mipsel.
llvm-svn: 134619
2011-07-07 17:01:45 +00:00
Douglas Gregor 2132584d36 Introduce a new libclang aPI function,
clang_codeCompleteGetContexts(), that provides the client with
information about the context in which code completion has occurred
and what kinds of entities make sense as completions at that
point. Patch by Connor Wakamo!

llvm-svn: 134615
2011-07-07 16:03:39 +00:00
David Chisnall 1bfe6d374d If we're using the pure non-fragile ABI, then skip some of the contortions required to support the transitional ABI.
llvm-svn: 134612
2011-07-07 12:34:51 +00:00
David Chisnall a918b88952 Set a flag to tell the runtime when we're compiling in ARC mode and use the pure-nonfragile ABI for both ARC and GC mode.
llvm-svn: 134611
2011-07-07 11:22:31 +00:00
John McCall 4db5c3c83a In ARC, reclaim all return values of retainable type, not just those
where we have an immediate need of a retained value.

As an exception, don't do this when the call is made as the immediate
operand of a __bridge retain.  This is more in the way of a workaround
than an actual guarantee, so it's acceptable to be brittle here.

rdar://problem/9504800

llvm-svn: 134605
2011-07-07 06:58:02 +00:00
Argyrios Kyrtzidis c44b93d772 [arcmt] Add -ccc-arcmt-check/-ccc-arcmt-modify driver option aliases.
llvm-svn: 134591
2011-07-07 04:00:39 +00:00
Nick Lewycky 7c6c6cc425 Sort #includes.
llvm-svn: 134589
2011-07-07 03:54:51 +00:00
Argyrios Kyrtzidis e245aa2a93 When expanding macro arguments, treat '##' coming from an argument as a normal token.
e.g.

#define M(x) A x B
M(##) // should expand to 'A ## B', not 'AB'

llvm-svn: 134588
2011-07-07 03:40:37 +00:00
Argyrios Kyrtzidis 41fb2d95a3 Make the Preprocessor more memory efficient and improve macro instantiation diagnostics.
When a macro instantiation occurs, reserve a SLocEntry chunk with length the
full length of the macro definition source. Set the spelling location of this chunk
to point to the start of the macro definition and any tokens that are lexed directly
from the macro definition will get a location from this chunk with the appropriate offset.

For any tokens that come from argument expansion, '##' paste operator, etc. have their
instantiation location point at the appropriate place in the instantiated macro definition
(the argument identifier and the '##' token respectively).
This improves macro instantiation diagnostics:

Before:

t.c:5:9: error: invalid operands to binary expression ('struct S' and 'int')
int y = M(/);
        ^~~~
t.c:5:11: note: instantiated from:
int y = M(/);
          ^

After:

t.c:5:9: error: invalid operands to binary expression ('struct S' and 'int')
int y = M(/);
        ^~~~
t.c:3:20: note: instantiated from:
\#define M(op) (foo op 3);
                ~~~ ^  ~
t.c:5:11: note: instantiated from:
int y = M(/);
          ^

The memory savings for a candidate boost library that abuses the preprocessor are:

- 32% less SLocEntries (37M -> 25M)
- 30% reduction in PCH file size (900M -> 635M)
- 50% reduction in memory usage for the SLocEntry table (1.6G -> 800M)

llvm-svn: 134587
2011-07-07 03:40:34 +00:00
Argyrios Kyrtzidis c8f7e213b9 Fix bug in SourceManager::getDecomposedInstantiationLocSlowCase.
It would add up relative (decomposed) offsets like in getDecomposedSpellingLocSlowCase, but while
it makes sense to preserve the offset among lexed spelling locations, it doesn't make
sense to add anything to the offset of the instantiation location. The instantiation
location will be the same regardless of the relative offset in the tokens that were
instantiated.

This bug didn't actually affect anything because, currently, in practice we never create macro
locations with relative offset greater than 0.

llvm-svn: 134586
2011-07-07 03:40:27 +00:00
Argyrios Kyrtzidis 2cc62093fc For -print-stats, add the number of bytes that SLocEntryTable consumes.
llvm-svn: 134585
2011-07-07 03:40:24 +00:00
Nick Lewycky 365efd62a1 In an in-class initialization, defer checks for value-dependent initialization
expressions.

llvm-svn: 134583
2011-07-07 02:20:13 +00:00
Eli Friedman a3c122db7e Zap a couple unnecessary loops.
llvm-svn: 134578
2011-07-07 01:54:01 +00:00
Chandler Carruth 50020d9461 Based on comments from Chris, switch to using CFG::getNumBlockIDs()
rather than a computed std::distance(). At some point I had convinced
myself that these two were different; but as far as I can tell on
re-exampination they aren't, and the number of block IDs is actually
just a count of the blocks in the CFG.

While this removes the primary motivation for guarding all of this with
CollectStats, I have a patch coming up that will almost certainly make
it important again.

llvm-svn: 134552
2011-07-06 22:21:45 +00:00
Douglas Gregor 53e191ed94 Properly implement the scope restriction on the NRVO for
throw-expressions, such that we don't consider the NRVO when the
non-volatile automatic object comes from outside the innermost try
scope (C++0x [class.copymove]p13). In C++98/03, our ASTs were
incorrect but it didn't matter because IR generation doesn't actually
apply the NRVO here. In C++0x, however, we were moving from an object
when in fact we should have copied from it. Fixes PR10142 /
<rdar://problem/9714312>.

llvm-svn: 134548
2011-07-06 22:04:06 +00:00
Fariborz Jahanian 134f4587e7 revert patch for // rdar://9227352
llvm-svn: 134536
2011-07-06 21:05:11 +00:00
Fariborz Jahanian c6ba959ab1 Some code cleanup of r134522
llvm-svn: 134529
2011-07-06 20:48:48 +00:00
Fariborz Jahanian 1f626d6fd1 objc-arc: Support objc_arc_weak_unavailable on those
classes which are incompatible with weak references.
// rdar://9693477

llvm-svn: 134522
2011-07-06 19:24:05 +00:00
Douglas Gregor 750734c677 Don't try to type-check a copy construction of an exception
declaration with dependent type. Fixes PR10232 /
<rdar://problem/9700653>.

llvm-svn: 134515
2011-07-06 18:14:43 +00:00
Douglas Gregor 8a60bbe13f Keep track of when "unrecoverable" errors occur, then allow
clang_saveTranslationUnit() to save a PCH file if the only errors it
contains are recoverable errors. Fixes <rdar://problem/9727804>.

llvm-svn: 134503
2011-07-06 17:40:26 +00:00
Benjamin Kramer 37d30835f0 SmallVectorize a critical vector.
The small number of elements was determined by taking the median
file length in clang+llvm and /usr/include on OS X with xcode installed.

llvm-svn: 134496
2011-07-06 16:43:46 +00:00
Douglas Gregor 30c80fa3eb libclang: Allow callers of clang_saveTranslationUnit() to distinguish
between different classes of errors. Addresses most of
<rdar://problem/9660328>.

llvm-svn: 134495
2011-07-06 16:43:36 +00:00
Chandler Carruth b4836ea7a8 Build up statistics about the work done for analysis based warnings.
Special detail is added for uninitialized variable analysis as this has
serious performance problems than need to be tracked.

Computing some of this data is expensive, for example walking the CFG to
determine its size. To avoid doing that unless the stats data is going
to be used, we thread a bit into the Sema object to track whether
detailed stats should be collected or not. This bit is used to avoid
computations whereever the computations are likely to be more expensive
than checking the state of the flag. Thus, counters are in some cases
unconditionally updated, but the more expensive (and less frequent)
aggregation steps are skipped.

With this patch, we're able to see that for 'gcc.c':
*** Analysis Based Warnings Stats:
232 functions analyzed (0 w/o CFGs).
  7151 CFG blocks built.
  30 average CFG blocks per function.
  1167 max CFG blocks per function.
163 functions analyzed for uninitialiazed variables
  640 variables analyzed.
  3 average variables per function.
  94 max variables per function.
  96409 block visits.
  591 average block visits per function.
  61546 max block visits per function.

And for the reduced testcase in PR10183:
*** Analysis Based Warnings Stats:
98 functions analyzed (0 w/o CFGs).
  8526 CFG blocks built.
  87 average CFG blocks per function.
  7277 max CFG blocks per function.
68 functions analyzed for uninitialiazed variables
  1359 variables analyzed.
  19 average variables per function.
  1196 max variables per function.
  2540494 block visits.
  37360 average block visits per function.
  2536495 max block visits per function.

That last number is the somewhat scary one that indicates the problem in
PR10183.

llvm-svn: 134494
2011-07-06 16:21:37 +00:00
Douglas Gregor 5c70b06feb Teach the static analyzer's interpretation of Cocoa conventions to
obey the objc_method_family attribute when provided. Fixes
<rdar://problem/9726279>.

llvm-svn: 134493
2011-07-06 16:00:34 +00:00