Commit Graph

41 Commits

Author SHA1 Message Date
Manman Ren
16aa8a0a05 [CodeMotion] handle retain_value as well.
Follow up to r19283.


Swift SVN r19298
2014-06-27 17:54:35 +00:00
Manman Ren
c749d8e4a0 [CodeMotion] sink retains down so we can pair up retains with releases.
This enables us to pair up retains with releases on the fast path with inline
cache. The run time of rdar://17327077 is down to 0.07s from 0.7s.

We should be able to simplify the code for sinking retains down switch_enum,
now we have the enum simplification.

Thanks Michael for the review.


Swift SVN r19283
2014-06-27 00:53:37 +00:00
Michael Gottesman
b127cf5c4c [codemotion] Teach SILCodeMotion how to use the ARC infrastructure to be more aggressive in sinking retain insts over switch_enums.
This commit reuses utility methods from the ARC optimizer to know if an
instruction can decrement the ref count of a retain_value's operand. If
we can conservatively ascertain that it can not, we can ignore the
instruction for the purposes of determining if we can move the
retain_value into the switch region.

<rdar://problem/17225910>

Swift SVN r18894
2014-06-14 05:42:33 +00:00
Michael Gottesman
72ea293ed8 [sil-code-motion] When sinking retain_value, release_value over switch_enum, allow for there to be a dealloc_stack intervening.
This is safe to do since the switch_enum can not be on the dealloc_stack.

Swift SVN r18709
2014-06-05 05:55:46 +00:00
Michael Gottesman
ba182e6679 [sil-code-motion] Teach SILCodeMotion how to push retain_value, release_value on enums over switch_enums onto the enum payloads.
rdar://17107213

Swift SVN r18696
2014-06-03 09:38:10 +00:00
Nadav Rotem
b62e2e2288 Sink identical block arguments from predecessors into the destination block.
Swift SVN r18684
2014-05-31 00:25:10 +00:00
Mark Lacey
cb9e8e88cf Remove include of unused header.
Swift SVN r16506
2014-04-18 07:19:29 +00:00
Mark Lacey
1452d24671 Small cleanup: Remove unnecessary calls to getDef(), mostly in dyn_cast<>(...).
Swift SVN r16235
2014-04-11 23:05:16 +00:00
Chris Lattner
001c1890e5 put all the SIL*Transform classes in anonymous namespaces, there is
no need for their symbols to be exported out of their implementation
file.


Swift SVN r14714
2014-03-06 01:49:53 +00:00
Michael Gottesman
8cff098f1e Split SILCodeMotion into two passes, LoadStoreOpts and SILCodeMotion.
LoadStoreOpts removes duplicate loads, forwards stores to loads, and eliminates
dead stores.

Swift SVN r13789
2014-02-11 23:36:51 +00:00
Michael Gottesman
3a1d46d145 [sil-code-motion] Refactor out the address projection path computation from findExtractPathBetweenValues to a new function findAddressProjectionPathBetweenValues and wire up the old method to use the results of the refactored method.
This is in preparation for using the refactored functionality in Alias
Analysis's address projection disambiguation code.

Swift SVN r13765
2014-02-11 00:09:15 +00:00
Michael Gottesman
5b3423308d Refactor out the class Projection class into its own header swift/SIL/Projection.h.
This class allows you to deal with tuple and nominal projections in a way that
is agnostic of either of them.

Expect some incoming utilities based off of this for dealing with what I call
'aggregate type trees'.

Swift SVN r13735
2014-02-10 05:07:36 +00:00
Michael Gottesman
655f0be796 [sil-code-motion] Change debug assert into a proper assert.
Swift SVN r13690
2014-02-09 01:41:41 +00:00
Andrew Trick
731000b4cd Added -sil-print-all and -sil-verify-all options.
Swift SVN r13662
2014-02-07 23:07:11 +00:00
Michael Gottesman
c9f7bba46d [sil-code-motion] Refactor out load invalidation into its own method so that we can use it both for stores and generic instructions that write to memory.
Swift SVN r13652
2014-02-07 21:38:43 +00:00
Michael Gottesman
1905d85aab [sil-code-motion] Teach SIL code motion how to forward a load of an aggregate type + struct_extracts for a load of a gep + load of field of aggregate type.
Swift SVN r13651
2014-02-07 21:38:43 +00:00
Michael Gottesman
fb512b48f4 [sil-code-motion] Teach SIL Code Motion that dealloc_stack does not disrupt reads/writes.
Swift SVN r13650
2014-02-07 21:38:41 +00:00
Nadav Rotem
27a1a63134 Remove unneeded empty virtual destructors.
Swift SVN r13599
2014-02-06 22:24:33 +00:00
Nadav Rotem
1ef0d157ca PassManager: Inject the function/module into the Transformation.
Now the pass does not need to know about the pass manager. We also don't have
runOnFunction or runOnModule anymore because the trnasformation knows
which module it is processing. The Pass itself knows how to invalidate the
analysis, based on the injected pass manager that is internal to the
transformation.

Now our DCE transformation looks like this:

class DCE : public SILModuleTransform {
  void run() {
    performSILDeadCodeElimination(getModule());
    invalidateAnalysis(SILAnalysis::InvalidationKind::All);
  }
};





Swift SVN r13598
2014-02-06 22:11:21 +00:00
Nadav Rotem
fda4a88be5 Teach the codemotion pass not to invalidate the analysis if no change was made.
Swift SVN r13590
2014-02-06 18:06:57 +00:00
Michael Gottesman
3b43e09bae Change getAnalysis<T> to be asserting and provide a new entry point getAnalysisOrNull<T>. Remove all of the unneeded asserts in the various passes.
Swift SVN r13576
2014-02-06 10:06:18 +00:00
Michael Gottesman
80f1451534 [sil-code-motion] Put in assert to make sure we always get a non-null alias analysis. The only way this can happen is if someone is careless and does not add the alias analysis to the pass manager.
Swift SVN r13551
2014-02-06 02:31:43 +00:00
Michael Gottesman
098fda670f [sil-aa] Change SIL AliasAnalysis into an Analysis.
Swift SVN r13550
2014-02-06 02:29:41 +00:00
Nadav Rotem
99b075c32a Rename SILFunctionTrans -> SILFunctionTransform
Swift SVN r13536
2014-02-06 01:32:10 +00:00
Nadav Rotem
f8c7b54d28 Delete the unused performXXX() functions.
Swift SVN r13531
2014-02-06 00:57:28 +00:00
Michael Gottesman
7461dbd70a Now that we have a PM, separate passes from analyses by creating a separate library swiftSILAnalysis and a separate folder/etc.
Swift SVN r13511
2014-02-05 22:17:50 +00:00
Michael Gottesman
631f9326ab [PM] Change enum => enum class everywhere in the PM code. Additionally fix some typos.
Swift SVN r13507
2014-02-05 21:25:15 +00:00
Nadav Rotem
baa1d1679a Teach some of the passes about the new PM.
Swift SVN r13494
2014-02-05 18:58:23 +00:00
Michael Gottesman
473927a1ed [sil-codemotion] Added debug statements to promoteMemoryOperationsInBlock().
Swift SVN r13460
2014-02-05 00:30:35 +00:00
Michael Gottesman
e066574abe [sil-codemotion] After seeing a store only invalidate loads that we can not prove it does not write to.
Swift SVN r13458
2014-02-05 00:27:00 +00:00
Michael Gottesman
f1e247e399 [sil-aa] Convert AliasAnalysis::alias(SILInstruction *, SILValue) -> AliasAnalysis::getMemoryBehavior(SILInstruction *, SILValue).
AliasAnalysis::getMemoryBehavior() returns a SILInstruction::MemoryBehavior
object that specifies the memory behavior of the SILInstruction with respect to
the SILValue. This name fits better the intention behind the aforementioned
poorly named alias instruction.

This is analogous to memdep in LLVM, except using the enum values from
SILInstruction::MemoryBehavior since we already have them.

Currently it always returns the most conservative answer, MayHaveSideEffects for
everything.

The patch also updates SILCodeMotion in light of these changes.

Swift SVN r13457
2014-02-05 00:26:59 +00:00
Michael Gottesman
1d1de86f37 [sil-code-motion] If we find an Inst that can not be proven to not alias a load, only invalidate that load instead of all of the loads.
Swift SVN r13382
2014-02-03 23:05:03 +00:00
Michael Gottesman
8789bd3b51 Small cleanup. NFC.
Swift SVN r13329
2014-02-03 02:34:01 +00:00
Michael Gottesman
bbdfb8bcad [sil-code-motion] Teach SILCodeMotion how to use the AliasAnalysis infrastructure.
Swift SVN r13328
2014-02-03 02:34:00 +00:00
Michael Gottesman
33a8cc36a2 [codemotion] CondFail does not cause us to read/write memory in a manner that we care about.
Swift SVN r13323
2014-02-03 00:11:14 +00:00
Michael Gottesman
ebf12a9b9c Recommit r13291 with proper tests, etc.
Swift SVN r13304
2014-02-01 21:00:07 +00:00
Michael Gottesman
934e0756db Revert "[sil-code-motion] Read none builtins can not cause reads or writes. Don't let them disrupt load/store forwarding."
This reverts commit r13291. Had a thinko here.

Swift SVN r13303
2014-02-01 19:20:41 +00:00
Michael Gottesman
3fa7c641b1 [sil-code-motion] Read none builtins can not cause reads or writes. Don't let them disrupt load/store forwarding.
Swift SVN r13291
2014-02-01 05:51:19 +00:00
Michael Gottesman
091cdb499e [sil-code-motion] Rename statistics so they dont have CSE in the name since CodeMotion is a separate pass now.
Swift SVN r13153
2014-01-30 17:53:03 +00:00
Nadav Rotem
312448756d whitespace.
Swift SVN r13151
2014-01-30 17:34:38 +00:00
Nadav Rotem
230842221e Move the code motion optimizations into a new pass. NFC.
Swift SVN r13150
2014-01-30 17:32:57 +00:00