Drop libgcc and default to libc++ for NetBSD/ARM on 6.99.40+.
Don't bother with keeping the old support for x86_64 in 6.99.23+, just
use a single range. Update test cases for the always-on --eh-frame-hdr.
Richard Smith [Wed, 7 May 2014 02:25:43 +0000 (02:25 +0000)]
If an instantiation of a template is required to be a complete type, check
whether the definition of the template is visible rather than checking whether
the instantiated definition happens to be in an imported module.
Tobias Grosser [Tue, 6 May 2014 22:06:56 +0000 (22:06 +0000)]
tblgen: Modularize the diagnostic emitter
Replace a large monolitic function, with per-table functions which all nicely
fit on my screen. I also added documentation to each function that describes
what kind of tables are generated and which information is contained and
switched to range based for loops. Finally, I run clang-format over the moved
code.
I spent a significant amount of time to understand this code when reasoning
about possible extensions to the diagnostic interface to support 'remark'
diagnostics. This change will definitely help such an implementation, but
already by itself it will save other people a lot of time when trying to
understand this functionality.
Even though the patch touches the full function, it is mostly mechanical. No
functional change intended. The generated tblgen files are identical.
Nico Weber [Tue, 6 May 2014 20:32:45 +0000 (20:32 +0000)]
Include translation unit filename in global ctor symbol names.
This makes it easier to see where a global ctor comes from, and it also makes
ASan's init order analyzer output easier to understand. gcc does this too,
but only in -fPIC mode for some reason. Don't do this for constructors with
explicit init priority.
Also prepend "sub_" before the 'I', that way regular constructors stay
lexicographically after symbols with init priority (because
ord('s') > ord('I')). gold seems to ignore the name of constructor symbols,
and ld only looks at the symbol if it includes an init priority, which this
patch doesn't change.
David Blaikie [Tue, 6 May 2014 18:35:21 +0000 (18:35 +0000)]
Reapply: DebugInfo: Emit the definition of enums when the definition preceeds the declaration and initial use.
Reverting r208106 to reapply r208065 with a fix for the regression. The
issue was that the enum tried to be built even if the declaration hadn't
been constructed for debug info - presenting problems for enum templates
and typedefs of enums with names for linkage purposes.
Original commit message:
This regressed a little further 208055 though it was already a little
broken.
While the requiresCompleteType optimization should be implemented here.
Future (possibly near future) work.
Nico Weber [Tue, 6 May 2014 17:33:42 +0000 (17:33 +0000)]
Fix leak in ObjCSelfInitChecker, found by LSan.
BugReport doesn't take ownership of the bug type, so let the checker own the
the bug type. (Requires making the bug type mutable, which is icky, but which
is also what other checkers do.)
Nico Weber [Tue, 6 May 2014 17:18:03 +0000 (17:18 +0000)]
Fix a leak found by LSan: ConsumedBlockInfo owns its StateMapsArray entries.
(I tried converting StateMapsArray to a vector<unique_ptr> and changing the
types of getInfo() and addInfo() to take unique_ptrs. This mostly worked,
except for the three-argument form of addInfo() which I found confusing enough
that I went with this simpler fix for now.)
David Blaikie [Tue, 6 May 2014 03:42:01 +0000 (03:42 +0000)]
PR19598: Ensure temporary metadata nodes used in debug info are destroyed.
CGDebugInfo and DIBuilder were lax in their handling of temporary
MDNodes. All temporary nodes need to be deleted, which means they need
to be RAUW'd with a permanent node. This was not happening.
To ensure this, leverage DIBuilder's new ability to create both
permanent and temporary declarations. Ensure all temporary declarations
are RAUW'd, even with itself. (DIDescriptor::RAUW handles the case where
it is replaced with itself and creates a new, duplicate permanent node
to replace itself with)
This means that all temporary declarations must be added to the
ReplacementMap even if they're never upgraded to definitions - so move
the point of insertion into the map to the point of creation of the
declarations.
David Blaikie [Mon, 5 May 2014 23:23:53 +0000 (23:23 +0000)]
Build debug info for ObjC interface types at the end of the translation unit to ensure all ivars are included.
This takes a different approach than the
completedType/requiresCompleteType work which relies on AST callbacks to
upgrade the type declaration to a definition. Instead, just defer
constructing the definition to the end of the translation unit.
This works because the definition is never needed by other debug info
(so far as I know), whereas the definition of a struct may be needed by
other debug info before the end of the translation unit (such as
emitting the definition of a member function which must refer to that
member function's declaration).
If we had a callback for whenever an IVar was added to an ObjC interface
we could use that, and remove the need for the ObjCInterfaceCache, which
might be nice. (also would need a callback for when it was more than
just a declaration so we could get properties, etc).
A side benefit is that we also don't need the CompletedTypeCache
anymore. Just rely on the declaration-ness of a type to decide whether
its definition is yet to be emitted.
There's still the PR19562 memory leak, but this should hopefully make
that a bit easier to approach.
David Blaikie [Mon, 5 May 2014 21:21:39 +0000 (21:21 +0000)]
Simplify replacement map by avoiding duplicate values and ensuring the values it does contain are necessary.
Items were being redundantly added to the replacement map (both when the
declaration was created, and then again when its definition was
constructed) which caused extra handling to be required when walking the
map (as elements may've already been replaced due to prior entries). By
avoiding adding the duplicates, the checks in the replacement handling
can be replaced with assertions.
Reid Kleckner [Mon, 5 May 2014 21:12:12 +0000 (21:12 +0000)]
MS ABI: Emit an error during IRgen on C++ exception handling
Currently, users get error messages about RTTI descriptor mangling with
no useful source location. This addresses that.
Another approach would be to disable C++ exceptions by default in the
driver when using the Microsoft C++ ABI. However, this makes it
impossible to parse system headers that use exception handling
constructs. By delaying the error to IRgen, we can figure out if we
actually need to emit code for this construct. Additionally, users who
are only interested in building refactoring tools on Windows still get a
correct AST without having to add flags. Finally, this is consistent
with what we do for SEH.
David Majnemer [Mon, 5 May 2014 18:54:23 +0000 (18:54 +0000)]
CodeGen: Assign linkage to thread-wrappers correctly
We would sometimes incorrectly give a thread-wrapper external linkage
instead of internal linkage if we had only CodeGen'd it's declaration,
not it's definition.
Manuel Klimek [Mon, 5 May 2014 18:21:06 +0000 (18:21 +0000)]
Fix handling of condition variables in the face of temp dtors.
The assignment needs to be before the destruction of the temporary.
This patch calls out to addStmt, which invokes VisitDeclStmt, which has
all the correct logic for handling temporaries.
Manuel Klimek [Mon, 5 May 2014 09:58:03 +0000 (09:58 +0000)]
Fix crash when resolving branch conditions for temporary destructor condition blocks.
Document and simplify ResolveCondition.
1. Introduce a temporary special case for temporary desctructors when resolving
the branch condition - in an upcoming patch, alexmc will change temporary
destructor conditions to not run through this logic, in which case we can remove
this (marked as FIXME); this currently fixes a crash.
2. Simplify ResolveCondition; while documenting the function, I noticed that it
always returns the last statement - either that statement is the condition
itself (in which case the condition was returned anyway), or the rightmost
leaf is returned; for correctness, the rightmost leaf must be evaluated anyway
(which the CFG does in the last statement), thus we can just return the last
statement in that case, too. Added an assert to verify the invariant.
Alp Toker [Mon, 5 May 2014 06:22:21 +0000 (06:22 +0000)]
Add speculative clang-interpreter test
Let's see how far this gets on the build servers. The application requires
native JIT and uses the C standard library, but hopefully we can get this
tested on at least some configurations.
Taking a lead from the clang-format tests, we'll just expect the executable to
get picked up from the build output path for now.
Ben Langmuir [Mon, 5 May 2014 05:31:33 +0000 (05:31 +0000)]
Make module self-import an error
Ideally, importing Foo.a from Foo.b would "do the right thing", but
until it does, this patch makes it an error rather than allow it to
silently be ignored.
Windows on ARM uses AAPCS, but has some deviations. wchar_t remains an unsigned
short on WoA, which does not conform to AAPCS. Ensure that wchar_t is defined
accordingly.
Nico Weber [Sat, 3 May 2014 22:07:35 +0000 (22:07 +0000)]
Minor cleanups, no behavior change.
* Fixes a "return" that was indented at the same level as the continuation
from the previous line
* Wrap several lines to 80 columns
* Remove an if check that was always true
* Move a variable declaration slightly closer to its use
[leaks] The PDFileEntry nodes in the FilesMade FoldingSet contain
a std::vector that allocates on the heap. As a consequence, we have to
run all of their destructors when tearing down the set, not just
deallocate the memory blobs.
[leaks] Re-shuffle code such that we don't create a basic block for
initializing an array unless we need it. Specifically, position the
creation of a new basic block after we've checked all of the cases that
bypass the need for it.
Fixes another leak in test/CodeGen* found by LSan.
David Majnemer [Sat, 3 May 2014 02:23:35 +0000 (02:23 +0000)]
CodeGen: Cleanup ABIArgInfo
ABIArgInfo was pretty hard to grok, it had data members with names like
"BoolData0" and "UIntData". Constructors with lots of bool arguments.
Reusing the same data member for multiple purposes.
It was also wasteful with memory, this new layout is 8 bytes smaller.
Nick Lewycky [Sat, 3 May 2014 00:41:18 +0000 (00:41 +0000)]
Rewrite NRVO determination. Track NRVO candidates on the parser Scope and apply the NRVO candidate flag to all possible NRVO candidates here, and remove the flags in computeNRVO or upon template instantiation. A variable now has NRVO applied if and only if every return statement in that scope returns that variable. This is nearly optimal.
Performs NRVO roughly 7% more often in a bootstrap build of clang. Patch co-authored by Richard Smith.
Reid Kleckner [Sat, 3 May 2014 00:33:28 +0000 (00:33 +0000)]
MS ABI x64: Pass small objects with dtors but no copy ctors directly
Passing objects directly (in registers or memory) creates a second copy
of the object in the callee. The callee always destroys its copy, but
we also have to destroy any temporary created in the caller. In other
words, copy elision of these kinds of objects is impossible.
Objects larger than 8 bytes with non-trivial dtors and trivial copy
ctors are still passed indirectly, and we can still elide copies of
them.
[leaks] Fix a leak of a basic block when we successfully fold a switch
condition to a constant and emit only the relevant statement. In that
case, we were previously creating the epilog jump destination, a cleanup
scope, and emitting any condition variable into it. Instead, we can emit
the condition variable (if we have one) into the cleanup scope used for
the entire folded case sequence. We avoid creating a jump dest, a basic
block, and an extra cleanup scope. Win!
[leaks] Parse the schema file every time we try to verify the XML. Yes,
this is wasteful, blah blah, but this is a test utility only. It turns
out that without doing this, libxml2 will always leak a bunch of the XML
data, and that is causing failures with LSan. This is also quite a bit
simpler and I don't think it is slow enough to really be a show stopper.
If someone yells about the runtime of c-index-test, we can do other
things to try to mitigate it, but the current strategy wasn't working
well.