Commit Graph

1252 Commits

Author SHA1 Message Date
Justin Bogner
c6945d9e32 llvm-cov: Don't use llvm::outs() in library code
Nothing in lib/ should be using llvm::outs() directly. Thread it in
from the caller instead.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226961 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-23 23:09:27 +00:00
Justin Bogner
798383b3ff llvm-cov: Use range-for (NFC)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226960 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-23 22:57:02 +00:00
Justin Bogner
4c61bbe673 llvm-cov: clang-format the GCOV files (NFC)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226952 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-23 22:38:01 +00:00
Adrian Prantl
d5dc4cff6a Move the accessor functions from DIExpression::iterator into a wrapper
DIExpression::Operand, so we can write range-based for loops.

Thanks to David Blaikie for the idea.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226939 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-23 21:24:41 +00:00
Duncan P. N. Exon Smith
a791aea5ae IR: Change GenericDwarfNode::getHeader() to StringRef
Simplify the API to use a `StringRef` directly rather than exposing the
`MDString` bits underneath.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226876 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-22 23:10:55 +00:00
Duncan P. N. Exon Smith
cee1699e9f IR: DwarfNode => DebugNode, NFC
These things are potentially used for non-DWARF data (see the discussion
in PR22235), so take the `Dwarf` out of the name.  Since the new name
gives fewer clues, update the doxygen to properly describe what they
are.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226874 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-22 22:47:44 +00:00
Benjamin Kramer
1552e50011 Remove dead leak detector parts that fell out of use in r224703.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226867 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-22 21:43:01 +00:00
Duncan P. N. Exon Smith
003346177c IR: Update references to temporaries before deleting
During `MDNode::deleteTemporary()`, call `replaceAllUsesWith(nullptr)`
to update all tracking references to `nullptr`.

This fixes PR22280, where inverted destruction order between tracking
references and the temporaries themselves caused a use-after-free in
`LLParser`.

An alternative fix would be to add an assertion that there are no users,
and continue to fix inverted destruction order in clients (like
`LLParser`), but instead I decided to make getting-teardown-right easy.
(If someone disagrees let me know.)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226866 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-22 21:36:45 +00:00
Chris Bieneman
40a218658a Refactoring cl::parser construction and initialization.
Summary:
Some parsers need references back to the option they are members of. This is used for handling the argument string as well as by the various pass name parsers for making pass names into flags.

Making parsers that need to refer back to the option have a reference to the option eliminates some of the members of various parsers, and enables further code cleanup.

Reviewers: dexonsmith

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D7131

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226864 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-22 21:01:12 +00:00
Ramkumar Ramachandra
230796b278 Intrinsics: introduce llvm_any_ty aka ValueType Any
Specifically, gc.result benefits from this greatly. Instead of:

gc.result.int.*
gc.result.float.*
gc.result.ptr.*
...

We now have a gc.result.* that can specialize to literally any type.

Differential Revision: http://reviews.llvm.org/D7020

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226857 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-22 20:14:38 +00:00
Adrian Prantl
8d8b891500 Rewrite DIExpression::printInternal() to use the iterator interface.
NFC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226836 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-22 16:55:22 +00:00
Adrian Prantl
71676d492a Rename DIExpressionIterator to DIExpression::iterator.
Addresses review feedback from Duncan.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226835 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-22 16:55:20 +00:00
Adrian Prantl
f51d86f02c Rewrite DIExpression::Verify() using an iterator. NFC.
Addresses review comments for r226627.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226747 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-22 00:00:52 +00:00
Adrian Prantl
9dc47c0c4a Let subprograms with instructions without parent scopes fail the
verification. Tested via a unit test.

Follow-up to r226616.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226684 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-21 18:32:56 +00:00
Adrian Prantl
4d569edd37 Make DIExpression::Verify() stricter by checking that the number of
elements and the ordering is sane and cleanup the accessors.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226627 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-21 00:59:20 +00:00
Adrian Prantl
6b89efe375 DebugLocs without a scope should fail the verification.
Follow-up to r226588.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226616 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-20 22:37:25 +00:00
Ramkumar Ramachandra
b8ae0acfaf [GC] Verify-pass void vararg functions in gc.statepoint
With the appropriate Verifier changes, exactracting the result out of a
statepoint wrapping a vararg function crashes. However, a void vararg
function works fine: commit this first step.

Differential Revision: http://reviews.llvm.org/D7071

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226599 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-20 19:42:46 +00:00
Manman Ren
0d12d4ebc6 [llvm link] Destroy ConstantArrays in LLVMContext if they are not used.
ConstantArrays constructed during linking can cause quadratic memory
explosion. An example is the ConstantArrays constructed when linking in
GlobalVariables with appending linkage.

Releasing all unused constants can cause a 20% LTO compile-time
slowdown for a large application. So this commit releases unused ConstantArrays
only.

rdar://19040716. It reduces memory footprint from 20+G to 6+G.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226592 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-20 19:24:59 +00:00
Adrian Prantl
61b4b8088d Add an assertion and prefer a crash over an infinite loop.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226588 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-20 18:03:37 +00:00
Duncan P. N. Exon Smith
e0c5d6d490 Reapply "IR: Simplify DIBuilder's HeaderBuilder API, NFC"
This reverts commit r226542, effectively reapplying r226540.  This time,
initialize `IsEmpty` in the copy and move constructors as well.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226545 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-20 05:02:42 +00:00
Duncan P. N. Exon Smith
0ab88ac2a1 Revert "IR: Simplify DIBuilder's HeaderBuilder API, NFC"
This reverts commit r226540, since I hit an unexpected bot failure [1].
I'll investigate.

[1]: http://bb.pgr.jp/builders/cmake-llvm-x86_64-linux/builds/20244

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226542 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-20 03:01:27 +00:00
Duncan P. N. Exon Smith
749d6fbf7e IR: Move MDNode clone() methods from ValueMapper to MDNode, NFC
Now that the clone methods used by `MapMetadata()` don't do any
remapping (and return a temporary), they make more sense as member
functions on `MDNode` (and subclasses).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226541 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-20 02:56:57 +00:00
Duncan P. N. Exon Smith
eefbe59844 IR: Simplify DIBuilder's HeaderBuilder API, NFC
Change `HeaderBuilder` API to work well even when it's not starting with
a tag.  There's already one case like this, and the tag is moving
elsewhere as part of PR22235.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226540 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-20 02:54:07 +00:00
Duncan P. N. Exon Smith
47ddb76984 IR: Delete GenericDwarfNode during teardown
Fix a leak in `LLVMContextImpl` teardown that the leak sanitizer tracked
down [1].  I've just switched to automatic dispatch here (since I'll
inevitably forget again with the next class).

[1]: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/811/steps/check-llvm%20asan/logs/stdio

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226536 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-20 01:18:32 +00:00
Duncan P. N. Exon Smith
62475afaf2 IR: Canonicalize GenericDwarfNode empty headers to null
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226532 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-20 00:58:46 +00:00
Duncan P. N. Exon Smith
c10ef2df5c IR: Detect whether to call recalculateHash() via SFINAE, NFC
Rather than relying on updating switch statements correctly, detect
whether `setHash()` exists in the subclass.  If so, call
`recalculateHash()` and `setHash(0)` appropriately.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226531 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-20 00:57:33 +00:00
Duncan P. N. Exon Smith
0a9f921686 IR: Introduce GenericDwarfNode
As part of PR22235, introduce `DwarfNode` and `GenericDwarfNode`.  The
former is a metadata node with a DWARF tag.  The latter matches our
current (generic) schema of a header with string (and stringified
integer) data and an arbitrary number of operands.

This doesn't move it into place yet; that change will require a large
number of testcase updates.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226529 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-20 00:01:43 +00:00
Duncan P. N. Exon Smith
0d7ab29889 IR: Cleanup MDNode field use, NFC
Swap usage of `SubclassData32` and `MDNodeSubclassData`, and rename
`MDNodeSubclassData` to `NumUnresolved`.  Small drive-by cleanup to
`countUnresolvedOperands()` since otherwise the name clash with local
vars named `NumUnresolved` would be confusing.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226523 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-19 23:18:34 +00:00
Duncan P. N. Exon Smith
c062fbe4ca IR: Move replaceWithUniqued(), etc., to source file, NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226522 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-19 23:17:09 +00:00
Duncan P. N. Exon Smith
898c48822f IR: Cleanup MDNode::MDNode(), NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226521 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-19 23:15:21 +00:00
Duncan P. N. Exon Smith
b0617860b5 IR: Merge UniquableMDNode back into MDNode, NFC
As pointed out in r226501, the distinction between `MDNode` and
`UniquableMDNode` is confusing.  When we need subclasses of `MDNode`
that don't use all its functionality it might make sense to break it
apart again, but until then this makes the code clearer.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226520 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-19 23:13:14 +00:00
Duncan P. N. Exon Smith
fce53dd939 IR: Extract MDNodeOpsKey, NFC
Make the MDTuple operand hashing logic reusable.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226519 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-19 22:53:18 +00:00
Duncan P. N. Exon Smith
ce8f144e00 IR: Simplify uniquifyImpl(), NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226518 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-19 22:52:07 +00:00
Duncan P. N. Exon Smith
668bd8ccfe IR: Simplify erasing from uniquing store, NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226517 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-19 22:47:08 +00:00
Duncan P. N. Exon Smith
37c7ccc40c IR: Allow temporary nodes to become uniqued or distinct
Add `MDNode::replaceWithUniqued()` and `MDNode::replaceWithDistinct()`,
which mutate temporary nodes to become uniqued or distinct.  On uniquing
collisions, the unique version is returned and the node is deleted.

This takes advantage of temporary nodes being folded back in, and should
let me clean up some awkward logic in `MapMetadata()`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226510 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-19 22:24:52 +00:00
Duncan P. N. Exon Smith
0927997ce8 IR: Split out countUnresolvedOperands(), NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226508 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-19 22:18:29 +00:00
Duncan P. N. Exon Smith
f9eaea701d IR: Return unique_ptr from MDNode::getTemporary()
Change `MDTuple::getTemporary()` and `MDLocation::getTemporary()` to
return (effectively) `std::unique_ptr<T, MDNode::deleteTemporary>`, and
clean up call sites.  (For now, `DIBuilder` call sites just call
`release()` immediately.)

There's an accompanying change in each of clang and polly to use the new
API.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226504 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-19 21:30:18 +00:00
Duncan P. N. Exon Smith
8ec0aee3b4 IR: Remove MDNodeFwdDecl
Remove `MDNodeFwdDecl` (as promised in r226481).  Aside from API
changes, there's no real functionality change here.
`MDNode::getTemporary()` now forwards to `MDTuple::getTemporary()`,
which returns a tuple with `isTemporary()` equal to true.

The main point is that we can now add temporaries of other `MDNode`
subclasses, needed for PR22235 (I introduced `MDNodeFwdDecl` in the
first place because I didn't recognize this need, and thought they were
only needed to handle forward references).

A few things left out of (or highlighted by) this commit:

  - I've had to remove the (few) uses of `std::unique_ptr<>` to deal
    with temporaries, since the destructor is no longer public.
    `getTemporary()` should probably return the equivalent of
    `std::unique_ptr<T, MDNode::deleteTemporary>`.
  - `MDLocation::getTemporary()` doesn't exist yet (worse, it actually
    does exist, but does the wrong thing: `MDNode::getTemporary()` is
    inherited and returns an `MDTuple`).
  - `MDNode` now only has one subclass, `UniquableMDNode`, and the
    distinction between them is actually somewhat confusing.

I'll fix those up next.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226501 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-19 20:36:39 +00:00
Duncan P. N. Exon Smith
e5afc6570f IR: Extract out and reuse storeImpl(), NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226499 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-19 20:18:13 +00:00
Duncan P. N. Exon Smith
1c588db19b IR: Extract out getUniqued(), NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226498 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-19 20:16:50 +00:00
Duncan P. N. Exon Smith
518025f8a1 IR: Reuse getImpl() for getDistinct(), NFC
Merge `getDistinct()`'s implementation with those of `get()` and
`getIfExists()` for both `MDTuple` and `MDLocation`.  This will make it
easier to scale to supporting temporaries.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226497 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-19 20:14:15 +00:00
Duncan P. N. Exon Smith
e85df9e0a2 IR: Simplify MDNode::setOperand(), NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226492 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-19 19:29:25 +00:00
Duncan P. N. Exon Smith
e2644b68c1 IR: Simplify handleChangedOperand() fast path, NFC
Use `isUniqued()` instead of `isStoredDistinctInContext()`, and remove
an assertion that won't be valid once temporaries are merged back in.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226491 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-19 19:28:28 +00:00
Duncan P. N. Exon Smith
5cc26e0d4b IR: Remove direct comparisons against Metadata::Storage, NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226490 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-19 19:26:24 +00:00
Duncan P. N. Exon Smith
2c22f8dc09 IR: Assert that resolve() is only called on uniqued nodes, NFC
Add an assertion in `UniquableMDNode::resolve()` to prevent temporaries
from being resolved (once they're merged back in).  Needed to shuffle
order of `resolve()` and `storeDistinctInContext()` to prevent it from
firing.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226489 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-19 19:25:33 +00:00
Duncan P. N. Exon Smith
a0ed724a44 IR: Remove isa<UniquableMDNode>, NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226488 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-19 19:10:14 +00:00
Duncan P. N. Exon Smith
68094bc021 IR: Simplify DIBuilder::trackIfUnresolved(), NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226487 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-19 19:09:14 +00:00
Duncan P. N. Exon Smith
2b6db3ceeb IR: Remove isa<MDNodeFwdDecl>, NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226486 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-19 19:06:41 +00:00
Duncan P. N. Exon Smith
c9a780aec5 IR: Unify code for MDNode::isResolved(), NFC
Unify the definitions of `MDNode::isResolved()` and
`UniquableMDNode::isResolved()`.  Previously, `UniquableMDNode` could
answer this question more efficiently, but now that RAUW support has
been unified with `MDNodeFwdDecl`, `MDNode` doesn't need any casts to
figure out the answer.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226485 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-19 19:03:18 +00:00
Duncan P. N. Exon Smith
641414a6c0 IR: Store RAUW support and Context in the same pointer, NFC
Add an `LLVMContext &` to `ReplaceableMetadataImpl`, create a class that
either holds a reference to an `LLVMContext` or owns a
`ReplaceableMetadataImpl`, and use the new class in `MDNode`.

  - This saves a pointer in `UniquableMDNode` at the cost of a pointer
    in `ValueAsMetadata` (which didn't used to store the `LLVMContext`).
    There are far more of the former.
  - Unifies RAUW support between `MDNodeFwdDecl` (which is going away,
    see r226481) and `UniquableMDNode`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226484 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-19 19:02:06 +00:00