Commit Graph

2934 Commits

Author SHA1 Message Date
swift-ci
cca3398543 Merge pull request #7517 from gottesmm/revert_cmake_changes 2017-02-15 23:51:44 -08:00
Joe Shajrawi
9178030d92 Merge pull request #7514 from shajrawi/store_opaque_values
support stores of non-loadable types under opaque mode
2017-02-15 23:32:48 -08:00
Michael Gottesman
8437819b5a [CMake] Revert recent changes.
These changes caused a number of issues:

1. No debug info is emitted when a release-debug info compiler is built.
2. OS X deployment target specification is broken.
3. Swift options were broken without any attempt any recreating that
functionality. The specific option in question is --force-optimized-typechecker.

Such refactorings should be done in a fashion that does not break existing
users and use cases.

This reverts commit e6ce2ff388.
This reverts commit e8645f3750.
This reverts commit 89b038ea7e.
This reverts commit 497cac64d9.
This reverts commit 953ad094da.
This reverts commit e096d1c033.

rdar://30549345
2017-02-15 22:26:06 -08:00
Joe Shajrawi
992caba90e support stores of non-loadable types under opaque mode 2017-02-15 17:19:18 -08:00
Arnold Schwaighofer
876cea81ae SIL: Add an allowed access kind to the opened value of an open_existential_addr instruction
Once we move to a copy-on-write implementation of existential value buffers we
can no longer consume or destroy values of an opened existential unless the
buffer is uniquely owned.

Therefore we need to track the allowed operation on opened values.

Add qualifiers "mutable_access" and "immutable_access" to open_existential_addr
instructions to indicate the allowed access to the opened value.

Once we move to a copy-on-write implementation, an "open_existential_addr
mutable_access" instruction will ensure unique ownership of the value buffer.
2017-02-15 14:23:12 -08:00
Chris Bieneman
e096d1c033 [CMake] Simplify add_swift_library
This patch splits add_swift_library into two functions one which handles
the simple case of adding a library that is part of the compiler being
built and the second handling the more complicated case of "target"
libraries, which may need to build for one or more targets.

The new add_swift_library is built using llvm_add_library, which re-uses
LLVM's CMake modules. In adapting to use LLVM's modules some of
add_swift_library's named parameters have been removed and
LINK_LIBRARIES has changed to LINK_LIBS, and LLVM_LINK_COMPONENTS
changed to LINK_COMPONENTS.

This patch also cleans up libswiftBasic's handling of UUID library and
headers, and how it interfaces with gyb sources.

add_swift_library also no longer has the FILE_DEPENDS parameter, which
doesn't matter because llvm_add_library's DEPENDS parameter has the same
behavior.
2017-02-14 14:28:10 -08:00
practicalswift
8af31961b2 Merge pull request #7464 from practicalswift/gardening-20170214b
[gardening] Fix recently introduced typos
2017-02-14 21:10:52 +01:00
practicalswift
65b0219f7b [gardening] Fix typos 2017-02-14 20:04:08 +01:00
practicalswift
1c64f04997 [gardening] Fix header inconsistencies 2017-02-14 20:04:05 +01:00
Michael Gottesman
9a136cfc1e [ownership-verifier] Teach the ownership verifier how to handle control dependent ownership from cond_br.
Rememebering that the verifier ensures that any edge that propagates ownership
along a cond_br can not be critical, we do this by sinking the use by the
cond_br into the destination blocks.

rdar://29791263
2017-02-14 11:03:29 -08:00
Roman Levenstein
fc7b9e1081 [sil-linker] Minor clean-ups of function lookup code in SILModule and SIL linker. NFC.
Stop using SILLinkage::Private as a flag for "linkage doesn't matter". Use Optional instead.
2017-02-14 08:15:51 -08:00
Michael Gottesman
8b0fc4e6ed [sil] Ban critical edges from cond_br with non-trivial arguments in Semantic SIL.
This is a small corner case that simplifies the ownership verifier.
Specifically, today the ownership verifier has problems with the control
dependent nature of a cond_br's condition operand on the arguments of the
cond_br. By eliminating the possibility of values with ownership being
propagated along critical edges, the verifier can associate the arguments of the
cond_br with the destination blocks safely.

*NOTE* I ran a full testing run with sil-verify-all and this check did not
trigger once after SILGen.  Thus I think it is safe to say that there is no real
effect of this change today. It is change ensuring that we maintain the current
behavior. As part of teaching the optimizer how to handle ownership, this
property will need to be pushed back there as well.

rdar://29791263
2017-02-13 17:49:30 -08:00
Andrew Trick
10b118dfa9 [Lowering] Make the AddressLowering pass functional. 2017-02-13 17:10:02 -08:00
Andrew Trick
855918c620 [Lowering] Add an AddressLowering pass. 2017-02-13 17:10:02 -08:00
swift-ci
b454c78ea9 Merge pull request #7443 from gottesmm/ownership_unreachable_code 2017-02-13 17:06:46 -08:00
Michael Gottesman
ed67bf9f21 [ownership-verifier] Teach the ownership verifier how to handle unreachable code.
There are a few different use cases here:

1. In Raw SIL, no return folding may not have been run yet implying that a call
to a no-return function /can/ have arbitrary control flow after it (consider
mandatory inlined functions). We need to recognize that the region of code that
is strictly post dominated by the no-return function is "transitively
unreachable" and thus leaking is ok from that point. *Footnote 1*.

2. In Canonical and Raw SIL, we must recognize that unreachables and no-return
functions constitute places where we are allowed to leak.

rdar://29791263

----

*Footnote 1*: The reason why this is done is since we want to emit unreachable
code diagnostics when we run no-return folding. By leaving in the relevant code,
we have preserved all of the SILLocations on that code allowing us to create
really nice diagnostics.
2017-02-13 16:36:01 -08:00
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