Commit Graph

2441 Commits

Author SHA1 Message Date
Evan Wilde
250082df25 [NFC] Reformat all the LLVMs
Reformatting everything now that we have `llvm` namespaces. I've
separated this from the main commit to help manage merge-conflicts and
for making it a bit easier to read the mega-patch.
2023-06-27 09:03:52 -07:00
Evan Wilde
f3ff561c6f [NFC] add llvm namespace to Optional and None
This is phase-1 of switching from llvm::Optional to std::optional in the
next rebranch. llvm::Optional was removed from upstream LLVM, so we need
to migrate off rather soon. On Darwin, std::optional, and llvm::Optional
have the same layout, so we don't need to be as concerned about ABI
beyond the name mangling. `llvm::Optional` is only returned from one
function in
```
getStandardTypeSubst(StringRef TypeName,
                     bool allowConcurrencyManglings);
```
It's the return value, so it should not impact the mangling of the
function, and the layout is the same as `std::optional`, so it should be
mostly okay. This function doesn't appear to have users, and the ABI was
already broken 2 years ago for concurrency and no one seemed to notice
so this should be "okay".

I'm doing the migration incrementally so that folks working on main can
cherry-pick back to the release/5.9 branch. Once 5.9 is done and locked
away, then we can go through and finish the replacement. Since `None`
and `Optional` show up in contexts where they are not `llvm::None` and
`llvm::Optional`, I'm preparing the work now by going through and
removing the namespace unwrapping and making the `llvm` namespace
explicit. This should make it fairly mechanical to go through and
replace llvm::Optional with std::optional, and llvm::None with
std::nullopt. It's also a change that can be brought onto the
release/5.9 with minimal impact. This should be an NFC change.
2023-06-27 09:03:52 -07:00
nate-chandler
98d895db52 Merge pull request #66892 from nate-chandler/rdar111221183
[MoveOnlyAddressChecker] Fixed two use-before-def handlings.
2023-06-23 19:13:56 -07:00
Nate Chandler
7c1e5ec1d1 [SIL] NFC: Added debug printing of block ids. 2023-06-23 10:16:53 -07:00
Joe Groff
31952cc470 Merge pull request #66860 from jckarter/no-moveonly-property-descriptors
SILGen: Don't emit key path property descriptors for properties in or of noncopyable types.
2023-06-22 17:50:57 -07:00
Joe Groff
024efd2a4e SILGen: Don't emit key path property descriptors for properties in or of noncopyable types.
Key paths don't support them yet, and the current component representation is inadequate to
handle them without requiring internal copying in all cases, so let's avoid generating
invalid property descriptors for them today. rdar://111171284
2023-06-22 11:10:32 -07:00
Meghana Gupta
03b8c49371 Merge pull request #66645 from meg-gupta/mixinremovesmall
Simplify forwarding instruction definitions in SIL
2023-06-21 13:02:13 -07:00
Erik Eckstein
ceb32c014a SIL: hop_to_executor can release
The `hop_to_executor` instruction is a synchronization point and any kind of other code might run at this point,
which potentially can release objects.

Fixes a miscompile

rdar://110924258
2023-06-20 20:47:19 +02:00
Meghana Gupta
fff1c5d09a Merge pull request #66685 from meg-gupta/interiorpointerupdate
Update operand ownership of some concurrency instructions
2023-06-20 10:51:22 -07:00
nate-chandler
13cdc66405 Merge pull request #66705 from nate-chandler/rdar110901430
[TypeLowering] Move-only types are lexical.
2023-06-16 13:26:51 -07:00
Nate Chandler
9b6904498e [TypeLowering] Move-only types are lexical.
Vars of such types should be given lexical `alloc_stack`s by
`AllocBoxToStack` which requires that the `alloc_box` insts formed for
them have an associated borrow scope which in turn requires that type
lowering for move only structs and enums have their lexical bits set.

rdar://110901430
2023-06-16 08:26:04 -07:00
Alex Lorenz
4590aa1ede Merge pull request #65813 from hyp/eng/passInRegs
[cxx-interop] Itanium ABI C++ records should have address-only layout when they can't be passed in registers
2023-06-16 07:47:48 -07:00
Meghana Gupta
acba067916 Update operand ownership of some concurrency instructions that were inacurrately marked as InteriorPointer.
Also add verification to check whenever a new instruction is marked with InteriorPointer,
the InteriorPointerOperand utility is updated.
2023-06-15 16:30:31 -07:00
John McCall
9b7123bad7 Handle pack expansion types when verifying lowered types in SIL
I don't like that this method exists, and I'd like to rip it out
in favor of expecting an opaque lowering, but I'm worried about
doing that this late in 5.9.

Fixes rdar://107290521
2023-06-15 16:33:40 -04:00
Meghana Gupta
16c300c2af Remove OwnershipForwardingConversionInst, ConversionInst.
Add new ConversionOperation abstraction, use this in place of ConversionInst
2023-06-15 10:53:28 -07:00
Meghana Gupta
6df7ebbb4e Update and add new apis on ForwardingInstruction 2023-06-15 10:53:06 -07:00
John McCall
acbd4a6022 Fix the emission of closures into reabstracted contexts with
variadic-tuple results.  There are three parts to this.

First, fix the emission of indirect result parameters to do a
proper abstraction-pattern-aware traversal of tuple patterns.
There was a FIXME here and everything.

Second, fix the computation of substituted abstraction
patterns to properly handle vanishing tuples.  The previous code
was recursively destructuring tuples, but only when it saw a
tuple as the substituted type, which of course breaks on vanishing
tuples.

Finally, fix the emission of returns into vanishing tuple
patterns by allowing the code to not produce a TupleInitialization
when the tuple pattern vanishes.  We should always get a singleton
element initializer in this case.

Fixes rdar://109843932, plus a closely-related test case for
vanishing tuples that I added myself.
2023-06-14 21:29:22 -04:00
Meghana Gupta
7cb3733e29 Rename OwnershipForwardingMixin -> ForwardingInstruction 2023-06-14 10:40:32 -07:00
Meghana Gupta
5d401fb70a Remove select_value SIL instruction 2023-06-13 14:13:43 -07:00
Holly Borla
cd752cca22 [NameLookup] Plumb source location arguments through all name lookup APIs.
This source location will be used to determine whether to add a name lookup
option to exclude macro expansions when the name lookup request is constructed.
Currently, the source location argument is unused.
2023-06-11 23:09:47 -07:00
eeckstein
4bacb7f069 Merge pull request #66376 from eeckstein/simplify-retain-release-value
Optimizer: implement the SILCombine peephole optimizations for retain_value and release_value in Swift
2023-06-08 18:37:03 +02:00
Slava Pestov
7cc8063889 SIL: Forgot to pass SubstFlags::PreservePackExpansionLevel in one place 2023-06-07 15:17:54 -04:00
Erik Eckstein
5325a4fe21 Swift SIL: add some instruction classes and APIs
* add `UnownedRetainInst` and `UnownedReleaseInst`
* add `var value` to `RetainValueInst` and `ReleaseValueInst`
* make the protocol `UnaryInstruction` be an `Instruction`
* add `var Type.isValueTypeWithDeinit`
* add `var Type.isUnownedStorageType`
* add `var OperandArray.values`
2023-06-07 12:55:56 +02:00
Pavel Yaskevich
d191ef8fca [SIL/Parse] InitAccessors: Implement printing and parsing of previously iniitalized properties
Properties that are marked as initialized are printed as `[assign=<index>]`
where `<index>` point to the property position in `getInitializedProperties()`
list.
2023-06-06 18:59:46 -07:00
Pavel Yaskevich
85a8a056f1 [SILParse] InitAccessors: Print/parse "mode" of assign_or_init instructions when its known 2023-06-06 18:59:46 -07:00
Pavel Yaskevich
b22e8e6ea1 [SIL] InitAccessors: Add tracking of properties that require assign instead of initialization
Some properties from `initializes(...)` list could be already initialized,
which means that Raw SIL lowering has to emit `destroy_addr` for them
before calling init accessor.
2023-06-06 18:59:46 -07:00
Pavel Yaskevich
63e7561f8c [SIL] InitAccessors: Introduce a new Out kind to MarkUninitializedInst
`Out` marks indirect results that have to be fully initialized
before their lifetime ends.
2023-06-06 18:59:43 -07:00
Pavel Yaskevich
3b85840611 [SIL/DI] InitAccessors: Get all required info from AssignOrInit instead of instruction location
This is a more robust way of accessing the property information
because instruction has a reference to init accessor declaration.
2023-06-06 18:59:13 -07:00
Pavel Yaskevich
2a64f285ac [SIL] InitAccessors: Implement lowering of init accessor types
- Convesion is `thin`
- `newValue` is passed as +1
- All properties listed in `accesses(...)` appear as `@inout` parameters
- All properties listed in `initialized(...)` appear as `@out` results.
2023-06-06 18:59:13 -07:00
Pavel Yaskevich
dc9420eaca [SILGen] InitAccessors: Add a way to check whether SILDeclRef points to an init accessor 2023-06-06 18:59:13 -07:00
Holly Borla
7512f6e366 [SIL] Add an assignment mode to AssignOrInitInst that will be set by DI. 2023-06-06 18:59:13 -07:00
Holly Borla
ac66a06199 [SIL] Add a new AssignOrInit instruction for init accessors.
This instruction is similar to AssignByWrapperInst, but instead of having
a destination operand, the initialization is fully factored into the init
function operand. Like AssignByWrapper, AssignOrInit has partial application
operands of both the initializer and the setter, and DI will lower the
instruction to a call based on whether the assignment is initialization or
a setter call.
2023-06-06 18:59:10 -07:00
Holly Borla
684ef9c482 [AST] Add a new accessor kind for init accessors. 2023-06-06 18:57:31 -07:00
Michael Gottesman
29672c503a Merge pull request #66381 from gottesmm/noimplicitcopy-borrow-consuming
[borrowing/consuming] Make borrowing and consuming parameters no implicit copy.
2023-06-06 21:41:18 -04:00
Slava Pestov
c30f7dcdd8 Merge pull request #66096 from slavapestov/pack-element-type
Preliminary support for substitution with nested pack expansions
2023-06-06 19:11:52 -04:00
Michael Gottesman
59c8cff917 [borrowing] Add support for borrowing/consuming copyable types to be a noimplicitcopy type.
rdar://108383660
2023-06-06 18:12:29 -04:00
Michael Gottesman
70ab38d9da [move-only] Add a new instruction: moveonlywrapper_to_copyable_box.
I am going to use this to unwrap ${ @moveOnly T } so that I can pass it to
partial_apply that expect a ${ T }
2023-06-06 14:26:22 -04:00
Slava Pestov
29bbd66a91 SIL: Preliminary type lowering support for PackElementType 2023-06-06 14:18:37 -04:00
Slava Pestov
ec3aa5c9d7 SIL: Preliminary AbstractionPattern support for PackElementType 2023-06-06 14:18:37 -04:00
Slava Pestov
a3e13610be SIL: Use walkPackReferences() instead of bespoke logic 2023-06-06 14:18:37 -04:00
Slava Pestov
be218f5e16 AST: Use PackElementType to model references to pack elements of outer expansions 2023-06-06 14:18:37 -04:00
Michael Gottesman
611e6760f5 [borrowing/consuming] Add a new instruction called copyable_to_moveonlywrapper_addr.
Just the $*T -> $*@moveOnly T variant for addresses. Unlike the object version
this acts like a cast rather than something that provides semantics from the
frontend to the optimizer.
2023-06-06 12:42:23 -04:00
Michael Gottesman
43f42e2c04 [borrowing/consuming] Add new instruction: moveonlywrapper_to_copyable_addr.
The reason why I am using a different instruction for addresses and objects here
is that the object checker doesnt have to deal with things like initialization.
2023-06-06 12:42:23 -04:00
Andrew Trick
ef6de50ecd [move-only] Fix TypeLowering to preserve value deinits
MoveOnlyLoadableStruct should only lower to memberwise destroys if it
has no deinit.
2023-06-06 09:17:53 -07:00
Allan Shortlidge
9c98ee88cd Merge pull request #66353 from tshortli/avoid-stripping-obsolete-decls
SIL: Don't skip lowering obsolete decls
2023-06-06 08:29:41 -07:00
Allan Shortlidge
e3c0d17875 SIL: Don't skip lowering obsolete decls.
When `-unavailable-decl-optimization=complete` is specified obsolete decls
should be preserved because their symbols are still ABI since they are
available to use when targeting deployment targets earlier than the obsoletion
version.

Resolves rdar://110268649
2023-06-05 20:30:06 -07:00
swift-ci
4ef135cc10 Merge pull request #66201 from nate-chandler/dealloc-on-stack-packs
[IRGen] Dealloc on-stack metadata/wtable packs on the dominance frontier.
2023-06-05 13:30:18 -07:00
Nate Chandler
c51d53b0d3 [PackMetadataMarkerInserter] Insert fewer markers.
Rather than emitting markers for every single instruction of the
relevant sorts, check whether the instructions' types involve packs.
Only record them as potential on-stack pack metadata emitters if they
do.
2023-06-05 08:11:28 -07:00
Nate Chandler
fd45076a02 [SIL] Added no-stack-pack-metadata annotation. 2023-06-05 08:11:28 -07:00
Nate Chandler
efca4e57c8 [SIL] Added on-stack pack metadata marker insts.
The new alloc_pack_metadata and dealloc_pack_metadata are inserted as
part of IRGen lowering.  The former indicates that the next instruction
might result in on-stack pack metadata being emitted.  The latter
indicates that this is the position at which metadata emitted on behalf
of its operand should be cleaned up.
2023-06-05 08:11:28 -07:00