1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00
Commit Graph

23262 Commits

Author SHA1 Message Date
Daniel Berlin
101acbc47e Only recalculate DFS Numbers if invalid. Invalidate DFS numbers on reset. Add unit test to verify recalculation
llvm-svn: 234933
2015-04-14 19:49:26 +00:00
Daniel Berlin
b83bd6bed3 Make updateDFSNumbers API public
Summary:
There are a number of passes that could be sped up by using dominator tree DFS numbers to order or compare things across multiple bbs
(MemorySSA, MergedLoadStoreMotion, EarlyCSE, Sinking, GVN, NewGVN, for starters :P).

For example, GVN/CSE elimination can be done with a simple stack/etc (instead of full-on scoped hash table or repeated leader set walks)
  if the DFS pair is stored next to leaders.

The dominator tree keeps them, and the DOM tree nodes expose them as public, but you have no guarantee they are up to date (and in fact,
if you split blocks or whatever during your pass, they definitely won't be)

This means passes either have to compute their own versions[1], or make 32 queries, or ....
Rather than try to hide this, i just made the API public, and make it do nothing if the numbers are already valid.

[1] Which we want as a non-recursive walk, which is not pretty, sadly,
because it cannot use the depth first iterators since you don't get called on the way back up. So you either have to do one walk with po_iterator
and one with df_iterator, or write your own non-recursive walk that looks identical to the one in updateDFSNumbers.

Reviewers: chandlerc

Subscribers: llvm-commits

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

llvm-svn: 234930
2015-04-14 19:09:16 +00:00
Duncan P. N. Exon Smith
74f370958b 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...)

llvm-svn: 234904
2015-04-14 16:19:44 +00:00
Rafael Espindola
273d012050 Fix MSVC build.
llvm-svn: 234899
2015-04-14 15:25:14 +00:00
Rafael Espindola
971bb23eca Add raw_pwrite_stream type.
This is a raw_ostream that also supports pwrite.
I will be used in a sec.

llvm-svn: 234895
2015-04-14 15:00:34 +00:00
Petar Jovanovic
9a0a08ccc4 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

llvm-svn: 234883
2015-04-14 13:23:34 +00:00
Jingyue Wu
5bb1ce8bf8 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

llvm-svn: 234855
2015-04-14 04:59:22 +00:00
Duncan P. N. Exon Smith
b45f18bf7d DebugInfo: Update signature of DICompileUnit::replace*()
Change `DICompileUnit::replaceSubprograms()` and
`DICompileUnit::replaceGlobalVariables()` to match the `MDCompileUnit`
equivalents that they're wrapping.

llvm-svn: 234852
2015-04-14 03:51:36 +00:00
Dmitri Gribenko
f4af843949 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.

llvm-svn: 234851
2015-04-14 03:49:53 +00:00
Duncan P. N. Exon Smith
3b5fae31ff DebugInfo: Gut DISubprogram and DILexicalBlock*
Gut the `DIDescriptor` wrappers around `MDLocalScope` subclasses.  Note
that `DILexicalBlock` wraps `MDLexicalBlockBase`, not `MDLexicalBlock`.

llvm-svn: 234850
2015-04-14 03:40:37 +00:00
Sanjoy Das
2763237d5a [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.

llvm-svn: 234847
2015-04-14 03:20:40 +00:00
Sanjoy Das
b9907c45f6 [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

llvm-svn: 234846
2015-04-14 03:20:38 +00:00
Sanjoy Das
30ca3be9e4 [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

llvm-svn: 234844
2015-04-14 03:20:28 +00:00
Duncan P. N. Exon Smith
447735d82c DebugInfo: Gut DINamespace and DITemplate*Parameter
Continue gutting `DIDescriptor` subclasses, turning them into
as-bare-as-possible pointer wrappers.

llvm-svn: 234843
2015-04-14 03:01:27 +00:00
Duncan P. N. Exon Smith
baaabdb7fa 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.

llvm-svn: 234842
2015-04-14 02:50:07 +00:00
Duncan P. N. Exon Smith
ac19c888b2 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`).

llvm-svn: 234840
2015-04-14 02:22:36 +00:00
Duncan P. N. Exon Smith
fbf4b02970 DebugInfo: Move DIVariable::printExtendedName() to its only caller
Move the local function `printDebugLoc()` along with it.

llvm-svn: 234838
2015-04-14 02:09:32 +00:00
Duncan P. N. Exon Smith
1756352377 DebugInfo: Inline DIVariable::isBlockByrefVariable() into its callers
I don't think this API is helping much.  Change the callers to call
`MDType::isBlockByrefStruct()` directly.

llvm-svn: 234837
2015-04-14 01:59:58 +00:00
Duncan P. N. Exon Smith
c1a1d9a119 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.

llvm-svn: 234836
2015-04-14 01:46:44 +00:00
Duncan P. N. Exon Smith
cbde5503ef 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->()`).

llvm-svn: 234835
2015-04-14 01:35:55 +00:00
Duncan P. N. Exon Smith
2e9424982a 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).

llvm-svn: 234832
2015-04-14 01:12:42 +00:00
Duncan P. N. Exon Smith
129325cc57 DebugInfo: Move an assertion into MDCompositeTypeBase
In the name of gutting the `DIDescriptor` hierarchy.

llvm-svn: 234829
2015-04-14 00:57:50 +00:00
Duncan P. N. Exon Smith
d8e6e70445 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.

llvm-svn: 234825
2015-04-14 00:35:42 +00:00
Duncan P. N. Exon Smith
68bf43ebd7 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.

llvm-svn: 234824
2015-04-14 00:34:30 +00:00
Duncan P. N. Exon Smith
b3c1193774 DebugInfo: Move DILocation::getDiscriminator() to MDLocation
llvm-svn: 234819
2015-04-14 00:05:13 +00:00
Duncan P. N. Exon Smith
c12bb65760 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.

llvm-svn: 234818
2015-04-13 23:55:01 +00:00
Duncan P. N. Exon Smith
42c613035b DebugInfo: Move DIDerivedType accessors to MDDerivedType, NFC
Add accessors in `MDDerivedType` to downcast `getExtraData()`, matching
those in `DIDerivedType`.

llvm-svn: 234816
2015-04-13 23:36:36 +00:00
Daniel Berlin
f347b8bede Add new getModRefInfo API to determine whether an Instruction and a call modify the same memory
llvm-svn: 234814
2015-04-13 23:25:41 +00:00
Daniel Berlin
aae6ae7aa7 Common some code from MemoryDependenceAnalysis that will be used in MemorySSA
llvm-svn: 234813
2015-04-13 23:20:13 +00:00
Duncan P. N. Exon Smith
4913c0eff3 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.

llvm-svn: 234812
2015-04-13 23:13:18 +00:00
Daniel Berlin
0dd1c441f1 Make getModRefInfo with a default location not crash.
Add getModRefInfo that works without location.
Add unit tests.

llvm-svn: 234811
2015-04-13 23:05:45 +00:00
Daniel Berlin
f5b91cde0f Allow printing functions with an optional annotationwriter
llvm-svn: 234807
2015-04-13 22:36:38 +00:00
Lang Hames
dd40ba2a66 [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.

llvm-svn: 234805
2015-04-13 22:12:54 +00:00
Duncan P. N. Exon Smith
9363e95afe 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.

llvm-svn: 234802
2015-04-13 21:58:26 +00:00
Duncan P. N. Exon Smith
c982c7dea2 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.

llvm-svn: 234799
2015-04-13 21:38:48 +00:00
Duncan P. N. Exon Smith
933300cefc 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.

llvm-svn: 234796
2015-04-13 20:39:25 +00:00
Duncan P. N. Exon Smith
60cd6704e0 DebugInfo: Remove a few unnecessary wrappers
llvm-svn: 234783
2015-04-13 19:44:31 +00:00
Duncan P. N. Exon Smith
55aa9652c3 DebugInfo: Assume valid pointer in DISubprogram::replaceFunction()
Other accessors assume this already; not sure how `replaceFunction()`
got left behind.

llvm-svn: 234782
2015-04-13 19:41:30 +00:00
Duncan P. N. Exon Smith
6ba180eadf 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.

llvm-svn: 234778
2015-04-13 19:07:27 +00:00
Duncan P. N. Exon Smith
c107098997 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.

llvm-svn: 234776
2015-04-13 18:53:11 +00:00
Krzysztof Parzyszek
3efcf81e03 Allow memory intrinsics to be tail calls
llvm-svn: 234764
2015-04-13 17:16:45 +00:00
Duncan P. N. Exon Smith
41e27d946d 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.

llvm-svn: 234717
2015-04-13 00:06:28 +00:00
Petr Hosek
bbb668b972 [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

llvm-svn: 234714
2015-04-12 23:42:25 +00:00
Lang Hames
2bf8a1716d [Orc] Remove duplicate "then" in comment.
llvm-svn: 234710
2015-04-12 22:23:57 +00:00
Lang Hames
521a759f11 [Orc] Fix out-of-date comment for the IRCompileLayer.
llvm-svn: 234709
2015-04-12 22:21:48 +00:00
Duncan P. N. Exon Smith
70f9252a1a DebugInfo: Make MDSubprogram::getFunction() return Constant
Change `MDSubprogram::getFunction()` and
`MDGlobalVariable::getConstant()` to return a `Constant`.  Previously,
both returned `ConstantAsMetadata`.

llvm-svn: 234699
2015-04-11 20:27:40 +00:00
Duncan P. N. Exon Smith
112124e807 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.

llvm-svn: 234698
2015-04-11 19:58:35 +00:00
Duncan P. N. Exon Smith
50254bcfdc DebugInfo: Remove dead DIDescriptor::replaceAllUsesWith()
r234696 replaced the only use of `DIDescriptor::replaceAllUsesWith()`
with `DIBuilder::replaceTemporary()` (added in r234695).  Delete the
dead code.

llvm-svn: 234697
2015-04-11 19:29:09 +00:00
Duncan P. N. Exon Smith
c0c5b3d5ed 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.

llvm-svn: 234695
2015-04-11 19:04:09 +00:00
Benjamin Kramer
a304c427ee Mark empty default constructors as =default if it makes the type POD
NFC

llvm-svn: 234694
2015-04-11 18:57:14 +00:00