Commit Graph

25 Commits

Author SHA1 Message Date
Slava Pestov
9ec80df97e SIL: Remove curried SILDeclRefs 2020-03-19 02:20:21 -04:00
Arnold Schwaighofer
448a6cef1e Outliner: Check that we have a self argument before we ask for it
rdar://57849479
2019-12-12 10:14:37 -08:00
Arnold Schwaighofer
95475aaf15 Outliner: Verify that getBridgeFromObjectiveC and getBridgeToObjectiveC return a valid SILDeclRef
rdar://57757241
2019-12-10 11:39:26 -08:00
Arnold Schwaighofer
97d69ab57b Outliner: Make sure that the argument convention is guaranteed or owned
rdar://57759220
2019-12-09 12:39:17 -08:00
Michael Gottesman
67ff2ae69e [semantic-arc-opts] Change to always use the worklist.
Previously we were:

1. Doing a linear scan, performing certain optimizations, and setting up a
worklist for future processing.

2. Draining the worklist of changed instructions until we reached a fix point.

The key thing here is that for (1) to be safe, we would need to not perform any
optimizations on block arguments since there was an ssumption that we would only
perform SSA-like optimizations.

I am going to be adding such optimizations soon, so it makes sense to just
convert the initial traversal to non-destructively seed the worklist and
eliminate that initial optimization pass.

This should be NFC.
2019-12-06 11:50:17 -08:00
Michael Gottesman
343b4002e5 [outliner] Add end sil function patterns to FileCheck tests so that they can only match one function uniquely. 2019-12-06 11:27:13 -08:00
Arnold Schwaighofer
6842134152 Outliner fix: Make sure the enum actually has an operand before we access it
rdar://54837190
2019-08-29 09:29:09 -07:00
Arnold Schwaighofer
c26ad8681f Pattern match SIL in test case 2019-01-09 06:23:33 -08:00
Arnold Schwaighofer
50cac1d081 Outliner: We don't support calls with opened existentials
rdar://47099026
2019-01-08 11:41:50 -08:00
Andrew Trick
a17dbc7c74 Enable run-time exclusivity checking in release mode.
This change could impact Swift programs that previously appeared
well-behaved, but weren't fully tested in debug mode. Now, when running
in release mode, they may trap with the message "error: overlapping
accesses...".

Recent optimizations have brought performance where I think it needs
to be for adoption. More optimizations are planned, and some
benchmarks should be further improved, but at this point we're ready
to begin receiving bug reports. That will help prioritize the
remaining work for Swift 5.

Of the 656 public microbenchmarks in the Swift repository, there are
still several regressions larger than 10%:

TEST                    OLD      NEW      DELTA      RATIO
ClassArrayGetter2       139      1307     +840.3%    **0.11x**
HashTest                631      1233     +95.4%     **0.51x**
NopDeinit               21269    32389    +52.3%     **0.66x**
Hanoi                   1478     2166     +46.5%     **0.68x**
Calculator              127      158      +24.4%     **0.80x**
Dictionary3OfObjects    391      455      +16.4%     **0.86x**
CSVParsingAltIndices2   526      604      +14.8%     **0.87x**
Prims                   549      626      +14.0%     **0.88x**
CSVParsingAlt2          1252     1411     +12.7%     **0.89x**
Dictionary4OfObjects    206      232      +12.6%     **0.89x**
ArrayInClass            46       51       +10.9%     **0.90x**

The common pattern in these benchmarks is to define an array of data
as a class property and to repeatedly access that array through the
class reference. Each of those class property accesses now incurs a
runtime call. Naturally, introducing a runtime call in a loop that
otherwise does almost no work incurs substantial overhead. This is
similar to the issue caused by automatic reference counting. In some
cases, more sophistacated optimization will be able to determine the
same object is repeatedly accessed. Furthermore, the overhead of the
runtime call itself can be improved. But regardless of how well we
optimize, there will always a class of microbenchmarks in which the
runtime check has a noticeable impact.

As a general guideline, avoid performing class property access within
the most performance critical loops, particularly on different objects
in each loop iteration. If that isn't possible, it may help if the
visibility of those class properties is private or internal.
2018-11-02 16:54:31 -07:00
Erik Eckstein
39bb14b094 change mangling prefix from $S to $s
This is the final ABI mangling prefix

rdar://problem/38471478
2018-09-19 13:55:11 -07:00
Pavel Yaskevich
b1bd9b6d05 [TypeChecker] Make sure that load always emitted before parens/forcing
While trying to emit implicit load expression make sure that it's
done in a way where force/paren expression is always top level,
that leads to better fix-its and, in case of forcing, more compact
SIL by intermediate optional container.

Resolves: [SR-8150](https://bugs.swift.org/browse/SR-8150) / rdar://problem/41725207
2018-07-07 19:25:41 -07:00
Erik Eckstein
7c8242f56a Outliner: fix a crash during pattern matching in case a SIL instruction is not the expected enum instruction.
SR-7870
rdar://problem/40810341
2018-06-05 11:08:18 -07:00
Arnold Schwaighofer
49ba28a9ac Outliner: Clear IsBridgedArgument state in between matching
Otherwise, when we mangle a signature of bridged/not_bridged arguments
we can see the state from the previous match of another instruction.

SR-7426
rdar://39414272
2018-04-13 11:10:22 -07:00
Erik Eckstein
2b4132be23 SILOptimizer: adapt Outliner pass to guaranteed-by-default calling convention
Also did some refactoring to share common code.

rdar://problem/38152291
2018-03-29 10:49:36 -07:00
Joe Shajrawi
a399d9bf60 XFAIL test wherein optimizations are not kicking in when compiling with a +0 runtime.
Turning these back on is tracked by:

rdar://38152291
2018-03-08 19:26:35 -08:00
Mark Lacey
f08823757a IUO: Generate Optional<T> rather than ImplicitlyUnwrappedOptional<T>.
Stop creating ImplicitlyUnwrappedOptional<T> so that we can remove it
from the type system.

Enable the code that generates disjunctions for Optional<T> and
rewrites expressions based on the original declared type being 'T!'.

Most of the changes supporting this were previously merged to master,
but some things were difficult to merge to master without actually
removing IUOs from the type system:
- Dynamic member lookup and dynamic subscripting
- Changes to ensure the bridging peephole still works

Past commits have attempted to retain as much fidelity with how we
were printing things as possible. There are some cases where we still
are not printing things the same way:
- In diagnostics we will print '?' rather than '!'
- Some SourceKit and Code Completion output where we print a Type
  rather than Decl.

Things like module printing via swift-ide-test attempt to print '!'
any place that we now have Optional types that were declared as IUOs.

There are some diagnostics regressions related to the fact that we can
no longer "look through" IUOs. For the same reason some output and
functionality changes in Code Completion. I have an idea of how we can
restore these, and have opened a bug to investigate doing so.

There are some small source compatibility breaks that result from
this change:
- Results of dynamic lookup that are themselves declared IUO can in
  rare circumstances be inferred differently. This shows up in
  test/ClangImporter/objc_parse.swift, where we have
    var optStr = obj.nsstringProperty
  Rather than inferring optStr to be 'String!?', we now infer this to
  be 'String??', which is in line with the expectations of SE-0054.
  The fact that we were only inferring the outermost IUO to be an
  Optional in Swift 4 was a result of the incomplete implementation of
  SE-0054 as opposed to a particular design. This should rarely cause
  problems since in the common-case of actually using the property rather
  than just assigning it to a value with inferred type, we will behave
  the same way.
- Overloading functions with inout parameters strictly by a difference
  in optionality (i.e. Optional<T> vs. ImplicitlyUnwrappedOptional<T>)
  will result in an error rather than the diagnostic that was added
  in Swift 4.1.
- Any place where '!' was being used where it wasn't supposed to be
  allowed by SE-0054 will now treat the '!' as if it were '?'.
  Swift 4.1 generates warnings for these saying that putting '!'
  in that location is deprecated. These locations include for example
  typealiases or any place where '!' is nested in another type like
  `Int!?` or `[Int!]`.

This commit effectively means ImplicitlyUnwrappedOptional<T> is no
longer part of the type system, although I haven't actually removed
all of the code dealing with it yet.

ImplicitlyUnwrappedOptional<T> is is dead, long live implicitly
unwrapped Optional<T>!

Resolves rdar://problem/33272674.
2018-01-31 12:15:58 -08:00
Arnold Schwaighofer
fe16c809e1 Outliner: Can't handle generic ObjC classes
The outliner can't handle outlining calls to generic objective c
classes resulting in crashes if it attempted so.

rdar://36395452
2018-01-10 10:56:21 -08:00
Erik Eckstein
cd3d50a5d9 ABI: Change the mangling prefix from _T0 to $S 2018-01-06 13:55:59 -08:00
Pavel Yaskevich
f90d943a29 [Mangling/ABI] NFC: Fix SILOptimizer tests to reflect label mangling changes 2017-12-18 15:45:50 -08:00
Arnold Schwaighofer
a6504fb5ac Outliner: Can't handle polymorphic objc methods
rdar://35796830
2017-12-01 13:57:31 -08:00
Roman Levenstein
53754a7a69 Add a new simple utility optimization pass for serialization of SILModules 2017-10-13 23:19:19 -07:00
Slava Pestov
7bf3b90b62 SIL: Split off objc_method / objc_super_method from class_method / super_method
This replaces the '[volatile]' flag. Now, class_method and
super_method are only used for vtable dispatch.

The witness_method instruction is still overloaded for use
with both ObjC protocol requirements and Swift protocol
requirements; the next step is to make it only mean the
latter, also using objc_method for ObjC protocol calls.
2017-10-03 22:13:31 -07:00
Alex Hoppen
1c7e289b96 [Mangling] Adjust subscript mangling to not include "subscript"
Change the mangling of accessors to have a variable or subscript node
as their only child node, while subscript nodes no longer contain a decl
name.
2017-09-10 19:44:07 +02:00
Arnold Schwaighofer
b625d4da8a Osize: Add a SIL Outliner pass that outlines the bridging of objective c calls.
Implements outlining of bridged objective c property and method calls.

rdar://33387700
2017-09-06 08:37:37 -07:00