Commit Graph

33 Commits

Author SHA1 Message Date
Roman Levenstein
202de40f05 [sil-opened-archetype-tracker] Improve tracking of archetypes in SILBuilder
Fixes rdar://problem/31749245
2017-04-24 08:50:55 -07:00
Roman Levenstein
a60e037c48 Revert "[sil-opened-archetype-tracker] Improve tracking of archetypes in SILBuilder" 2017-04-22 20:41:31 -07:00
Roman Levenstein
33c8bde859 [sil-opened-archetype-tracker] Improve tracking of archetypes in SILBuilder
Fixes rdar://problem/31749245
2017-04-22 10:03:37 -07:00
Michael Gottesman
ad7705ed42 [semantic-sil] Update OME for having mark_uninitialized on the alloc_box instead of project_box.
This consists of just removing support from OME for ensuring that all uses of a
box go through the project_box that has as its user a mark_uninitialized. Since
the lowering of mark_uninitialized onto the relevant project_box is done by
MarkUninitializedFixup pass, I can just rip out the hacks from the OME!

rdar://31521023
2017-04-17 21:10:24 -07:00
Andrew Trick
be1881aa1f Remove redundant Transform.getName() definitions.
At some point, pass definitions were heavily macro-ized. Pass
descriptive names were added in two places. This is not only redundant
but a source of confusion. You could waste a lot of time grepping for
the wrong string. I removed all the getName() overrides which, at
around 90 passes, was a fairly significant amount of code bloat.

Any pass that we want to be able to invoke by name from a tool
(sil-opt) or pipeline plan *should* have unique type name, enum value,
commend-line string, and name string. I removed a comment about the
various inliner passes that contradicted that.

Side note: We should be consistent with the policy that a pass is
identified by its type. We have a couple passes, LICM and CSE, which
currently violate that convention.
2017-04-09 15:20:28 -07:00
Michael Gottesman
c28a62d97c [ome] Make sure to rewire all project_box we insert through the mark_uninitialized project_box to preserve DI behavior.
Once I update DI in a bit, this will no longer be necessary.

rdar://29870610
2017-04-03 12:17:44 -07:00
Michael Gottesman
85688b87bb [ome] Change the eliminator to be a module pass instead of a function pass.
This ensures that the pass manager runs the eliminator on all functions once
before running any further passes. Otherwise, due to the way the pass manager
runs functions, sometimes a function with unqualified ownership is visible from
a function with qualified ownership. This makes it impossible to have an
invariant that a pass either sees an entire qualified or unqualified world. This
is a useful feature that I would like to keep if I can.

rdar://29870610
2017-04-03 09:43:37 -07:00
Michael Gottesman
f301044384 [ownership-model] Teach the ownership model eliminator how to eliminate the default argument of a switch_enum and tighten up assertions in SILVerifier.
rdar://31145255
2017-03-27 16:25:37 -07:00
Michael Gottesman
cfb5893663 [silgen] Fix destroying destructor to use proper ownership with its @owned return value.
rdar://29791263
2017-03-02 17:17:17 -08:00
Michael Gottesman
4bc12aedbd [sil] Add end_lifetime.
This is the lifetime ending variant of fix_lifetime. It is a lie to the
ownership verifier that a value is being consumed along a path. Its intention is
to be used to allow for the static verification of ownership in deallocating
deinits which for compatibility with objective-c have weird ownership behavior.
See the commit merged with this commit for more information.
2017-03-01 18:30:23 -08:00
Michael Gottesman
455c126238 [semantic-sil] Pass the uncasted argument as an @owned arg in the failed checked_cast_br cast.
Previously, we would put a destroy_value directly on the value that we tried to
cast. Since checked_cast_br is consuming, this would cause the destroy_value on
the failure path to be flagged as a double consume.

This commit causes SILGen to emit the value consumed by checked_cast_br as an
@owned argument to the failure BB, allowing semantic arc rules to be respected.

As an additional benefit, I also upgraded the ownership_model_eliminator test to
use semantic sil verification.

One issue that did come up though is that I was unable to use the new code in
all locations in the compiler. Specifically, there is one location in
SILGenPattern that uses argument unforwarding. I am going to need to undo
argument unforwarding in SILGenPattern in order to completely eliminate the old
code path.
2017-02-28 17:29:03 -05:00
Mikio Takeuchi
91b8db5e11 Replace newly introduced Atomicity::Atomic 2017-02-27 12:17:53 +09:00
Mikio Takeuchi
488d531846 Enhance -assume-single-threaded option (SR-3945) 2017-02-27 12:17:53 +09:00
Andrew Trick
eed44abd1d OwnershipModelEliminator should not rewrite address-only copy/destroy. 2017-02-16 18:50:31 -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
Michael Gottesman
2da18c7b47 [semantic-sil] Add special unmanaged_{retain,release}_value instructions for unpaired retain/release operations in semantic sil.
The reason why I am introducing special instructions is so I can maintain the
qualified ownership API wedge in between qualified SIL and the rest of the ARC
instructions that are pervasively used in the compiler.

These instructions in the future /could/ be extended to just take @sil_unmanaged
operands directly, but I want to maintain flexibility to take regular
non-trivial operands in the short term.

rdar://29791263
2017-01-19 13:23:08 -08:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Michael Gottesman
6213550239 [semantic-sil] Create copy_unowned_value.
This was in the first high level ARC instruction proposal, but I have not needed
it until now. The use case for this is to ahandle strong_retain_unowned (which
takes in an unowned value, asserts it is still alive, performs a strong_retain,
and returns the @owned value). This @owned value needs a destroy_value.

rdar://29671437
2016-12-14 19:22:24 -08:00
Michael Gottesman
66cff7e37e [semantic-arc] Add StoreBorrowInst and BeginBorrowInst. 2016-12-12 13:06:18 -08:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
Michael Gottesman
34ec32bc14 [semantic-arc] Handle the rest of the unqualified mem opts in SILGen.
Keep in mind that these are approximations that will not impact correctness
since in all cases I ensured that the SIL will be the same after the
OwnershipModelEliminator has run. The cases that I was unsure of I commented
with SEMANTIC ARC TODO. Once we have the verifier any confusion that may have
occurred here will be dealt with.

rdar://28685236
2016-11-09 11:37:52 -08:00
Michael Gottesman
bffa7addaf [semantic-arc] Eliminate default {Load,Store}OwnershipQualification argument to SILBuilder::create{Load,Store}(...)
Today, loads and stores are treated as having @unowned(unsafe) ownership
semantics. This leaves the user to specify ownership changes on the loaded or
stored value independently of the load/store by inserting ARC operations. With
the change to Semantic SIL, this will no longer be true. Instead loads, stores
have ownership semantics that one must reason about such as copy, take, and
trivial.

This change moves us closer to that world by eliminating the default
OwnershipQualification argument from create{Load,Store}. This means that the
compiler developer cannot ignore reasoning about the ownership semantics of the
memory operation that they are creating.

Operationally, this is a NFC change since I have just gone through the compiler
and updated all places where we create loads, stores to pass in the former
default argument ({Load,Store}OwnershipQualifier::Unqualified), to
SILBuilder::create{Load,Store}(...). For now, one can just do that in situations
where one needs to create loads/stores, but over time, I am going to tighten the
semantics up via the verifier.

rdar://28685236
2016-10-30 13:07:06 -07:00
Michael Gottesman
a1f489f450 [semantic-arc] Make sure to use TypeLowering methods in the OwnershipModelEliminator when creating lowered ARC operations.
Since we set the unqualified flag before we eliminate any instructions, this
will do the *right* thing and emit the most optimal lowered representation
whether it is a strong_* or *_value instruction.

This ensures that passes that expect values to have the most lowered
representation of instruction to be able to pattern match correctly.

This can up when alloc-box-to-stack was pattern matching on strong_retain on
Boxes, but I was being lazy and emitted retain_value.

rdar://28851920
2016-10-29 20:11:06 -07:00
Michael Gottesman
f9b4ac714b [semantic-arc] Make sure that the ownership model eliminator sets the unqualified flag before it runs.
Otherwise, we will trigger verification in SILBuilder?!

rdar://28851920
2016-10-25 22:31:05 -07:00
Michael Gottesman
bb9197c7ff [semantic-arc] Move the Ownership Model Eliminator and management of SILFunction::hasQualifiedOwnership in front of SILOptions::EnableSILOwnership.
This is a NFC change, since verification still will be behind the flag. But this
will allow me to move copy_value, destroy_value in front of the
EnableSILOwnership flag and verify via SILGen that we are always using those
instructions.

rdar://28851920
2016-10-23 18:30:43 -07:00
Michael Gottesman
813facfcff [gardening] Refactor out setting Insertion Point and Debug Scope from each visitor to beforeVisit in the OwnershipModelEliminator. 2016-10-22 22:26:07 -07:00
Michael Gottesman
271e3909df [semantic-arc] Implement OwnershipModelEliminator support for copy_value, destroy_value.
rdar://28851920
2016-10-22 22:26:06 -07:00
Michael Gottesman
b0539a9a15 [semantic-arc] Only run the ownership model eliminator on functions with qualified ownership and make it after running change such functions to have unqualified ownership.
rdar://28685236
2016-10-21 17:42:39 -07:00
Michael Gottesman
85269c767a [semantic-arc] Implement eliminating end_borrow and load_borrow from the OwnershipModelEliminator.
rdar://28685236
2016-10-20 12:30:18 -07:00
Michael Gottesman
abaed64e20 [semantic-arc] Refactor the ownership model eliminator to use a visitor type.
rdar://28685236
2016-10-20 12:24:15 -07:00
practicalswift
265a4605a0 [gardening] Fix typos. 2016-10-16 12:53:49 +02:00
practicalswift
5d7bf22381 [gardening] Improve header consistency 2016-10-16 12:41:09 +02:00
Michael Gottesman
e48e7b7fca [semantic-arc] Add a new pass called the OwnershipModelEliminator that eliminates SILOwnership from the IR.
It currently just breaks up qualified loads/stores into their unqualified
constituant parts.

rdar://28685236
2016-10-15 21:35:34 -07:00