Commit Graph

1074 Commits

Author SHA1 Message Date
Erik Eckstein
e2d313ef68 SIL: Extend cond_fail by a second operand, which is a static string literal, indicating the failure reason. 2019-07-12 14:03:13 +02:00
Michael Gottesman
db6d5a7cda Revert "Revert "[ownership] Ignore non-consuming uses in dead end blocks when we are analyzing objects that are consumed once in the same block in which they are defined.""
This reverts commit f53525b0a1.
2019-06-24 11:14:45 -07:00
Michael Gottesman
24cff27f0c Revert "Revert "[ownership] If we have an undef address, do not treat it as being owned. It is any.""
This reverts commit 7a28a02189.
2019-06-24 11:14:45 -07:00
Xi Ge
f53525b0a1 Revert "[ownership] Ignore non-consuming uses in dead end blocks when we are analyzing objects that are consumed once in the same block in which they are defined."
This reverts commit 9a67f2d3ba.
2019-06-24 11:02:44 -07:00
Xi Ge
7a28a02189 Revert "[ownership] If we have an undef address, do not treat it as being owned. It is any."
This reverts commit e2c540461e.
2019-06-24 11:02:35 -07:00
swift-ci
dd9a9fe195 Merge pull request #25704 from gottesmm/pr-4bfe70900a409216e2b3f647d33d6644012367d6 2019-06-24 00:08:16 -07:00
Michael Gottesman
e2c540461e [ownership] If we have an undef address, do not treat it as being owned. It is any. 2019-06-23 23:06:51 -07:00
Michael Gottesman
9a67f2d3ba [ownership] Ignore non-consuming uses in dead end blocks when we are analyzing objects that are consumed once in the same block in which they are defined. 2019-06-23 22:15:26 -07:00
Joe Groff
70aba4d1fe Serialization: Deserialize opaque type xrefs from the right extension module.
When deserializing an opaque type xref inside an extension context, we were looking
incorrectly in the base module of the type being extended, rather than in the module
of the extension, where the opaque type would really be. Fixes rdar://problem/51775500.

This includes a small refactoring of OpaqueTypeDecl deserialization to break the inevitable
cycle between deserializing the namingDecl, and the namingDecl turning around and re-
deserializing its opaque return type. This is NFC but avoids some unnecessary work.
2019-06-19 09:46:49 -07:00
Slava Pestov
f681cbe264 SIL: Remove SILVTable::Entry::Linkage
This field would store the linkage of the original method, if it was
distinct from the linkage of a vtable thunk. It is no longer used.
2019-06-09 15:54:05 -07:00
Ben Cohen
e9d4687e31 De-underscore @frozen, apply it to structs (#24185)
* De-underscore @frozen for enums

* Add @frozen for structs, deprecate @_fixed_layout for them

* Switch usage from _fixed_layout to frozen
2019-05-30 17:55:37 -07:00
Joe Groff
cec9e9e33a Opaque types require a newer Swift runtime.
Check the availability of decls that declare an opaque return type to ensure they deploy to a
runtime that supports opaque types.

rdar://problem/50731151
2019-05-15 11:39:53 -07:00
Michael Gottesman
4374754217 [sil] Teach the verifier that open_existential_addr immutable is safe to pass as Indirect_InoutAliasable.
We do not consider inout_aliasable to be "truly mutating" since today it is just
used as a way to mark a captured argument and not that something truly has
mutating semantics. The reason why this is safe is that the typechecker
guarantees that if our value was immutable, then the use in the closure must be
immutable as well.

In a future SIL, we want to remove Inout_Aliasable in favor of just using
inout/in_guaranteed using the capture info from the type checker.

rdar://50212579
2019-05-01 10:36:24 -07:00
Joe Groff
5215290f25 Serialization: Cross-reference opaque return types by mangled name. rdar://problem/50005972 2019-04-18 14:41:26 -07:00
Michael Gottesman
6552a0221e [ownership] Fix a corner case in the linear lifetime checker.
Specifically, if we had a value that was consumed in the same block that it was
produced in, we ignored use-after-frees in subsequent blocks. We did check for
use-after-frees in the same block though. The general case was handled
correctly, this was just an incorrect early exit.

On master, this only found one problem (namely the one fixed in:
14d39c0cf9). I do not expect this corner case to
have more impact after cherry-picking to 5.1.

rdar://49794321
2019-04-10 16:06:47 -07:00
Michael Gottesman
f854547c55 [ownership] Enable ownership verification by default.
I also removed the -verify-sil-ownership flag in favor of a disable flag
-disable-sil-ownership-verifier. I used this on only two tests that still need
work to get them to pass with ownership, but whose problems are well understood,
small corner cases. I am going to fix them in follow on commits. I detail them
below:

1. SILOptimizer/definite_init_inout_super_init.swift. This is a test case where
DI is supposed to error. The only problem is that we crash before we error since
the code emitting by SILGen to trigger this error does not pass ownership
invariants. I have spoken with JoeG about this and he suggested that I fix this
earlier in the compiler. Since we do not run the ownership verifier without
asserts enabled, this should not affect compiler users. Given that it has
triggered DI errors previously I think it is safe to disable ownership here.

2. PrintAsObjC/extensions.swift. In this case, the signature generated by type
lowering for one of the thunks here uses an unsafe +0 return value instead of
doing an autorelease return. The ownership checker rightly flags this leak. This
is going to require either an AST level change or a change to TypeLowering. I
think it is safe to turn this off since it is such a corner case that it was
found by a test that has nothing to do with it.

rdar://43398898
2019-03-25 00:11:52 -07:00
Michael Gottesman
7b0309b432 [ownership] Fix up some parse/serialization tests for ownership.
Since I am enabling ownership verification by default, rather than disabling it
on these tests I just fixed them to follow ownership invariants.
2019-03-24 22:24:46 -07:00
Michael Gottesman
0dfaa19f9f [ownership] Rename enable-sil-ownership => verify-sil-ownership.
I have been meaning to do this change for a minute, but kept on putting it off.
This describes what is actually happening and is a better name for the option.
2019-03-18 01:31:44 -07:00
Slava Pestov
1159af50d9 Rename -enable-resilience to -enable-library-evolution and make it a driver flag
Fixes <rdar://problem/47679085>.
2019-03-14 22:24:26 -04:00
Michael Gottesman
dfe65c20f1 [lit] Change all %target-swift-frontend invocations to verify ownership.
We are already doing this for most of the target-swift-frontend ones. In a
subsequent commit, I am going to remove the redundant ones.

NOTE: On Darwin, I have not enabled it on the %target-swift-frontend mock SDK
commands. I ran into an issue with one of the PrintAsObjC tests that I am still
tracking down. I would rather just get this turned on to prevent further
regressions.

I also updated a few tests that needed some small tweaks to pass
this. Specifically:

1. Some parser tests needed some extra ossa insts to pass the verifier. This
doesn't effect what they actually test.

2. IRGen tests that should never have processed ossa directly. Today, we are
working towards a world where IRGen never processes [ossa] directly. Instead we
lower first. If/when that changes, we should add back in specific [ossa] tests.

3. A singular SILOptimizer definite init test case where the ownership verifier
fails due to a case which DI already flags as illegal (we just crash earlier). I
am going to look into fixing that by putting in errors in the typechecker or in
SILGen (not sure yet). I changed it to use target-swiftc_driver which does not
have ownership verification enabled.
2019-03-12 20:17:20 -07:00
Michael Gottesman
abe5fa931f [ownership] init_existential_ref is not forwarding: it should only traffic in owned values. 2019-03-12 11:14:15 -07:00
Joe Groff
bb67cf815c Merge pull request #21355 from technicated/tuple-keypaths-2
Tuple KeyPaths
2019-02-25 12:56:05 -08:00
Michael Gottesman
1d7bc6cdfd [ownership] Change is_escaping_closure to accept any ownership as an operand instead of requiring guaranteed.
This is a point use that even makes sense for owned values.
2019-02-25 10:44:39 -08:00
Saleem Abdulrasool
348520c4f1 Merge pull request #22688 from sarveshtamba/master
Changes for test failures on PowerPC64LE when running as non-root user
2019-02-25 08:26:54 -08:00
Michael Gottesman
6ddc8589e8 [ownership] Treat mark_dependence as forwarding in its first parameter.
Previously, we only did this for the first parameter if it was converting from
escape to no-escape. We want to /always/ do this.
2019-02-20 21:44:18 -08:00
Jordan Rose
43feb9cbe1 On Apple platforms, use swiftmodule directories for the stdlib (#21797)
This changes the Swift resource directory from looking like

    lib/
      swift/
        macosx/
          libswiftCore.dylib
          libswiftDarwin.dylib
          x86_64/
            Swift.swiftmodule
            Swift.swiftdoc
            Darwin.swiftmodule
            Darwin.swiftdoc

to

    lib/
      swift/
        macosx/
          libswiftCore.dylib
          libswiftDarwin.dylib
          Swift.swiftmodule/
            x86_64.swiftmodule
            x86_64.swiftdoc
          Darwin.swiftmodule/
            x86_64.swiftmodule
            x86_64.swiftdoc

matching the layout we use for multi-architecture swiftmodules
everywhere else (particularly frameworks).

There's no change in this commit to how Linux swiftmodules are
packaged. There's been past interest in going the /opposite/ direction
for Linux, since there's not standard support for fat
(multi-architecture) .so libraries. Moving the .so search path /down/
to an architecture-specific directory on Linux would allow the same
resource directory to be used for both host-compiling and
cross-compiling.

rdar://problem/43545560
2019-02-19 14:47:21 -08:00
technicated
e7eb743d1b Fixed some tests after rebase 2019-02-18 14:45:24 +01:00
technicated
69b71f6f70 Added SIL/Serialization test
The test involves tuples in a generic environment (struct)
2019-02-18 10:22:17 +01:00
technicated
1577afee80 Added more tests (related to generic tuples) 2019-02-18 10:19:43 +01:00
technicated
d7324b977e Added more tests
Testing SILGen & IRGen tuple keypath generation
Added tuple element type check in SILVerifier
2019-02-18 10:19:42 +01:00
technicated
a0ed29d326 🎄 Improved tuple key path support in SIL ~ Merry Christmas 🎄
Using an anonymous union in KeyPathPatternComponent instead of the weird void * in SetterAndIdKind
Added TupleElement kind to KeyPathComponentKindEncoding
Written basic SIL keypath serialization tests
Deleted or edited some old Swift-level tuple key path tests
2019-02-18 10:15:58 +01:00
sarveshtamba
acc551f9bc Changes for test failures on PowerPC64LE when running as non-root user 2019-02-18 08:25:53 +00:00
Saleem Abdulrasool
28c8dccb2a test: alteration for Windows support
This brings the SIL test coverage to 100% passing.
2019-02-16 14:26:28 -08:00
Azoy
5af2663c57 Textualize assign init kind
Rename [assign] to [reassign]

fix some tests

AssignOwnershipQualifier

formatting

moar formatting
2019-02-12 20:16:25 -06:00
Michael Gottesman
ac6f318c4d [ownership] Fix the linear lifetime checker to emit leak fixups for certain loops it didn't handle correctly before.
Specifically:

bb0:
  br bb1

bb1:
  cond_br ..., bb2, bb3

bb2:
  br bb1

bb3:
  return

What would happen in this case is that we wouldn't revisit bb1 after we found
the double consume to grab the leak (and would early exit as well). So we would
not insert a destroy for the out of loop value causing a leak from the
perspective of the ownership checker. This was due to us early exiting and also
due to us not revisiting bb1 after we went around the backedge from bb2 ->
bb1. Now what we do instead is if we catch a double consume in a block we have
already visited, we check if we haven't visited any of that block's
successors. If we haven't, we add that to the list of successors we need to
visit.
2019-01-29 16:39:58 -08:00
sarveshtamba
c1612c73c3 Merge branch 'master' of https://github.com/apple/swift 2019-01-17 06:57:21 +00:00
sarveshtamba
78e968f026 Changes for #SR-9413:Swift 5.0 test failures on PowerPC #21541 2019-01-16 11:20:40 +00:00
Jordan Rose
6cfea1906b [test] Re-enable test whose issue has long since been fixed (#21789)
Unfortunately deserialize_appkit.sil seems to have developed another
issue in the mean time. Filed rdar://problem/47200045 for that.
2019-01-11 08:23:02 -08:00
Arnold Schwaighofer
cb0c53abee SIL: Remove isEscapedByUser flag on convert_escape_to_noescape instruction
It was only used for materializeForSet and is now dead code.
2019-01-04 09:21:38 -08:00
John McCall
e674d65dfd When parsing SILDeclRefs, ignore declarations that lack the right accessor.
Fixed rdar://46650834.
2019-01-03 16:26:46 -05:00
Slava Pestov
2e635e9603 Sema: Add @_hasInitialValue and @_hasStorage in typeCheckDecl() not validateDecl()
We only ever use this in TBDGen and interface printing, and we only ever
generate TBD files or print interfaces for declarations in primary files,
so let's avoid unnecessary work in validateDecl().

Eventually we want validateDecl() to be replaced with a getInterfaceType()
request, so adding new attributes in this path (or other side effects in
general) is a big no-no.
2019-01-02 15:12:02 -05:00
Slava Pestov
5e617b5cb9 SIL: Verifier checks resilience invariants for keypath instruction 2018-12-21 17:53:28 -05:00
Slava Pestov
c750f56261 SIL: Fix boxes test to actually emit SIB 2018-12-21 17:51:32 -05:00
Saleem Abdulrasool
bf7ea5b2e8 test: make the last SIL.Parse test pass on Windows
With the UUID conversion, this is the last SIL.Parse test failure on Windows due
to the DLLExport annotation.
2018-12-21 10:46:08 -08:00
Slava Pestov
fef729a2bc SIL: Set witness table linkage when parsing a witness table that already exists
I discovered this while testing the new commit, since it results in fewer
witness tables getting pre-declared.

There was a SIL test that relied on the old behavior; I'm going to explicitly
declare those witness tables as public_external to preserve behavior.
2018-12-20 17:36:38 -05:00
Slava Pestov
d7bd07112b SIL: Change the linker to deserialize more lazily
Note that SILModule::lookUpWitnessTable() only attempts to deserialize
the witness table if we already have a declaration. In the
SILLinkerVisitor, we would call lookUpWitnessTable(), see if it returned
null, create a declaration, and if deserializeLazily is true, we would
call lookUpWitnessTable() again; this time, there was a declaration, and
we would deserialize the witness table.

However, if there was already a witness table declaration when we first
called lookUpWitnessTable(), we would trigger deserialization, even if
deserializeLazily is false.

Change the first call to pass false.

I had to update a couple of tests; I believe they were already somewhat
nonsensical.
2018-12-20 17:36:38 -05:00
Michael Gottesman
4b95ca82b9 Merge pull request #21439 from gottesmm/pr-8067c5675a42d8ecfc248e2b2fe644ee2795fc06
[ownership] Eliminate -assume-parsing-unqualified-ownership-sil now that it is a no-op.
2018-12-19 17:35:40 -08:00
Michael Gottesman
fd4828e40a Eliminate -assume-parsing-unqualified-ownership-sil from tests.
I am doing this separately from the actual change to eliminate the option to
make it easier to review.
2018-12-19 12:54:13 -08:00
swift-ci
14dfa755a2 Merge pull request #21427 from brentdax/grading-tests-on-a-curve 2018-12-19 12:33:57 -08:00
Brent Royal-Gordon
7733cf27ca Switch swift-evolve XFAILs to UNSUPPORTEDs
These tests may not *reliably* fail with shuffled standard libraries, so we can’t use XFAIL, which fails if the test succeeds.
2018-12-18 16:25:12 -08:00