Commit Graph

458 Commits

Author SHA1 Message Date
Arnold Schwaighofer
1f65ee25f6 Distinguish between withoutActuallyEscaping and passing @noescape
Objective C closures when reporting that a closure has escaped

rdar://39682865
2018-05-01 07:24:19 -07:00
Arnold Schwaighofer
16c4d650e7 SIL: Allow is_escaping_closure on optional closure types
rdar://39682865
2018-05-01 07:24:19 -07:00
Arnold Schwaighofer
678a99e76a Add a copy_block_without_escaping %block withoutEscaping %closure instruction
Mandatory pass will clean it up and replace it by a copy_block and
is_escaping/cond_fail/release combination on the %closure in follow-up
patches.

The instruction marks the dependence of a block on a closure that is
used as an 'withoutActuallyEscaping' sentinel.

rdar://39682865
2018-05-01 07:24:19 -07:00
swift-ci
4ad1d595fe Merge remote-tracking branch 'origin/master' into master-next 2018-04-20 17:07:24 -07:00
Joe Shajrawi
62e00eeff8 SILVerifier: add missing SILStage::Lowered checks for Instructions that check an enum’s case type v.s. a pre-lowered type. 2018-04-20 15:45:26 -07:00
swift-ci
b95dd21966 Merge remote-tracking branch 'origin/master' into master-next 2018-04-17 06:29:07 -07:00
Arnold Schwaighofer
7b472f983e Merge pull request #15927 from aschwaighofer/remove_postponed_cleanup
Remove SILGen's PostponedCleanup
2018-04-17 06:19:29 -07:00
swift-ci
9b20271f51 Merge remote-tracking branch 'origin/master' into master-next 2018-04-16 19:09:12 -07:00
Slava Pestov
505c3198d9 SIL: Don't require shared functions to have bodies in raw SIL
We don't IRGen raw SIL, and once mandatory inlining and mandatory
linking are performed in separate passes, this invariant no longer
holds.
2018-04-16 16:18:49 -07:00
Arnold Schwaighofer
8c556f16d8 SILVerifier: Verify that convert_escape_to_noescape instructions were lowered by ClosureLifetimeFixup
The [not_guaranteed] and [escaped] attributes should be removed in that
process.
2018-04-16 12:51:21 -07:00
swift-ci
b9b0db1f42 Merge remote-tracking branch 'origin/master' into master-next 2018-04-05 22:36:21 -07:00
Slava Pestov
0d1a0a694a SIL: Tweak SIL verifier condition for witness_method conformance
- Existential type cannot appear here at all, don't handle it explicitly
- Archetypes can have concrete conformances via their superclass
2018-04-05 17:17:24 -07:00
swift-ci
8ff573b5ba Merge remote-tracking branch 'origin/master' into master-next 2018-04-03 19:41:16 -07:00
Slava Pestov
28d24f8f38 SIL: Remove redundant utility method and rename another one 2018-04-03 18:14:40 -07:00
swift-ci
7cbcf127c9 Merge remote-tracking branch 'origin/master' into master-next 2018-03-29 13:09:01 -07:00
Davide Italiano
f917c93557 [SIL] Enable verification of debug info scopes at -Onone. 2018-03-28 15:25:38 -07:00
swift-ci
3e53228828 Merge remote-tracking branch 'origin/master' into master-next 2018-03-28 15:09:15 -07:00
Davide Italiano
dfaf133d27 [LoadableByAddress] Fix debug info holes when expanding alloc_stack.
<rdar://problem/36876376>
2018-03-28 11:54:03 -07:00
swift-ci
7d334ee930 Merge remote-tracking branch 'origin/master' into master-next 2018-03-27 16:43:30 -07:00
Davide Italiano
47115e6dbd [SILVerifier] Loosen verification for debug info scopes holes.
We should also skip debug info as they don't really are lowered
to anything real. Add an helper so that we can use it in passes
as well.
2018-03-27 13:54:57 -07:00
swift-ci
694ba21173 Merge remote-tracking branch 'origin/master' into master-next 2018-03-19 12:38:45 -07:00
Joe Groff
b71686c736 SILGen: Fix issues with class-constrained generics and keypaths.
- Fix some type system issues with looking up member types in/out of context.
- Correctly upcast a class-constrained existential or archetype to the base class when referencing a base class field on a generic type.

Fixes SR-7106 | rdar://problem/38070998.
2018-03-17 10:25:17 -07:00
swift-ci
860b409021 Merge remote-tracking branch 'origin/master' into master-next 2018-03-14 14:53:53 -07:00
Joe Groff
a795b4fc0c SIL: Move responsibility for external keypath equals/hash to the caller.
A public subscript might have generic indexes that aren't unconditionally Hashable, or might use indexes that are retroactively made Hashable, so the property descriptor on the implementer's side can't always resiliently provide this information to the final instantiated KeyPath.
2018-03-14 14:05:49 -07:00
swift-ci
3cf414b1db Merge remote-tracking branch 'origin/master' into master-next 2018-03-10 15:09:02 -08:00
Slava Pestov
f7dd583ca3 SIL: Remove workaround for rdar://problem/36799163 2018-03-10 03:39:09 -08:00
swift-ci
1b64c063ab Merge remote-tracking branch 'origin/master' into master-next 2018-03-09 16:29:02 -08:00
Joe Groff
ad79b5c752 SILGen: Fix up ownership of key path entry points for +0. 2018-03-09 11:52:39 -08:00
swift-ci
ecd7a48bb2 Merge remote-tracking branch 'origin/master' into master-next 2018-03-09 09:49:07 -08:00
Arnold Schwaighofer
5940796cc1 SIL: Add an is_escaping_closure instruction
Will be used to verify that withoutActuallyEscaping's block does not
escape the closure.

``%escaping = is_escaping_closure %closure`` tests the reference count. If the
closure is not uniquely referenced it prints out and error message and
returns true. Otherwise, it returns false. The returned result can be
used with a ``cond_fail %escaping`` instruction to abort the program.

rdar://35525730
2018-03-07 08:56:00 -08:00
swift-ci
6c60b1d3e7 Merge remote-tracking branch 'origin/master' into master-next 2018-03-06 16:49:22 -08:00
Sho Ikeda
26d650292f [gardening] Use empty() over size() == 0 2018-03-05 14:43:13 +09:00
swift-ci
06a510d8ae Merge remote-tracking branch 'origin/master' into master-next 2018-03-01 00:12:11 -08:00
Andrew Trick
33b89122bc Allow address-phis with -enforce-exclusivity.
As long as begin/end access scopes are respected, enforce-exclusivity does not
actually care about address phis.

Eventually, we will disable address phis completely, but that requires adding a
"address legalization" transform to various CFG passes, such as jump threading
and loop rotate.

Meanwhile, we will continue to suppress these CFG transformations when access
markers are involved. This means that optimizations will work differently, and
some will be suppressed in the presence of access markers. That means that
optimizing the access markers themselves will be a prerequisite to enabling them
by default, even if the overhead of the checks is tolerable.
2018-03-01 00:05:34 -08:00
swift-ci
2f93c97676 Merge remote-tracking branch 'origin/master' into master-next 2018-02-27 10:09:46 -08:00
Andrew Trick
cf962e0148 [SILVerifier] Disallow address-type block arguments in raw SIL.
As a structural SIL property, we disallow address-type block
arguments. Supporting them would prevent reliably reasoning about the
underlying storage of memory access. This reasoning is important for
diagnosing violations of memory access rules and supporting future
optimizations such as bitfield packing. Address-type block arguments
also create unnecessary complexity for SIL optimization passes that
need to reason about memory aliasing.

This must be enforced in RAW SIL for diagnosing exclusive memory
access. The optimizer currently breaks the invariant in three places:
1. Normal Simplify CFG during conditional branch simplification
   (sneaky jump threading).
2. Simplify CFG via Jump Threading.
3. Loop Rotation.
2018-02-27 09:53:13 -08:00
swift-ci
25459d7aff Merge remote-tracking branch 'origin/master' into master-next 2018-02-26 15:48:53 -08:00
John McCall
a3d401439d Remove check that's been #if 0'd for years; if this is valuable,
it's for reasons that escape me.
2018-02-26 15:20:06 -05:00
swift-ci
63b1e11bd1 Merge remote-tracking branch 'origin/master' into master-next 2018-02-26 08:49:36 -08:00
Joe Groff
b00ea61945 SILGen: Lower keypath references to other modules' properties and subscripts as external keypath components.
This way we'll link against the key path component the other module provides instead of making fragile assumptions about its current implementation. Since external keypath lowering isn't fully implemented elsewhere in the compiler, this is enabled behind a staging flag.

external keypath staging
2018-02-23 12:58:19 -08:00
swift-ci
e6620914e1 Merge remote-tracking branch 'origin/master' into master-next 2018-02-21 13:17:22 -08: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
swift-ci
0565f6e9a6 Merge remote-tracking branch 'origin/master' into master-next 2018-02-19 11:03:06 -08:00
swift-ci
0ca90b8eeb Merge pull request #14637 from shajrawi/tuples 2018-02-19 06:26:25 -08:00
Joe Shajrawi
e28fc903c4 LoadableByAddress: Add better tuples support
When working with tuples, if the tuple does not contain a large loadable type but does contain a function signature, we currently do nothing.

We should convert the function signature inside the tuple type instead.
2018-02-19 13:41:51 +02:00
swift-ci
385212a589 Merge remote-tracking branch 'origin/master' into master-next 2018-02-14 15:29:26 -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
swift-ci
beae25974d Merge remote-tracking branch 'origin/master' into master-next 2018-02-14 05:29:28 -08:00
Arnold Schwaighofer
48b3737404 SIL: Add support for trivial @noescape function types
- @noescape functions are trivial types
That makes @noescape functions incompatible with escaping functions.
- Forward ownership of mark_dependence %3 : callee_guaranteed () -> () on %0 : noescape @callee_guaranteed () -> ()
- SIL: Add ABIEscapeToNoEscapeConversion to SILFunctionType::ABICompatibilityCheckResult
- SIL: A thin_to_thick_function with a @noescape result type has trivial ownership
- SIL: thin_to_thick_function can create noescape function types

Part of:
SR-5441
rdar://36116691
2018-02-13 04:19:58 -08:00
swift-ci
089fdec180 Merge remote-tracking branch 'origin/master' into master-next 2018-02-10 17:49:21 -08:00