Bob Wilson [Thu, 6 Mar 2014 04:55:41 +0000 (04:55 +0000)]
PGO: Use the main file name to help distinguish functions with local linkage.
In addition, for all functions, use the name from the llvm::Function to
identify the function in the profile data. Compute that "function name",
including the file name for local functions, once when assigning the PGO
counters and store it in the CodeGenPGO class.
Move the code to add InlineHint and Cold attributes out of StartFunction(),
because the "function name" string isn't available at that point.
Bob Wilson [Thu, 6 Mar 2014 04:55:37 +0000 (04:55 +0000)]
PGO: Rename variables to avoid referring to the "MangledName" of a function.
For C++ functions, we will continue to use the mangled name to identify
functions in the PGO profile data, but this name is confusing for things like
Objective-C methods. For functions with local linkage, we're also going to
include the file name to help distinguish those functions, so this changes to
use more generic variable names.
Bob Wilson [Thu, 6 Mar 2014 04:55:35 +0000 (04:55 +0000)]
Refactor PGO code in preparation for handling non-C/C++ code.
Move the PGO.assignRegionCounters() call out of StartFunction, because that
function is called from many places where it does not make sense to do PGO
instrumentation (e.g., compiler-generated helper functions). Change several
functions to take a StringRef argument for the unique name associated with
a function, so that the name can be set differently for things like Objective-C
methods and block literals.
Bob Wilson [Thu, 6 Mar 2014 04:55:28 +0000 (04:55 +0000)]
PGO: don't emit counter increment if no counters have been allocated.
I hit this while debugging another issue where my sources were in an
inconsistent state, so I don't have a testcase. Regardless, this check is
simpler and more direct than checking if the option is enabled.
Richard Smith [Thu, 6 Mar 2014 03:16:27 +0000 (03:16 +0000)]
Fix crash if a submodule overrides one of its own macros, and add support for
submodule macro overriding within the same top-level module (necessary for the
testcase to be remotely reasonable). Incidentally reduces the number of libc++
testsuite regressions with modules enabled from 7 to 6.
Use private linkage for remaining GlobalVariables with private names.
This patch changes the remaining GlobalVariables using "\01L" and
"\01l" prefixes to use private linkage. What is strange about them is
that they currently use WeakAnyLinkage. There is no comment stating
why and that is really odd since the symbols are completely hidden, so
it doesn't make sense for them to be weak.
Clang revisions like r63329, r63408, r63770, r65761 set the linkage to
weak, but don't say why. I suspect they were just copying llvm-gcc.
In llvm-gcc I found r58599 and r56322 that set DECL_WEAK, but they
were just syncing from the apple gcc. I am not exactly sure what that
means, since the last commit to
svn://gcc.gnu.org/svn/gcc/branches/apple was in 2006, 2 years earlier.
In summary, I have no idea why weak linkage was being used :-(
To quote John McCall, "Let’s try without it and see" :-)
Ted Kremenek [Thu, 6 Mar 2014 01:09:45 +0000 (01:09 +0000)]
[-Wunreachable-code] Handle idiomatic do...while() with an uninteresting condition.
Sometimes do..while() is used to create a scope that can be left early.
In such cases, the unreachable 'while()' test is not usually interesting
unless it actually does something that is observable.
Richard Trieu [Thu, 6 Mar 2014 01:09:03 +0000 (01:09 +0000)]
Change the color of comment nodes from bright yellow to blue. Bright yellow on
a white background is difficult to read. Also include a chart showing which
colors are used by which elements in the AST dump.
Objective-C properties. Fixes a crash in Sema where RHS of
the property assignment is an lvalue for an incomplete type.
// rdar://15118128. Reviewed offline by John McCall.
Richard Smith [Thu, 6 Mar 2014 00:33:23 +0000 (00:33 +0000)]
Switch to an idiomatic C++ erase/remove for this loop, and fix a bug in the
process (I don't believe it's possible to write a testcase for the bug with
a non-checking STL implementation).
Ted Kremenek [Thu, 6 Mar 2014 00:17:44 +0000 (00:17 +0000)]
[-Wunreachable-code] Handle idiomatic do...while() with an uninteresting condition.
Sometimes do..while() is used to create a scope that can be left early.
In such cases, the unreachable 'while()' test is not usually interesting
unless it actually does something that is observable.
Ted Kremenek [Wed, 5 Mar 2014 23:46:07 +0000 (23:46 +0000)]
[-Wunreachable-code] generalize pruning out warning on trivial returns.
Previously we only pruned dead returns preceded by a call to a
'noreturn' function. After looking at the results of the LLVM codebase,
there are many others that should be pruned as well.
Objective-C. Suppress the warning for auto synthesis of property not
synthesizing protocol properties if class's super class
implements them. // rdar://16089191
Aaron Ballman [Wed, 5 Mar 2014 21:47:13 +0000 (21:47 +0000)]
Capabilities are required to pass a name specifying what type of capability is being annotated. There are currently only two supported names: mutex and role. Adding functionality to check for the capability name and diagnose when it's unexpected.
Note that for backwards compatibility, an unnamed capability will default to being a "mutex." This allows the deprecated lockable attribute to continue to function.
Richard Smith [Wed, 5 Mar 2014 20:55:36 +0000 (20:55 +0000)]
When building a module from the command line via -emit-module, add an entry to
the module build stack for the module being built, so we can correctly detect
recursive module builds.
Aaron Ballman [Wed, 5 Mar 2014 16:49:55 +0000 (16:49 +0000)]
[C++11] Using std::unique_ptr to ensure that Argument objects do not leak (since clang-tblgen isn't long-lived, the old leak is probably acceptable, but it offended my senses nonetheless).
David Majnemer [Wed, 5 Mar 2014 10:35:06 +0000 (10:35 +0000)]
MS ABI: Mangle lambdas
Use a scheme inspired by the Itanium ABI to properly implement the
mangling of lambdas.
N.B. The incredibly astute observer will notice that we do not generate
external names that are identical, or even compatible with, MSVC.
This is fine because they don't generate names that they can use across
translation units. Technically, we can generate any name we'd like so
long as that name wouldn't conflict with any other and would be stable
across translation units.
David Majnemer [Wed, 5 Mar 2014 08:57:59 +0000 (08:57 +0000)]
[-cxx-abi microsoft] Implement local manglings accurately
Summary:
The MSVC ABI appears to mangle the lexical scope into the names of
statics. Specifically, a counter is incremented whenever a scope is
entered where things can be declared in such a way that an ambiguity can
arise. For example, a class scope inside of a class scope doesn't do
anything interesting because the nested class cannot collide with
another nested class.
There are problems with this scheme:
- It is unreliable. The counter is only incremented when a previously
never encountered scope is entered. There are cases where this will
cause ambiguity amongst declarations that have the same name where one
was introduced in a deep scope while the other was introduced right
after in the previous lexical scope.
- It is wasteful. Statements like: {{{{{{{ static int foo = a; }}}}}}}
will make the mangling of "foo" larger than it need be because the
scope counter has been incremented many times.
Because of these problems, and practical implementation concerns. We
choose not to implement this scheme if the local static or local type
isn't visible. The mangling of these declarations will look very
similar but the numbering will make far more sense, this scheme is
lifted from the Itanium ABI implementation.
Ted Kremenek [Wed, 5 Mar 2014 08:13:08 +0000 (08:13 +0000)]
Adjust logic for 'objc_protocol_requires_explicit_implementation' for inherited protocols and protocols already conformed in the class hierarchy.
Per more discussion, 'objc_protocol_requires_explicit_implementation' is
refinement that it mainly adds that requirement that a protocol must be
explicitly satisfied at the moment the first class in the class hierarchy
conforms to it. Any subclasses that also conform to that protocol,
either directly or via conforming to a protocol that inherits that protocol,
do not need to re-implement that protocol.
Doing this requires first doing a pass on the super class hierarchy,
gathering the set of protocols conformed to by the super classes,
and then culling those out when determining conformance. This
two-pass algorithm could be generalized for all protocol checking,
and could possibly be a performance win in some cases. For now
we restrict this change to protocols with this attribute to isolate
the change in logic (especially as the design continues to evolve).
This change needs to be adjusted for properties as well; this
only impacts methods right now.
Ted Kremenek [Wed, 5 Mar 2014 00:01:17 +0000 (00:01 +0000)]
[-Wunreachable-code] Don't warn about dead code guarded by a "configuration value".
Some unreachable code is only "sometimes unreachable" because it
is guarded by a configuration value that is determined at compile
time and is always constant. Sometimes those represent real bugs,
but often they do not. This patch causes the reachability analysis
to cover such branches even if they are technically unreachable
in the CFG itself. There are some conservative heuristics at
play here to determine a "configuration value"; these are intended
to be refined over time.
Ben Langmuir [Tue, 4 Mar 2014 22:34:50 +0000 (22:34 +0000)]
Support relative paths in VFSFromYAML
Use llvm::sys::fs::make_absolute to get an absolute path before
matching. Also, allow "." directories to enable testing. ".." is still
not supported, and will require crossing file system boundaries to
implement correctly.
Reid Kleckner [Tue, 4 Mar 2014 20:51:58 +0000 (20:51 +0000)]
Fix unconditional dereference of a WeakVH in CGDebugInfo TypeCache
This fails an "isa<> used with null pointer" assert during a clang-cl
self-host on Windows. This was caused by r202769, and I'm currently
reducing a test case.
Simon Atanasyan [Tue, 4 Mar 2014 18:37:28 +0000 (18:37 +0000)]
[Mips] Check all MIPS toolchains to find the one that best meets command
line arguments and directories tree. The old toolchain selection heuristics
worked incorrectly when user has a reduced MIPS toolchain supports
the O32 ABI only.
Patch reviewed by Jonathan Roelofs, David Majnemer.
Objective-C IRGen. Fix up the hueristics for determining
if an ivar offset load is invariant iff inside an instance method
and ivar belongs to instance method's class and one of its super class.
// rdar://16095748
Roman Divacky [Tue, 4 Mar 2014 18:26:12 +0000 (18:26 +0000)]
The wmmintrin.h header includes two different sub-headers: one for AES support
and one for PCLMUL support. The current immintrin.h header only includes
wmmintrin.h if AES support is enabled. It should include it if either AES or
PCLMUL is enabled (GCC's version of immintrin.h does this).
Sean Callanan [Tue, 4 Mar 2014 18:11:50 +0000 (18:11 +0000)]
When deciding whether or not to resolve two
anonymous structs to the same Decl in the
ASTImporter, ensure that both are filled in
from their external sources (if present).
Otherwise two different structs may be
identified erroneously.
[cleanup] Re-sort includes with llvm/utils/sort_includes.py and fix
a missing include from CLog.h.
CLog.h referenced most of the core libclang types but never directly
included Index.h that provides them. Previously it got lucky and other
headers were always included first but with the sorting it ended up
first in one case and stopped compiling. Adding the Index.h include
fixes it right up.
David Majnemer [Tue, 4 Mar 2014 05:38:05 +0000 (05:38 +0000)]
MS ABI: Mangle variable templates properly
We wouldn't recognize variable templates as being templates leading us
to leave the template arguments off of the mangled name. This would
allow two unrelated templates to map to the same mangled name.
N.B. While MSVC doesn't support variable templates as of this date,
this mangling is the most likely thing they will choose to use. Their
demangler can successfully demangle our manglings with the template
arguments shown.