Commit Graph

11 Commits

Author SHA1 Message Date
Erik Eckstein
7cceaff5f3 SIL: don't print operand types in textual SIL
Type annotations for instruction operands are omitted, e.g.

```
  %3 = struct $S(%1, %2)
```

Operand types are redundant anyway and were only used for sanity checking in the SIL parser.

But: operand types _are_ printed if the definition of the operand value was not printed yet.
This happens:

* if the block with the definition appears after the block where the operand's instruction is located

* if a block or instruction is printed in isolation, e.g. in a debugger

The old behavior can be restored with `-Xllvm -sil-print-types`.
This option is added to many existing test files which check for operand types in their check-lines.
2024-11-21 18:49:52 +01:00
Nate Chandler
06921cfe84 [SIL] Hollow out Builtin.copy, deprecate _copy.
The copy operator has been implemented and doesn't use it.  Remove
`Builtin.copy` and `_copy` as much as currently possible.

Source compatibility requires that `_copy` remain in the stdlib.  It is
deprecated here and just uses the copy operator.

Handling old swiftinterfaces requires that `Builtin.copy` be defined.
Redefine it here as a passthrough--SILGen machinery will produce the
necessary copy_addr.

rdar://127502242
2024-05-03 15:56:25 -07:00
Kavon Farvardin
cc7a41fc2c [stdilb] introduce Copyable protocol
This replaces the old, unavailable `_Copyable`.

rdar://110420673
2023-09-21 00:55:17 -07:00
Kavon Farvardin
091d63a5c8 revise how the Copyable constraint is added
The _Copyable constraint was implemented as a marker protocol.
That protocol is part of the KnownProtocol's in the compiler.
When `ASTContext::getProtocol(KnownProtocolKind kind)` tries
to find the ProtocolDecl for Copyable, it will look in the
stdlib module (i.e., Swift module), which is where I initially
planned to put it.

That created problems initially when some regression tests
use `-parse-stdlib` failed to do that protocol lookup, which is
essential for adding the constraint (given the current implementation).

That led to believe we need to pull Copyable out of the stdlib, but that's
wrong. In fact, when building the Swift module itself, we do `-parse-stdlib`
but we also include `-module-name Swift`. This causes the _Copyable protocol
defined in the Stdlib to be correctly discovered while building the stdlib
itself (see the test case in this commit). So, the only downside of
having the Copyable protocol in the Stdlib is that `-parse-stdlib` tests
in the compiler can't use move-only types correctly, as they'll be
allowed in generic contexts. No real program would build like this.

Until I have time to do a further refactoring, this is an acceptable trade-off.

fixes rdar://104898230
2023-03-04 11:42:09 -08:00
Kavon Farvardin
d2da71a58c update existing tests after banning move-only types in generics
A number of our existing tests put move-only types in optionals and
used them as arguments to generic type parameters. It turns out that
many of these appearances in the tests were not crucial for the test's
functionality itself.

The little coverage for force-unwrapping an Optional<moveOnly>
that was lost will be regained once we make these types sound.

I also tried to tidy up some of the tests with consistent naming for
operations on values, i.e., `consumeVal` and `borrowVal` functions.
2023-02-01 23:38:28 -08:00
Nate Chandler
24bbac52f1 [Test] Removed unused pattern match. 2023-01-04 07:46:38 -08:00
Nate Chandler
b6e6c20865 [AddressLowering] Handle builtins for resumes.
The builtins for resuming UnsafeContinuations traffic in generic values
and must be rewritten to use addresses instead of values.
2022-12-07 13:14:43 -08:00
Nate Chandler
ce43690d8e [AddressLowering] Handle existential_metatype.
The handling is the same as for value_metatype.
2022-11-04 10:47:09 -07:00
Nate Chandler
7dd0a609a2 [AddressLowering] Handle unchecked to loadable.
When casting via unchecked_bitwise_cast, if the destination type is
loadable, don't mark the value it produces rewritten--that value is not
one that AddressLowering is tracking.  Instead, replace its copy_value
uses with load [copy] uses of the address the rewritten instruction
produces.
2022-11-04 10:47:09 -07:00
Nate Chandler
520dfc26cd [OpaqueValues] Added variants of addressOfBorrow.
The variants are produced by SILGen when opaque values are enabled.
They are necessary because otherwise SILGen would produce
address_to_pointer of values.

They will be lowered by AddressLowering.
2022-11-02 14:41:35 -07:00
Nate Chandler
e357fb45c5 [OpaqueValues] Handle Builtin.copy.
Specify the operand ownership of the Builtin differently depending on
whether lowered addresses are used.  Handle rewriting the value version
of the builtin as the address version of the builtin in AddressLowering.
2022-11-02 13:48:47 -07:00