Commit Graph

221 Commits

Author SHA1 Message Date
Arnold Schwaighofer
51c31a3506 LoadableByAddress: Handle escape to noescape casts 2018-02-13 04:19:59 -08:00
Mark Lacey
b4b66bc8e8 Replace getAnyOptionalObjectType with getOptionalObjectType. 2018-02-05 23:59:00 -08:00
Joe Shajrawi
350e92119b IRGen: fix a corner-case wherein a partial_apply was not converted in LoadableByAddress
It cleans up shouldTransformParameter, fixing a corner-case for optional function parameter, and re-creates *all* partial applies that only contain function/optional function parameters
2018-01-26 10:09:44 -08:00
Adrian Prantl
cb125bd3f9 Don't drop function argument debug info in the LoadableByAddress transformation
rdar://problem/36392957
2018-01-10 08:58:56 -08:00
John McCall
3c54c0edfc IRGen and basic optimizer support for coroutines. 2018-01-09 11:35:09 -05:00
Slava Pestov
1b153ae5ac LoadableByAddress: I don't think these GenericContextScopes are necessary 2017-12-22 22:01:06 -08:00
Slava Pestov
57e206850b LoadableByAddress: If a SILFunction has a polymorphic lowered type it also has a generic environment 2017-12-22 22:01:06 -08:00
Slava Pestov
41c4afcdd3 LoadableByAddress: An ApplySite's substituted type is never polymorphic 2017-12-22 22:01:06 -08:00
Slava Pestov
0306519ff9 LoadableByAddress: Fix typo 2017-12-22 22:01:06 -08:00
Slava Pestov
b6157c0ab9 LoadableByAddress: Don't transform substitutions
Substitutions are always in terms of AST types and do not contain
SILFunctionTypes that need to be transformed here.
2017-12-22 22:01:06 -08:00
Slava Pestov
2356acceac LoadableByAddress: Idiomatic code cleanups 2017-12-22 22:01:06 -08:00
Joe Shajrawi
9c9b8527e5 LoadableByAddress: take the function type's generic environment when converting BB args 2017-12-21 16:05:12 -08:00
Joe Shajrawi
8fd6dc155e LoadableByAddress: use deterministic containers 2017-12-15 11:09:01 -08:00
Joe Shajrawi
cb33716475 Set SIL stage to lowered at the *start* of address lowering
SIL is not in a consistent state during the lowering pass. We just make sure it is correct at the end of the pass. This broke PR https://github.com/apple/swift/pull/13283 (verifying convert_function instructions in the builder)

To workaround this issue we will be running the builder’s verifier when the SIL stage != SILStage::Lowered

The SIL stage is set to lowered at the end of the module pass. This means that if this is the first lowering pass said workaround would not work.

This commit sets the SIL stage to lowered at the beginning of the module pass instead
2017-12-05 17:18:58 -08:00
swift-ci
5e7aba6568 Merge pull request #13228 from gottesmm/pr-5feef94b3c080c9a6cf510b23576b94c19fbe1a9 2017-12-02 18:38:14 -08:00
Michael Gottesman
5263e9e74e [sil] Eliminate redundant method SILFunction::hasUnqualifiedOwnership().
We can just !SILFunction::hasQualifiedOwnership(). Plus as Andy pointed out,
even ignoring the functional aspects, having APIs with names this close can
create confusion.
2017-12-02 17:42:34 -08:00
Adrian Prantl
521de91ba7 Fix the debug info generated by the LoadableByAddress transformation.
And unbreak the LLDB testsuite.

This patch fixes three problems with the original implementation:
- Use SILBuilderWithScope instead of SILBuilder to avoid holes in the
  lexical scopes.
- Use an artificial location for stores to the alloca to avoid the debugger
  stopping before the variable is initialized.
- Recognize debug_value_addr instructions referring to an alloc_stack
  instruction to avoid introducing an extra indirection in the debug info.

rdar://problem/31975108
2017-12-02 16:48:34 -08:00
Joe Shajrawi
86ea17a85f Revert "Large Types Lowering: workaround LLDB issue by adding debug_value_addr for some new alloc_stack instrs" 2017-11-30 16:28:52 -08:00
swift-ci
1e2fad5164 Merge pull request #13168 from shajrawi/large_type_lldb_workaround 2017-11-29 18:57:41 -08:00
Joe Shajrawi
db5229330e Large Types Lowering: workaround LLDB issue by adding debug_value_addr for some new alloc_stack instrs 2017-11-29 18:13:23 -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
7100a09143 IRGen: Properly communicate ownership to IRGen from the LoadableByAddress pass
Communicate to IRGen whether a indirect promoted value was guaranteed or owned

rdar://35674625
2017-11-28 16:23:22 -08:00
John McCall
5c33d2106a Add simple accessor/generator coroutine support to SILFunctionType. 2017-11-07 01:50:12 -05:00
Huon Wilson
0236db7be1 [SIL] Witness methods store the conformance from which they come. 2017-11-01 11:33:26 -07:00
Andrew Trick
2874e18713 Fix LoadableByAddress to handle convert_functions.
Handle function_ref -> convert_function -> thin_to_thick.

Fixes <rdar://problem/35059942> Failed - Lark, 3.0, Swift Package - Source Compatibility Suite (master)
2017-10-19 00:34:16 -07:00
Andrew Trick
d369aa4070 Support @noescape SIL function types. (#12420)
Support for @noescape SILFunctionTypes.

These are the underlying SIL changes necessary to implement the new
closure capture ABI.

Note: This includes a change to function name mangling that
primarily affects reabstraction thunks.

The new ABI will allow stack allocation of non-escaping closures as a
simple optimization.

The new ABI, and the stack allocation optimization, also require
closure context to be @guaranteed. That will be implemented as the
next step.

Many SIL passes pattern match partial_apply sequences. These all
needed to be fixed to handle the convert_function that SILGen now
emits. The conversion is now needed whenever a function declaration,
which has an escaping type, is passed into a @NoEscape argument.

In addition to supporting new SIL patterns, some optimizations like
inlining and SIL combine are now stronger which could perturb some
benchmark results.

These underlying SIL changes should be merged now to avoid conflicting
with other work. Minor benchmark discrepancies can be investigated as part of
the stack-allocation work.

* Add a noescape attribute to SILFunctionType.

And set this attribute correctly when lowering formal function types to SILFunctionTypes based on @escaping.

This will allow stack allocation of closures, and unblock a related ABI change.

* Flip the polarity on @noescape on SILFunctionType and clarify that
we don't default it.

* Emit withoutActuallyEscaping using a convert_function instruction.

It might be better to use a specialized instruction here, but I'll leave that up to Andy.

Andy: And I'll leave that to Arnold who is implementing SIL support for guaranteed ownership of thick function types.

* Fix SILGen and SIL Parsing.

* Fix the LoadableByAddress pass.

* Fix ClosureSpecializer.

* Fix performance inliner constant propagation.

* Fix the PartialApplyCombiner.

* Adjust SILFunctionType for thunks.

* Add mangling for @noescape/@escaping.

* Fix test cases for @noescape attribute, mangling, convert_function, etc.

* Fix exclusivity test cases.

* Fix AccessEnforcement.

* Fix SILCombine of convert_function -> apply.

* Fix ObjC bridging thunks.

* Various MandatoryInlining fixes.

* Fix SILCombine optimizeApplyOfConvertFunction.

* Fix more test cases after merging (again).

* Fix ClosureSpecializer. Hande convert_function cloning.

Be conservative when combining convert_function. Most of our code doesn't know
how to deal with function type mismatches yet.

* Fix MandatoryInlining.

Be conservative with function conversion. The inliner does not yet know how to
cast arguments or convert between throwing forms.

* Fix PartialApplyCombiner.
2017-10-17 13:07:25 -07:00
swift-ci
3d53e7baa2 Merge pull request #12451 from lattner/SILValue-getLoc 2017-10-15 16:14:45 -07:00
Chris Lattner
cd99f859e3 NFC code cleanup changes:
- Hoist a duplicated static function with a fixme out to SILValue::getLoc()
 - Fix a whitespace issue.
2017-10-15 15:31:41 -07:00
Doug Gregor
936a701b15 [AST] Stop uniquing canonical GSBs based on the module.
Now that the GenericSignatureBuilder is no longer sensitive to the input
module, stop uniquing the canonical GSBs based on that module. The main
win here is when deserializing a generic environment: we would end up 
creating a canonical GSB in the module we deserialized and another
canonical GSB in the module in which it is used.
2017-10-10 09:41:23 -07:00
Slava Pestov
e806b6248d SIL: Remove dynamic_method instruction 2017-10-04 03:53:16 -07:00
Slava Pestov
7bf3b90b62 SIL: Split off objc_method / objc_super_method from class_method / super_method
This replaces the '[volatile]' flag. Now, class_method and
super_method are only used for vtable dispatch.

The witness_method instruction is still overloaded for use
with both ObjC protocol requirements and Swift protocol
requirements; the next step is to make it only mean the
latter, also using objc_method for ObjC protocol calls.
2017-10-03 22:13:31 -07:00
Joe Shajrawi
610aa582ce Fixes (another) IRGen compiler crash caused by the new large types ABI 2017-10-03 16:16:34 -07:00
John McCall
ab3f77baf2 Make SILInstruction no longer a subclass of ValueBase and
introduce a common superclass, SILNode.

This is in preparation for allowing instructions to have multiple
results.  It is also a somewhat more elegant representation for
instructions that have zero results.  Instructions that are known
to have exactly one result inherit from a class, SingleValueInstruction,
that subclasses both ValueBase and SILInstruction.  Some care must be
taken when working with SILNode pointers and testing for equality;
please see the comment on SILNode for more information.

A number of SIL passes needed to be updated in order to handle this
new distinction between SIL values and SIL instructions.

Note that the SIL parser is now stricter about not trying to assign
a result value from an instruction (like 'return' or 'strong_retain')
that does not produce any.
2017-09-25 02:06:26 -04:00
Joe Shajrawi
980e310119 Fixes a IRGen compiler crash caused by the new large types ABI 2017-08-31 17:21:07 -07:00
Joe Shajrawi
678f495664 Large loadable types: add support for destroy_value -> destroy_addr 2017-08-17 11:30:53 -07:00
Joe Shajrawi
84994dc786 Enable large loadable types by default 2017-08-03 11:45:28 -07:00
Joe Shajrawi
39014b2413 Large Types IRGen Pass: Support new ABI for block-storage calls and types 2017-07-27 18:22:41 -07:00
Joe Shajrawi
932e228e0a Large loadable types: add support for thin_function_to_pointer instructions 2017-07-27 14:35:04 -07:00
Joe Shajrawi
49ffa199da Large Types bugfix: support a corner case for try_apply's that return a large loadable type 2017-07-27 11:31:29 -07:00
Joe Shajrawi
95c188d715 Support indirectly returning large loadable types for type-parmater returns 2017-07-26 18:02:00 -07:00
Joe Shajrawi
32f6bab812 Remove subsumed CFunctionPointer/ObjCMethod/Block in large loadable types 2017-07-26 12:56:01 -07:00
Joe Shajrawi
ddce591dad Large Loadable Types: convention block functions / instructions should use the old ABI 2017-07-26 11:04:15 -07:00
Joe Shajrawi
f96936368c Large Loadable Types: Ignore debug instructions when re-creating function_ref instructions 2017-07-25 18:54:00 -07:00
Joe Shajrawi
34ae83e6f3 Add support for the latest large types test case when parsed as a library: handling builtin instructions. 2017-07-25 15:47:41 -07:00
Joe Shajrawi
faa51cbb64 Support calling functions that contain a large type as the return value from inside functions that maintain the old calling conventions 2017-07-25 14:30:53 -07:00
Joe Shajrawi
f0243c6f70 Resolves an issue with tuple returns for large loadable types + workaround a watch-target test failure 2017-07-25 11:36:31 -07:00
Joe Shajrawi
8faa45c3f5 Large Types IRGen Pass: bugfix for large-type returns 2017-07-24 15:31:04 -07:00
Joe Shajrawi
94935b5f78 Large Types IRGen Pass: return large types as @out 2017-07-17 15:36:51 -07:00