Commit Graph

1240 Commits

Author SHA1 Message Date
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
Duncan P. N. Exon Smith
1d72e18caa IR: Add isUniqued() and isTemporary()
Change `MDNode::isDistinct()` to only apply to 'distinct' nodes (not
temporaries), and introduce `MDNode::isUniqued()` and
`MDNode::isTemporary()` for the other two possibilities.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226482 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-19 18:45:35 +00:00
Duncan P. N. Exon Smith
5f50874b3d IR: Use an enum to describe Metadata storage, NFC
More clearly describe the type of storage used for `Metadata`.

  - `Uniqued`: uniqued, stored in the context.
  - `Distinct`: distinct, stored in the context.
  - `Temporary`: not owned by anyone.

This is the first in a series of commits to fix a design problem with
`MDNodeFwdDecl` that I need to solve for PR22235.  While `MDNodeFwdDecl`
works well as a forward declaration, we use `MDNode::getTemporary()` for
more than forward declarations -- we also need to create early versions
of nodes (with fields not filled in) that we'll fill out later (see
`DIBuilder::finalize()` and `CGDebugInfo::finalize()` for examples).
This was a blind spot I had when I introduced `MDNodeFwdDecl` (which
David Blaikie (indirectly) highlighted in an unrelated review [1]).

[1]: http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20150112/252381.html

In general, we need `MDTuple::getTemporary()` to give a temporary tuple
(like `MDNodeFwdDecl`), `MDLocation::getTemporary()` to give a temporary
location, and (the problem at hand) `GenericDebugMDNode::getTemporary()`
to give a temporary generic debug node.

So I need to fold the idea of "temporary" nodes back into
`UniquableMDNode`.  (More commits to follow as I refactor.)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226481 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-19 18:36:18 +00:00
Craig Topper
6f91bd79f3 [x86] Change AVX512 intrinsics to take a 8-bit immediate for the comparision kind instead of a 32-bit immediate. This better aligns with the emitted instruction. It also matches SSE and AVX1 equivalents. Also add auto upgrade support.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226430 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-19 06:07:27 +00:00
Philip Reames
999412767a clang-format all the GC related files (NFC)
Nothing interesting here...




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226342 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-16 23:16:12 +00:00
Philip Reames
07fbc5c1c6 Move ownership of GCStrategy objects to LLVMContext
Note: This change ended up being slightly more controversial than expected.  Chandler has tentatively okayed this for the moment, but I may be revisiting this in the near future after we settle some high level questions.

Rather than have the GCStrategy object owned by the GCModuleInfo - which is an immutable analysis pass used mainly by gc.root - have it be owned by the LLVMContext. This simplifies the ownership logic (i.e. can you have two instances of the same strategy at once?), but more importantly, allows us to access the GCStrategy in the middle end optimizer. To this end, I add an accessor through Function which becomes the canonical way to get at a GCStrategy instance.

In the near future, this will allows me to move some of the checks from http://reviews.llvm.org/D6808 into the Verifier itself, and to introduce optimization legality predicates for some of the recent additions to InstCombine. (These will follow as separate changes.)

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226311 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-16 20:07:33 +00:00
Duncan P. N. Exon Smith
fb7514fccb IR: Allow 16-bits for column info
Raise the limit for column information from 8 bits to 16 bits.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226291 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-16 17:33:08 +00:00
Duncan P. N. Exon Smith
44fb4b337f IR: Cleanup dead code, NFC
Line/column fixups already exist in `MDLocation`.  Delete the duplicated
logic in `DebugLoc`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226290 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-16 17:31:29 +00:00
Philip Reames
8f9d11309a getMangledTypeStr: clarify how it mangles types, and add tests
"Write a set of tests that show how name mangling is done for overloaded intrinsics."  These happen to use gc.relocates to exercise the codepath in question, but is not a GC specific test.

Patch by: artagnon@gmail.com
Differential Revision: http://reviews.llvm.org/D6915



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226056 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-14 23:05:17 +00:00
Duncan P. N. Exon Smith
37ac8d3622 IR: Move MDLocation into place
This commit moves `MDLocation`, finishing off PR21433.  There's an
accompanying clang commit for frontend testcases.  I'll attach the
testcase upgrade script I used to PR21433 to help out-of-tree
frontends/backends.

This changes the schema for `DebugLoc` and `DILocation` from:

    !{i32 3, i32 7, !7, !8}

to:

    !MDLocation(line: 3, column: 7, scope: !7, inlinedAt: !8)

Note that empty fields (line/column: 0 and inlinedAt: null) don't get
printed by the assembly writer.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226048 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-14 22:27:36 +00:00
Duncan P. N. Exon Smith
bf13dd03e7 IR: Always print MDLocation line
Print `MDLocation`'s `line` field even when it's 0.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226046 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-14 22:14:26 +00:00
Duncan P. N. Exon Smith
0294f639d2 IR: Drop metadata references more aggressively during teardown
Sometimes teardown happens before the debug info graph is complete
(e.g., when clang throws an error).  In that case, `MDNode`s will still
have RAUW, so deleting constants that the `MDNode`s point at will be
relatively expensive -- it'll cause re-uniquing all up the chain (what
I've been referring to as "teardown madness").

So, drop references *before* deleting constants.  We need to drop a few
more references now: the metadata side of the metadata/value bridges
needs to be dropped off the cliff along with the rest of it (previously,
the bridges were cleaned before we did anything with the `MDNode`s).

There's no real functionality change here -- state before and after
`LLVMContextImpl::~LLVMContextImpl()` is unchanged -- so no testcase.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226044 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-14 21:58:17 +00:00
Duncan P. N. Exon Smith
9e4a11f46c IR: Fix a use-after-free in RAUW
Happened pretty commonly during `LLVMContext` teardown when `clang -g`
hit an error.  This fixes the use-after-free.  Next I'll clean up
teardown so that it's not RAUW'ing when metadata-tracked values are
deleted (only really causes a problem if the graph is mid-construction
when teardown starts, but it's still unnecessary work).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226029 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-14 19:56:10 +00:00