Commit Graph

23 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
8cca130409 LoopRotate: Cleanup blocks after rotation
Swift SVN r25615
2015-02-27 22:07:36 +00:00
Andrew Trick
7adbae859d Comment UpdateSSA after reviewing.
Swift SVN r25397
2015-02-19 19:26:46 +00:00
Arnold Schwaighofer
b6896c8de9 LoopRotate: updateSSAForUseOfInst needs to properly map arguments
For basic block arguments we need to use the value index of the incoming value.

rdar://19881898

Swift SVN r25393
2015-02-19 16:25:10 +00:00
Andrew Trick
7c155bfcff Add LoopRotate insertBackedgeBlock.
Run a loopSimplify helper before loopRotate to put the loop in
canonical form. This now handles the case of multiple-backedges, which
is very common for unsimplified loops.

TODO: We still don't split nested loops that have a shared
header. LLVM has logic for this, we should probably do the same.

Swift SVN r24008
2014-12-18 20:10:24 +00:00
Michael Gottesman
93b92a8f9f Add in Passes.def for metaprogramming with SILPassKinds.
This simplifies some code in SILOpt and SILPasses. The real reason to do it is
to use it to procedurally generate random pipelines.

Swift SVN r23996
2014-12-17 23:56:26 +00:00
Andrew Trick
60b39024fa LoopRotate: canonicalize Struct BB args after UpdateSSA.
Without this, IndvarAnalysis can spuriously fail.

Roughly:
%i0 = integer_literal
%s0 = struct %i0
br (%i0, %s0)

bb(%i1, %s1)

Becomes:
%i0 = integer_literal
br (%i0)

bb(%i1)
%s0 = struct %i1

Swift SVN r23606
2014-12-02 01:07:46 +00:00
Andrew Trick
e828c4f199 Delete dead code from SSA Updater.
Swift SVN r23605
2014-12-02 01:07:45 +00:00
Roman Levenstein
742a9bf717 Don't jumpthread blocks containing MethodInst instructions referring to objc methods, because we cannot build SSA for method values that lower to objc methods.
rdar://18940762

Swift SVN r23245
2014-11-11 20:25:43 +00:00
Roman Levenstein
3910c25da1 Minor re-factoring: Move the logic to decide if a given instruction can be (easily) duplicated into SILInstruction. So far it was mainly used by jump-threading related optimizations. But it could be generally useful, or at least generally important, to optimizations that want to duplicate code.
Swift SVN r23213
2014-11-10 23:15:07 +00:00
Arnold Schwaighofer
e7c67120b0 LoopRotate: A method instruction can have operands
We can only hoist it if its operands are invariant.

rdar://18890758

Swift SVN r23145
2014-11-07 00:43:28 +00:00
Joe Groff
ea65d1e60b SIL: Remove the builtin_function_ref instruction.
Swift SVN r22797
2014-10-16 16:18:40 +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
6145377ec5 LoopRotate: Fix volatile method instructions and open_existential cloning
Volatile method instructions are not invariant. open_existential instructions
can't be cloned using the SILInstruction clone() api follow up instructions need
to use the same cloner so that the opened existential archetype uid can be
shared.

Swift SVN r22754
2014-10-15 17:07:00 +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
e5e11b9ade LoopRotate: Don't rotate single BB loops
Swift SVN r21123
2014-08-09 00:05:29 +00:00
Arnold Schwaighofer
6f2b8fae49 LoopRotate: Add option to disable rotation
Swift SVN r20097
2014-07-17 16:12:44 +00:00
Arnold Schwaighofer
8eba52fe4d LoopRotate: Silence unused variable warning in release mode
Swift SVN r19920
2014-07-14 03:42:40 +00:00
Arnold Schwaighofer
33502446e3 LoopRotate: Update comment to reflect reality
Swift SVN r19919
2014-07-14 03:42:40 +00:00
Arnold Schwaighofer
c50e396103 Add APIs to update preserved analysis information for dominance and loop info
Use it in loop rotation.

The pattern to update analysis information is:

  // The AnalysisInfo was preserved for this function.
  if (Changed) {
    // Preserve the analyis for this function by decoupling it from the analysis
    // cache.
    auto PreservedAnalysis = Analysis.preserveAnalysis(Function);

    // Invalidate analysis for this function.
    PM.invalidateAnalysis(Function, InvalidationKind::CFG);

    // Update the preserved analysis for this function.
    Analysis.updateAnalysis(F, std::move(PreservedAnalysis));
  }

Swift SVN r19918
2014-07-14 03:42:39 +00:00
Arnold Schwaighofer
fe5c3a2db7 LoopRotate: Don't assert on certain loop forms
Since we don't have guaranteed preheader insertion (yet). We can have the
situation where the new header (after rotation) is also a header of a nested
loop.  In such a case we must bail.

Try harder to created preheader for nested loops though.

Swift SVN r19881
2014-07-12 16:49:02 +00:00
Arnold Schwaighofer
5ad13207e5 Add a loop rotation pass
This is to support loop invariant code motion and bound check
hoisting.

Disabled for now.

Swift SVN r19635
2014-07-07 21:05:23 +00:00