Commit Graph

381 Commits

Author SHA1 Message Date
John McCall
30fa1df0fa Track whether types are fixed-ABI and ABI-accessible at the SIL level.
Fixed-ABI means that we can do value operations on the type without
any metadata: value-allocations, copies, and destroys.  It's currently
equivalent to being fixed-size, but (1) being fixed-size isn't useful
by itself at the SIL level and (2) you can imagine resilience or generics
micro-optimizations where there's like an attribute that tells us the
size of a type without actually telling us how to copy it.  All types
are fixed-ABI except:
  - layout-unconstrained generic types,
  - resilient value types, and
  - value types which contain a subobject of such a type (except within
    indirect enum cases).

ABI-accessible means that we can perform value operations at all.
We might not be able to if the type is not fixed-ABI and it is private
to a different file (in non-WMO builds) or internal to a different
module, because in such cases we will not be able to access its metadata.
In general, we can't use such types `T` directly, but we may be able to
use types `C` that contain such types as subobjects.  Furthermore, we
may be reasonably exposed to SIL that performs operations that treat `C`
as non-opaque, e.g. if `C` is frozen (as it will be by default for
modules in Swift 5).  We can still achieve correctness in these cases
as long as we don't either:
  - inline code that contains value operations on `T` or
  - attempt to recursively expand a value operation on `T` into value
    operations on its subobjects.

The SIL optimizer currently never tries to expand value operations on
objects in memory.  However, IRGen always recursively expands value
operations on frozen types; that will be fixed in a follow-up patch.

The SIL verification that I've added here is definitely incomplete.
2018-05-15 15:07:32 -04:00
swift-ci
942d065d80 Merge remote-tracking branch 'origin/master' into master-next 2018-05-14 18:29:11 -07:00
Erik Eckstein
6529787984 SILVerifier: fix quadratic behavior for large basic blocks.
For large basic blocks the dominance check between two instructions in the same block was very expensive.
Although the verifier does not run in no-assert compiler builds, we don't want it to be extra slow for assert builds.

https://bugs.swift.org/browse/SR-7632
2018-05-14 16:41:17 -07:00
swift-ci
7b7c4d7469 Merge remote-tracking branch 'origin/master' into master-next 2018-05-11 21:10:05 -07:00
Doug Gregor
911ed60a98 Eliminate dead code making use of SubstitutionList. 2018-05-11 17:37:27 -07:00
Doug Gregor
049c56dde6 Eliminate getForwardingSubstitutions().
Use the SubstitutionMap version everywhere.
2018-05-11 17:37:27 -07:00
swift-ci
fe33d12ead Merge remote-tracking branch 'origin/master' into master-next 2018-05-11 16:29:53 -07:00
Doug Gregor
09446defef Eliminate yet more SubstitutionLists from SIL in search of a steady-state 2018-05-11 13:18:06 -07:00
swift-ci
c1ab228590 Merge remote-tracking branch 'origin/master' into master-next 2018-05-07 11:49:14 -07:00
Michael Gottesman
a264b1ed9c [gardening] Use SmallPtrSetImpl instead of SmallPtr<N> in more function parameters/return values.
This is good practice like using SmallVectorImpl instead of SmallVector.
2018-05-07 10:35:51 -07:00
swift-ci
ad0712c02b Merge remote-tracking branch 'origin/master' into master-next 2018-05-04 08:49:40 -07:00
David Zarzycki
8c0c55539f [SIL] NFC: Rename misleading getSwiftRValueType() to getASTType()
Reference storage types are not RValues. Also, use more SILType helper
methods to avoid line wrap.
2018-05-04 08:14:38 -04:00
swift-ci
5f22c9ceec Merge remote-tracking branch 'origin/master' into master-next 2018-05-03 13:49:29 -07:00
swift-ci
5ce78da1d3 Merge remote-tracking branch 'origin/master' into master-next 2018-05-03 08:49:46 -07:00
Doug Gregor
d5c9f71a6d [SIL] Switch InitBlockStorageHeaderInst over to SubstitutionMap. 2018-05-03 08:48:54 -07:00
Doug Gregor
7e08b66499 [SIL] Use SubstitutionMap in KeyPathInst rather than SubstitutionList. 2018-05-03 08:48:54 -07:00
Doug Gregor
5724338abe [SIL] Switch "external" key path pattern components to SubstitutionMap.
Eliminates another source of SubstitutionList.
2018-05-03 08:48:54 -07:00
Doug Gregor
d2cf60c465 Revert "[SIL] Replace more SubstitutionLists with SubstitutionMap" 2018-05-03 08:35:20 -07:00
swift-ci
32853a9ed1 Merge remote-tracking branch 'origin/master' into master-next 2018-05-03 01:29:45 -07:00
Doug Gregor
216906cf59 [SIL] Switch InitBlockStorageHeaderInst over to SubstitutionMap. 2018-05-03 00:05:21 -07:00
Doug Gregor
a6dfe0ff88 [SIL] Use SubstitutionMap in KeyPathInst rather than SubstitutionList. 2018-05-03 00:05:21 -07:00
Doug Gregor
25b9afe20f [SIL] Switch "external" key path pattern components to SubstitutionMap.
Eliminates another source of SubstitutionList.
2018-05-03 00:05:21 -07:00
swift-ci
49b2c7fe2a Merge remote-tracking branch 'origin/master' into master-next 2018-05-01 12:08:52 -07:00
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