Commit Graph

3168 Commits

Author SHA1 Message Date
Slava Pestov
2fac86496f SILGen: Fix corner-case in emission of extension initializer
If the initializer is in a different file than the original
type, and the original type contains a stored property that
has both an initializer *and* a declared type, then the
initializer expression will not have been type checked.

So we must look at the type of pattern, which should still
be correct.

Fixes <https://bugs.swift.org/browse/SR-3942> and
<rdar://problem/25705157>.
2017-02-13 16:27:40 -08:00
Jordan Rose
1c60910198 Revert "Merge pull request #6092 from swiftix/wip-generics-inlining-flag-4"
This reverts commit 1b3d29a163, reversing
changes made to b32424953e.

We're seeing a handful of issues from turning on inlining of generics,
so I'm reverting to unblock the bots.
2017-02-13 10:52:17 -08:00
Jordan Rose
f0c0bd8791 Revert "Merge pull request #7401 from swiftix/wip-generics-inlining-flag-4"
This reverts commit a380855524, reversing
changes made to 66332140f3.

We're seeing a handful of issues from turning on inlining of generics,
so I'm reverting to unblock the bots.
2017-02-13 10:51:35 -08:00
Hugh Bellamy
f001b7562b Use relatively new LLVM_FALLLTHROUGH instead of our own SWIFT_FALLTHROUGH 2017-02-12 10:47:03 +07:00
Roman Levenstein
a380855524 Merge pull request #7401 from swiftix/wip-generics-inlining-flag-4
Fix a linking issue introduced by recent SILModule changes.
2017-02-11 01:09:55 -08:00
Roman Levenstein
e74473981c Fix a linking issue introduced by recent SILModule changes.
Only convert external public functions into declarations, because they are available elsewhere.
2017-02-11 00:20:32 -08:00
Doug Gregor
aa42045d66 [AST] “Error” types aren’t really unchecked; deal with them explicitly. 2017-02-11 00:04:13 -08:00
Roman Levenstein
1b3d29a163 Merge pull request #6092 from swiftix/wip-generics-inlining-flag-4
Enable inlining of generics
2017-02-10 20:13:36 -08:00
Roman Levenstein
199e76d6d4 Fixes for a lookup of functions by name
Among other things it fixes a bug in the function signature optimization where it would use an already existing mangled name for a different function
2017-02-10 18:07:30 -08:00
Erik Eckstein
ebe19757e1 Demangler: add a new API for the demangler which enables bump-pointer allocation of demangling nodes.
Instead of a global demangleSymbolAsNode, which returns a reference-counted NodePointer, there is now a Context class which owns the nodes.
So now demangleSymbolAsNode is a member of Context and the returned NodePointer is alive as long as the Context is alive.

This is still a NFC: the new ABI still maps to the old functions.
The purpose of this change is to let lldb adapt to the new API and then we can switch to the new implementation.
2017-02-10 12:25:58 -08:00
swift-ci
ec5a1c2265 Merge pull request #7367 from gottesmm/no_return_refactoring 2017-02-09 13:40:43 -08:00
Joe Shajrawi
df5297d877 Merge pull request #7349 from shajrawi/open_existential
Support for Open Existentials that do no take an address
2017-02-09 12:39:16 -08:00
Michael Gottesman
284a028e61 [sil] Add a new API SILModule::isNoReturnBuiltinOrIntrinsic(Identifier).
This is just refactoring code from DiagnoseUnreachable into a centralized
location.

rdar://29791263
2017-02-09 11:29:41 -08:00
Michael Gottesman
805786a913 [sil] Define SILFunctionType::isNoReturnFunction().
This just moves a bunch of queries that used information on SILFunction to
determine this property to just call a helper on SILFunctionType itself.

Centralized logic is good.

rdar://29791263
2017-02-09 11:29:40 -08:00
Joe Shajrawi
c478828de7 Support for Open Existentials that do no take an address 2017-02-09 11:25:34 -08:00
Roman Levenstein
163f58e293 Merge pull request #7277 from swiftix/wip-partial-pre-specializations-wip-specialize-attribute-2
Teach EagerSpecializer how to use the new form of the @_specialize attribute
2017-02-08 20:07:54 -08:00
Slava Pestov
3652190866 Merge pull request #7346 from slavapestov/misc-gardening
Add a couple of regression tests and make a small cleanup
2017-02-08 20:00:23 -08:00
Michael Gottesman
0bf0acd7f2 [ownership-verifier] Make unchecked_enum_data a propagating instruction.
This allows for an unchecked_enum_data to be either a consumed instruction or a
borrowed instruction. The reason why this makes sense in contrast to other value
projection operations like struct_extract and tuple_extract is that an enum
payload is essentially a tuple. This means that we are extracting the entire
value when we perform a struct_extract. So forwarding is viable from a semantic
perspective since if we destroy the payload, there is nothing left to destroy.

This contrasts with struct_extract and tuple_extract where we may have other
parts of the struct/tuple to destroy.

rdar://29791263
2017-02-08 19:13:54 -08:00
Michael Gottesman
49506557e3 [sil] Change SILResultInfo::getOwnershipKind to always take a CanGenericSignature.
This caused a crasher when running the ownership verifier. I don't have a test
case right now, since it happened several weeks ago.

The bug can not happen again since I eliminated the nullptr default argument.

rdar://29791263
2017-02-08 16:43:38 -08:00
Slava Pestov
a16faae73b AST: Move ProtocolConformance::getTypeWitnessByName() to ProtocolConformanceRef
I need to move some #includes around ("include what you use") to
break circularities for an upcoming refactoring.
2017-02-08 15:33:46 -08:00
Roman Levenstein
6f767267d1 Teach SIL type lowering about trivial, but address only types. 2017-02-08 01:08:09 -08:00
Roman Levenstein
2b9444e03a Add mangling support for partial specializations. 2017-02-07 23:16:00 -08:00
Slava Pestov
bd4f31025f AST: GenericEnvironment::mapTypeIntoContext() no longer needs to take a ModuleDecl
Now, use LookUpConformanceInSignature instead.
2017-02-07 19:25:34 -08:00
Slava Pestov
f2173e9b24 AST: Remove ModuleDecl parameter from GenericEnvironment::getSubstitutionMap()
This method maps interface types to archetypes, which in general
requires a module for performing conformance lookups, if mapping
a member type of a generic parameter which has been made concrete.

However, in practice the types we are mapping here are all canonical
with respect to the generic signature, because they came from
GenericSignature::getAllDependentTypes(), so we actually don't need
to do conformance lookups.

This allows some code to be simplified.
2017-02-06 22:39:26 -08:00
Slava Pestov
3519e0cd25 AST: Introduce new SubstitutionList type to replace ArrayRef<Substitution>
SubstitutionList is going to be a more compact representation of
a SubstitutionMap, suitable for inline allocation inside another
object.

For now, it's just a typedef for ArrayRef<Substitution>.
2017-02-06 21:36:33 -08:00
Slava Pestov
b22f9ea487 AST: Remove SubstitutionMap::getMap()
We don't want to expose the fact that SubstitutionMaps are
backed by a DenseMap, since that's going to change soon.
2017-02-06 19:43:33 -08:00
Slava Pestov
a961eeccd7 AST: Add SubstitutionMap variant of substGenericArgs() for completeness 2017-02-06 16:14:08 -08:00
Slava Pestov
7e927b578d Merge pull request #7283 from slavapestov/kill-uncurry-level
SIL: Remove uncurryLevel parameter from type lowering
2017-02-06 15:45:07 -08:00
Slava Pestov
162b1c0de0 SIL: Remove uncurryLevel parameter from type lowering
There was only one place where we lowered AST types with a non-zero
uncurry level, in SILGenApply.cpp. Add a new overload of the
getSILFunctionType() method that takes an uncurry level. All the
other methods no longer have to thread it through.
2017-02-06 15:24:03 -08:00
Michael Gottesman
4139b716fc [ownership-verifier] Builtin "unsafeGuaranteed" returns its value at +1.
I thought this was modeling a value returned at +0. But in reality, the
instruction is created a guaranteed region by performing the following
instruction sequence:

  %1 = copy_value %0 : $GuaranteedValue
  (%2, %3) = Builtin "unsafeGuaranteed" (%1)
  ... *STUFF* ...
  Builtin "endUnsafeGuaranteed" (%2) : $Token
  destroy_value %3 : $GuaranteedValue

rdar://29791263
2017-02-06 14:59:48 -08:00
Michael Gottesman
07a71d0518 [ownership-verifier] Implement use checking for builtins.
I implemented the mapping from  SILValue -> ValueOwnershipKind for builtins a
long time ago, but did not implement the stub for what ValueOwnershipKind's can
be accepted by builtins. It is a pretty simple mapping (most things are
trivial).

The only interesting cases are:

1. ErrorInMain, UnexpectedError, WillThrow: These take in an @owned error
parameter, but are just normal uses of the value, not lifetime ending uses.

2. UnsafeGuaranteed. This is a bonafide actual +1 lifetime ending use. It is the
only one in the builtins.

rdar://29791263
2017-02-06 14:59:48 -08:00
swift-ci
f188521109 Merge pull request #7276 from gottesmm/loosen_mark_dependence 2017-02-06 14:20:44 -08:00
swift-ci
93d8dbc272 Merge pull request #7275 from gottesmm/trivial_payload_enum_passed_to_owned_args 2017-02-06 13:40:37 -08:00
Michael Gottesman
a80882f6aa Merge pull request #7273 from gottesmm/value_metatype_fix
[ownership-verifier] ValueMetatype has a single argument that can be trivial or @owned... so just make it take anything.
2017-02-06 13:19:24 -08:00
Michael Gottesman
15a12a3f34 Merge pull request #7272 from gottesmm/unmanaged_autorelease_value
[semantic-sil] Create unmanaged_autorelease_value.
2017-02-06 13:19:01 -08:00
swift-ci
efb5517fc0 Merge pull request #7271 from gottesmm/ref_element_addr_cleanups 2017-02-06 13:17:54 -08:00
Michael Gottesman
6a4368529d [ownership-verifier] Loosen the restrictions on mark_dependence since turns out we can also take a guaranteed argument as the value that is depended upon.
This occurs specifically, when our base is a class and we are performing a
materialize for set on a sub field of the class.

rdar://29791263
2017-02-06 12:58:01 -08:00
Michael Gottesman
9c47c305db [ownership-verifier] Allow for trivial cases of non-trivial enums to be passed as @owned, @unowned, and @guaranteed arguments.
The logic here is that a function argument can be viewed as a PHI node in the
program graph (i.e. cfg for each function + call graph). Just like with normal
PHI nodes, we need to treat enums passed into these PHI nodes as true sum types,
but at the same time, do not want to constrain optimization when we know that
the payloaded type is trivial.

rdar://29791263
2017-02-06 12:50:14 -08:00
Michael Gottesman
88dc60c2ff [ownership-verifier] ValueMetatype has a single argument that can be trivial or @owned... so just make it take anything.
rdar://29791263
2017-02-06 12:43:50 -08:00
Michael Gottesman
554feff463 [semantic-sil] Create unmanaged_autorelease_value.
This is an autorelease for use with Builtin.autorelease that does not need to be
balanced as part of the ownership model.

rdar://29791263
2017-02-06 12:11:46 -08:00
swift-ci
e5b66c0a70 Merge pull request #6891 from adrian-prantl/cleanup 2017-02-06 12:10:45 -08:00
Michael Gottesman
dc8b994fc2 [silgen] ref_element_addr should always take a borrowed operand.
rdar://29791263
2017-02-06 11:45:49 -08:00
swift-ci
7716a6875b Merge pull request #7263 from gottesmm/more_ownership_changes 2017-02-06 11:20:09 -08:00
Adrian Prantl
4d1ae142c6 Remove the redundant DeclCtx field in SILFunction.
In all cases the DeclCtx field was supposed to be initialized from the
SILLocation of the function, so we can save one pointer per
SILFunction.

There is one test case change where a different (more precise)
diagnostic is being generated after this change.
2017-02-06 11:07:50 -08:00
Joe Groff
938e733923 Remove accidentally left behind debug assertion.
This was intended to track down a bug, not be left in. Sorry.
2017-02-06 08:44:23 -08:00
Michael Gottesman
0bea544c34 [ownership-verifier] alloc_value_buffer returns a trivial value... 2017-02-05 20:18:24 -08:00
Michael Gottesman
8d570fdfbf [ownership-verifier] existential_metatype can accept addresses as well as objects meaning it can accept also trivial ownership. 2017-02-05 20:18:24 -08:00
Michael Gottesman
7517391d86 [ownership-verifier] unchecked_trivial_bit_cast always produces trivial types, but accepts any type. 2017-02-05 20:18:24 -08:00
Michael Gottesman
88fc2fed6f [ownership-verifier] Another place I forgot to change getType().isTrivial(Mod) to a check against ValueOwnershipKind::Trivial.
This is needed to handle correctly:

1. non-trivial addresses.
2. trivial enum cases of enums that also have non-trivial payloaded cases.
2017-02-05 20:18:24 -08:00
Michael Gottesman
e9f073761e [ownership-verifier] All builtins that do not return a value, actually return an empty tuple which is trivial.
rdar://29791263
2017-02-05 20:18:24 -08:00