Commit Graph

3719 Commits

Author SHA1 Message Date
swift-ci
f80606acce Merge remote-tracking branch 'origin/master' into master-next 2018-05-19 17:29:42 -07:00
Slava Pestov
ebb1198d57 AST: There's no longer any reason to pass SubstitutionMap by const reference
SubstitutionMaps are now just a trivial pointer-sized value, so
pass them by value instead.

I did have to move a couple of functors from Type.h to SubstitutionMap.h
to resolve some issues with forward declarations.
2018-05-19 00:45:36 -07:00
swift-ci
2714ed70c6 Merge remote-tracking branch 'origin/master' into master-next 2018-05-15 14:09:30 -07:00
John McCall
f75d0e76d2 Merge pull request #16615 from rjmccall/abi-accessibility
Perform value operations opaquely on ABI-inaccessible types
2018-05-15 16:59:52 -04:00
swift-ci
3c1802a186 Merge remote-tracking branch 'origin/master' into master-next 2018-05-15 13:29:11 -07:00
Andrew Trick
7fc2d6267b Rename findAccessedStorageOrigin() to findAccessedStorageNonNested(). 2018-05-15 12:29:19 -07:00
Andrew Trick
495d5aecf6 [exclusivity] Add an access marker folding pass.
Use AccessedStorageAnalysis to find access markers with no nested conflicts.

This optimization analyzes the scope of each access to determine
whether it contains a potentially conflicting access. If not, then it
can be demoted to an instantaneous check, which still catches
conflicts on any enclosing outer scope.

This removes up to half of the runtime calls associated with
exclusivity checking.
2018-05-15 12:29:19 -07:00
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
23f5553589 Merge remote-tracking branch 'origin/master' into master-next 2018-05-11 23:09:52 -07:00
Doug Gregor
ef020c74aa Eliminate all vestiges of Substitution and SubstitutionList.
Introduced during the bring-up of the generics system in July, 2012,
Substitution (and SubstitutionList) has been completely superseded by
SubstitutionMap. R.I.P.
2018-05-11 21:43:40 -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
Doug Gregor
4b5abbddbc [SIL] Teach *ApplyInst to traffic in SubstitutionMap.
Push SubstitutionMaps through most of SILGen and the SIL optimizers
that involve the various *ApplyInsts.
2018-05-11 13:18:06 -07:00
swift-ci
fed5ddea66 Merge remote-tracking branch 'origin/master' into master-next 2018-05-11 04:29:13 -07:00
David Zarzycki
77494e2ba5 [SIL] NFC: Keep building after clang r332076 2018-05-11 06:32:25 -04:00
swift-ci
ebc2c0e05a Merge remote-tracking branch 'origin/master' into master-next 2018-05-10 19:49:11 -07:00
swift-ci
02045f1765 Merge pull request #16522 from vedantk/cov-symtab 2018-05-10 19:35:20 -07:00
Vedant Kumar
bdfd220968 [Coverage] Mark symtab entries as guaranteed after intrinsic lowering
SIL optimizations may rewrite profiling intrinsics in a way that IRGen
can't lower (r://39146527). Don't claim that a coverage mapping has a
guaranteed associated symbol table entry when this happens.

I have not added a test, as this is a defensive workaround until we can
land add a SIL verifier check that prevents profiling intrinsics from
being rewritten.

rdar://40133800
2018-05-10 18:51:40 -07:00
swift-ci
bed7dc124d Merge remote-tracking branch 'origin/master' into master-next 2018-05-10 16:09:03 -07:00
Andrew Trick
6a48b2d02d Merge pull request #16491 from atrick/enforce-keypath-exclusivity-as-error
Enforce keypath exclusivity as an error.
2018-05-10 16:03:01 -07:00
Andrew Trick
fe326266cc [exclusivity] Add a [builtin] flag to begin_[unpaired_]access.
This flag supports promoting KeyPath access violations to an error in
Swift 4+, while building the standard library in Swift 3 mode. This is
only necessary as long as the standard library continues to build in
Swift 3 mode. Once the standard library build migrates, it can all be
ripped out.

<rdar://problem/40115738> [Exclusivity] Enforce Keypath access as an error, not a warning in 4.2.
2018-05-09 21:42:37 -07:00
swift-ci
00a95cda83 Merge remote-tracking branch 'origin/master' into master-next 2018-05-09 19:49:22 -07:00
Erik Eckstein
df6a3af5a5 SILCombine: remove a problematic cast peephole optimization.
This optimization inserted bit casts based on structural properties of types.
It caused a miscompile in case of imported C structs. Also, by inspection, I found that checks for resilient types are missing.
As this optimization does not have any noticeable impact on the benchmarks it's better to remove it at all, together with the complexity for checking the types.

rdar://problem/40074362
2018-05-09 13:28:20 -07:00
swift-ci
524ebb1e95 Merge remote-tracking branch 'origin/master' into master-next 2018-05-08 17:29:29 -07:00
Michael Gottesman
fa157871f0 [func-sig-opts][+0->+1] Extract out the LinearLifetimeChecker from the Ownership verifier.
I am doing this for two reasons:

1. I am going to use this in function signature opts to prove that a guaranteed
parameter is "consumed".
2. It puts the ownership verifier on a diet.

rdar://38196046
2018-05-08 16:47:17 -07:00
swift-ci
4a81a403ad Merge remote-tracking branch 'origin/master' into master-next 2018-05-08 16:29:16 -07:00
Michael Gottesman
903a9835b4 Merge pull request #16447 from gottesmm/pr-706a441a07092d7de9b9cb987dfcac30cfe7ec08
[func-sig-opts][+0->+1] Rename GeneralizedUser -> BranchPropagatedUse…
2018-05-08 16:20:47 -07:00
swift-ci
17045afe85 Merge remote-tracking branch 'origin/master' into master-next 2018-05-08 16:09:15 -07:00
Andrew Trick
fb3ae2549c Merge pull request #16296 from atrick/exclusivity-fix
Shoring up the exclusivity diagnostics.
2018-05-08 15:56:57 -07:00
swift-ci
7b974f8427 Merge remote-tracking branch 'origin/master' into master-next 2018-05-08 15:29:15 -07:00
Andrew Trick
55ba1437d7 Add a comment on getCalleeArgIndexOfFirstAppliedArg() that I find personally helpful. 2018-05-08 12:44:41 -07:00
Michael Gottesman
0de2b76ec9 [func-sig-opts][+0->+1] Rename OwnershipChecker.h => OwnershipUtils.h
I am going to be expanding this to contain more general utilities so naming the
file OwnershipChecker.h really doesn't make sense.

rdar://38196046
2018-05-08 11:21:06 -07:00
Michael Gottesman
f6666aaac1 [func-sig-opts][+0->+1] Rename GeneralizedUser -> BranchPropagatedUser and move it to its own header.
rdar://38196046
2018-05-08 11:20:48 -07:00
swift-ci
b966d3fbc1 Merge remote-tracking branch 'origin/master' into master-next 2018-05-07 08:29:22 -07:00
Jordan Rose
7641aa77ea Merge pull request #16406 from jrose-apple/malfunction
[SIL] Avoid std::function in transform-iterators
2018-05-07 08:28:47 -07:00
swift-ci
d24ea7f319 Merge remote-tracking branch 'origin/master' into master-next 2018-05-04 18:29:26 -07:00
Andrew Trick
0a2c935e06 Merge pull request #16398 from atrick/access-analysis-callee-origin
Access analysis callee origin
2018-05-04 18:26:08 -07:00
Jordan Rose
f6e85d1d64 [SIL] Simplify SILInstructionResultArray::iterator
No major change in execution time, but why make things more
complicated than they need to be? It does make
SILInstructionResultArray::begin drop out of the top ten functions in
the inverted call stack (not counting performLLVM).
2018-05-04 17:48:52 -07:00
Jordan Rose
5bf9b9ac76 [SIL] Avoid std::function in transform-iterators
In a non-rigorous test, this change shaves off 20% of the time spent
in SIL optimizations for the standard library in a +Asserts build.
(Admittedly the wins for a no-asserts build will be much lower because
SILInstructionResultArray has a bunch of assertions in its
constructor.)
2018-05-04 17:48:52 -07:00
Andrew Trick
c34b50d545 Fix a comment typo. 2018-05-04 13:20:40 -07:00
swift-ci
8ee09ae579 Merge remote-tracking branch 'origin/master' into master-next 2018-05-04 11:09:35 -07:00
swift-ci
38cb9e9b73 Merge pull request #16379 from DougGregor/sil-cloner-substitution-map 2018-05-04 10:50:16 -07:00
Doug Gregor
5b6b335e8a [SIL Cloner] Substitute for open existentials in substitution maps.
When introducing SIL cloner support for substitution maps, I failed
to account for the separate handling of substitutions for opened
existentials. Perform this substitution when needed.

Fixes rdar://problem/39976572.
2018-05-04 09:54:53 -07:00
Doug Gregor
f0c0c6cd24 [SIL Cloner] Only substitute opened archetypes into conformances when needed.
Substitution can be expensive; only do it when there might be something to
substitute. While here, use QueryTypeSubstitutionMapOrIdentity rather than
open-coding the same thing in a lambda.
2018-05-04 09:53:11 -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
604f5930fe Merge remote-tracking branch 'origin/master' into master-next 2018-05-03 19:29:42 -07:00