Commit Graph

3719 Commits

Author SHA1 Message Date
Michael Gottesman
598a541a36 Merge pull request #27928 from gottesmm/pr-6389dd6f50f2b37f04a9b24d79436b133411accc
[inlining] Fix two bugs around inlining of coroutines.
2019-10-29 23:01:55 -07:00
swift-ci
bce668175f Merge remote-tracking branch 'origin/master' into master-next 2019-10-29 21:49:52 -07:00
swift-ci
2534af7045 Merge pull request #27942 from ravikandhadai/oslog-append-interpolation-consteval-improved 2019-10-29 21:48:50 -07:00
Ravi Kandhadai
861c0aaca9 [OSLogOptimization][stdlib/private] Make string interpolation methods
of OSLogMessage constant evaluable and remove @_transparent annotation
from the methods. Also, improve diagnostics in the OSLogOptimization
pass as now it rely on seeing the appendInterpolation/Literal calls.
2019-10-29 19:35:37 -07:00
swift-ci
8c1c35a36c Merge remote-tracking branch 'origin/master' into master-next 2019-10-29 17:10:37 -07:00
Robert Widmann
4f84c2a628 Use the default constructor to clean up some APIs
Use ProtocolConformanceRef::forInvalid() in implementations only as a semantic signal.  In one place, use the default constructor to drop the final use of Optional<ProtocolConformanceRef>.
2019-10-29 16:56:22 -07:00
Robert Widmann
3e1a61f425 [NFC] Fold The Tri-State In Optional<ProtocolConformanceRef>
ProtocolConformanceRef already has an invalid state.  Drop all of the
uses of Optional<ProtocolConformanceRef> and just use
ProtocolConformanceRef::forInvalid() to represent it.  Mechanically
translate all of the callers and callsites to use this new
representation.
2019-10-29 16:55:56 -07:00
Varun Gandhi
033be473a8 [NFC] Change ValueOwnershipKind::Any to ValueOwnershipKind::None in comments. (#27925)
Follow-up to PR #27879.
2019-10-29 16:50:45 -07:00
Michael Gottesman
8264009e83 [inlining] Fix inlining of coroutines to properly handle owned values passed as guaranteed args.
Previously, we were inserting the end_borrow after the call site, rather than
after the end_apply, abort_apply.
2019-10-29 09:25:46 -07:00
Xi Ge
64c0680686 Merge remote-tracking branch 'apple/master' into master-next 2019-10-28 10:19:36 -07:00
Michael Gottesman
acfaa91798 Merge pull request #27903 from gottesmm/pr-db9fd274761ac09be56a104f6eec8792448e7544
[ownership] Update the ownership utils infrastructure to treat mark_dependence as forwarding.
2019-10-27 20:14:20 -07:00
Michael Gottesman
750c4cc487 [sil] Refactor out BeginApplyInst::getCoroutineEndPoints() impl from Inliner into method on the class itself.
I found this to be really useful outside of the inliner since this is exactly
what I needed to ensure that borrowed values used by a begin_apply, have the
end_apply/abort_apply as uses. I am adding that in a forthcoming commit.

NFC.
2019-10-27 18:38:58 -07:00
Michael Gottesman
179cddcc04 [ownership] Update the ownership utils infrastructure to treat mark_dependence as forwarding.
We have already been forwarding ownership in terms of ValueOwnership and
OwnershipUtils, I just had not setup certain parts of the ownership utils to
recognize mark_dependence as forwarding of guaranteed values. We did not hit
this before since we have not had been late enough in the pipeline to get
mark_dependence on guaranteed values.

In the future, we want to move to mark_dependence only taking guaranteed
values. This is a first step in that direction that at the same time allows me
to enable ownership lowering after diagnostics sooner since fixing the bigger
issue would be a relatively medium sized project.
2019-10-27 16:32:09 -07:00
Michael Gottesman
7ee5ad7318 [sil] Rename {,Strong}Copy{Unowned,Unmanaged}. 2019-10-26 17:03:47 -07:00
Joe Groff
1a1d9e63f7 Merge pull request #27887 from jckarter/subst-sil-function-type-interface
SIL: Add fields to SILFunctionType for substituted function types.
2019-10-26 10:44:48 -07:00
Joe Groff
03c7919b4a SIL: Add fields to SILFunctionType for substituted function types.
https://forums.swift.org/t/improving-the-representation-of-polymorphic-interfaces-in-sil-with-substituted-function-types/29711

This prepares SIL to be able to more accurately preserve the calling convention of
polymorphic generic interfaces by letting the type system represent "substituted function types".
We add a couple of fields to SILFunctionType to support this:

- A substitution map, accessed by `getSubstitutions()`, which maps the generic signature
  of the function to its concrete implementation. This will allow, for instance, a protocol
  witness for a requirement of type `<Self: P> (Self, ...) -> ...` for a concrete conforming
  type `Foo` to express its type as `<Self: P> (Self, ...) -> ... for <Foo>`, preserving the relation
  to the protocol interface without relying on the pile of hacks that is the `witness_method`
  protocol.

- A bool for whether the generic signature of the function is "implied" by the substitutions.
  If true, the generic signature isn't really part of the calling convention of the function.
  This will allow closure types to distinguish a closure being passed to a generic function, like
  `<T, U> in (*T, *U) -> T for <Int, String>`, from the concrete type `(*Int, *String) -> Int`,
  which will make it easier for us to differentiate the representation of those as types, for
  instance by giving them different pointer authentication discriminators to harden arm64e
  code.

This patch is currently NFC, it just introduces the new APIs and takes a first pass at updating
code to use them. Much more work will need to be done once we start exercising these new
fields.

This does bifurcate some existing APIs:

- SILFunctionType now has two accessors to get its generic signature.
  `getSubstGenericSignature` gets the generic signature that is used to apply its
  substitution map, if any. `getInvocationGenericSignature` gets the generic signature
  used to invoke the function at apply sites. These differ if the generic signature is
  implied.
- SILParameterInfo and SILResultInfo values carry the unsubstituted types of the parameters
  and results of the function. They now have two APIs to get that type. `getInterfaceType`
  returns the unsubstituted type of the generic interface, and
  `getArgumentType`/`getReturnValueType` produce the substituted type that is used at
  apply sites.
2019-10-25 13:38:51 -07:00
Michael Gottesman
26a734e58e [sil] Rename ValueOwnershipKind::{Any,None} 2019-10-25 10:28:25 -07:00
Brent Royal-Gordon
ecf76c8fdf Merge pull request #27586 from brentdax/everything-evil
Fix keypath-as-function crasher
2019-10-15 17:54:13 -07:00
swift-ci
eb248762b6 Merge remote-tracking branch 'origin/master' into master-next 2019-10-14 17:29:44 -07:00
Brent Royal-Gordon
e01ce6ccec Fix property wrapper profiling bug 2019-10-14 15:59:39 -07:00
Brent Royal-Gordon
ca25640cc3 Merge branch 'master' into everything-evil 2019-10-14 13:24:03 -07:00
swift-ci
f1fc228ebc Merge remote-tracking branch 'origin/master' into master-next 2019-10-14 12:58:24 -07:00
Ravi Kandhadai
d037183a48 Merge pull request #27640 from ravikandhadai/constexpr-closure-support
[Constant Evaluator] Add support for interpreting SIL code with partial applies (i.e., closure creations).
2019-10-14 12:29:34 -07:00
swift-ci
0ef58de2c7 Merge remote-tracking branch 'origin/master' into master-next 2019-10-14 10:49:48 -07:00
Erik Eckstein
8e21379ffc SILOptimizer: always assume that inout arguments are not aliasing
We can do that now as we have exclusivity checking
2019-10-14 16:35:50 +02:00
swift-ci
5193a0ee4d Merge remote-tracking branch 'origin/master' into master-next 2019-10-14 06:29:36 -07:00
Erik Eckstein
33afd0eb2b MemoryLifetime: Make debug dump functions for bitsets usable from other optimizations
NFC
2019-10-14 13:07:22 +02:00
Brent Royal-Gordon
ab96afacb5 [SILGen] Assert that captures have been computed
Before using the capture info, SILGen now asserts that it has computed, except for declarations which are not in a local context and therefore can’t have captures.

This causes failures in REPL tests, but they are actual failures—there’s a bug in TypeCheckREPL.
2019-10-11 19:16:58 -07:00
Ravi Kandhadai
940119c5ff [Constant Evaluator] Add support for interpreting SIL code with
partial applies (i.e., closure creations).

A new SymbolicValue: SymbolicClosure represents a closure. It
tracks the SILFunction corresponding to the target of the closure
and the SIL and Symbolic Values of the captured arguments. The
representation does not impose that all captured values must have an
associated symbolic value. This allows the evaluator to track
creations of closures whose captured arguments or bodies are not
constant evaluable.

This commit does not add support for closure applications. It only
adds suppport for closure creations, which correspond to partial_apply
instructions in SIL.
2019-10-11 18:54:19 -07:00
swift-ci
da686f2aa7 Merge remote-tracking branch 'origin/master' into master-next 2019-10-09 17:09:31 -07:00
Jordan Rose
a1ea211f22 Add llvm::iterator_range to LLVM.h
If we're going to get rid of swift::IteratorRange, let's make
llvm::iterator_range easy to use.

No functionality change.
2019-10-08 15:24:06 -07:00
Steve (Numerics) Canon
c2bd0546b8 Merge remote-tracking branch master into master-next 2019-10-08 16:25:47 -04:00
Jordan Rose
7b0d081965 Remove IteratorRange in favor of llvm::iterator_range
Now that llvm::iterator_range has 'empty', there's not enough reason to
keep our own version of it in the Swift repo.

No functionality change.
2019-10-08 11:23:28 -07:00
Umberto Raimondi
4055530278 Update assert on SymbolicValue size (#27515)
Since the storage is a multiple of uint64_t (derived by what LLVM's APInt does) we want to check for 2*uin64_t here, even on 32bit platforms.
2019-10-08 10:44:45 -07:00
marcrasi
cb85ecf124 SymbolicValue is_pod -> is_trivial
is_pod is getting deprecated. All we really care about is that the type stay trivial. (And that's just a performance thing, I don't think we rely on that anywhere).
2019-10-03 10:37:38 -07:00
swift-ci
b91537d1b4 Merge remote-tracking branch 'origin/master' into master-next 2019-10-02 16:09:39 -07:00
Jordan Rose
0746d1e896 Merge pull request #27493 from jrose-apple/this-isnt-even-my-final-form
Remove TransformArrayRef, FilterIterator, and FilterRange
2019-10-02 16:09:16 -07:00
swift-ci
7e7410cab7 Merge remote-tracking branch 'origin/master' into master-next 2019-10-02 15:09:29 -07:00
Michael Gottesman
6d789e36a9 Merge pull request #27499 from gottesmm/pr-dc6371871f1797246355f4fc6795f1d0116e360a
[ownership] Allow for the ownership verifier to be run in non-asserts…
2019-10-02 15:06:52 -07:00
swift-ci
ded4197d59 Merge remote-tracking branch 'origin/master' into master-next 2019-10-02 13:29:41 -07:00
swift-ci
62ccf81f77 Merge pull request #27417 from atrick/cleanup-cfg-utils 2019-10-02 13:12:27 -07:00
Michael Gottesman
d535e3e6cf [ownership] Allow for the ownership verifier to be run in non-asserts builds if -sil-verify-all is set.
This is matching the behavior of the rest of the verifier. NOTE: Both early exit
if said flag is not set, so this should not hit compile time in any way unless
the flag is set (in which case someone is asking for more verification...).

While I was here, I also noticed an ancillary bug where we were not checking if
a value was from in a block that was in a SILGlobalVariable or a SILFunction. We
already had a check that stopped this early when validating ownership of
SILInstructions. I guess we have never had a situation where the verifier was
given values to run on SILGlobalVariable blocks.
2019-10-02 12:36:17 -07:00
Michael Gottesman
7f24c992e0 [gardening] Eliminate unneeded include of <string>. 2019-10-02 11:51:41 -07:00
Andrew Trick
22500e7e6b Update the coding style for all code moved in the previous commit.
Requested by gottesmm during review.

Update the variable naming conventions to lower-camel.

Run clang-format.

I'm sure I missed some local variables somewhere--this was a best
effort.
2019-10-02 11:34:54 -07:00
Andrew Trick
bddc69c8a6 Organize SILOptimizer/Utils headers. Remove Local.h.
The XXOptUtils.h convention is already established and parallels
the SIL/XXUtils convention.

New:
- InstOptUtils.h
- CFGOptUtils.h
- BasicBlockOptUtils.h
- ValueLifetime.h

Removed:
- Local.h
- Two conflicting CFG.h files

This reorganization is helpful before I introduce more
utilities for block cloning similar to SinkAddressProjections.

Move the control flow utilies out of Local.h, which was an
unreadable, unprincipled mess. Rename it to InstOptUtils.h, and
confine it to small APIs for working with individual instructions.
These are the optimizer's additions to /SIL/InstUtils.h.

Rename CFG.h to CFGOptUtils.h and remove the one in /Analysis. Now
there is only SIL/CFG.h, resolving the naming conflict within the
swift project (this has always been a problem for source tools). Limit
this header to low-level APIs for working with branches and CFG edges.

Add BasicBlockOptUtils.h for block level transforms (it makes me sad
that I can't use BBOptUtils.h, but SIL already has
BasicBlockUtils.h). These are larger APIs for cloning or removing
whole blocks.
2019-10-02 11:34:54 -07:00
Jordan Rose
8b8c88e258 Improve swift::TransformRange enough to delete TransformArrayRef
We have a lot of "transform a range" types already:
llvm::mapped_iterator, swift::TransformRange and
swift::TransformIterator, and swift::ArrayRefView for static
transformations. This gets rid of one more layer without losing
any real functionality.
2019-10-02 10:23:05 -07:00
swift-ci
5e50242b5e Merge remote-tracking branch 'origin/master' into master-next 2019-09-30 16:09:53 -07:00
Robert Widmann
75670c1727 Merge pull request #27436 from CodaFi/signed-sealed-delivered
[NFC] Adopt TypeBase-isms for GenericSignature
2019-09-30 15:50:42 -07:00
Joe Groff
b92c37e434 Merge branch 'master' into master-next 2019-09-30 15:43:57 -07:00
Robert Widmann
5a8d0744c3 [NFC] Adopt TypeBase-isms for GenericSignature
Structurally prevent a number of common anti-patterns involving generic
signatures by separating the interface into GenericSignature and the
implementation into GenericSignatureBase.  In particular, this allows
the comparison operators to be deleted which forces callers to
canonicalize the signature or ask to compare pointers explicitly.
2019-09-30 14:04:36 -07:00