Commit Graph

48 Commits

Author SHA1 Message Date
Nadav Rotem
680c565af5 Refactor the code that checks if a function is marked with noopt semantics. NFC.
Swift SVN r27485
2015-04-20 17:27:31 +00:00
Nadav Rotem
926042ff81 Add @semantics("optimize.never") to disable optimizations of a specific function.
This commit adds a flag to disable optimizations on a specific functions. The
primary motivation of this patch is to allow the optimizer developers to reduce
testcasese by disabling optimizations of parts of the code without having to
recompile the compiler or inspect SIL. The annotations  "inline(never)"
and "optimize.none" can go a long way.

The second motivation for this patch is to allow our internal adopters to work
around compiler bugs.

rar://19745484

Usage:

@semantics("optimize.never")
public func miscompile() { ... }

Swift SVN r27475
2015-04-20 05:06:55 +00:00
Erik Eckstein
ab2dd51bb0 SIL passmanager: Add an option -sil-disable-pass for disabling passes by name.
Example: swiftc -O -Xllvm -sil-disable-pass="Performance Inliner" test.swift
All passes are disabled which contain the option argument string in their name.

This is useful for testing and debugging.



Swift SVN r27204
2015-04-10 09:39:30 +00:00
Chris Lattner
a7a54734c8 revert rr26760: SILPassManager: Further reduce the number of pass runs
this unbreaks the stdlib build with assertions enabled.


Swift SVN r26763
2015-03-31 16:47:15 +00:00
Erik Eckstein
1110dc6cd4 SILPassManager: Further reduce the number of pass runs.
Avoid running a pass a second time if the pass has its own optimize-until-no-more-changes loop.
This pass property can be configured.
Currently I assume that all our function passes don't need to run a second time (without other changes in between).

It further reduces the number of pass runs by about 6%. But this improvement is cosmetic. There is no significant compile time reduction.

There are no performance changes.



Swift SVN r26760
2015-03-31 15:54:42 +00:00
Erik Eckstein
160b8e07db SILPassManager: A new method to reduce the number of SIL pass runs.
It avoids that a pass runs a second time if didn't make any changes in the previous run and no other pass changed the function in between.
rdar://problem/20336764

In this change I also removed the CompleteFunctions analysis which is now obsolete.

Some measurements with swiftbench (-wmo, single threaded):
It reduces the number of pass runs by about 28%. Because only passes are skipped that don't do anything, the effect on compile time is not so dramatic.
The time spent in runSILOptimizationPasses is reduced by ~9% which gives a total compile time reduction of about 3%.




Swift SVN r26757
2015-03-31 14:19:51 +00:00
Erik Eckstein
f520ef894a Add the PassKind as a property in SILTransform.
To set the PassKind automatically, I needed to refactor some code of the pass manager and the pass definitions.
The main changes are:
1) SILPassManager now has an add-function for each pass: PM.add(createP()) -> PM.addP()
2) I removed the ARGS argument in Passes.def, which we didn't use anyway.



Swift SVN r26756
2015-03-31 14:08:19 +00:00
Nadav Rotem
5ad8aeef25 [PM] Teach the pass manager about locked analysis that should not be invalidated.
Swift SVN r26375
2015-03-20 22:53:08 +00:00
Michael Gottesman
b2d9833259 Add PrettyStackTrace support for SILFunctionTransforms and SILModuleTransforms.
In the case of a crash in the optimizer or verifier, this prints out information
about the source of the crash. This saves engineering time by allowing one to
get some quick information about the crash without needing to jump into the
buffer.

In the case of a SILFunctionTransform, this prints out the name of the function
being optimized and the name of the transform.

In the case of a SILModuleTransform, this prints out the name of the transform.

<rdar://problem/19946491>

Swift SVN r25831
2015-03-07 03:08:28 +00:00
Nadav Rotem
663482ea93 Split the debugging feature to set the pass name inside the PassManager resetAndRemoveTransformations into a new function.
Swift SVN r25562
2015-02-26 21:01:46 +00:00
Michael Gottesman
6942a0944b Put verification of analyses behind a flag in preparation for committing call graph verification code.
This is b/c the callgraph verifier currently trips (I believe) due to passes
eliminating ApplyInsts without invalidating the CallGraph.

Swift SVN r25517
2015-02-24 22:53:38 +00:00
Michael Gottesman
4a34f25c6b Add support for verifying analyses when -sil-verify-all is passed in.
Currently no passes implement this, but I am going to add support to the
callgraph. I just ran into a callgraph bug that this would have helped
to catch.

rdar://19930214

Swift SVN r25514
2015-02-24 22:49:46 +00:00
Roman Levenstein
492d8c365c Fix a bug in the debug printing logic.
Inverse the condition. Bail if the function name does not match, continue if the name matches. NFC.

Swift SVN r25064
2015-02-07 03:13:32 +00:00
Michael Gottesman
d644a6f765 Add support for passing multiple substrings to -sil-print-before, -sil-print-after, and -sil-print-around.
Swift SVN r24965
2015-02-04 18:21:53 +00:00
Roman Levenstein
7a1faed66f Add a new helper option -sil-print-only-functions useful for controlling SIL output.
-sil-print-only-functions takes a string as its argument and only prints out SIL for the functions whose name contains this string as a substring. This is useful e.g. if you want to emit SIL only for certain functions and see how their SIL changes after each pass.

Swift SVN r24914
2015-02-03 01:58:13 +00:00
Michael Gottesman
480bdd6caf Move the NumOptPassesToRun check *after* doPrintAfter so even if we exit early after a specific pass is run, we will dump and verify the pass if it changed.
Swift SVN r24080
2014-12-22 22:01:53 +00:00
Andrew Trick
6cc72ee21b Print SIL optimization stages. SIL debugging.
Swift SVN r23902
2014-12-12 23:57:03 +00:00
Andrew Trick
bdc11c1ba8 Fix -sil-print-before/after/around to work with -sil-print-only-function.
Swift SVN r23899
2014-12-12 23:57:01 +00:00
Erik Eckstein
72f0cc2ab4 Add more options to dump the SIL during optimizations.
-sil-print-before=<string>     Print out the sil before passes which contain this string in their names
-sil-print-after=<string>      Print out the sil after passes which contain this string in their names
-sil-print-around=<string>     Print out the sil before and after passes which contain this string in their names

Output can further be restricted to a single function with the existing option
-sil-print-only-function=<function>




Swift SVN r23737
2014-12-05 16:52:23 +00:00
Michael Gottesman
123b8e6f61 Access SILOptions in SILPassManager via the SILModule now that we store the SILOptions in the SILPassManager.
Swift SVN r23651
2014-12-03 20:39:05 +00:00
Andrew Trick
bfa7525765 Fix -sil-print-only-function to print SIL before transforming it.
Swift SVN r22517
2014-10-04 01:23:11 +00:00
Mark Lacey
e76a6c7333 Add -sil-print-pass-name option.
Prints the pass number and name along with the function being
processed. This can be handy when bisecting by pass number.

Swift SVN r21219
2014-08-14 22:38:30 +00:00
Arnold Schwaighofer
e3b33d7bca PassManager: Add flag to only print one SIL function
Swift SVN r21122
2014-08-09 00:05:29 +00:00
Michael Gottesman
e9a7f91667 Revert "Add the frontend option -disable-sil-perf-optzns."
Revert "For debugging purposes allow passes to stop any more passes from running by calling PassManager::stopRunning()."

This reverts commit r20604.
This reverts commit r20606.

This was some debugging code that snuck in.

Swift SVN r20615
2014-07-28 06:21:30 +00:00
Michael Gottesman
6f1262538e Change pass manager pass limit to consider each invocation of a function pass on a function as a "pass being run". This eases bisecting on SILOptions::NumOptPassesToRun.
Swift SVN r20607
2014-07-27 18:37:12 +00:00
Michael Gottesman
7136c53208 For debugging purposes allow passes to stop any more passes from running by calling PassManager::stopRunning().
The intended use case is the user puts in a counter and wants the pass manager
to ensure that no further passes run.

Swift SVN r20606
2014-07-27 18:37:12 +00:00
Arnold Schwaighofer
12cb97d284 PassManager: Reset state and remove all currently owned transformations
In the current setup analysis information is not reused by new pass managers.
There is no point in having different pass managers. Instead, we can just remove
transformations, reset the internal state of the pass manager, and add new
transformation passes. Analysis information can be reused.

Reuse one pass manager in the pass pipeline so that we don't have to
unnecessarily recompute analysis information.

Swift SVN r19917
2014-07-14 03:42:39 +00:00
Manman Ren
44ea9dae04 Use the same variable in debugging message of SILFunctionPass and SILModulePass.
Swift SVN r18801
2014-06-11 00:55:31 +00:00
Michael Gottesman
70274f31bc [sil-pass-manger] Do not use an LLVM statistic as the counter when deciding that we have iterated too many times. They are compiled out with a release compiler.
Swift SVN r18576
2014-05-22 23:16:05 +00:00
Manman Ren
1f280bba73 [SILPasses] limit number of iterations to 20.
This prevents us going in an infinite optimization loop. According to Michael,
we need at least 15 for performance.

The fix at r17635 does not handle the case where the recursive function calls
itself only once.

rdar://16761933


Swift SVN r17686
2014-05-08 05:40:58 +00:00
Michael Gottesman
ae248df628 Some verify statements were wrapped in DEBUG() in PassManager.cpp that did not need to be. The reason why is the SILModule::verify is #ifndef NDEBUG out in no-assert builds. Thus the only thing these DEBUG() wrappers do is cause the user to need to pass in -Xllvm -debug-only=sil-passmanager to trigger the verifier. This also causes confusion for people not familiar with this property since they pass in -sil-verify-all and don't hit assertions in the verifier giving the mistaken impression that their code is verified when it is not.
Swift SVN r16263
2014-04-12 19:22:37 +00:00
Michael Gottesman
ea1f77f638 When running with -sil-verify-all only verify the function processed by a function pass after every iteration instead of the whole module.
Verifying the module after every function transform is run on every function
takes so much compile time that the mode is not really useful. I don't imagine
we are really getting anything for verifying the whole module so it makes sense
to limit what we are verifying.

Swift SVN r14834
2014-03-09 05:05:39 +00:00
Nadav Rotem
443f284a5e 80 col
Swift SVN r14348
2014-02-25 18:51:31 +00:00
Joe Groff
c0a0a8b584 Add a -sil-opt-pass-count frontend flag.
Until our SIL printing and parsing is robust enough to round-trip, this is useful for bisecting optimizer issues.

Swift SVN r14061
2014-02-18 23:37:25 +00:00
Michael Gottesman
190de1cc6a Add support for option -time-transforms which causes the pass manager to emit time information for each transform run.
Swift SVN r14042
2014-02-18 15:50:17 +00:00
Andrew Trick
90bdf1f841 Run a sequence of SILFunctionTransforms on the same function.
It is much easier to follow the progreses of optimizations. And should
be more efficient.

Swift SVN r13678
2014-02-08 08:20:46 +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
4da216c7c7 Add a PassManager analysis that tracks changed/complete functions.
Don't print/verify unless something has changed.
Don't rerun function passes on functions that have not changed.

Swift SVN r13675
2014-02-08 08:20:44 +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
Andrew Trick
47b936fbae Let passes get their options (current configuration) from the
PassManager.

I think this is much cleaner and more flexible. The various pass
builders have no business marshalling these things around, and they
shouldn't be bound to the pass C'tor. In the future we will be able
override and dynamically modify pass configuration this way.

Swift SVN r13626
2014-02-07 05:01:00 +00:00
Nadav Rotem
dec5d764f4 Bring back the verify-after-all feature.
Swift SVN r13605
2014-02-06 23:27: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
591a42aae3 Rename a few more pass factory methods.
Swift SVN r13588
2014-02-06 17:52:18 +00:00
Nadav Rotem
abed15c3c3 Add the runOneIteration method to the Pass Manager.
Swift SVN r13580
2014-02-06 17:13:13 +00:00
Nadav Rotem
99b075c32a Rename SILFunctionTrans -> SILFunctionTransform
Swift SVN r13536
2014-02-06 01:32:10 +00:00
Nadav Rotem
7a50a4c79d Pass the Module in the pass manager constructor.
Swift SVN r13497
2014-02-05 20:00:18 +00:00
Nadav Rotem
a3bf2fe096 Small cleanups and comments. NFC.
Swift SVN r13496
2014-02-05 19:49:43 +00:00
Nadav Rotem
587545b87c PM implementation
Swift SVN r13493
2014-02-05 18:57:36 +00:00