Commit Graph

70 Commits

Author SHA1 Message Date
Mark Lacey
dda599f11e Refactor to separate collection of promotable boxes from promoting them.
Swift SVN r15619
2014-03-29 17:05:18 +00:00
Mark Lacey
8e698b993a Factor out common code for getting a parameter.
Given an operand to an apply/partial_apply, we want to get the BB
argument in the body of the called function that represents the operand.

Swift SVN r15609
2014-03-29 05:53:53 +00:00
Mark Lacey
a18b979da0 Fix another logic inversion bug.
Swift SVN r15608
2014-03-29 05:53:52 +00:00
Mark Lacey
5cc6a44994 Correct inverted logic.
Swift SVN r15607
2014-03-29 05:53:51 +00:00
Mark Lacey
66d779966b Move escape helper functions back to AllocBoxToStack.cpp.
These are only being used by that transform at this time, so it makes
sense to have them together.

Swift SVN r15606
2014-03-29 05:53:51 +00:00
Mark Lacey
22ed644333 More groundwork for further improvements to box-to-stack promotion.
Drill down into partial_apply to examine how the container pointer is
used within the partial_apply. If the uses are not unexpected, and do
not allow the container pointer to escape the partial_apply, then we'll
check how the partial_apply is used when passed into an apply by
drilling down one level into that apply (but no further). If the
partial_apply itself cannot escape the current function or any funtion
it is passed to, then we should be able to clone the partial_apply body
and rewrite it to remove the box container pointer (coming in a future
commit).

This is all effectively disabled now by passing false to the call to
canValueEscape in findUnexpectedBoxUse which disables drilling down into
the apply.

Swift SVN r15591
2014-03-28 23:42:54 +00:00
Mark Lacey
0bb09627ab Move the validation of uses of the box pointer into a separate function.
Eventually we'll scan one level deep into the body of a partial_apply to
validate uses there, and use the same logic.

Swift SVN r15553
2014-03-27 05:24:52 +00:00
Mark Lacey
c07f3284c2 Separate analysis from rewriting in box-to-stack promotion.
This is in preparation for handling more complex cases than we handle at
the moment.

Swift SVN r15525
2014-03-26 21:23:05 +00:00
Mark Lacey
ff128d64c5 Assert that a mark_uninitialized use is the only use of an alloc_stack address.
This is after we've just replaced uses of the alloc_box address.

Swift SVN r15520
2014-03-26 20:55:55 +00:00
Mark Lacey
f02cdba27b Minor cleanup - add accessors for a box's container result and address result.
Swift SVN r15519
2014-03-26 20:33:23 +00:00
Chris Lattner
011f2f055a fix <rdar://problem/16382973> DI misses destroy_addr because allocbox_to_stack isn't preserving mark_uninitialized invariants
This is a nasty bug where early returns (return/continue/etc) out of a variables scope could cause miscompiles.


Swift SVN r15410
2014-03-24 15:31:31 +00:00
Mark Lacey
b6442dde4e Remove unused code in box-to-stack promotion.
r15322 reworked the logic for determining where the final releases are,
which means that we no longer need to collect the uses and releases as
we evaluate candidates for promotion.

Swift SVN r15333
2014-03-21 20:26:43 +00:00
Mark Lacey
088e0ee6f1 Handle multiple releases in allocbox-to-stack.
Promote alloc_box to alloc_stack in the case where we have multiple
releases along different paths (including paths that follow a back-edge
to the alloc_box itself).

The new approach effectively uses liveness (computed on a per-alloc_box
basis) to determine where the final release on any path will
be. Building the stdlib takes the same amount of time as it did before
this change.

Deletes 56 of the 116 remaining alloc_box in the stdlib, and speeds up
the string walk benchmark by ~8%.

Swift SVN r15322
2014-03-21 02:20:46 +00:00
Mark Lacey
c2e217d8b4 Minor clean-up in getting lowered type.
Swift SVN r15231
2014-03-19 08:59:45 +00:00
Nadav Rotem
5752bff1a5 Refactor the code that checks if a box is captured and move it to Local.{h,cpp}. NFC.
Swift SVN r14924
2014-03-11 18:24:58 +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
Mark Lacey
daf717a93b Update documentation for checkAllocBoxUses. NFC.
Swift SVN r14044
2014-02-18 16:59:06 +00:00
Mark Lacey
9dbb7c1a16 Remove duplicate code for handling mark_uninitialized.
checkAllocBoxUses had two places where mark_uninitialized was being
processed, the second one unreachable.

The code removed by this commit was the code added later, and it makes
the assumption that the mark_uninitialized is the only use of the value
being processed. Although that assumption might be reasonable and
currently true, it's not verified.

Swift SVN r14043
2014-02-18 16:59:04 +00:00
Doug Gregor
2134072285 Split open_existential[_ref] out as their own instructions.
Riding off of project_existential[_ref] was convenient, but the
resuls are used quite differently. Note that open_existential[_ref]
still don't print/parse reasonably yet.



Swift SVN r13878
2014-02-13 23:42:23 +00:00
Andrew Trick
0825258b80 SIL transforms should only invalidate when things change.
-sil-print-all shows a nice readable evolution now.

Oh yeah, and we don't unnecessarilly rerun passes.

Swift SVN r13677
2014-02-08 08:20:45 +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
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
7cfb83449e Rename the pass to AllocBoxToStack
Swift SVN r13586
2014-02-06 17:43:54 +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
Nadav Rotem
0651b9bbd0 Add a new Dominance Analysis that wraps DomInfo and PDomInfo, and migrate the
passes that use them.



Swift SVN r13571
2014-02-06 07:52:16 +00:00
Chris Lattner
827acad533 Various inout improvements:
- purge @inout from comments in the compiler except for places talking about
   the SIL argument convention.
 - change diagnostics to not refer to @inout
 - Change the astprinter to print InoutType without the @, so it doesn't show
   up in diagnostics or in closure argument types in code completion.
 - Implement type parsing support for the new inout syntax (before we just 
   handled patterns).
 - Switch the last couple of uses in the stdlib (in types) to inout.
 - Various testcase updates (more to come).



Swift SVN r13564
2014-02-06 06:22:27 +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
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
Joe Groff
7bb68490a1 Text files end with newlines.
Swift SVN r13500
2014-02-05 20:23:32 +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
Joe Groff
71379f5bad SILGen: Explicitly mark uninitialized locals with mark_uninitialized, and have DI only consider mark_uninitialized storage.
Have SILGen mark all variables bound from pattern bindings without initializers (and *only* ones without initializers) with mark_uninitialized [var] pseudo instructions. On the DI end, *only* consider mark_uninitialized instructions for DI analysis. This has many benefits:

- DI doesn't waste time analyzing locals that are trivially initialized in the original source code.
- DI doesn't try to mangle canonical SIL that has been inlined from transparent functions, which may have been optimized into a form DI isn't written to understand.

While we're here, fix an issue with DCE where it would try to kill unused MarkUninitialized instructions. Although MarkUninitialized has no side effects, it still is semantically important to raw SIL, and can't be killed.

Chris did most of the work here; I just finished updating tests and fixing bugs.

Swift SVN r13247
2014-01-31 22:50:21 +00:00
Nadav Rotem
eef626efc9 Fix doc typos. Thanks Mark!
Swift SVN r13164
2014-01-30 19:47:41 +00:00
Nadav Rotem
862bc545bf add a comment
Swift SVN r13158
2014-01-30 18:39:50 +00:00
Nadav Rotem
a1da309fa5 Rename the function that checks for cycles in SESE regions and document it.
Swift SVN r13157
2014-01-30 18:37:51 +00:00
Nadav Rotem
2c9857b0c2 Refactor the capture check code and add support for ptr2addr and addr2ptr casts.
This gives a 10% boost on StringWalk and 5% on StringSort.



Swift SVN r13143
2014-01-30 07:45:28 +00:00
Michael Gottesman
ff68b1341e [allocbox-to-stack] Improve comments. NFC.
Swift SVN r12819
2014-01-22 23:59:02 +00:00
Michael Gottesman
38c5989cfe [allocbox-to-stack] In checkForEntryCycles, perform the necessary changes so we can just add the initial AllocBoxBB to the worklist and eliminate the initial loop that added the AllocBoxBB's successors to the worklist.
Swift SVN r12670
2014-01-21 23:35:14 +00:00
Michael Gottesman
0aaf736011 [allocbox-to-stack] Make sure that if we have a cycle into the allocbox BB, do not optimize.
This pass is attempting to do a simple optimization where it determines if we
have an allocbox that has a most post dominating retain together which it
forms a single entry/single exit region.

It does this by checking domination/post-domination, but it does not check
control equivalence. This patch puts in a check to make sure that if we have a
cycle into the entry BB, we do not optimize.

rdar://15832873.

Swift SVN r12662
2014-01-21 22:00:15 +00:00
Nadav Rotem
a07aed9d1f Change errs() -> dbgs() in a few files.
Swift SVN r12572
2014-01-20 06:36:50 +00:00
Joe Groff
b2f0b90ba2 SIL: Switch to SILFunctionType interface types in easy-to-reach places.
In nongeneric contexts, or contexts where we only care about the indirectness of parameters or have already substituted the generic parameters for a function, the interface types are interchangeable, so just switch over.

Swift SVN r12044
2014-01-08 04:48:29 +00:00
Chris Lattner
ca9912f74b rework validation of the use list of a box in the allocboxtostack pass
to avoid confusing uses of the box with uses of the allocation in partial
apply instructions.  This resolves rdar://15595118.

Unfortunately, the testcase cannot be reduced into something that the
silparser handles, since it goes away when non-generic.


Swift SVN r11408
2013-12-18 02:04:06 +00:00
Joe Groff
02a0e996c4 SIL: Kill initialize_var instruction.
Remove the initialize_var instruction now that DI fully diagnoses initialization problems. Change String-to-NSString bridging to explicitly invoke String's default constructor; it was the last remaining user of initialize_var. Remove dead code to emit an implicit default constructor without a body.

Swift SVN r11066
2013-12-10 03:36:59 +00:00
Chris Lattner
aed29b4e92 When r10841 turned on DI for struct init methods, it started SILGen generating
new mark_unitialized instructions.  These defeated the alloc_box to stack promotion
pass, so everything ended up on the heap, leading to really terrible performance.
This updates things to understand mark_uninitialized, allowing us to promote them.

This fixes rdar://15607469.


Swift SVN r10985
2013-12-07 23:38:09 +00:00
Michael Gottesman
4379283013 Remove inclusion of SILPasses/Passes.h into Subsystems.h and update all relevant files.
Swift SVN r10880
2013-12-05 19:58:21 +00:00
John McCall
20e58dcf93 Change the type of function values in SIL to SILFunctionType.
Perform major abstraction remappings in SILGen.  Introduce
thunking functions as necessary to map between abstraction
patterns.

Swift SVN r10562
2013-11-19 22:55:09 +00:00
Anna Zaks
e5eb77ea6e [SIL] Mark these locations as cleanup.
The empty tuple used for return value when none is supplied does not really correspond to user code. (We don’t have epilog, so mark it as pert of cleanup.)
The destroy_addr instructions are doing the cleanup.

Swift SVN r9765
2013-10-29 22:27:25 +00:00
Chris Lattner
968e89a3be improve the DEBUG output of inout-deshadow and allocbox-to-stack.
clean up a couple random things in silcombiner:
  - it shouldn't return "made any changes" out of the pass.
  - statistics should be spelled out more and don't end with periods.



Swift SVN r9755
2013-10-29 04:02:32 +00:00
Chris Lattner
c31e5c755c teach allocbox-to-stack about assign instructions, enabling it to
promote a lot more boxes.  This is the last step to resolve
rdar://15228172 getting us back O(n) string performance.  There is
still more work to do, but this is progress.


Swift SVN r9751
2013-10-29 03:06:25 +00:00