Commit Graph

55 Commits

Author SHA1 Message Date
Mark Lacey
bd30572f80 Minor clean-up of -assert-config option handling.
* Replace 'Fast' with 'Unchecked' everywhere.
* Update the help text to specify DisableReplacement rather than
  Replacement and to document Unchecked.
* Simplify tests slightly and add a tests for Unchecked.
2016-02-12 15:10:45 -08:00
practicalswift
71e00fefa1 [gardening] Fix typos: "word word" (two spaces) → "word word" (one space) 2016-01-24 21:27:16 +01:00
David Farler
bd8d85da0a Turn on dynamic super method dispatch by default
This removes the -use-native-super-method flag and turns on dynamic
dispatch for native method invocations on super by default.

rdar://problem/22749732
2016-01-15 13:37:53 -08:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Joe Groff
611defcdcb Introduce -enable-guaranteed-closure-contexts staging option. 2015-12-30 20:30:38 -08:00
David Farler
a53a31cb6e SILGen: Use super_method for native non-final methods in classes
Use the `super_method` instruction for non-final `func` and `class func`
declarations in native Swift classes. Previously, we would always emit
a static `function_ref` for these, which prevents resilient dynamic
dispatch.

This is hidden behind a -use-native-super-dispatch flag while I
survey the effects on devirtualization and stack promotion. When
that's figured out, I'll add more tests and update test cases that
still assume static dispatch.

rdar://problem/22749732
2015-12-05 13:06:31 -08:00
Nadav Rotem
2a7af5fb44 Delete the flag -disable-func-sig-opts.
This commit removes the flag -disable-func-sig-opts.
2015-12-01 22:26:29 -08:00
Nadav Rotem
2c820feb29 Revert "Remove the flag that controls signature optimization."
This reverts commit 0dd26039ce.

I did not notice that some tests depend on this flag.
2015-11-12 20:36:16 -08:00
Nadav Rotem
0dd26039ce Remove the flag that controls signature optimization. 2015-11-12 20:35:58 -08:00
Nadav Rotem
c1f417b7fb Remove the UsePrespecialized flag. It is now enabled by default. 2015-11-12 17:41:08 -08:00
Adrian Prantl
0acbc9bbd1 Thread -emit-verbose-sil into SILPasses, so it can be combined with
-sil-print-all & friends.

Swift SVN r32251
2015-09-25 23:46:50 +00:00
Roman Levenstein
19a3821a56 Implementation of the pre-specialization for the most popular stdlib generic types.
This patch implements the pre-specialization for the most popular generic types from the standard library. If there are invocations of generic functions from the standard library in the user-code and the compiler can find the specialized, optimized versions of these functions, then calls of generic functions are simply replaced by the calls of the specialized functions.

This feature is supposed to be used with -Onone to produce much faster (e.g. 5x-10x faster) executables in debug builds without impacting the compile time. In fact, the compile-time is even improved, because IRGen has less work to do. The feature can be considered a light-weight version of the -Odebug, because pre-specialization is limited in scope, but does not have a potentially negative compile-time impact compared to -Odebug. It is planned to enable it by default in the future.

This feature is disabled by default for the time being. It can be enabled by using a hidden flag: -Xllvm -use-prespecialized.

The implementation consists of two logical steps:
- When the standard library is being built, we force a creation of specializations for the most popular generic types from the stdlib, e.g. Arrays of integer and floating point types, Range<Int>, etc. The list of specializations is not fixed and can be easily altered by editing the Prespecialized.swift file, which is responsible for forcing the specialization of generic types (this is simple solution for now, until we have a proper annotation to indicate which specializations of a given generic type or function we want to generate by means of the pre-specialization). These specializations are then optimized and preserved in the stdlib dylib and in the Swift SIL module. The size increase of the stdlib due to creation of pre-specializations is currently about 3%-7%.

- When a user-code is being compiled with -Onone, the compiler would run a generic specializer over the user-code. If there are calls of generic functions from the standard library, the specializer would check if there is an existing specialization matching these invocations. If such a specialization is found, the original call is replaced by the call of this more efficient specialized version.

Swift SVN r30309
2015-07-17 06:52:07 +00:00
Joe Groff
9bdac157d2 SIL: Remove EnableTypedBoxes staging option.
Swift SVN r29762
2015-06-27 18:10:12 +00:00
Joe Groff
6babfe36b5 SIL: Enable typed boxes.
Swift SVN r29750
2015-06-27 00:52:36 +00:00
Roman Levenstein
251bda4959 Add a field to SILOption to represent the current optimization level.
The value is set based on the -O command-line option. It is generally useful if SIL optimization passes can check the current optimization level.
A couple of subsequent commits are going to make use of this information.

Swift SVN r29653
2015-06-25 02:38:02 +00:00
Joe Groff
910badfe4d SIL: Stage in a typed-boxes dialect.
When -sil-enable-typed-boxes is passed, have alloc_box and dealloc_box instructions work with box types instead of NativeObject.

Swift SVN r29511
2015-06-19 16:39:04 +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
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
Michael Gottesman
75ea31dba9 Turn on +0 self by default.
The only caveat is that:

1. We do not properly recognize when we have a let binding and we
perform a guaranteed dynamic call. In such a case, we add an extra
retain, release pair around the call. In order to get that case I will
need to refactor some code in Callee. I want to make this change, but
not at the expense of getting the rest of this work in.

2. Some of the protocol witness thunks generated have unnecessary
retains or releases in a similar manner.

But this is a good first step.

I am going to send a large follow up email with all of the relevant results, so
I can let the bots chew on this a little bit.

rdar://19933044

Swift SVN r27241
2015-04-12 22:23:37 +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
Erik Eckstein
8531045449 Add --num-threads option.
This is in preparation for multi-threaded code generation.
Currently this option has no effect yet.



Swift SVN r25883
2015-03-09 15:41:38 +00:00
Michael Gottesman
494305dcd1 Revert "Remove sil option flags that are no longer needed."
This reverts commit r25828. I forgot that some tests depend on these. Thanks
Andy!

Michael

Swift SVN r25832
2015-03-07 03:10:15 +00:00
Michael Gottesman
e40f01c9ed Remove sil option flags that are no longer needed.
Swift SVN r25828
2015-03-07 02:31:52 +00:00
Justin Bogner
d44090d29e InstrProf: Optionally generate coverage maps when profiling
This adds the -profile-coverage-mapping option to swift, and teaches
SILGenProfiling to generate mappings from source ranges to counters.

Swift SVN r25266
2015-02-13 08:42:15 +00:00
Justin Bogner
a49008298e InstrProf: Set up the basic infrastructure for profiling swift
This adds the -profile-generate flag, which enables LLVM's
instrumentation based profiling. It implements the instrumentation
for basic control flow, such as if statements, loops, and closures.

Swift SVN r25155
2015-02-11 01:06:18 +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
Joe Groff
9489605a8f Enable vtable thunks.
Swift SVN r24736
2015-01-26 21:52:20 +00:00
Joe Groff
a449948275 SILGen: Emit vtable thunks to handle optional variance.
If a subclass overrides methods with variance in the optionality of non-class-type members, emit a thunk to handle wrapping more optional parameters or results and force-unwrapping any IUO parameters made non-optional in the derived. For this to be useful, we need IRGen to finally pay attention to SILVTables, but this is a step on the way to fixing rdar://problem/19321484.

Swift SVN r24705
2015-01-24 05:21:26 +00:00
Michael Gottesman
1ae4002b6f Add the frontend flag '-external-pass-pipeline-filename'
This flag enables one to specify a json file that expresses a specific
pipeline in the following format:

[
  [
    "$PASS_MANAGER_ID",
    "run_n_times"|"run_to_fixed_point",
    $NUM_ITERATIONS,
    "$PASS1", "$PASS2", ...
  ],
  ...
]

This will make it easier to experiment with different pass pipelines by
allowing:

1. Automatic generation of pass pipelines without needing to recompile
   the compiler itself.
2. Simple scripting of pass pipelines via the json meta language.
3. Enabling the easy expression and reproducability of a specific
   pipeline ordering via radar.

In the next commit I will provide a python library for the generation of these
json files with a few types of pipeline generators already created.

Swift SVN r24055
2014-12-20 04:09:47 +00:00
Michael Gottesman
6fdf2a2a2f [silgen] Add support for emitting guaranteed self behind the flag -enable-guaranteed-self.
This does not have any tests since I am going to start going through SILGen
tests and updating them for guaranteed self as the appropriate tests.

*NOTE* There is more work to be done in terms of thunks, but the basic
functionality is done.

rdar://15729033

Swift SVN r23653
2014-12-03 21:20:25 +00:00
Michael Gottesman
f33e6306e8 [func-sig-opts] Enable func sig opts.
This currently handles owned -> guaranteed argument conversion and dead argument
elimination.

RecursiveOwnedParameter||90.0%
ClassArrayGetter|||||||||23.3%
Life|||||||||||||||||||||16.7%
Prims||||||||||||||||||||11.2%
StringWalk|||||||||||||||5.7%

The next step is to implement SROA and address -> value optimizations.

rdar://16917049

Swift SVN r23023
2014-10-30 23:22:51 +00:00
Michael Gottesman
93494cf44f [func-sig-opts] Add frontend option -enable-func-sig-opts to enable function signature optimization as a late pass. This is disabled by default and is only for testing purposes.
Swift SVN r21787
2014-09-08 21:29:09 +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
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
af222321dc Add missing include. NFC.
This was hidden by all the other files that included this already
including limits.h.

Swift SVN r20605
2014-07-27 18:37:12 +00:00
Michael Gottesman
112269fb33 Add the frontend option -disable-sil-perf-optzns.
Swift SVN r20604
2014-07-27 18:37:11 +00:00
Nadav Rotem
766316f3ab Reduce the inline threshold to a more sane default. It works well with the new pass order.
Swift SVN r19165
2014-06-25 17:14:42 +00:00
Michael Gottesman
a0f7d9c3fd Add an option to run the inst-count pass after performing optimizations.
This will enable via the -print-stats function the ability to quickly
find out the final count of various forms of instructions. My intention
is to use this to count retains and releases.

Swift SVN r18946
2014-06-17 02:30:34 +00:00
Nadav Rotem
91841acc9c Increase the inliner threshold.
Swift SVN r17999
2014-05-13 07:54:23 +00:00
Michael Gottesman
e99379b75c Revert "[performance-inliner] Up inline threshold to 225 so that we are at least as aggressive with inlining as LLVM is."
This reverts commit r17979. This causes a regression on Phonebook sort
due to it changing inlining characteristics which causes us to reference
certain functions from the stdlib dylib (which have asserts).

If Arnold's specialization code gets in I will recommit this.

Swift SVN r17986
2014-05-13 01:06:04 +00:00
Michael Gottesman
72c60f13ec [performance-inliner] Up inline threshold to 225 so that we are at least as aggressive with inlining as LLVM is.
Currently we attempt to simulate LLVM's inlining cost model. Due to the
Swift optimizer being strictly more conservative with the inlining cost
model due to swift not having as many arithmetic simplifications (for
example), the swift level cost should always be greater than or equal to
the LLVM's cost model.

Given the aforementioned paragraph, it makes sense to at least match
LLVM's cost inline threshold given we are "simulating" it.

Swift SVN r17979
2014-05-12 23:59:51 +00:00
Jordan Rose
db872f666e [Frontend] Make CompilerInvocation::parseArgs additive.
No options should be changed because of the absence of a flag. This is
necessary for clients like LLDB which may have an initial set of options
that differs from the usual set.

Part of <rdar://problem/16776705>

Swift SVN r17819
2014-05-10 01:17:36 +00:00
Arnold Schwaighofer
ce0e6698c5 Add _isFast predicate that is true at Ofast
We want to support three configurations:

* Debug (-Onone, -O0): user assertions, library precondition checks, runtime
  checks enabled and verbose.

* Release (-O): library precondition checks, runtime checks enabled but succinct
  (trap).

* Fast (-Ofast): all checks off.

The _isFast predicate will allow to write standard library functions to support
this plan. This commit changes fatal() to differentiate between the three modes.

Support for rdar://16477198

Swift SVN r17697
2014-05-08 15:30:29 +00:00
Arnold Schwaighofer
989d554a45 Add support for an assert_configuration builtin function
This patch adds support for a builtin function assert_configuration that is
replaced by constant progpagation by an appropriate value dependent on a compile
time setting. This replacement can also be disabled when serializing sil for a
library.

Using this mechanism we implement assertions that can  be disabled (or whose
behavior changes) depending on compile time build settings (Debug, Release,
DisableReplacement).

In the standard library we can now write one assert function that uses this
builtin function to provide different compile time selectable runtime behavior.

Example

Assert.swift:

@transparent
func assert<T : LogicValue>(
  condition: @auto_closure () -> T, message: StaticString = StaticString(),

  // Do not supply these parameters explicitly; they will be filled in
  // by the compiler and aren't even present when asserts are disabled
  file: StaticString = __FILE__, line: UWord = __LINE__
) {
  // Only in debug mode.
  if _isDebug() {
    assert(condition().getLogicValue(), message, file, line)
  }
}

AssertCommon.swift:

@transparent
func _isDebug() -> Bool {
  return Int32(Builtin.assert_configuration()) == 0;
}

rdar://16458612

Swift SVN r16472
2014-04-17 22:05:42 +00:00
Nadav Rotem
5500bdae22 Add a command line flag for removing cond_fails in SIL.
Swift SVN r15432
2014-03-25 00:51:01 +00:00
Michael Gottesman
29e1a53bbb [deserialization] Deserialize transparent functions lazily iff they will be used in mandatory inlining.
Swift SVN r14490
2014-02-28 01:05:01 +00:00
Joe Groff
a7b75fc396 Remove inaccurate comment.
Swift SVN r14062
2014-02-18 23:38:39 +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
731000b4cd Added -sil-print-all and -sil-verify-all options.
Swift SVN r13662
2014-02-07 23:07:11 +00:00