Commit Graph

6754 Commits

Author SHA1 Message Date
Pavel Yaskevich
c38b9b1e08 Merge pull request #67945 from xedin/remove-runtimeMetadata
[Frontend] NFC: Remove code and tests related to rejected @runtimeMetadata feature
2023-08-16 17:16:46 -07:00
Michael Gottesman
a897257d06 [silgen] Add a new private API on CleanupManager called isFormalAccessCleanup.
I am going to use this in ManagedValue.
2023-08-16 11:12:20 -07:00
swift-ci
214b779cb8 Merge remote-tracking branch 'origin/main' into rebranch 2023-08-15 17:14:23 -07:00
Michael Gottesman
d7be3993dc Merge pull request #67943 from gottesmm/pr-c5eb72c4d397b9ab4e8a1b477187c3b7b059f540
[silgen] Convert even more cases of using trivial and values without ownership to use for*RValueWithoutOwnership APIs.
2023-08-15 17:02:36 -07:00
Pavel Yaskevich
23d838af32 [SIL/SILGen] [AST] NFC: Remove @runtimeMetadata related code 2023-08-15 12:17:31 -07:00
Michael Gottesman
ff948f7309 [silgen] Convert even more cases of using trivial and values without ownership to use for*RValueWithoutOwnership APIs. 2023-08-15 11:04:01 -07:00
swift-ci
b61e014970 Merge remote-tracking branch 'origin/main' into rebranch 2023-08-14 22:34:47 -07:00
John McCall
66ea1f1ddd [NFC] Fix an oversight in my previous NFC patches
This is starting to feel a little spaghetti-ish.  This kind of
existential stuff is hard to do in C++.
2023-08-14 22:29:27 -04:00
John McCall
127acfa686 [NFC] Share argument order and names between the arguments and results code
This was an annoying change, but mostly mechanical.  The goal here is
to create parallel structure between the two paths so that it isn't
utterly confusing to share common CRTP paths between them.  The renaming
of translate->process is just to make sure that all of the call sites
get correctly rewritten.
2023-08-14 21:48:13 -04:00
John McCall
bcb6230302 [NFC] Extract a lot of common expansion logic out of ResultPlanner 2023-08-14 19:06:49 -04:00
John McCall
939270c573 [NFC] More prep work for sharing code between param and result reabstraction 2023-08-14 19:06:49 -04:00
John McCall
c2207c6608 [NFC] Fold PlanData into the main ResultBuilder in SILGenPoly
I'm trying to create more parallel structure between the param
and result reabstraction code so that, hopefully, some of the
basic explosion reasoning can be shared.
2023-08-14 19:06:49 -04:00
Zak Kent
17fedabb5e [Immediate] Implemented SwiftMaterializationUnit
Implemented SwiftMaterializationUnit, supporting
lazy compilation of individual Swift functions.
2023-08-14 13:28:22 -07:00
swift-ci
f7d8889924 Merge remote-tracking branch 'origin/main' into rebranch 2023-08-10 07:15:40 -07:00
nate-chandler
c3fb1377a0 Merge pull request #67752 from nate-chandler/opaque-values/20230804/1/any-hashable-var
[OpaqueValues] Emit RValue of AnyHashable erasure into new context.
2023-08-10 06:57:50 -07:00
nate-chandler
9d5b175220 Merge pull request #67846 from nate-chandler/nfc/20230809/1/silgen-closure-simplification
[SILGen] Remove subtle identity function call.
2023-08-10 06:57:25 -07:00
Nate Chandler
368536ce92 [SILGen] Remove subtle identity function call.
Back in 33f4f57cc4 of
https://github.com/apple/swift/pull/28044 fame,
non-`CaptureKind::Constant:` uses of `Entry.val` in
`SILGenFunction::emitCaptures` were replaced with a use of the newly
added lambda `getAddressValue` applied at `Entry.val`.

The replacement of `Entry.value` with `getAddressValue(Entry.value)` in
the case of `CaptureKind::Box` had no effect.

Back then, the reason was that the condition

    SGM.Types
        .getTypeLowering(
            valueType,
            TypeExpansionContext::noOpaqueTypeArchetypesSubstitution(
                expansion.getResilienceExpansion()))
            .isAddressOnly() &&
        !entryValue->getType().isAddress()

under which something other than the input was returned would never
hold: CaptureKind::Box is used for LValues and those never satisfy
`!entryValue->getType().isAddress()`.

Since that PR, the getAddressValue lambda has grown.  There are two
additional aspects to consider: (1) forceCopy, (2) isPack.  (1) is not
relevant because `false` was being passed for the `CaptureKind::Box`
case.  (2) can not currently happen because pack lvalues haven't been
implemented.  But even if they were implemented, the argument passed to
the lambda would still need to be an address.

The same all holds for the `CaptureKind::ImmutableBox` case which only
differs from the `CaptureKind::Box` by a couple of lines.
2023-08-09 16:55:55 -07:00
Nate Chandler
e894a34ef8 [SILGen] Gardening: Deleted comment.
Way back in

commit d0bb0274e9
Author: Joe Groff <jgroff@apple.com>
Date:   Mon Nov 23 11:47:09 2015 -0800

the convention was changed such that LValues were passed only by box
rather than by box and address.  Delete the comment that says that both
are passed.
2023-08-09 16:49:30 -07:00
swift-ci
a4bb99bd1b Merge remote-tracking branch 'origin/main' into rebranch 2023-08-09 07:15:49 -07:00
Nate Chandler
999f2b023a [OpaqueValues] AnyHashable src gets new context.
When storing an instance of some type that conforms to Hashable into an
lvalue of type AnyHashable, the source rvalue needs to be emitted within
a new SGFContext.  Otherwise, the LocalVarInitialization for the var of
type AnyHashable would be used and an attempt would be made to store the
instance of the conforming type into the projected box.
2023-08-09 07:03:07 -07:00
nate-chandler
1791108bde Merge pull request #67722 from nate-chandler/opaque-values/1/20230803/unowned-copies
[SIL] Represent copies to @sil_unowned values.
2023-08-09 06:59:49 -07:00
nate-chandler
3336083265 Merge pull request #67690 from nate-chandler/opaque-values/20230802/2/weak-copies
[SIL] Represent copies to and from @sil_weak values.
2023-08-09 06:59:19 -07:00
Nate Chandler
c8d1ea5aae [SILGen] Gardening: Line wrapping. 2023-08-08 16:45:13 -07:00
Nate Chandler
6e26b416f4 [SILGen] Gardening: Moved comment. 2023-08-08 16:45:13 -07:00
swift-ci
864fd7fc68 Merge remote-tracking branch 'origin/main' into rebranch 2023-08-08 16:14:54 -07:00
zachary0kent
d240ffa340 Merge pull request #67747 from zachary0kent/sil-gen-top-level
[SILGen] Unified Entry Point Emission
2023-08-08 16:14:45 -07:00
Nate Chandler
ded4d32c71 [OpaqueValues] Emit unowned copies.
In opaque values mode, emit the unowned copy instructions to convert as
follows:

strong_copy_unowned_value: `@owned $sil_unowned T` -> `@owned $T`
unowned_copy_value: `@owned T` -> `@owned $sil_unowned T`

Doing so is necessary in opaque values mode where it is needed to deal
with unowned values directly rather than indirectly via `load_unowned`s
and `store_unowned`s.
2023-08-08 15:49:17 -07:00
Nate Chandler
b616d14ff5 [OpaqueValues] Emit weak copies.
In opaque values mode, emit the new weak copy instructions to convert as
follows:

strong_copy_weak_value: `@owned $sil_weak T?` -> `@owned $T?`
weak_copy_value: `@owned $T?` -> `@owned $@sil_weak T?`

Doing so is necessary in opaque values mode where it is needed to deal
with weak values directly rather than indirectly via `load_weak`s and
`store_weak`s.
2023-08-08 15:47:13 -07:00
Nate Chandler
c007bae723 [SIL] Added weak_copy_value.
The new instruction wraps a value in a `@sil_weak` box and produces an
owned value. It is only legal in opaque values mode and is transformed
by `AddressLowering` to `store_weak`.
2023-08-08 15:47:13 -07:00
Nate Chandler
e135c5cac7 [SIL] Added strong_copy_weak_value.
The new instruction unwraps an `@sil_weak` box and produces an owned
value. It is only legal in opaque values mode and is transformed by
`AddressLowering` to `load_weak`.
2023-08-08 15:47:13 -07:00
swift-ci
cab8e41175 Merge remote-tracking branch 'origin/main' into rebranch 2023-08-08 13:53:58 -07:00
Zak Kent
db1cdbd99f [SILGen] Refactor use of removed forEachMemberToLower 2023-08-08 11:30:34 -07:00
Zak Kent
a459c97d74 [SILGen] [Test] Address code review comments 2023-08-08 11:25:11 -07:00
Zak Kent
03526c3ad0 [SILGen] Remove TODO referring to unified entry point emission 2023-08-08 11:25:11 -07:00
Zak Kent
3657cbafc9 [SILGen] Move all top-level emission code to SILGenTopLevel.cpp 2023-08-08 11:25:11 -07:00
Zak Kent
441a356200 [SILGen] Emit toplevel code through emitFunctionDefinition
Emit SILDeclRefs representing entry points with SourceFile
source correctly.
2023-08-08 11:25:11 -07:00
Zak Kent
3b4e94f65b [SILGen] Emit toplevel code through emitFunctionDefinition
Emit SILDeclRefs representing entry points with SourceFile
source correctly.
2023-08-08 11:25:11 -07:00
Zak Kent
7dae2e6905 [SILGen] Implement SILGenTopLevel
Implement SILGenTopLevel, a class that walks a file
run in script mode to generate all toplevel code
at once.
2023-08-08 11:25:11 -07:00
Michael Gottesman
cece84f345 [silgen] Rename forTrivialRValue -> forRValueWithoutOwnership and use it in a few places to eliminate more forUnmanaged.
With this commit, we have now eliminated ~55% of all forUnmanaged in the code
base.
2023-08-08 11:15:06 -07:00
Michael Gottesman
2faa8193d0 [silgen] Fix another trivial forUnmanaged -> forObjectRValueWithoutOwnership. 2023-08-08 11:15:06 -07:00
Michael Gottesman
5095bd31b0 [silgen] Convert a few instances of ManagedValue::forUnmanaged(*).copy() -> ManagedValue::forCopyOwnedObjectRValue.
Just removing more ManagedValue::forUnmanaged.
2023-08-08 11:15:06 -07:00
swift-ci
35d06a45ac Merge remote-tracking branch 'origin/main' into rebranch 2023-08-08 10:14:49 -07:00
Michael Gottesman
85e38afbac Merge pull request #67780 from gottesmm/pr-d9b586775f6ea84fe9868857eb8dd2eeaeb39f6f
[silgen] Rename forTrivialObjectRValue -> forObjectRValueWithoutOwnership and change a bunch of forUnmanaged to use this API
2023-08-08 09:58:33 -07:00
swift-ci
e4e98ae506 Merge remote-tracking branch 'origin/main' into rebranch 2023-08-08 09:19:39 -07:00
Allan Shortlidge
7a38f171e0 Merge pull request #67785 from tshortli/decls-for-lowering-conveniences
NFC: Refactor conveniences for filtering out unavailable decls
2023-08-08 09:04:09 -07:00
swift-ci
20999e2089 Merge remote-tracking branch 'origin/main' into rebranch 2023-08-08 07:21:10 -07:00
nate-chandler
0cfa74763f Merge pull request #67725 from nate-chandler/opaque-values/20230803/2/open-opaque-existential-value
[OpaqueValues] Open opaque existential value.
2023-08-08 06:57:00 -07:00
Allan Shortlidge
cf5888a149 NFC: Refactor conveniences for filtering out unavailable decls.
Introduce `AvailableDuringLoweringDeclFilter` which can be composed with
`OptionalTransformRange` to implement iterators that filter out unavailable
decls.
2023-08-07 18:59:49 -07:00
Michael Gottesman
2208caac32 [silgen] Convert a bunch of forUnmanaged -> forObjectRValueWithoutOwnership.
NFCI.
2023-08-07 13:36:02 -07:00
Michael Gottesman
7dbcdfb126 [silgen] Rename forTrivialObjectRValue -> forObjectRValueWithoutOwnership.
The reason to do this rename is that this is also used for objects that while
non-trivial have .none ownership. Example: enum instance without a case.
2023-08-07 13:36:02 -07:00