Commit Graph

2777 Commits

Author SHA1 Message Date
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
Erik Eckstein
fc3d8f11d6 Move the constant folding logic into a separate utility which can be used by multiple passes.
NFC
2018-01-18 18:27:17 -08:00
swift-ci
fc2e2ee06e Merge remote-tracking branch 'origin/master' into master-next 2018-01-17 23:53:17 -08:00
Adrian Prantl
c74ae5f375 Remove the redundant SILLocation::getCompilerGenerated interface (NFC) 2018-01-17 11:09:23 -08:00
swift-ci
9afdaa1a2e Merge remote-tracking branch 'origin/master' into master-next 2018-01-13 19:29:48 -08:00
Michael Gottesman
dfd40e4443 [cast-optimizer] Move the cast optimizer into its own .cpp file.
Local.cpp was ~3k lines of which 1.5k (i.e. 1/2) was the cast optimizer. This
commit extracts the cast optimizer into its own .cpp and .h file. It is large
enough to stand on its own and allows for Local.cpp to return to being a small
group of helper functions.

I am making some changes in this area due to the change in certain function
conventions caused by the +0-normal-arg work. I am just trying to leave the area
a little cleaner than before.
2018-01-13 18:26:22 -08:00
swift-ci
e44e13f5c4 Merge remote-tracking branch 'origin/master' into master-next 2018-01-13 00:10:15 -08:00
Slava Pestov
48d0407f43 SIL: Remove SILFunction::{is,set}KeepAsPublic() 2018-01-12 22:08:00 -08:00
swift-ci
1ba0c5c480 Merge remote-tracking branch 'origin/master' into master-next 2018-01-11 20:29:26 -08:00
swift-ci
551701a476 Merge pull request #13890 from dcci/di-stacksolver 2018-01-11 20:19:20 -08:00
swift-ci
8a7d0fbc03 Merge remote-tracking branch 'origin/master' into master-next 2018-01-11 18:29:32 -08:00
adrian-prantl
ecf9ee749d Merge pull request #13818 from vedantk/empty-locs
[DebugInfo] Add a free helper to get empty locations, NFC
2018-01-11 18:14:37 -08:00
Davide Italiano
5e7c3084bd [StackNesting] Preserve debug info correctly when solving.
Some of the `dealloc_stack` instructions inserted where getting
 a wrong scope. This manifests when running AllocBoxToStack because
it uses StackNesting as an utility. Yet another improvement in
debug informations at `-Onone`.

Fixes SR-6738.
2018-01-11 16:50:00 -08:00
swift-ci
486b479122 Merge remote-tracking branch 'origin/master' into master-next 2018-01-10 15:10:54 -08:00
Davide Italiano
5e92cae970 [ConstantPropagation] Preserve DebugInfo when creating DestroyAddr.
This code was assigning the wrong scope, resulting in wrong/degraded
debug info quality.
2018-01-10 11:27:23 -08:00
Vedant Kumar
d60ff05265 Rename getEmptyLocation to getCompilerGeneratedLocation 2018-01-09 12:38:45 -08:00
Ben Langmuir
627d6d0a9f Merge remote-tracking branch 'origin/master' into master-next
Conflicts:
	lib/IRGen/IRGen.cpp
2018-01-09 10:54:33 -08:00
John McCall
3c54c0edfc IRGen and basic optimizer support for coroutines. 2018-01-09 11:35:09 -05:00
Vedant Kumar
e33f3b663d [DebugInfo] Add a free helper to get empty locations, NFC 2018-01-08 17:59:16 -08:00
swift-ci
331f02938f Merge remote-tracking branch 'origin/master' into master-next 2018-01-08 11:29:35 -08:00
Andrew Trick
fd99f4d8e2 Code review. 2018-01-08 11:26:56 -08:00
Andrew Trick
197c6c7446 Teach SILInliner to insert begin/end borrow for guaranteed args. 2018-01-08 11:26:56 -08:00
Andrew Trick
fb1ab27e8e [nfc] SILInliner obvious cleanup. 2018-01-08 11:26:56 -08:00
Bob Wilson
f9497f5649 master-next: Update phi iteration for the LLVM SSAUpdater change in r321783
This replaces the previous solution that requires non-upstream changes
to LLVM.
2018-01-03 19:08:49 -08:00
Chris Lattner
415cd50ba2 Reduce array abstraction on apple platforms dealing with literals (#13665)
* Reduce array abstraction on apple platforms dealing with literals

Part of the ongoing quest to reduce swift array literal abstraction
penalties: make the SIL optimizer able to eliminate bridging overhead
 when dealing with array literals.

Introduce a new classify_bridge_object SIL instruction to handle the
logic of extracting platform specific bits from a Builtin.BridgeObject
value that indicate whether it contains a ObjC tagged pointer object,
or a normal ObjC object. This allows the SIL optimizer to eliminate
these, which allows constant folding a ton of code. On the example
added to test/SILOptimizer/static_arrays.swift, this results in 4x
less SIL code, and also leads to a lot more commonality between linux
and apple platform codegen when passing an array literal.

This also introduces a couple of SIL combines for patterns that occur
in the array literal passing case.
2018-01-02 15:23:48 -08:00
Arnold Schwaighofer
c82df2d521 When inserting retain/releases for sil_unowned types use the right instruction
rdar://36184409
2017-12-23 07:08:40 -08:00
swift-ci
ac95e6116b Merge pull request #13503 from anemet/opt-remark-devirt 2017-12-18 12:09:22 -08:00
Adam Nemet
3a9012d742 Add opt-remarks to the Devirtualizer pass 2017-12-18 10:18:13 -08:00
Erik Eckstein
5d1827b5ba Remove a wrong assert in the specializer.
In case of partial specialization, the replacement type of a substitution can be generic.
I couldn't find a small unit test for this bug fix. But it is tested by compiling the stdlib with the change in Collection.swift.

rdar://problem/36033852
2017-12-14 15:28:07 -08:00
Joe Shajrawi
0559e7cd3e Cast Optimizer: optimizeBridgedSwiftToObjCCast - should never reach an unreachable code path: if the Destination does not have the same type, is not a bridgeable CF type and isn't a superclass/subclass of the source operand then bail before going through with the code generation.
This commit makes sure we bail early + adds a test case wherein we did not do that until now.
2017-12-12 13:41:35 -08: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
Joe Groff
16f5e64ef2 Merge pull request #13101 from jckarter/address-only-bridged-cast-leak
SIL: Correct handling of bridging casts with address-only types.
2017-11-28 10:50:01 -08:00
Slava Pestov
2f0bc945fe SILOptimizer: Make a function static 2017-11-27 22:27:35 -08:00
Slava Pestov
1d6ec8e69e SILOptimizer: Fix incorrect check for unsupported generic case
We don't have a way to represent a cast in SIL where the destination
type introduces new archetypes that depend on the input value, sort
of like opening an existential.

Previously we would only rule out the case where the class itself
was generic, but a class can also be nested inside another generic
context.

Fixes <rdar://problem/35478838>.
2017-11-27 22:27:35 -08:00
Slava Pestov
47a3a66e52 SILOptimizer: Kill off duplicated getAllSubclasses() algorithm 2017-11-27 22:20:14 -08:00
Joe Groff
5eb830cf22 SIL: Correct handling of bridging casts with address-only types.
We would leak AnyHashable or other bridged address-only value types when turning a take-always cast into a bridging call, since the bridging method takes the value as guaranteed and we didn't arrange to destroy the value after the bridging happened. The code had unnecessarily different paths for indirect and direct arguments, and furthermore, has an untestable path for when the self argument of the bridging method is taken at +1 (when it's currently only ever +0). Join up the direct and indirect logic, and move the handling of differences down to where we introduce retain/releases so that we generate in-memory operations when appropriate. Fixes SR-6465 | rdar://problem/35678523.
2017-11-27 18:30:20 -08:00
swift-ci
012cc4a6e7 Merge pull request #12933 from anemet/opt-remark-generic-specialization 2017-11-17 10:05:22 -08:00
Adam Nemet
bd8764caaa Add opt remarks to Generic Specializer pass
Adds a combined API to output both debug message and optimization remarks.

The previously added test partial_specialization_debug.sil ensures that it's an
NFC for debug output.
2017-11-16 10:10:24 -08:00
Slava Pestov
f07cde75e7 AST: Move mapTypeOutOfContext() from GenericEnvironment to TypeBase
It doesn't actually *use* the generic environment.
2017-11-15 22:52:13 -08:00
Michael Gottesman
49adf11a00 [cfg] Add back in bool return value, returning a value to it this time. 2017-11-15 21:52:50 -08:00
Slava Pestov
2aa126e680 SILOptimizer: Fix a warning 2017-11-15 20:58:58 -08:00
swift-ci
00e71a1a38 Merge pull request #12926 from gottesmm/pr-7d7ad787aa26105e196576774cbf2188fdd8b1b0 2017-11-14 23:36:25 -08:00
Michael Gottesman
1c33bc19c4 [cfg] Add Ownership SIL utility method splitAllCondBrCriticalEdgesWithNonTrivialArgs.
Currently, the ownership verifier assumes that all cond_br with critical edges
do not have non-trivial arguments. This utility method fixes any such issues and
should be run /after/ any passes that mess with the CFG in ownership SIL if this
could come up.

Chopping this off of a larger commit.

rdar://31521023
2017-11-14 12:04:58 -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
Erik Eckstein
90c21be191 Unify the implementation of optimization mode in various option classes.
This commit is mostly refactoring.

*) Introduce a new OptimizationMode enum and use that in SILOptions and IRGenOptions
*) Allow the optimization mode also be specified for specific SILFunctions. This is not used in this commit yet and thus still a NFC.

Also, fixes a minor bug: we didn’t run mandatory IRGen passes for functions with @_semantics("optimize.sil.never")
2017-11-14 11:25:02 -08:00
Michael Gottesman
1288bff937 [cfg] Add utility method completeJointPostDominanceSet.
This helper utility given a set of uses/defs determines the set of blocks that
together with the user blocks jointly post-dominate the def blocks. In a sense
this is completing the providing set of user blocks to a joint-post dominating
set. This completion is not unique.

I am adding this method because often times when working with Ownership SIL, one
needs to hoist/sink operations and then compensate to ensure that ownership
properties are still preserved.

I think with a little bit of work I can get the ownership model eliminator to
use this routine (since the condition for ownership to be correct on an @owned
value is an empty joint-post dominating completion. I wrote it b/c I need it in
pred-memopts and I expect it to be a general useful routine for Ownership SIL.

rdar://31521023
2017-11-14 09:46:51 -08:00
John McCall
045998544f Add begin_apply, abort_apply, and end_apply instructions to allow
yield_once coroutines to be executed.
2017-11-13 04:03:54 -05:00
swift-ci
de1a5b7c55 Merge pull request #12878 from gottesmm/pr-5370d522e1c13d545057d310b4a6f0e1b981d4a4 2017-11-11 12:06:28 -08:00
Michael Gottesman
bfbf98f7ee [ssa-updater] Add support for multiple return values.
rdar://31521023
2017-11-11 11:35:02 -08:00
Huon Wilson
ae54ac0444 [AST] Allow retrieving substitutions from an arbitrary ProtocolConformance. 2017-11-08 17:02:50 -08:00