Commit Graph

218 Commits

Author SHA1 Message Date
Michael Gottesman
49fe60cd41 [ownership-verifier] Instead of dumping the entire block, just dump the block's debug id.
Thanks to Erik for pointing out to me that this is the same value as a block's
printed ID. This makes the output significantly more readable!
2017-01-19 17:40:08 -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
Michael Gottesman
d873926108 [semantic-sil] Value projections of a trivial value are trivial. Otherwise, they are guaranteed.
Also added some tests to verify that this behavior does not change.
2017-01-18 16:19:05 -08:00
Michael Gottesman
e33ea6aefc [semantic-sil] Handle verification of guaranteed arguments correctly.
This commit makes the following changes:

1. guaranteed arguments will trip the verifier if they have a lifetime ending
use.
2. owned arguments must have a lifetime ending use in a function. We already
would have exposed this as a leak via the dataflow, but exiting early gives us a
better clearer error message.
2017-01-18 16:18:16 -08:00
Michael Gottesman
a0b498ca1b [semantic-sil] Print out function name when incompatible ownership is detected.
This makes FileCheck matching easier.
2017-01-18 14:46:54 -08:00
Michael Gottesman
186361c622 [ownership-verifier] Fix a small thinko from a previous refactoring and add a test to be sure I don't break it again...
rdar://29791263
2017-01-17 19:18:40 -08:00
swift-ci
eec18b01cb Merge pull request #6871 from gottesmm/fix_sil_result_info 2017-01-17 19:16:12 -08:00
Michael Gottesman
3950ada6f0 Merge pull request #6872 from gottesmm/assign_store_of_trivial
[ownership-verifier] When checking uses, make sure to treat sources of assign/store that are trivially typed as trivial.
2017-01-17 19:08:42 -08:00
Michael Gottesman
8fde305225 [ownership-verifier] When checking uses, make sure to treat sources of assign/store that are trivially typed as trivial.
Noticed while working through SILGen.

rdar://29791263
2017-01-17 18:05:31 -08:00
Michael Gottesman
4063694e85 [semantic-sil] Change SILResultInfo::getOwnershipKind(SILModule &) to also take a Generic Signature.
The way SILResultInfo::getOwnershipKind(SILModule &) was implemented before was
incorrect, resulting in getTypeLowering being called on a lowered type without a
proper generic signature being pushed on the type lowering stack. This commit
fixes that issue locally.

The real fix is in a PR that Slava is preparing that provides a getTypeLowering
that takes a SILType and a GenericSignature so that the user does not need to
perform a push/pop.

rdar://29791263
2017-01-17 18:01:17 -08:00
Michael Gottesman
17b4d05e4e [semantic-sil] Rename EndBorrowInst::get{Src,Dest} => get{BorrowedValue,OriginalValue}.
This is a clearer name that makes it easier to remember what each part of the
end borrow is meant to accomplish.
2017-01-17 17:01:14 -08:00
Hugh Bellamy
2445862e1b FIx recently introduced MSVC control path warnings 2017-01-14 12:40:41 +00:00
Michael Gottesman
d944930591 Remove the deallocating convention.
This is dead code and can be re-added if it is needed. Right now though there
really isnt a ValueOwnershipKind that corresponds to deallocating and I do not
want to add a new ValueOwnershipKind for dead code.
2017-01-10 17:32:17 -08:00
Michael Gottesman
f23086bfaf [semantic-sil] Change ValueOwnershipKind into a struct enum and change helper functions to be helper methods. 2017-01-08 00:22:54 -08:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Michael Gottesman
d77bcdce57 [sil-ownership-verifier] Fix a few bugs and add a few tests. 2016-12-21 22:28:29 -08:00
Michael Gottesman
4931161929 [semantic-sil] Implement the dataflow checker behind the -enable-semantic-sil flag.
This commit includes the dataflow verifier and plugs in the use checker into the
dataflow verifier.

Some specific checks in the use checker need revision, but I for today
this is good enough. As I go through SILGen I am going to fix them.

rdar://29671437
2016-12-18 22:55:03 -08:00
Michael Gottesman
ef6462de47 [semantic-sil] Add the SILOwnershipUseVerifier behind the -enable-semantic-sil flag
This is the first verifier for SemanticSIL. The verifier is very simple and
verifies that given a SILValue V, V->getOwnershipKind() returns an ownership
kind compatible with all of V's user instructions.

This is implemented by adding a new method to SILInstruction:

    SILInstruction::verifyOperandOwnership()

This method creates an instance of the visitor OwnershipCompatibilityUseChecker
and then has the instance visit this.

The OwnershipCompatibilityUseChecker is a SILInstructionVisitor that for a given
instruction verifies that the given SILInstruction's operand SILValue's produce
ValueOwnershipKind that are compatible with the SILInstruction. The reason why
it is implemented as a visitor is to ensure that a warning is produced if a new
instruction is added and a method on the OwnershipCompatibleUseChecker isn't
added.

Keep in mind that this is just the first verifier and the full verifier (that
also verifies dataflow) is built on top of it. The reason why this separate API
to the use verifier is exposed is that exposing the checker enables us to place
an assert in SILBuilder to diagnose any places where SIL ownership is violated
immediately when the violation occurs allowing for an easy debugging experience
for compiler writers. This assert is a key tool that I am going to be using to
make SILGen conform to the SIL Ownership Model.

Again, this will be behind the -enable-semantic-sil flag, so normal development
will be unaffected by this change.

rdar://29671437
2016-12-18 21:04:26 -08:00