Commit Graph

35 Commits

Author SHA1 Message Date
Nadav Rotem
d78b376d07 [passes] Replace the old invalidation lattice with a new invalidation scheme.
The old invalidation lattice was incorrect because changes to control flow could cause changes to the
call graph, so we've decided to change the way passes invalidate analysis.  In the new scheme, the lattice
is replaced with a list of traits that passes preserve or invalidate. The current traits are Calls and Branches.
Now, passes report which traits they preserve, which is the opposite of the previous implementation where
passes needed to report what they invalidate.

Node: I tried to limit the changes in this commit to mechanical changes to ease the review. I will cleanup some
of the code in a following commit.

Swift SVN r26449
2015-03-23 21:18:58 +00:00
Arnold Schwaighofer
3b921a123d ArrayBoundsCheckOpts: Don't set the debug scope manually for instructions created by a SILBuilderWithScope
The SILBuilderWithScope will set the debug scope on destruction and complain if
there is one set already.

rdar://20166693

Swift SVN r26183
2015-03-16 18:00:16 +00:00
Arnold Schwaighofer
aa24e126e4 ArraySemantic: Move to its own file in SILAnalysis
I want to use it in ARCAnalysis.

Swift SVN r25924
2015-03-10 15:20:20 +00:00
Arnold Schwaighofer
06f7c40c32 ArraySemanticsCall: Handle @guaranteed parameters
Also improve checking of parameter requirements.

This is needed for our move to +0 self.

radar://20039357

Swift SVN r25798
2015-03-06 03:20:47 +00:00
Arnold Schwaighofer
951dc2875a Nuke isSideEffectFree
We can now compute the same result with Inst.mayHaveSideEffects(). NFC.

Swift SVN r25742
2015-03-04 05:03:44 +00:00
Arnold Schwaighofer
244a804f99 Use createBuiltinBinaryFunctionWithOverflow in ArrayBoundsCheckOpts.
NFC.

Swift SVN r25664
2015-03-02 01:05:33 +00:00
Arnold Schwaighofer
44479683b3 SILBuilder: createBuiltinCmp -> createBuiltinBinaryFunction
Also add createBuiltinBinaryFunctionWithOverflow. NFC.

Swift SVN r25663
2015-03-02 01:05:33 +00:00
Luqman Aden
b9c360e864 Minor changes to incorporate feedback on r25416.
Swift SVN r25434
2015-02-20 19:48:07 +00:00
Luqman Aden
e1c60464d3 Fold getCmpFunction function into helper method on SILBuilder.
Swift SVN r25416
2015-02-20 04:08:08 +00:00
Luqman Aden
858d8d99df SILCombine: Add cmp_*_T . (zext U->T x, zext U->T y) => cmp_*_T (x, y)
peephole for unsigned/equality comparisons.

Fixes <rdar://problem/19759124>

Swift SVN r25404
2015-02-20 00:39:33 +00:00
Arnold Schwaighofer
283a6bee39 Fix users of ArraySemantics::getSelf to correctly handle Array.init
Array.init does not have a self argument (it returns the newly created array
@owned). Passes using the ArraySemantic::getSelf() interface must handle it
specially.

rdar://19724033

Swift SVN r25013
2015-02-05 19:31:23 +00:00
Mark Lacey
6170bbb0ed Minor code clean-up.
Primarily replacing getParent()->getParent() with getFunction().

Swift SVN r24596
2015-01-21 06:35:13 +00:00
Arnold Schwaighofer
7f6824e74f ABCOpts: Adopt for future array addressor changes.
We need to strip the MarkDependenceInst when recognizing safe stores.

Swift SVN r24444
2015-01-15 15:33:43 +00:00
Arnold Schwaighofer
0af8adf33f ABCOpts: Make array element store recognition more powerful
We can skip address projections when looking for a call to _getElementAddress.
This allows us to recognize more harmless (stores that don't effect the array
size) stores that just store to elements in the array.

Swift SVN r23650
2014-12-03 17:28:50 +00:00
Andrew Trick
a395317260 ABCOpts DEBUG output.
Swift SVN r23602
2014-12-02 01:07:44 +00:00
Arnold Schwaighofer
19b01516d8 ArrayBoundsCheck: Use the destructor analysis to make sure the array's destructor is memory safe
rdar://18940376

Swift SVN r23243
2014-11-11 19:27:41 +00:00
Arnold Schwaighofer
a2066b6222 ABCOpts: releases can have memory unsafe side effects due to the deinit method
To guarantuee memory safety we need to guarantuee that the deinit method can not
do anything unsafe. This means we need to treat general releases like any
arbitrary function call. We need to assume it does something unsafe.
Conservatively, we only releases on arrays are known to be safe.

Thanks Andy for pointing this out to me!

Swift SVN r23181
2014-11-08 18:00:26 +00:00
Adrian Prantl
c41b30299f Audit all SILPasses to ensure that new instructions are never created
without a valid SILDebugScope. An assertion in IRGenSIL prevents future
optimizations from regressing in this regard.
Introducing SILBuilderWithScope and SILBuilderwithPostprocess to ease the
transition.

This patch is large, but mostly mechanical.
<rdar://problem/18494573> Swift: Debugger is not stopping at the set breakpoint

Swift SVN r22978
2014-10-28 01:49:11 +00:00
Joe Groff
e3f9a2035c SIL: Move SILGen and passes over to use "builtin" instead of "apply (builtin_function_ref)".
Swift SVN r22785
2014-10-15 23:37:22 +00:00
Arnold Schwaighofer
b6f28bede1 ArraySemantics: Teach array semantics about getting the address of an array element
rdar://18517410

Swift SVN r22439
2014-10-01 21:08:22 +00:00
Arnold Schwaighofer
f6654aa1ae ABCOpts: Invariant values must strictly dominate the header
Fixes an embarrassing mistake. I am used to saying something is loop invariant
if it dominates the loop header. What I really mean of course, is that it
strictly dominates the loop header.
Unfortunately, I actually wrote code that checks dom(invariant?, header). :(

rdar://18498770

Swift SVN r22393
2014-09-30 17:28:03 +00:00
Arnold Schwaighofer
c8679d91eb ABCOpts: rewrite in terms of ArraySemantics call wrapper
NFC

Swift SVN r21928
2014-09-12 21:05:23 +00:00
Arnold Schwaighofer
813d43415f ArraySemantics: Add wrapper utility for array semantics calls to Local.h
This encapsulates common operations on array semantic calls like identifying
them or hoisting/copying them.

Will be used by follow-up commits. NFC.

Swift SVN r21926
2014-09-12 21:05:22 +00:00
Michael Gottesman
4609513593 Remove SILValue::stripRCIdentityPreservingArgs and teach all uses of that method to use the new RCIdentityAnalysis.
Currently, the pass just calls a local version of that function. After OzU, I
will enable the full pass (which is currently disabled behind a flag).

Swift SVN r21894
2014-09-11 22:29:31 +00:00
Michael Gottesman
24c138f29c Move SILLoopInfo into swiftSIL from swiftSILAnalysis so that we match the separation in between analysis and IR entities.
This follows the model of dominance info and allows me to create reachability
methods on SILBasicBlock without creating dependencies from swiftSIL to
swiftSILAnalysis.

Swift SVN r21866
2014-09-11 03:03:06 +00:00
Arnold Schwaighofer
24e361635b ABCOpts: Use stripRCIdentityPreservingOps directly instead of pattern matching
known array retain patterns

NFC

Swift SVN r21551
2014-08-29 00:12:03 +00:00
Arnold Schwaighofer
84de9c6763 ABCOpts: Accept retains of the array as matching retains to subscript checks
After stripRCIdentityPreservingOps the indirection through the array buffer data
structure is gone. We would no longer recognize a matching retain.

Where we had this before:

  %3 = load %0 : $*ArrayInt
  %4 = struct_extract %3 : $ArrayInt, #ArrayInt.buffer
  %5 = struct_extract %4 : $ArrayIntBuffer, #ArrayIntBuffer.storage
  retain_value %5 : $Builtin.NativeObject
  subscript_check(%3, i)

We now would just have:

  %3 = load %0 : $*ArrayInt
  retain_value %3 : $
  subscript_check(%3, i)

Swift SVN r21512
2014-08-28 02:50:21 +00:00
Michael Gottesman
0f7053bd01 Remove SILBasicBlock::getBBArgIndex(SILArgument *) in favor of SILArgument::getIndex().
The index is a property of the argument. There is no reason from a modeling
perspective to go through the BB to get it.

Swift SVN r21338
2014-08-21 04:06:19 +00:00
Arnold Schwaighofer
338739d873 ABCOpts: Comment code that matches an integer passed to the bounds check.
NFC.

Swift SVN r21212
2014-08-14 18:18:39 +00:00
Arnold Schwaighofer
86d43be559 IndVars: Store the increment of an induction variable
Such that we don't need to repeat part of the analysis in ABCOpts.

No functionality change.

Swift SVN r21211
2014-08-14 18:18:38 +00:00
Arnold Schwaighofer
effa193a01 ABCOpts: Cleanup - use PointerIntPair instead of reinterpret cast
No functionality change.

Swift SVN r21210
2014-08-14 18:18:37 +00:00
Arnold Schwaighofer
e0173f4585 ABCOpts: Move member variables to the top of the class
No functionality change.

Swift SVN r21209
2014-08-14 18:18:37 +00:00
Arnold Schwaighofer
04ca5e128e ABCOpts: Add bounds check hoisting of induction identity accesses
We can now hoist the check in:

 for (i = start; i != end; ++i)
   a[i] = ...

or

 for i in start ..< end
   a[i] = ...

We will also hoist invariant checks as in

 k =
 for i in start ..< end
   a[k] = ...

We will also hoists the overflow check for "++i" out of the loop.

The only thing blocking vectorization of memset loops is the fact that we are
overflow checking the type size muliplication of array accesses. "a[i]" is
translated to "a + sizeof(T) * i" and this multiplication is still overflow
checked.

We can remove bounds checks in PrimeNum, XorLoop, Hash, MemSet, NBody, Walsh.

Memset                 ,  2371.00   ,  1180.00  ,  1179.00  ,        99.9%
XorLoop                ,  1403.00   ,  1255.00  ,  149.00   ,        11.9%

rdar://14757945

Swift SVN r21182
2014-08-13 20:00:08 +00:00
Arnold Schwaighofer
32af1c622c ABCOpts: Enable per default
Swift SVN r20213
2014-07-20 00:16:37 +00:00
Arnold Schwaighofer
f6b0682988 Array bounds check optimization pass
Implements redundant bounds check elimination for basic blocks and along the
dominator tree of loops.

No induction variable based hoisting yet.

O3:
NBody          ,  473.00     ,  122.00    ,  294.2%
QuickSort      ,  477.00     ,  310.00    ,  53.9%
RC4            ,  1022.00    ,  736.00    ,  38.6%
Walsh          ,  1781.00    ,  1142.00   ,  55.5%

No effect on Ofast.

Disabled for now.

Swift SVN r20199
2014-07-19 01:18:50 +00:00