Commit Graph

238 Commits

Author SHA1 Message Date
Slava Pestov
04c2d33718 sil-opt: Run SIL verifier after parsing 2016-02-05 20:57:11 -08:00
Slava Pestov
5a92446f8b sil-opt: Add -enable-resilience flag 2016-02-05 20:57:11 -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
Andrew Trick
84450b4c43 Reorganize SILOptimizer directories for better discoverability.
(Headers first)

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 12:34:51 -08:00
Mark Lacey
7fea483078 Avoid trying to close stdout twice in sil-opt.
Running sil-opt with the new call graph printing pass (which uses
llvm::outs) was resulting in some spew about "LLVM IO Error" because we
could potentially close stdout twice.

Swift SVN r32041
2015-09-17 18:26:59 +00:00
Erik Eckstein
f73e2e6ee9 Register SILAnalysis classes directly in the constructor of the PassManager.
This reduces some redundant code.



Swift SVN r31939
2015-09-14 21:56:15 +00:00
Roman Levenstein
4cef619c19 Revert "Verify SIL modules at the beginning and at the end of the SIL optimization pipelines, if -sil-verify-all is provided"
This reverts commit r31863, which was committed by mistake.

Swift SVN r31864
2015-09-10 22:32:36 +00:00
Roman Levenstein
141b8f814d Verify SIL modules at the beginning and at the end of the SIL optimization pipelines, if -sil-verify-all is provided
Till now, a SIL module would be only verified if an optimization has changed it. But if there were no changes, then no verification would happen and some SIL module format errors would stay unnoticed. This was happening in certain cases when reading a textual SIL module representation, which turned out to be broken, but SIL verifier wouldn't catch it.

Swift SVN r31863
2015-09-10 22:26:37 +00:00
Roman Levenstein
66e13af73e Add support for whole-module optimizations for SIL files.
To invoke the front-end on a SIL with whole-module optimizations enabled, execute:
swiftc -frontend myfile.sil

To invoke the front-end on a SIL without whole-module optimizations enabled, add a -primary-file option:
swiftc -frontend -primary-file myfile.sil

To invoke a sil-opt with whole-module optimizations enabled, use the -wmo option:
sil-opt myfile.sil -wmo

This change was need to be able to write SIL unit tests which should be compiled in the WMO mode.

Swift SVN r31862
2015-09-10 22:26:35 +00:00
Michael Gottesman
e864f02690 In all executables make sure to completely initialize LLVM.
I also added a macro called INITIALIZE_LLVM(argc, argv) which moves this logic
into one place and should be used at the beginning of *all* binaries. It
initializes an LLVM shutdown object, sets up the pretty stack trace, and then
initializes all of the parts of LLVM. This will make it easy to update this in
the future.

The reason why a macro was required was because of llvm_shutdown_obj, an RAII
object that cleans up LLVM. It has to be at the function level scope of the main
function.

Swift SVN r31815
2015-09-09 04:37:38 +00:00
Slava Pestov
5a16405330 Fix compile errors from r31420
Swift SVN r31424
2015-08-24 00:23:59 +00:00
Michael Gottesman
0276d86694 Add Analysis.def to allow for metaprogramming with Analysis names.
This allows one by editing one place to create an Analysis kind and ensure that
your analysis is properly registered in all of the relevant places for use with
swift/sil-opt.

If we add tools like a sil bugpoint, this will make it easy to add analysis
without having to know about all of these locations.

It also standardizes the create***Analysis API to take a SILModule and a
SILPassManager. All passes take in a SILModule and some take in a
SILPassManager. By standardizing the API and in the cases where SILPassManager
is not used, just making it a dead argument enables metaprogramming.

Swift SVN r31420
2015-08-23 19:31:27 +00:00
Roman Levenstein
66b5a4e072 [sil-opt] Properly set the SILOpt.Optimization flag
If we are not running diagnostics, then we are optimizing.

Swift SVN r30312
2015-07-17 06:52:09 +00:00
Michael Gottesman
4d085380e5 Move sil-opt pass names and definitions into Passes.def.
This was the last bit of boilerplate associated with adding a new pass that had
not been added to Passes.def. Now to add a new pass, all you need to do is:

1. Add the pass to Passes.def.
2. Implement the pass in SILPasses and update the CMake files.

Swift SVN r29856
2015-07-01 22:08:42 +00:00
Nadav Rotem
e6781476b2 Chane flag name and test to reflect pass rename
Swift SVN r29852
2015-07-01 20:19:07 +00:00
Nadav Rotem
93fff21037 Rename the InlineCaches pass to Speculative Devirtualization
Swift SVN r29851
2015-07-01 20:19:00 +00:00
Jordan Rose
8106a11dac Disallow @objc on non-ObjC-rooted classes.
These classes don't show up well in generated headers (rdar://problem/20855568),
can't actually be allocated from Objective-C (rdar://problem/17184317), and
make the story of "what is exposed to Objective-C" more complicated. Better
to just disallow them.

All classes are still "id-compatible" in that they can be converted to
AnyObject and passed to Objective-C, they secretly implement NSObjectProtocol
(via our SwiftObject root class), and their members can still be individually
exposed to Objective-C.

The frontend flag -disable-objc-attr-requires-foundation-module will disable
this requirement as well, which is still necessary for both the standard
library and a variety of tests I didn't feel like transforming.

Swift SVN r29760
2015-06-27 16:27:56 +00:00
Erik Eckstein
1aa561a1c8 Cleanup internal options in SIL pass manager.
I was always confused by the inconsistency of -sil-print-all and the other -sil-print options.
So I thought it would be a good idea to make -sil-print-all also an llvm option.
Together with some other internal options which are only used in the pass manager.



Swift SVN r29365
2015-06-12 13:37:00 +00:00
Dmitri Hrybenko
0f7f247d4b Add a -F option to sil-opt
Swift SVN r29108
2015-05-28 19:16:13 +00:00
Slava Pestov
fd256e70e3 EmitGuaranteedSelf is always on now
NFC except for removal of flag

Swift SVN r28427
2015-05-11 18:21:37 +00:00
Arnold Schwaighofer
3812583031 DominatorBasedJumpThreading: Resurrected
Teach dominator based simplifications to also thread dominated edges.

The code now handles cond_br and switch_enum terminators for both value based
simplifications (where the use is dominated) and jump threading edges (the edge
is dominated).

Update simplify_cfg.sil test cases for split edges.

This also handles the test case from rdar://20390647.

Swift SVN r27843
2015-04-27 23:44:57 +00:00
Erik Eckstein
115090d6f7 Re-apply r27361: A new SIL pass for static analysis of array properties.
...with a fix for the compiler crash in external projects.
rdar://problem/20579035



Swift SVN r27427
2015-04-17 08:18:29 +00:00
Mark Lacey
0b423c1844 Revert "A new SIL pass for static analysis of array properties."
This reverts commit r27361. It may have broken some of the external
projects we test.

Swift SVN r27426
2015-04-17 06:19:59 +00:00
Erik Eckstein
6cfb3716bf A new SIL pass for static analysis of array properties.
The GlobalPropertyOpt pass performs a static analysis over the whole module.
If it can prove that an array property call (_getArrayPropertyIsNativeNoTypeCheck) always yiels true,
then it replaces the call with a literal-true.

The pass runs on the high-level SIL using the array semantics calls.
Currently it only handles the isNativeNoTypeCheck array property, but in future it might handle additinal properties
(therefore I chose this general name for it).

It gives +24% on DeltaBlue.




Swift SVN r27361
2015-04-16 17:28:14 +00:00
Michael Gottesman
5f1206526f Enable +0 self in both sil-opt and sil-extract.
Swift SVN r27245
2015-04-13 01:23:11 +00:00
Mark Lacey
bd14e0cc4c Remove -sil-devirt-threshold frontend option.
This was used by "deep devirtualization", which is no longer around, so
it is currently ignored.

Swift SVN r27138
2015-04-08 21:53:47 +00:00
Luqman Aden
a8807a9014 [sil-opt] Use -O instead of -performance for consistency.
Swift SVN r26907
2015-04-02 22:12:58 +00:00
Luqman Aden
4c267aafde [sil-opt] Add -O as an alias for -performance.
rdar://problem/19671368

Swift SVN r26891
2015-04-02 20:21:21 +00:00
Luqman Aden
d2dfeb31f2 [sil-opt] Support emitting sib files.
rdar://problem/20235265

Swift SVN r26889
2015-04-02 20:21:19 +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
Michael Gottesman
99e0b6bb19 [codemotion] Instead of passing in whether we are late or early, create late early entry points.
I need this so I can write some tests for the late code motion pass in sil-opt.
Plus it follows the model in the inliner.

Swift SVN r26671
2015-03-28 02:47:07 +00:00
Michael Gottesman
d4e274841f Add guaranteed self option to sil-opt.
Swift SVN r26661
2015-03-28 00:43:46 +00:00
Nadav Rotem
240ff14db1 Split DominanceAnalysis into Dom and PDom using FunctionAnalysisBase.
This commit splits DominanceAnalysis into two analysis (Dom and PDom) that
can be cached and invalidates using the common FunctionAnalysisBase interface
independent of one another.

Swift SVN r26643
2015-03-27 20:54:28 +00:00
Erik Eckstein
9ef85c461b SimplifyCFG: Move optimization from CondFailOpt to SimplifyCFG and remove CondFailOpt pass.
I completely missed that one of the CondFailOpt optimization was already implemented in SimplifyCFG.
I move the other optimization also into SimplifyCFG because both share some code.



Swift SVN r26626
2015-03-27 14:07:14 +00:00
Erik Eckstein
9d8c98551c Add an optimization pass to optimize cond_fail instructions.
Summary: it tries to move cond_fail instruction to predecessor blocks, if benefitial.
For details see the comment in CondFailOpt.cpp.



Swift SVN r26592
2015-03-26 14:40:59 +00:00
Luqman Aden
3f83973928 Handle multiple sib inputs.
Swift SVN r26572
2015-03-26 01:21:21 +00:00
Arnold Schwaighofer
f79e6abd2e Missing header includes ...
Swift SVN r26454
2015-03-23 22:05:47 +00:00
Luqman Aden
44de78350c [sil-opt] Handle SIB inputs.
Swift SVN r26087
2015-03-13 03:41:49 +00:00
Nadav Rotem
5d08db87ec [overflow checks] Add a new (empty) pass to remove overflow checks
Swift SVN r26006
2015-03-12 00:55:06 +00:00
Arnold Schwaighofer
b3c0d9a0c9 SILOpt: Add an option to run the array specializer
Swift SVN r25981
2015-03-11 17:25:16 +00:00
Arnold Schwaighofer
374f8b66bd RemovePins: Add test cases
NFC.

Swift SVN r25887
2015-03-09 17:29:06 +00:00
Erik Eckstein
de09d1e684 SimplifyCFG: create a simplifyBBArgs pass.
Purpose: for testing



Swift SVN r25756
2015-03-04 15:18:08 +00:00
Arnold Schwaighofer
f027fc2bd0 sil-opt: Fix description string I missed when copying
Swift SVN r25700
2015-03-03 01:18:43 +00:00
Arnold Schwaighofer
1f399aa192 MergeCondFail: Combine cond_fail instructions in basic blocks
We can combine cond_fail instructions in basic blocks if there is no side-effect
or read in between them.

rdar://20006530

Swift SVN r25697
2015-03-03 00:45:56 +00:00
Manman Ren
a43db3621f [Driver] add InputFileKind to FrontendOptions.
Separate InputFileKind from SourceFileKind, FrontendOptions will now use
InputFileKind, while Module will use SourceFileKind.

This is in preparation for adding an input file kind for LLVM IR.

rdar://19048891


Swift SVN r25555
2015-02-26 19:13:39 +00:00
Dmitri Hrybenko
f6faf8ad81 sil-opt: implement partial AST verification
... and use it to parallelize the parse_stdlib.sil test, which was
taking too long.

Swift SVN r25295
2015-02-14 11:48:11 +00:00
Jordan Rose
dbd3b60f6b [Serialization] Move (Module)Status and validateSerializedAST into a namespace.
Also into a separate file.

Before (swift/Serialization/SerializedModuleLoader.h):
  ModuleStatus
  SerializedModuleLoader::ValidationInfo
  SerializedModuleLoader::ExtendedValidationInfo
  SerializedModuleLoader::isSerializedAST
  SerializedModuleLoader::validateSerializedAST

After (swift/Serialization/Validation.h):
  serialization::Status
  serialization::ValidationInfo
  serialization::ExtendedValidationInfo
  serialization::isSerializedAST
  serialization::validateSerializedAST

No functionality change, just a lot of renaming and a bit of reorganizing.

Swift SVN r25226
2015-02-12 05:32:25 +00:00
Erik Eckstein
4491f2a00d Improvement of the inlining heuristic.
Main changes:
*) Instruction costs are not counted for blocks which are dead after inlining
*) Terminator instructions which get constant after inlining increase the threshold
*) Calls inside loops increase the threshold

In theory this should be a step towards making the performance not so dependent on the inlining heuristic.
But I must admit that I still did some fine tuning of all the parameters to get the best results.

Improvements in the benchmarks:
-O:
Chars: +11%
CommonMarkRender: +11%
DollarReduce: +22%
ForLoops: +22%
Forest: +10%
HeapSort: +36%
ImageProc: +14%
StrCat: +14%
StrComplexWalk: +70%
StrToInt: +11%
StringWalk: +99%

-Ounchecked:
Ary: +40%
Ary2: +30%
EditDistance: +22%
Forest: +18%
HeapSort: +50%
Histogram: +11%
StrCat: +12%
StrComplexWalk: +63%
StrSplitter: +11%
StrToInt: +17%
StringWalk: +75%

Regressions (I will file radars for them):
-Ounchecked:
PolymorphicCalls: -21%
QuickSort: -22%
Rectangles: -12%

Code size of the PerfTests_O decreased by 8% 
Code size of the PerfTests_Ounchecked increased by 1%



Swift SVN r24801
2015-01-28 19:01:00 +00:00
Michael Gottesman
3d28921607 Add pass ExternalDefsToDecls that changes all available_external functions into declarations.
This is useful to ascertain how much code size comes from available_external functions.

Swift SVN r24471
2015-01-16 03:17:53 +00:00