Commit Graph

24 Commits

Author SHA1 Message Date
Mark Lacey
5394f41a3b Add a check to avoid infinite looping in the pass manager.
It's possible to construct programs where the optimization pass manager
will just continually execute, never making progress.

Add a check to the pass manager that only allows us to optimize a
limited number of functions with the function passes before moving on.

Unfortunately even the tiny test case that I have for this takes minutes
before we bail out with the limit I've set (which is not *that* much
bigger than the maximum that I saw in our build). I don't think it would
be prudent to add that test to the test suite, and I haven't managed to
come up with something that finishes in a more reasonable amount of time.

rdar://problem/21260480
2016-03-03 06:47:36 -08:00
Dmitri Gribenko
a9f8d97d3e Replace 'unsigned int' with 'unsigned'
'unsigned' is more idiomatic in LLVM style.
2016-02-27 16:20:27 -08:00
Mark Lacey
945065f37d Change where in the pass manager we validate that analyses are unlocked.
Verify just prior to running passes, and after running each pass, that
no analyses are locked from being invalidated.
2016-02-19 13:32:40 -08:00
Mark Lacey
378e94b901 Formatting changes on recently added lines. 2016-02-01 21:50:01 -08:00
Mark Lacey
beb0f7dc2f Update pass manager execution strategy for function passes.
Allow function passes to:

1. Add new functions, to be optimized before continuing with the current
   function.
2. Restart the pipeline on the current function after the current pass
   completes.

This makes it possible to fully optimize callees that are the result of
specialization prior to generating interprocedural information or making
inlining choices about these callees.

It also allows us to solve a phase-ordering issue we have with generic
specialization, devirtualization, and inlining, by rescheduling the
current function after changes happen in one of these passes as opposed
to running all of these as part of the inlining pass as happens today.

Currently this is NFC since we have no passes that use this
functionality.
2016-02-01 16:47:26 -08:00
Mark Lacey
5948ac38a6 Fix coding style: capitalize member variable 2016-01-18 22:38:29 -08:00
Michael Gottesman
385c4a54dc [passmanager] When visiting functions in runFunctionPasses, make sure to check continueTransforming.
While debugging some code I noticed that we were not checking
continueTransforming everywhere that we needed to. This commit adds the missing
check.
2016-01-07 19:22:47 -08:00
practicalswift
1339b5403b Consistent use of header comment format.
Correct format:
//===--- Name of file - Description ----------------------------*- Lang -*-===//
2016-01-04 13:26:31 +01:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
practicalswift
22e10737e2 Fix typos 2015-12-26 01:19:40 +01:00
Mark Lacey
faba6e56b7 Add a stand-alone generic specializer pass.
Begin unbundling devirtualization, specialization, and inlining by
recreating the stand-alone generic specializer pass.

I've added a use of the pass to the pipeline, but this is almost
certainly not going to be the final location of where it runs. It's
primarily there to ensure this code gets exercised.

Since this is running prior to inlining, it changes the order that some
functions are specialized in, which means differences in the order of
output of one of the tests (one which similarly changed when
devirtualization, specialization, and inlining were bundled together).
2015-12-18 14:08:56 -08:00
Mark Lacey
dbde7cc4c1 Update the pass manager to allow for function creation in function passes.
Add interfaces and update the pass execution logic to allow function
passes to create new functions, or ask for functions to be optimized
prior to continuing.

Doing so results in the pass pipeline halting execution on the current
function, and continuing with newly added functions, returning to the
previous function after the newly added functions are fully optimized.
2015-12-18 14:08:56 -08:00
Mark Lacey
90b45c4dd7 Extract method to run all function passes over a given function.
More small refactoring in the pass manager.
2015-12-17 14:57:30 -08:00
Mark Lacey
d770376981 Replace tabs with spaces.
Also run clang-format over the changed area.
2015-12-17 12:25:03 -08:00
Mark Lacey
fbb7abc7c6 Fix 80-column violations. 2015-12-17 12:25:03 -08:00
Mark Lacey
bed0da6472 Typo: consequtive -> consecutive 2015-12-16 22:43:54 -08:00
Mark Lacey
3ed75f4fb0 Move the pass manager's function worklist into PassManager.
Make it a std::vector that reserves enough space based on the number of
functions in the initial bottom-up ordering.

This is the first step in making it possible for function passes to
notify the pass manager of new functions to process.
2015-12-16 21:30:33 -08:00
Mark Lacey
226a825807 Simplify the pass manager execution logic.
Make it a bit more clear that we're alternating between collecting (and
then running) function passes, and running module passes. Removes some
duplication that was present.

Reapplies 9d4d3c8 with fixes for bisecting pass execution.
2015-12-15 15:17:53 -08:00
Mark Lacey
59544560d1 Revert "Simplify the pass manager execution logic."
This reverts commit 9d4d3c8055.

I forgot to finish up changes required to make -Xllvm
-sil-opt-pass-count continue working the way it did, so I'll back that
out until I have those changes as well.
2015-12-15 13:23:59 -08:00
Mark Lacey
9d4d3c8055 Simplify the pass manager execution logic.
Make it a bit more clear that we're alternating between collecting (and
then running) function passes, and running module passes. Removes some
duplication that was present.
2015-12-15 13:08:08 -08:00
Mark Lacey
a8fbc4722f Minor pass manager refactoring.
Extract the code related to running a module pass into a separate
function.
2015-12-15 10:25:38 -08:00
Mark Lacey
6c4bc75d3f Use a work list when running function passes.
Rather than iterating over an array of functions, build a work list and
pop functions off of it.

This is a small step towards allowing function passes to create new
functions to be processed.
2015-12-13 20:42:07 -08:00
practicalswift
39f3e49e27 Fix typo: analyis → analysis 2015-12-13 23:56:40 +01:00
Andrew Trick
739b0e9c56 Reorganize SILOptimizer directories for better discoverability.
(libraries now)

It has been generally agreed that we need to do this reorg, and now
seems like the perfect time. Some major pass reorganization is in the
works.

This does not have to be the final word on the matter. The consensus
among those working on the code is that it's much better than what we
had and a better starting point for future bike shedding.

Note that the previous organization was designed to allow separate
analysis and optimization libraries. It turns out this is an
artificial distinction and not an important goal.
2015-12-11 15:14:23 -08:00