Commit Graph

381 Commits

Author SHA1 Message Date
John McCall
5c33d2106a Add simple accessor/generator coroutine support to SILFunctionType. 2017-11-07 01:50:12 -05:00
Davide Italiano
1ebaee199f Merge pull request #12519 from dcci/noabort
[SILVerifier] Add a flag to not abort upon verification failure.
2017-10-23 20:11:43 -07:00
swift-ci
44e3e17627 Merge pull request #12583 from gottesmm/pr-e194681a009c5227d83b0062a44d05474bdc1801 2017-10-23 10:26:35 -07:00
Michael Gottesman
c3182d17ef [gardening] Replace else-if with early returns and sink computation of ownership in the SILVerifier.
Noticed this while doing other work. Just chopping it off to ease review on the
larger patch.
2017-10-23 10:00:56 -07:00
Roman Levenstein
d86ef3b7e3 Add [serialized] flag to sil_vtables 2017-10-21 19:18:15 -07:00
Davide Italiano
98992dfc60 [SILVerifier] Add a flag to exit instead of aborting on failure.
This matches what LLVM does, and makes testing/fuzzing easier.
It's also slightly more friendly in case the user violates an
assumption. It can't be turned on by default (yet) because it's
important to crash on verification failures, when running swiftc
in a debugger.
2017-10-21 18:13:21 -07:00
Davide Italiano
ff402cf47c [SIL] Enforce dominance property of the entry block.
An entry block can't have predecessors. I'll commit a
test as a follow-up to make sure this doesn't regress.
2017-10-19 09:12:38 -07:00
Joe Shajrawi
b9c93bde47 Relax the open_existential_addr immutable_access verifier further after sil-combine bail-out 2017-10-17 00:26:06 -07:00
Slava Pestov
0acf3ac8d9 SIL: Remove is_nonnull instruction 2017-10-13 17:38:32 -07:00
Joe Shajrawi
89cb274717 Merge pull request #12356 from shajrawi/sil_combine_bugfix_v2
Fixes a bug in SILCombiner that caused a use-after-free
2017-10-10 16:29:39 -07:00
Joe Shajrawi
ac8a48b2c2 Fixes a bug in SILCombiner that caused a use-after-free 2017-10-10 13:40:14 -07:00
Doug Gregor
1f1b75a56d [AST] Eliminate ModuleDecl parameters from GenericSignature. 2017-10-10 10:01:39 -07:00
Slava Pestov
6def545696 AST: Remove GenericEnvironment::containsPrimaryArchetype()
This is no longer necessary now that archetypes refer back to a
GenericEnvironment.
2017-10-07 04:46:37 -07:00
Slava Pestov
e806b6248d SIL: Remove dynamic_method instruction 2017-10-04 03:53:16 -07:00
Slava Pestov
aceb620595 SIL: Relax invariants on objc_method, allowing it to be used for dynamic method calls 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
Jordan Rose
b6c28b02d0 [SIL] Remove the builtins related to UnknownObject.
No functionality change; nothing is using them.
2017-10-02 09:05:31 -07:00
Roman Levenstein
c15ffa0571 Some fixes for the Serialized attribute of pre-specializations
Pre-specializations need some special handling when it comes to the Serialized attribute. Their bodies should not be SIL serialized. Instead, only their declarations should be serialized.

And since their bodies are not serialized and cannot be imported by the client code, it is OK if pre-specializations reference non-fragile functions inside their bodies. Due to the same reason, it is fine if pre-specializations are referenced from fragile functions, even though these pre-specializations are not fragile in a usual sense.
2017-09-29 12:45:31 -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
Slava Pestov
6478256b20 SIL: Relax some verifier checks when merging partial modules
When merging partial SIL modules we only link in function bodies defined
in the current module, so we might encounter functions with shared
linkage and no body.

Since pulling in these functions from other modules is a waste of time,
run the verifier in "single function" mode in this case.

Note that when the module is ultimately used and one of these functions
is deserialized, we should link in all downstream functions with shared
linkage, and failure to do so will be caught by the SIL verifier then.

Fixes <rdar://problem/34469704>.
2017-09-18 23:59:23 -07:00
Erik Eckstein
fb935a3d49 SIL: support statically initialized StaticString globals
The main part of the change is to support the ptr_to_int builtin in statically initialized globals. This builtin is used to build a StaticString from a string_literal.
On the other hand I removed the support of the FPTrunc builtin, which is not needed anyway (because it can be constant propagated).
2017-09-18 17:50:24 -07:00
Joe Groff
78d75428d6 SILGen: Lower key path subscript indexes.
And fill out SIL support for parsing, printing, and serializing key path
patterns with captured indexes.
2017-09-15 10:00:32 -07:00
Andrew Trick
15df313481 [sil-opaque-values] Allow open_existential_addr to be loaded (post-ownership). 2017-09-11 14:37:39 -07:00
Andrew Trick
157de8c312 NFC. Reorder a verifier check for obvious efficiency. 2017-09-11 13:28:13 -07:00
Michael Gottesman
b2550ecb44 [ownership] Do not print out ownership convention on BBArgs once ownership is stripped.
rdar://31521023
2017-08-31 17:53:54 -07:00
Erik Eckstein
9c6fe76927 SIL, IRGen: add instructions "object" and "global_value” to support statically initialized objects.
This commit contains:
-) adding the new instructions + infrastructure, like parsing, printing, etc.
-) support in IRGen to generate global object-variables (i.e. "heap" objects) which are statically initialized in the data section.
-) IRGen for global_value which lazily initializes the object header and returns a reference to the object.

For details see the documentation of the new instructions in SIL.rst.
2017-08-23 09:15:49 -07:00
Erik Eckstein
1ab582e121 SIL: A new representation of static initializers for global variables.
Static initializers are now represented by a list of literal and aggregate instructions in a SILGlobalVariable.
For details see SIL.rst.

This representation is cleaner than what we did so far (point to the initializer function and do some pattern matching).

One implication of that change is that now (a subset of) instructions not necessarily have a parent function.
Regarding the generated code it's a NFC.
Also the swift module format didn't change because so far we don't serializer global variables.
2017-08-23 09:15:01 -07:00
Erik Eckstein
020a283bbb SIL: Let the OpenedArchetypesTracker be constructed with a null SILFunction.
NFC
2017-08-23 09:15:00 -07:00
Erik Eckstein
6377cc095a SIL: Replace TransitivelyUnreachableBlocks with DeadEndBlocks
We had both utilities doing the same thing.
NFC
2017-07-24 09:50:42 -07:00
Andrew Trick
b48b3b02e1 [sil-opaque-values] Add support for createLoadBorrow. 2017-07-18 09:02:43 -07:00
Andrew Trick
4db2a46cff Add SIL instruction: open_existential_box_value.
This has the same semantics as open_existential_box, but returns an object value
instead of an address.

This is used in SIL opaque values mode. Attempting to reuse open_existential_box
in this mode causes SIL type inconsistencies that are too difficult to work
around. Adding this instruction allows for consistent handling of opaque values.

The original versions of several of these currently redundant instructions will
be removed once the SIL representation stabilizes.
2017-07-17 23:46:41 -07:00
Andrew Trick
f657ad2d3a Rename *ExistentialOpaque instructions to *ExistentialValue.
These instructions have the same semantics as the *ExistentialAddr instructions
but operate directly on the existential value, not its address.

This is in preparation for adding ExistentialBoxValue instructions.
The previous name would cause impossible confusion with "opaque existentials"
and "opaque existential boxes".
2017-07-17 23:46:41 -07:00
swift-ci
210b577481 Merge pull request #11019 from gottesmm/silgen_unowned_fixes 2017-07-17 16:44:12 -07:00
Michael Gottesman
8797d88d7c [silgen] Fix a few uses of UnownedRetain, UnownedRelease, StrongRetainUnowned in favor of their ownership counterparts.
The counterparts are:

UnownedRetain -> CopyValue.
UnownedRelease -> DestroyValue.
StrongRetainUnowned -> CopyUnownedValue.

I thought I hit all of these already. When I was fixing some DI stuff I realized
that I missed a few cases in SILGenLValue.cpp. To make sure we do not regress, I
added some verifier checks to make sure these instructions can only be used in
non-ownership sil.

rdar://31880847
2017-07-17 15:59:30 -07:00
Joe Groff
69a290edda Handle IUO unwraps in key paths.
In the type checker, we need to recognize when a member lookup succeeded through an IUO unwrap, and insert the implicit optional-unwrap component into the key path. In the standard library, we need to cope with the fact that IUO is still a first-class type with unique type metadata in a few places. Fix for rdar://problem/33230845.
2017-07-17 11:21:36 -07:00
Michael Gottesman
f2c4aeac31 [sil] Refactor isLoweringOf from the verifier onto SILType.
I am going to use this to put an assertion in SILBuilder on ValueMetatype so
that the assertion fires right when the ValueMetatype is created instead of
later once we are verifying. It is still only being used in assertions/etc.

rdar://problem/31880847
2017-07-12 17:31:59 -07:00
Joe Groff
3c82e981f9 KeyPaths: Add support for optional chaining/forcing components.
rdar://problem/31768715
2017-06-26 09:40:31 -07:00
Arnold Schwaighofer
ca63326e1b Delete unused existential value witnesses from the old existential
implementation

And remove the SWIFT_RUNTIME_ENABLE_COW_EXISTENTIALS flag.
2017-06-02 14:34:41 -07:00
Erik Eckstein
26642ec419 SIL optimizer: Don’t crash if the user illegally lets an address of a local variable escape with withUnsafePointer
rdar://problem/32307046
2017-05-22 11:39:49 -07:00
Robert Widmann
3b202c18d8 Use 'hasAssociatedValues'
Use 'hasAssociatedValues' instead of computing and discarding the
interface type of an enum element decl.  This change has specifically not
been made in conditions that use the presence or absence of the
interface type, only conditions that depend on the presence or absence
of associated values in the enum element decl.
2017-05-22 09:54:47 -07:00
Joe Groff
69a7ef6e2d Revert "SILGen: Tweak key path computed property lowering to produce a consistent runtime-callable ABI."
This reverts commit 4522cd09aa. This was a failed approach I shouldn't have committed. Fixes rdar://problem/32201589.
2017-05-15 16:10:55 -07:00
Roman Levenstein
f6e24fa1e9 Remove conditional compilation from maybeScopeless, because SILVerifier is not conditionally compiled anymore 2017-05-11 23:29:43 -07:00
Roman Levenstein
4133e30cb9 [sil-verifier] Make it possible to use -sil-verify-all even in noasserts builds
This can be useful for reproducing bugs, etc.

rdar://32080465
2017-05-11 18:23:06 -07:00
practicalswift
8c40c65c80 [gardening] Fix typos. 2017-05-09 21:50:04 +02:00
Joe Shajrawi
748efafd89 Merge pull request #9352 from shajrawi/fix_class_large_types
Resolves an issue with large loadable types wherein functions types inside classes misbehaved
2017-05-05 15:23:07 -07:00
Joe Shajrawi
e334da4efe Resolves an issue with large loadable types wherein functions types inside classes misbehaved 2017-05-05 14:29:41 -07:00
Michael Gottesman
86620aaa7e Merge pull request #9318 from practicalswift/redundant-types-in-casts
[gardening] Remove redundant repetition of type names (DRY): RepeatedTypeName foo = dyn_cast<RepeatedTypeName>(bar)
2017-05-05 13:37:12 -07:00
practicalswift
492f5cd35a [gardening] Remove redundant repetition of type names (DRY): RepeatedTypeName foo = dyn_cast<RepeatedTypeName>(bar)
Replace `NameOfType foo = dyn_cast<NameOfType>(bar)` with DRY version `auto foo = dyn_cast<NameOfType>(bar)`.

The DRY auto version is by far the dominant form already used in the repo, so this PR merely brings the exceptional cases (redundant repetition form) in line with the dominant form (auto form).

See the [C++ Core Guidelines](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es11-use-auto-to-avoid-redundant-repetition-of-type-names) for a general discussion on why to use `auto` to avoid redundant repetition of type names.
2017-05-05 09:45:53 +02:00
Joe Shajrawi
018e79716f Large loadable types pass: resolves a case wherein a tuple’s extracted type is a function signature 2017-05-04 16:54:33 -07:00
Joe Shajrawi
87526696ad Merge pull request #9177 from shajrawi/fix_verifier_large_types
Fix an issue that was uncovered by the linux fix: resolves verifier bug in 32-bit code
2017-05-01 19:32:30 -07:00