Commit Graph

33 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
Nadav Rotem
2781e93d9f Port COW and LoopRotate to use the new locking-analysis API. NFC.
Swift SVN r26376
2015-03-20 22:53:09 +00:00
Arnold Schwaighofer
4aa6de5744 COWArrayOpt: A side-effect free instruction cannot mutate the array
This was blocking hoisting make_mutable with +0 Self enabled.

rdar://20071261

Swift SVN r26112
2015-03-13 21:31:31 +00:00
Arnold Schwaighofer
2106b44704 RegionCloner: Split edges from non cond_br terminators to exit blocks
When we clone the exiting block such edges become critical and we don't like
critical non cond_br edges (updating SSA needs to put arguments somewhere and
such).

radar://20114457

Swift SVN r25982
2015-03-11 17:25: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
8038fd65a4 Revert "Revert "COWArrayOpt: Enable array.props hoisting""
Renable array property check hoisting. Third try.

This reverts commit r25751.

Swift SVN r25839
2015-03-07 05:07:32 +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
Michael Gottesman
d7d5dac460 Revert "COWArrayOpt: Enable array.props hoisting"
This reverts commit r25737. The pass was just turned on and is causing Asan to
trigger.

Swift SVN r25751
2015-03-04 08:17:44 +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
459fdb52ea Revert "Revert "COWArrayOpt: Enable array.props hoisting""
This reverts commit r25702 and reenabling array property hoisting.

Swift SVN r25737
2015-03-04 01:06:29 +00:00
Arnold Schwaighofer
a4c4f3aa2a COWArrayOpt: Split cond_br critical edges after cloning loops
Our cannonical form requires this.

Swift SVN r25736
2015-03-04 01:06:28 +00:00
Arnold Schwaighofer
7859522dbc COWArrayOpt: Only invalidate if we have changed the CFG
Swift SVN r25735
2015-03-04 01:06:28 +00:00
Arnold Schwaighofer
c52593fdce COWArrayOpt: No need to call SILAnalysis::invalidate twice
Invalidating the CFG will invalidate instructions.

Swift SVN r25734
2015-03-04 01:06:27 +00:00
Arnold Schwaighofer
411ba4e830 COWArrayOpt: Fix the array property specializer to recompute the loop tree after cloning
Cloning the loop is going to invalidate the loop tree. Be conservative and
recompute it.

No test case. I did not run into an error but also don't want to in the future.

Swift SVN r25733
2015-03-04 01:06:27 +00:00
Arnold Schwaighofer
c8180d6ee7 Revert "COWArrayOpt: Enable array.props hoisting"
This reverts commit r25699.

There is build bot breakage I believe due to this.

Swift SVN r25702
2015-03-03 02:43:50 +00:00
Arnold Schwaighofer
646e5e1f68 COWArrayOpt: Enable array.props hoisting
O speedup (before/after):
  ClassArrayGetter`7.4
  Rectangles```````1.9
  InsertionSort````0.9
  Chars````````````0.92

I looked at the Chars and InsertionSort regressions and did not see something
actionable. It looked like noise.

rdar://17955309

Swift SVN r25699
2015-03-03 00:46:00 +00:00
Arnold Schwaighofer
c087f218f9 COWArrayOpt: Hoist array projections to the preheader
In nested loops the projection operations to get to the array are only
conditionally executed (they reside in the preheader of the inner loop).
So LICM will not hoist them. Instead, recognize them and hoist them on demand.

rdar://19957962

Swift SVN r25620
2015-02-27 22:07:40 +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
Arnold Schwaighofer
71922a4daa COWArrayOpt: Handle cases where the array is not uniquely identified
We can still hoist in many cases if all operations in the loop are 'safe' wrt.
hoisting.

'Safe' array operations are

  * all array semantic functions (as long as one array type cannot contain
    another).
  * stores to array elements
  * any instruction that does not have side effects.
  * any retain must be matched by a release before we hit a make_unique.

rdar://19668784

Swift SVN r24960
2015-02-04 16:39:14 +00:00
Arnold Schwaighofer
0f4f6833c1 COWArrayOpt: Update for array addressor changes
A mark_dependence use of the buffer is safe.

Swift SVN r24445
2015-01-15 15:33:44 +00:00
Mark Lacey
4a74e94b40 Fix release build warnings about unused variables.
Swift SVN r23893
2014-12-12 20:05:30 +00:00
Arnold Schwaighofer
2f949056d6 SIL utils: Rename array.props.isCocoa to array.props.isNative
The upcoming stdlib patch will also be modified.

NFC

rdar://17955309

Swift SVN r23813
2014-12-09 21:58:16 +00:00
Arnold Schwaighofer
83cf4f3405 Add a pass to specialize array code based on array semantic array.props calls
We know that a native swift array that does not need an element type check is
not going to change to an nsarray, or to an array that needs an element type
check. This allows us to specialize array code.

The array semantic calls 'array.props.isCocoa/needsElementTypeCheck' returns
said array properties for a read.

  func f(a : A[AClass]) {
     for i in 0..a.count {
       let b = a.props.isCocoa()
        .. += _getElement(a, i, b)
     }
  }

   ==>

  func f(a : A[AClass]) {
    let b2 = a.props.isCocoa()
    if (!b2) {
      for i in 0..a.count {
         .. += _getElement(a, i, false)
      }
    } else {
      for i in 0..a.count {
        let b = a.props.isCocoa
        .. += _getElement(a, i, b)
      }
    }
  }

The stdlib will be changed to use array.props calls in a future commit.

rdar://17955309

Swift SVN r23689
2014-12-04 19:24:40 +00:00
Ben Langmuir
e9e1666ab0 Update for upstream LLVM changes
* removal of StringMap's GetOrCreateValue
* SmallSet::insert now returns a pair like std::set

Swift SVN r23435
2014-11-19 16:49:30 +00:00
Arnold Schwaighofer
bb47ce9e00 COWArrayOpts: strong_release on the array is also harmless
Needed for the upcoming array implementation change.

rdar://18777237

Swift SVN r23075
2014-11-03 02:18:35 +00:00
Arnold Schwaighofer
e6c44a377b COWArrayOpt: We could (and are now) also use a strong retain on the array storage
Swift SVN r22998
2014-10-29 01:56:14 +00:00
Andrew Trick
2ca16462b2 NFC: Update COW Array pass name string
Swift SVN r21964
2014-09-16 01:56:41 +00:00
Arnold Schwaighofer
12b0e13459 COWArrayOpt: Use ArraySemanticsCall utility
NFC

Swift SVN r21929
2014-09-12 21:05:23 +00:00
Arnold Schwaighofer
6da1647e1f COWArrayOpt: Use ValueBase's getParentBB api
Swift SVN r21927
2014-09-12 21:05:22 +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
Andrew Trick
bba2a37070 More COWArrayOpts cleanup.
Arnold noticed during review that ArrayUserSet was not properly
updated after previous rounds of cleanup.

This also removes some innefficiency by eliminating a few hash maps.

I want to make sure this is in good shape before reusing the analysis
for immutable array properties.

Swift SVN r21608
2014-08-30 09:20:07 +00:00
Andrew Trick
ed4d8e6b71 Cleanup COWArrayOpts.
Rewrite comments and refactor.

The refactored code now handles the latest SILCombine.

Swift SVN r21547
2014-08-28 22:42:15 +00:00
Andrew Trick
da5a4411bf Rename ArrayOpts to COWArrayOpts.
It looks like we'll have a separate pass for different types of array
opts. There isn't much overlap between COW and ABC opts.

Swift SVN r21258
2014-08-18 18:44:01 +00:00