Commit Graph

806 Commits

Author SHA1 Message Date
swift-ci
8d9dfa47a6 Merge pull request #15485 from gottesmm/pr-524a60964d1eb583711748d34362982011cbe9af 2018-03-24 12:18:09 -07:00
swift-ci
bbcb57661e Merge pull request #15484 from gottesmm/pr-762fbb7b46d42781016643ce31e84d03bbdcf6dc 2018-03-24 12:15:31 -07:00
Michael Gottesman
ddb88c92ac [globalopt] Eliminate unnecessary coercion to SILValue and improve some small other nits. 2018-03-24 11:27:59 -07:00
Michael Gottesman
a99b65c073 [globalopt] Eliminate indentation by inverting a condition into an early exit. 2018-03-24 11:24:48 -07:00
Michael Gottesman
541c2e4b33 [globalopt] Remove a local ToRemove vector that is never appended to.
This didn't trigger any unused variable warnings since we always try to clean up
the contents in the ToRemove vector. Of course since the ToRemove vector is
never actually appended to, nothing ever happens there.

The other aspect of this is whether or not we actually need a ToRemove vector. I
read the code in this section and it is not necessary since the section of
GlobalOpt is only collecting information about the function we are
processing. Later after function iteration is over, we later process the data
that we filled our caches with. So no iterator invalidation can happen.
2018-03-24 11:24:43 -07:00
Michael Gottesman
002326f3b2 [globalopt] Small style fixes. 2018-03-24 11:23:48 -07:00
Michael Gottesman
6e98703391 [globalopt] Eliminate unused field.
Some time ago I believe due to compile time? Not sure, we started to use
ColdBlockInfo in a per function way. So for each function, we instantiate a new
ColdBlockInfo and never use this one. So there is no reason for it to exist...
2018-03-24 11:21:29 -07:00
Michael Gottesman
087769ce5c [globalopt] Use std::reverse instead of trying to reverse an array by hand.
I also changed a dyn_cast to a cast since we assume here that the cast can never
fail.
2018-03-24 11:20:02 -07:00
Michael Gottesman
086171bd8c [globalopt] Clean up doxygen comments in GlobalOpt.cpp.
I need to fix a few things in GlobalOpt to deal with +0 changes I believe. So
while I am here, I am just cleaning up the file a little bit.
2018-03-24 09:37:44 -07:00
Slava Pestov
c35d1f5fc7 SIL: Remove unused code for optional (non-@objc) protocol requirements 2018-03-23 18:59:06 -06:00
Michael Gottesman
51b20a2881 [globalopt][gardening] Standardize "Foo*" => "Foo *"
In most of the file, "Foo *" is used. So this commit just standardizes the rest
of "Foo*" to that.
2018-03-23 13:23:38 -07:00
Joe Groff
a84f7f175a SIL: Consider accessors from property descriptors to be used. 2018-03-22 13:46:50 -07:00
Andrew Trick
defc710f8b [exclusivity] Teach LetPropertiesOpt how to handle begin_access. 2018-03-11 14:20:39 -07:00
Adrian Prantl
9b6a9946ec Be explicit about whether a DebugInfo-carying SILInstruction has debug info.
This patch both makes debug variable information it optional on
alloc_stack and alloc_box instructions, and forced variable
information on debug_value and debug_value_addr instructions. The
change of the interface uncovered a plethora of bugs in SILGen,
SILTransform, and IRGen's LoadableByAddress pass.

Most importantly this fixes the previously commented part of the
DebugInfo/local-vars.swift.gyb testcase.

rdar://problem/37720555
2018-02-21 10:50:19 -08:00
Joe Groff
8381ba6795 Merge pull request #14643 from jckarter/keypath-external-component
SIL: Add an 'external' KeyPathPatternComponent kind.
2018-02-14 15:19:08 -08:00
Arnold Schwaighofer
b6db2f06d1 CapturePropagation: Can't forward to a function if it is not swift co… (#14640)
* CapturePropagation: Can't forward to a function if it is not swift convention compatible

This causes breakage in check-swift-optimize_size on a release stdlib
bot.

Test case to follow.

* Test case for capture propagation involving a c function
2018-02-14 14:05:06 -08:00
Joe Groff
d4e03f2ba3 SIL: Add an 'external' KeyPathPatternComponent kind.
This will allow key paths to resiliently reference public properties from other binaries by referencing a descriptor vended by the originating binary. NFC yet, this just provides printing/parsing/verification of the new component.
2018-02-14 10:48:24 -08:00
Arnold Schwaighofer
08872244b7 ClosureSpecializer: Handle closure arguments in throwing functions
We can treat a throw instruction like we would a return. Insert the
release for the propagated partial_apply before the throw instruction.
2018-02-13 11:13:14 -08:00
Arnold Schwaighofer
5cce301f85 ClosureSpecializer: Fixes for trivial @noescape closures 2018-02-13 04:19:59 -08:00
Andrew Trick
4734920222 Don't rerun diagnostic passes on deserialized SIL. 2018-02-09 09:55:47 -08:00
Erik Eckstein
bf87035a36 GlobalOpt: Move the object outlining from GlobalOpt into a separate pass "ObjectOutliner"
We run GlobalOpt multiple times in the pass pipeline but in some cases object outlining shouldn't be done too early.
Having it done in a separate pass enables to run it independently from GlobalOpt.
2018-01-19 11:32:36 -08:00
eeckstein
b126b62256 Revert "Optimization changes to completely fold OptionSet literals" 2018-01-18 22:05:07 -08:00
Erik Eckstein
1f511ab846 GlobalOpt: Move the object outlining from GlobalOpt into a separate pass "ObjectOutliner"
We run GlobalOpt multiple times in the pass pipeline but in some cases object outlining shouldn't be done too early.
Having it done in a separate pass enables to run it independently from GlobalOpt.
2018-01-18 18:27:17 -08:00
Slava Pestov
d5723cff59 SILOptimizer: Use PublicNonABI linkage for global getters in GlobalOpt
Previously we were creating private [serialized] functions here, which
do not deserialize properly. This was only exposed by making default
argument generators PublicNonABI also.
2018-01-14 22:59:40 -08:00
Slava Pestov
48d0407f43 SIL: Remove SILFunction::{is,set}KeepAsPublic() 2018-01-12 22:08:00 -08:00
Slava Pestov
8027e8108e DeadFunctionElimination: Serialized functions are not anchors 2018-01-12 21:56:17 -08:00
Slava Pestov
6c055652b6 DeadFunctionElimination: Fold shouldBeSerializedOrEmitted() into isAnchorFunction() 2018-01-12 21:56:17 -08:00
Slava Pestov
9ff97367df AST: Rename hasFixedLayout() to isResilient() and flip polarity
In IRGen we call this isResilient() already in IRGen, and it's
more consistent to call it the same thing everywhere.
2018-01-11 21:57:42 -08:00
Davide Italiano
14d3779e29 [CapturePromotion] Preserve DebugInfo when creating project_box.
The code was assigning an incorrect lexical scope, which was
responsible for an hole (and likely, wrong DI at `-Onone` in some
cases).

Fixes SR-6709.
2018-01-08 11:55:15 -08:00
Kuba Mracek
0b7bb605cb Don't hardcode the function representation of builtin "once". Make emitLazyGlobalInitializer retrieve the convention from getBuiltinValueDecl. 2018-01-03 10:30:24 -08:00
John McCall
b13f30ff30 Move a convenience API for changing a SILFunctionType into the AST. NFC. 2017-12-15 18:19:07 -05:00
Michael Gottesman
5263e9e74e [sil] Eliminate redundant method SILFunction::hasUnqualifiedOwnership().
We can just !SILFunction::hasQualifiedOwnership(). Plus as Andy pointed out,
even ignoring the functional aspects, having APIs with names this close can
create confusion.
2017-12-02 17:42:34 -08:00
Arnold Schwaighofer
3e04f21a41 SIL: Remove EnableGuaranteedClosureContext now that it is the default 2017-11-27 07:25:03 -08:00
Slava Pestov
7f84ae5449 SILOptimizer: Remove special handling of transparent functions from dead function elimination
This is no longer sound after https://github.com/apple/swift/pull/12903.
We no longer special-case the linkage of transparent functions at all.
2017-11-20 00:21:49 -05:00
Joe Shajrawi
4d5949942d Merge branch 'master' into sil-serialization-before-optimizations5 2017-11-17 16:17:16 -08:00
Slava Pestov
cce30cc9bb SIL: Remove SILFunction::mapTypeOutOfContext() 2017-11-15 22:52:28 -08:00
Erik Eckstein
8033476b64 Function-level optimization attributes.
For now these are underscored attributes, i.e. compiler internal attributes:
@_optimize(speed)
@_optimize(size)
@_optimize(none)

Those attributes override the command-line specified optimization mode for a specific function.
The @_optimize(none) attribute is equivalent to the already existing @_semantics("optimize.sil.never") attribute
2017-11-14 11:25:02 -08:00
Arnold Schwaighofer
68d0a8774a SIL: Make adjustFunction type of closures parameterized on whether we use
guaranteed closures

This is going to go away once we change the default to guaranteed
closures.

SR-5441
rdar://33255593
2017-11-10 15:18:01 -08:00
Huon Wilson
99c4cddfca [SILGen] Store conditional conformances in SILWitnessTables. 2017-11-08 17:02:50 -08:00
John McCall
5c33d2106a Add simple accessor/generator coroutine support to SILFunctionType. 2017-11-07 01:50:12 -05:00
Arnold Schwaighofer
0163852a93 CapturePromotion: Fix promotion of guaranteed closure parameters
SR-5441
rdar://33255593
2017-11-03 13:53:22 -07:00
Huon Wilson
0236db7be1 [SIL] Witness methods store the conformance from which they come. 2017-11-01 11:33:26 -07:00
Greg Parker
d6e1866344 [SIL] Make @_silgen_name and @_cdecl functions immune to some optimizations (#12696)
@_silgen_name and @_cdecl functions are assumed to be referenced from
C code. Public and internal functions marked as such must not be deleted
by the optimizer, and their C symbols must be public or hidden respectively.

rdar://33924873, SR-6209
2017-11-01 01:41:05 -07:00
Erik Eckstein
2d95f4993a GlobalOpt/IRGen: Instead of not converting an array of empty elements to a statically initialized array, handle this special case in IRGen. 2017-10-31 17:14:51 -07:00
Erik Eckstein
4a485f54fc GlobalOpt: add assertion for resilient classes 2017-10-27 15:36:36 -07:00
Slava Pestov
a07e991093 SILOptimizer: Fix string switch optimization with resilient stdlib
Progress on <rdar://problem/34794790>, but since the build started failing
some other things broke.
2017-10-26 23:58:50 -07:00
Davide Italiano
5ece6d46e4 [GlobalOpt] Fix style/indentation and add a comment. NFCI. 2017-10-26 16:18:11 -07:00
eeckstein
76d15512c3 Merge pull request #12622 from dcci/globalopt-worklist
[GlobalOpt] Switch to a worklist to avoid iterator invalidation issues.
2017-10-26 15:49:52 -07:00
Roman Levenstein
0fed27fefe [dead-function-elimination] Do not consider transparent functions as anchors
Transparent functions are emitted into the client in most cases, so there is no need to keep them alive in the defining module unless they are used there.

The only exception are transparent global initializers, because bodies of global initializer functions are never SIL serialized and are always IRGened into the defining module, so that clients can invoke them

This change results in small code size reductions of the binaries being produced after recent changes related to the early SIL serialization and the removal of -sil-serialize-all mode.

Fixes rdar://problem/35022861
2017-10-26 14:02:31 -07:00
Davide Italiano
423eb798da [GlobalOpt] Defer instruction deletion to prevent iterator invalidation.
eraseFromParent() might invalidate the iterator, so when we're
walking the pointer to the next instruction in the SILBB we end up
crashing. In order to avoid this issue, collect a SmallVector of
instructions to remove, and defer the actualy removal after we
iterated the whole SILBasicBlock, as we know it's safe.

Fixes SR-6215.
2017-10-26 11:13:01 -07:00