Commit Graph

1223 Commits

Author SHA1 Message Date
Doug Gregor
c9b50e0171 [SILGen] Eliminate SubstitutionList from the LValue infrastructure. 2018-05-11 17:37:27 -07:00
Doug Gregor
921d41ca10 [SILGen] Eliminate emitApplyOfLibraryIntrinsic() for SubstitutionList.
There was only one caller; update it to use the SubstitutionMap version.
2018-05-11 17:37:26 -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
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
Doug Gregor
408aaa5332 [SIL] Use SubstitutionMap in BuiltinInst. 2018-05-03 08:48:55 -07:00
Doug Gregor
d2cf60c465 Revert "[SIL] Replace more SubstitutionLists with SubstitutionMap" 2018-05-03 08:35:20 -07:00
Doug Gregor
ed1983d9d0 [SIL] Use SubstitutionMap in BuiltinInst. 2018-05-03 00:05:21 -07:00
Doug Gregor
192234415d [AST] Store SubstitutionMaps in ConcreteDeclRef and Witness data structures.
Replace two prominent uses of SubstitutionList, in ConcreteDeclRef and
Witness, with SubstitutionMap. Deal with the myriad places where we
now have substitution maps and need substitution lists (or vice versa)
caused by this change.

Overall, removes ~50 explicit uses of SubstitutionList (of ~400).
2018-05-02 13:38:14 -07:00
Slava Pestov
db9380f9a8 SILGen: Fix latent bugs in emitApplyAllocatingInitializer()
The condition we want to test for emitting a downcast is isRequired(),
not isInheritable(). The latter is only true for convenience
initializers.

The other fix is that we actually have to emit a class_method
dispatch here to support class hierarchies conforming to literal
protocols.
2018-05-01 17:40:12 -06:00
Doug Gregor
0ea8f3da66 [SILGen] Fix no-parameter subscript accessor emission more thoroughly. 2018-04-26 13:53:28 -07:00
Doug Gregor
d7c68871cb [SILGen] Don't assert on subscripts with no index arguments. 2018-04-26 10:05:52 -07:00
Arnold Schwaighofer
e36655fddc SILGen: Remove PostponedCleanup in favor or the SIL pass that fixes
closure lifetimes.

SILGen will now unconditionally emit

  %cvt = convert_escape_to_noescape [guaranteed] %op

instructions. The mandatory ClosureLifetimeFixup pass ensures that %op's
lifetime spans %cvt's uses.

The code in DefiniteInitialization that handled a subset of cases is
removed.
2018-04-13 13:44:09 -07:00
Slava Pestov
b2e85f7eb5 SILGen: Use a concrete conformance if we have a witness_method call on a concrete type 2018-04-05 17:17:24 -07:00
Michael Gottesman
e567bc9028 [+0-all-args] Enable +0 normal arguments.
rdar://34222540
2018-03-19 20:25:31 -07:00
Mark Lacey
1dec7cc70e Remove SILGenModule::getLoweredEnumElementDecl.
This became a no-op at some point during the IUO work.
2018-03-14 23:59:26 -07:00
Slava Pestov
dac689a470 SILGen: Remove unused method 2018-03-14 17:21:39 -07:00
Slava Pestov
ebf017042a SILGen: Simplify AccessorBaseArgPreparer::prepareAccessorObjectBaseArg()
It's always an error to materialize an rvalue and pass it
as inout, even if the base type is class-constrained.
2018-03-14 16:14:36 -07:00
Joe Groff
2d194e7765 Merge pull request #15034 from jckarter/keypath-resilience-silgen
SILGen: Emit property descriptors for (some) decls that need them.
2018-03-07 16:49:36 -08:00
Joe Groff
a8e3c4fc8b SILGen: Emit property descriptors for (some) decls that need them.
If a property or subscript is referenceable from other modules, we need to give it a descriptor so that we can reliably build an equivalent key path in or out of that module.

There are some cases that we should handle but don't yet:

- Global and static properties ought to be key-path-able someday, so we should make descriptors for them, but this might need a new key path component kind.
- Subscripts with indexes that aren't Hashable in the current module ought to get descriptors too, in case we ever support non-hashable key path components, and also because a generic subscript might be substituted with Hashable types by an external user, or an external module might post-hoc extend a type to be Hashable, so we really need to change things so that the client supplies the hashing and equality implementations for the indexes instead of the descriptor.
2018-03-07 15:32:12 -08:00
Joe Groff
34e77c0f25 Merge pull request #14893 from jckarter/keypath-resilience-silgen-refactor
SILGen: Refactor key path component lowering.
2018-03-01 11:19:26 -08:00
Joe Groff
2f0a3f2e2d SILGen: Refactor key path component lowering.
Factor out the code to lower an individual key path component to be independent of overall KeyPathExpr lowering, so that we can soon reuse the same code paths to build property descriptors for resilient properties. NFC intended.
2018-02-28 15:06:44 -08:00
swift-ci
07c7b5a526 Merge pull request #14886 from gottesmm/pr-1d8a01abff8ba53eef44341acc0e36484a133f95 2018-02-28 14:04:13 -08:00
Michael Gottesman
dc56ec150e [+0-normal-args] When partially applying a super method, be sure that upcasted self is at +1.
Since I used ensurePlusOne, this should not have any effect on the compiler
today. This happens quite often once "normal arguments" are at +0 though.

I also changed this code to use SILGenBuilder APIs to ensure that ownership is
forwarded correctly.

Found when updating SILGen tests for +0.

rdar://34222540
2018-02-28 12:47:10 -08:00
Michael Gottesman
56556b785f [silgenapply] Centralize top level SILGenFunction entrypoints (i.e. SILGenFunction entrypoints) in 1 section of SILGenApply.cpp. 2018-02-27 12:59:35 -08:00
Michael Gottesman
1de4cc0fc3 [silgen] In SILGenApply.cpp, consistently indent classes in LLVM style.
Some of the classes in this file were using LLVM style for long classes, i.e.:

```
namespace {
class Foo {
  ... long class ...
};
} // end anonymous namespace
```

Other places, we were adding a level of indentation, i.e.:

```
namespace {
  class Foo {
    ... long class ...
  };
} // end anonymous namespace
```

This PR just standardizes the classes in this file that follow the later style,
to instead follow the former style.
2018-02-27 12:59:35 -08:00
Michael Gottesman
b74ed23022 [silgen] Add some "flags" to SILGenApply.cpp to organize it a little better. 2018-02-27 12:59:26 -08:00
swift-ci
706e3dbba8 Merge pull request #14857 from gottesmm/pr-2b8da82466d75390465abccce3442cda2d85c5ca 2018-02-27 12:25:03 -08:00
Michael Gottesman
b6bffcaced [silgen] prepareApplyExpr => CallEmission::forApplyExpr.
prepareApplyExpr is a static function that changes an expr into a CallEmission
and has no other uses beyond that purpose. This is the definition of a static
factory method. This PR performs that refactor.

NFC.
2018-02-27 11:01:46 -08:00
Michael Gottesman
536bc5a4e7 [silgen] Add some comments to Callee's constructors that explain which constructor corresponds to which factory methods.
NFC.
2018-02-27 10:01:06 -08:00
Arnold Schwaighofer
025a8b909a Fix PostponedCleanup and use it in more places.
It can't be moved because there are pointers to it
2018-02-13 04:19:59 -08:00
Arnold Schwaighofer
64943836ba SILGen: Support for trivial @noescape function types
- Emit a withoutActuallyEscapingClosure partial apply
This is to convert an @noescape closure to an escaping closure.
This needs to be done in preparation of @noescape closure contexts
becoming trivial.

- Insert escaping to noescape conversions

- Fix SILGen for @noescape

- Postpone closure cleanups to outside the argument scope

- Apply postponement recursively for closures passed to subscripts

- Only skip applying escapeness conversions for Swift thick functions

- Fix parameter convention for noescape closures in thunks

Part of:
SR-5441
rdar://36116691
2018-02-13 04:19:59 -08:00
Mark Lacey
b4b66bc8e8 Replace getAnyOptionalObjectType with getOptionalObjectType. 2018-02-05 23:59:00 -08:00
Arnold Schwaighofer
fac09e985b SIL : Use the enum 's generic signature and the payloads type for an indirect enum payload's box type.
i.e for:

enum Indirect<T> {
  indirect cast payload(first: T, second :T)
}

let _ = Indirect<X>

The payload's SIL box type will be:

$<t_0_0> { var (first: t_0_0, second: t_0_0) } <X>

rdar: //36799330
2018-01-27 15:33:47 -08:00
John McCall
52bb547a7e Merge pull request #13866 from rjmccall/accessor-decl
Split AccessorDecl out from FuncDecl.  NFC.
2018-01-12 17:02:35 -05:00
John McCall
7f0f8830cd Split AccessorDecl out from FuncDecl. NFC.
This has three principal advantages:

- It gives some additional type-safety when working
  with known accessors.

- It makes it significantly easier to test whether a declaration
  is an accessor and encourages the use of a common idiom.

- It saves a small amount of memory in both FuncDecl and its
  serialized form.
2018-01-12 14:20:27 -05:00
Michael Gottesman
20d47009a7 [+0-all] Use +1 for builtins. 2018-01-12 10:09:49 -08:00
Slava Pestov
72735ec1c6 SILGen: Remove unnecessary isFinal() check from getBaseAccessorFunctionRef() 2018-01-04 21:53:35 -08:00
Slava Pestov
2590142b7b SILGen: Remove shouldReferenceForeignAccessor()
Also, the 'isDirectAccess' parameter to various methods is now dead,
because it was never being set to true in the foreign case anyway.
2018-01-04 21:53:34 -08:00
Mark Lacey
b6430d0644 IUO: Add ImplicitlyUnwrappedFunctionConversionExpr.
This expression node is only used when applying the results of
expression type checking. It initially appears above the function
reference that returns an optional that needs to be unwrapped, and
then when dealing with function application we remove this and insert
a node to force-unwrap the result of the function application.
2018-01-04 11:40:45 -08:00
Andrew Trick
17fa484f04 SILGen. Fix temporary LValue cleanup.
Use the LValue formal evaluation scope to destroy temporary lvalues that aren't
part of the expression's resulting value.

Disable an old hack that destroyed call site arguments after the call.

This is the first step in cleanup up LValue materialization.
2018-01-01 19:05:22 -08:00
Slava Pestov
c16c2c35bf SIL: Move getOverriddenVTableEntry() from TypeLowering to SILDeclRef
There's no reason for this to be an instance method on the TypeLowering
object, because it (no longer?) uses any type lowering operations.
2017-12-18 23:28:33 -08:00
Michael Gottesman
62e6d2f65d [silgen] Teach emitApplyOfLibraryIntrinsic how to convert arguments to the appropriate +0/+1 convention.
Sometimes we need to copy/borrow now.

*NOTE* right now it is basically impossible to test this using a fake stdlib
since I would need to implement Array or String in my local stdlib since this
comes up via ArrayToPointer/friends. If/when we flip the switch though, this is
guaranteed to be tested by stdlib dependent tests that we already have in tree.

rdar://34222540
2017-12-05 12:59:10 -08:00
Slava Pestov
1f79af7504 SIL: Use objc_method instruction for Objective-C protocol method calls
Fixes <rdar://problem/15933365>.
2017-11-29 16:26:43 -08:00
Arnold Schwaighofer
ea9907ae15 Revert "SIL: Use objc_method instruction for Objective-C protocol method calls" 2017-11-29 11:19:46 -08:00
Slava Pestov
1ee0970934 SIL: Use objc_method instruction for Objective-C protocol method calls
Fixes <rdar://problem/15933365>.
2017-11-29 01:22:05 -08:00
Arnold Schwaighofer
3e04f21a41 SIL: Remove EnableGuaranteedClosureContext now that it is the default 2017-11-27 07:25:03 -08:00
Slava Pestov
8f10485798 SILGen: Tighten up assertions 2017-11-19 23:58:48 -05:00
Michael Gottesman
04056ce243 [silgen] When emitting convertBridgeObjectToRef, forward ownership through the instruction rather than unconditionally adding a cleanup.
Otherwise, we may put cleanups on borrowed values.

rdar://34222540
2017-11-19 16:00:45 -08:00
Arnold Schwaighofer
ce2966dd6e Merge pull request #12957 from aschwaighofer/callee_guaranteed_closures
SILGen: Remaining fixes for @callee_guaranteed closures and enable it
2017-11-16 11:12:54 -08:00
Slava Pestov
75fe659eab SILGen: Fix a warning 2017-11-15 22:52:28 -08:00