Commit Graph

23306 Commits

Author SHA1 Message Date
Duncan P. N. Exon Smith
66192e4b08 DebugInfo: Add implicit conversion from DISubprogram to DIScope
As a follow-up to r234850, add an implicit conversion from
`DISubprogram` to `DIScope` to support Kaleidoscope Ch. 8.  This also
reverts that band-aid from r234890.

(/me learns *again* to build Kaleidoscope before commit...)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234904 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-14 16:19:44 +00:00
Rafael Espindola
b9735c4333 Fix MSVC build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234899 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-14 15:25:14 +00:00
Rafael Espindola
661ed85834 Add raw_pwrite_stream type.
This is a raw_ostream that also supports pwrite.
I will be used in a sec.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234895 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-14 15:00:34 +00:00
Petar Jovanovic
01b026b023 Re-enable target-specific relocation table sorting and use it for Mips
Some targets (ie. Mips) have additional rules for ordering the relocation
table entries. Allow them to override generic sortRelocs(), which sorts
entries by Offset.
Then override this function for Mips, to emit HI16 and GOT16 relocations
against the local symbol in pair with the corresponding LO16 relocation.

Patch by Vladimir Stefanovic.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234883 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-14 13:23:34 +00:00
Jingyue Wu
9cecacd16a Simplify n-ary adds by reassociation
Summary:
This transformation reassociates a n-ary add so that the add can partially reuse
existing instructions. For example, this pass can simplify

  void foo(int a, int b) {
    bar(a + b);
    bar((a + 2) + b);
  }

to

  void foo(int a, int b) {
    int t = a + b;
    bar(t);
    bar(t + 2);
  }

saving one add instruction.

Fixes PR22357 (https://llvm.org/bugs/show_bug.cgi?id=22357).

Test Plan: nary-add.ll

Reviewers: broune, dberlin, hfinkel, meheff, sanjoy, atrick

Reviewed By: sanjoy, atrick

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234855 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-14 04:59:22 +00:00
Duncan P. N. Exon Smith
35adce33f1 DebugInfo: Update signature of DICompileUnit::replace*()
Change `DICompileUnit::replaceSubprograms()` and
`DICompileUnit::replaceGlobalVariables()` to match the `MDCompileUnit`
equivalents that they're wrapping.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234852 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-14 03:51:36 +00:00
Dmitri Gribenko
32439e7d88 LinkAllPasses.h: also link in parts of libLLVMSupport
When a loadable (.so or .dylib) pass is built with assertions enabled and
loaded into the 'opt' tool, we need to ensure that the extra symbols that such
passes depend on are linked into the tool.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234851 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-14 03:49:53 +00:00
Duncan P. N. Exon Smith
125e3d3959 DebugInfo: Gut DISubprogram and DILexicalBlock*
Gut the `DIDescriptor` wrappers around `MDLocalScope` subclasses.  Note
that `DILexicalBlock` wraps `MDLexicalBlockBase`, not `MDLexicalBlock`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234850 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-14 03:40:37 +00:00
Sanjoy Das
89d640a824 [SCEVExpander] Fix comments for functions. NFC.
Bring function documentation for ScalarEvolutionExpander up to code by
not repeating the function name in the comment documenting
functionality.  Reflow the edited comments where needed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234847 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-14 03:20:40 +00:00
Sanjoy Das
888e8e3a66 [LoopUnrollRuntime] Avoid high-cost trip count computation.
Summary:
Runtime unrolling of loops needs to emit an expression to compute the
loop's runtime trip-count.  Avoid runtime unrolling if this computation
will be expensive.

Depends on D8993.

Reviewers: atrick

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234846 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-14 03:20:38 +00:00
Sanjoy Das
dee1e82714 [SCEV] Refactor out isHighCostExpansion. NFCI.
Summary:
Move isHighCostExpansion from IndVarSimplify to SCEVExpander.  This
exposed function will be used in a subsequent change.

Reviewers: bogner, atrick

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234844 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-14 03:20:28 +00:00
Duncan P. N. Exon Smith
41ed49389b DebugInfo: Gut DINamespace and DITemplate*Parameter
Continue gutting `DIDescriptor` subclasses, turning them into
as-bare-as-possible pointer wrappers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234843 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-14 03:01:27 +00:00
Duncan P. N. Exon Smith
32cb99437e DebugInfo: Add MDLexicalBlockBase::getLine(), etc.
Add a few functions from `DILexicalBlock` to `MDLexicalBlockBase`,
leaving `DILexicalBlock` a simple wrapper.

IMO, the new functions (`getLine()` and `getColumn()`) don't really
belong in the base class, but to simplify transitioning old code it
seems like the right incremental step.  I've explicitly deleted them in
`MDLexicalBlockFile`, and eventually the callers should be updated to
downcast to `MDLexicalBlock` directly and the forwarding functions
removed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234842 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-14 02:50:07 +00:00
Duncan P. N. Exon Smith
355ec009e5 DebugInfo: Gut DIVariable and DIGlobalVariable
Gut all the non-pointer API from the variable wrappers, except an
implicit conversion from `DIGlobalVariable` to `DIDescriptor`.  Note
that if you're updating out-of-tree code, `DIVariable` wraps
`MDLocalVariable` (`MDVariable` is a common base class shared with
`MDGlobalVariable`).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234840 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-14 02:22:36 +00:00
Duncan P. N. Exon Smith
79666c21ab DebugInfo: Move DIVariable::printExtendedName() to its only caller
Move the local function `printDebugLoc()` along with it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234838 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-14 02:09:32 +00:00
Duncan P. N. Exon Smith
3e31f5eeb1 DebugInfo: Inline DIVariable::isBlockByrefVariable() into its callers
I don't think this API is helping much.  Change the callers to call
`MDType::isBlockByrefStruct()` directly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234837 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-14 01:59:58 +00:00
Duncan P. N. Exon Smith
b0b5cb29ab DebugInfo: Gut DIObjCProperty and DIImportedEntity
Gut a couple more classes in the DIDescriptor hierarchy.  Leave behind
an implicit conversion to `DIDescriptor`, the old base class.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234836 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-14 01:46:44 +00:00
Duncan P. N. Exon Smith
d59e30dfb7 DebugInfo: Gut DILocation
This is along the same lines as r234832, but for `DILocation`.  Clean
out all accessors from `DILocation`.  Any callers should be using
`MDLocation` directly (e.g., via `operator->()`).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234835 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-14 01:35:55 +00:00
Duncan P. N. Exon Smith
15552c46a0 DebugInfo: Gut DIExpression
Completely gut `DIExpression`, turning it into a simple wrapper around
`MDExpression *`.  There are two bits of magic left:

  - It's constructed from `const MDExpression*` but convertible to
    `MDExpression*`.
  - It's default-constructed to `nullptr`.

Otherwise, it should behave quite like a raw pointer.  Once I've done
the same to the rest of the `DIDescriptor` subclasses, I'll come back to
delete them entirely (and update call sites as necessary to deal with
the missing magic).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234832 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-14 01:12:42 +00:00
Duncan P. N. Exon Smith
d48d32bba9 DebugInfo: Move an assertion into MDCompositeTypeBase
In the name of gutting the `DIDescriptor` hierarchy.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234829 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-14 00:57:50 +00:00
Duncan P. N. Exon Smith
5f1ef8aec6 DebugInfo: Move DILocation::computeNewDiscriminators()
As documented in PR23200 (and the FIXMEs I've added to the code here),
this logic is fairly broken: it modifies the `LLVMContext` in a way that
affects other modules and cannot be serialized to assembly/bitcode.  For
now, move it over to `MDLocation::computeNewDiscriminators()` anyway.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234825 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-14 00:35:42 +00:00
Duncan P. N. Exon Smith
31bbd1ac1e AddDiscriminators: Create new MDLocation directly
I don't see a reason to add the `copyWithNewScope()` API over to
`MDLocation` -- it seems to be a holdover from when creating locations
required knowing details of operand layout -- so change
`AddDiscriminators` to call `MDLocation::get()` directly.  Should be no
functionality change here.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234824 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-14 00:34:30 +00:00
Duncan P. N. Exon Smith
3c42b7f3b7 DebugInfo: Move DILocation::getDiscriminator() to MDLocation
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234819 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-14 00:05:13 +00:00
Duncan P. N. Exon Smith
dc4806ef72 DebugInfo: Remove DIObjCProperty attribute accessors, NFC
There's only one user of the various `DIObjCProperty::is*Property()`
accessors -- `DwarfUnit::constructTypeDIE()` -- and it's just using the
reverse logic to reconstruct the bitfield.  Drop this API and simplify
the only caller.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234818 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-13 23:55:01 +00:00
Duncan P. N. Exon Smith
8ae5482d49 DebugInfo: Move DIDerivedType accessors to MDDerivedType, NFC
Add accessors in `MDDerivedType` to downcast `getExtraData()`, matching
those in `DIDerivedType`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234816 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-13 23:36:36 +00:00
Daniel Berlin
1f13e20f7d Add new getModRefInfo API to determine whether an Instruction and a call modify the same memory
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234814 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-13 23:25:41 +00:00
Daniel Berlin
e7122e58a1 Common some code from MemoryDependenceAnalysis that will be used in MemorySSA
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234813 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-13 23:20:13 +00:00
Duncan P. N. Exon Smith
7ca9328e16 DebugInfo: Make DIDerivedType accessors more strict
These accessors in `DIDerivedType` should only be called when `DbgNode`
really is a `MDDerivedType`, not just a `MDDerivedTypeBase`.  Assume
that it is.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234812 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-13 23:13:18 +00:00
Daniel Berlin
b4f6438352 Make getModRefInfo with a default location not crash.
Add getModRefInfo that works without location.
Add unit tests.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234811 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-13 23:05:45 +00:00
Daniel Berlin
8bdb7dbe57 Allow printing functions with an optional annotationwriter
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234807 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-13 22:36:38 +00:00
Lang Hames
597d2b7309 [Orc] Add an Orc layer for applying arbitrary transforms to IR, use it to add
debugging output to the LLI orc-lazy JIT, and update the orc-lazy "hello.ll"
test to actually test for lazy compilation.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234805 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-13 22:12:54 +00:00
Duncan P. N. Exon Smith
26117d38cc DebugInfo: Simplify a few more wrappers
This is almost NFC, but I'm removing some assertions against `nullptr`.
The assertions aren't worth all that much since we'll typically get
segfaults at the same site (and I imagine ASan catches this sort of
thing), and besides: the whole idea is to replace the `DIDescriptor`
hierarchy with raw pointers to the new one.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234802 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-13 21:58:26 +00:00
Duncan P. N. Exon Smith
fafe7a41a5 SelectionDAG: Stop using DIVariable::isInlinedFnArgument()
Instead of calling the somewhat confusingly-named
`DIVariable::isInlinedFnArgument()`, do the check directly here.
There's possibly a small functionality change here: instead of
`dyn_cast<>`'ing `DV->getScope()` to `MDSubprogram`, I'm looking up the
scope chain for the actual subprogram.  I suspect that this is a no-op
for function arguments so in practise there isn't a real difference.

I've also added a `FIXME` to check the `inlinedAt:` chain instead, since
I wonder if that would be more reliable than the
`MDSubprogram::describes()` function.

Since this was the only user of `DIVariable::isInlinedFnArgument()`,
delete it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234799 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-13 21:38:48 +00:00
Duncan P. N. Exon Smith
7153e0d49b DebugInfo: Remove DIGlobalVariable::getGlobal()
`DIGlobalVariable::getGlobal()` isn't really helpful, it just does a
`dyn_cast_or_null<>`.  Simplify its only user by doing the cast directly
and delete the code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234796 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-13 20:39:25 +00:00
Duncan P. N. Exon Smith
461b82ddb6 DebugInfo: Remove a few unnecessary wrappers
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234783 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-13 19:44:31 +00:00
Duncan P. N. Exon Smith
eed6a11f81 DebugInfo: Assume valid pointer in DISubprogram::replaceFunction()
Other accessors assume this already; not sure how `replaceFunction()`
got left behind.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234782 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-13 19:41:30 +00:00
Duncan P. N. Exon Smith
8ca57e685e DebugInfo: Migrate DISubprogram::describes() to new hierarchy, NFC
I don't really like this function at all -- I think it should be as
simple as `return getFunction() == F` -- but for now this seems like the
best we can do.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234778 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-13 19:07:27 +00:00
Duncan P. N. Exon Smith
88116fe71a Reapply "Verifier: Check for incompatible bit piece expressions"
This reverts commit r234717, reapplying r234698 (in spirit).

As described in r234717, the original `Verifier` check had a
use-after-free.  Instead of storing pointers to "interesting" debug info
intrinsics whose bit piece expressions should be verified once we have
typerefs, do a second traversal.  I've added a testcase to catch the
`llc` crasher.

Original commit message:

    Verifier: Check for incompatible bit piece expressions

    Convert an assertion into a `Verifier` check.  Bit piece expressions
    must fit inside the variable, and mustn't be the entire variable.
    Catching this in the verifier will help us find bugs sooner, and makes
    `DIVariable::getSizeInBits()` dead code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234776 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-13 18:53:11 +00:00
Krzysztof Parzyszek
fcc330abfe Allow memory intrinsics to be tail calls
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234764 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-13 17:16:45 +00:00
Duncan P. N. Exon Smith
ea8c159524 Revert "Verifier: Check for incompatible bit piece expressions"
This reverts commit r234698.

This caused a use-after-free: `QueuedBitPieceExpressions` holds onto
references to `DbgInfoIntrinsic`s and references them past where they're
deleted (this is because the verifier is run as a function pass, and
then `verifyTypeRefs()` is called during `doFinalization()`).

I'll include a reduced crasher for `llc` when I recommit the check.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234717 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-13 00:06:28 +00:00
Petr Hosek
054db7df5b [MC] Write padding into fragments when -mc-relax-all flag is used
Summary:
When instruction bundling is enabled and the -mc-relax-all flag is
set, we can write bundle padding directly into fragments and avoid
creating large number of fragments significantly reducing LLVM MC
memory usage.

Test Plan: Regression test attached

Reviewers: eliben

Subscribers: jfb, mseaborn

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234714 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-12 23:42:25 +00:00
Lang Hames
138418f22a [Orc] Remove duplicate "then" in comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234710 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-12 22:23:57 +00:00
Lang Hames
e9136a0993 [Orc] Fix out-of-date comment for the IRCompileLayer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234709 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-12 22:21:48 +00:00
Duncan P. N. Exon Smith
e2e641234f DebugInfo: Make MDSubprogram::getFunction() return Constant
Change `MDSubprogram::getFunction()` and
`MDGlobalVariable::getConstant()` to return a `Constant`.  Previously,
both returned `ConstantAsMetadata`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234699 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-11 20:27:40 +00:00
Duncan P. N. Exon Smith
3ec16b419f Verifier: Check for incompatible bit piece expressions
Convert an assertion into a `Verifier` check.  Bit piece expressions
must fit inside the variable, and mustn't be the entire variable.
Catching this in the verifier will help us find bugs sooner, and makes
`DIVariable::getSizeInBits()` dead code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234698 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-11 19:58:35 +00:00
Duncan P. N. Exon Smith
429f5391ad DebugInfo: Remove dead DIDescriptor::replaceAllUsesWith()
r234696 replaced the only use of `DIDescriptor::replaceAllUsesWith()`
with `DIBuilder::replaceTemporary()` (added in r234695).  Delete the
dead code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234697 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-11 19:29:09 +00:00
Duncan P. N. Exon Smith
9b30c7bd38 DebugInfo: Introduce DIBuilder::replaceTemporary()
Add `DIBuilder::replaceTemporary()` as a replacement for
`DIDescriptor::replaceAllUsesWith()`.  I'll update clang to use the new
method, and then come back to delete the original.

This method dispatches to `replaceAllUsesWith()` or
`replaceWithUniqued()`, depending on whether the replacement is actually
a different node from the original.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234695 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-11 19:04:09 +00:00
Benjamin Kramer
822147fcb2 Mark empty default constructors as =default if it makes the type POD
NFC

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234694 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-11 18:57:14 +00:00
Benjamin Kramer
38ebdeea7a Make OnDiskChainedHashTableGenerator's Bucket type a POD type and reorder fields to optimize padding
For the common case of offset_type=unsigned this brings Bucket from 24 to 16
bytes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234692 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-11 18:00:28 +00:00
Duncan P. N. Exon Smith
4e1b79bbd8 DebugInfo: Move DIScope::getName() and getContext() to MDScope
Continue gutting the `DIDescriptor` hierarchy.  In this case, move the
guts of `DIScope::getName()` and `DIScope::getContext()` to
`MDScope::getName()` and `MDScope::getScope()`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234691 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-11 17:37:23 +00:00