Commit Graph

6583 Commits

Author SHA1 Message Date
swift-ci
e1bf084cc6 Merge remote-tracking branch 'origin/main' into rebranch 2024-05-03 22:34:10 -07:00
nate-chandler
768b3a4944 Merge pull request #73422 from nate-chandler/rdar127502242
[SIL] Hollow out Builtin.copy and deprecate _copy.
2024-05-03 22:19:47 -07: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
swift-ci
0f21099e90 Merge remote-tracking branch 'origin/main' into rebranch 2024-05-03 15:14:09 -07:00
nate-chandler
b7a84da318 Merge pull request #73408 from nate-chandler/rdar127452206
[SILCombine] Handle indirect error in apply(convert_function).
2024-05-03 15:03:29 -07:00
Nate Chandler
d2a8128ca3 [SIL] Expose indirect error type on convention. 2024-05-03 08:06:21 -07:00
Nate Chandler
cad0761acb [Test] Expose current pass.
Some clients need to access their parent transformation.
2024-05-03 08:06:21 -07:00
swift-ci
118192a63b Merge remote-tracking branch 'origin/main' into rebranch 2024-05-02 16:55:08 -07:00
Slava Pestov
625436af05 Merge pull request #73393 from slavapestov/pack-expansion-closures-part-3
SIL type lowering support for closures that capture pack element archetypes
2024-05-02 19:43:24 -04:00
Slava Pestov
34fc06919b SIL: Allow setting SILFunction's forwarding substitution map 2024-05-02 14:28:30 -04:00
Slava Pestov
fa89c52556 SIL: Introduce TypeConverter::getForwardingSubstitutionsForLowering() 2024-05-02 14:28:30 -04:00
Slava Pestov
1cad5f9350 SIL: Plumb pack element captures through type lowering 2024-05-02 13:40:54 -04:00
Kshitij
a7f8d6c647 [Autodiff] Adds bridging code in preparation for the Swift based Autodiff closure-spec pass 2024-05-02 09:14:05 -07:00
swift-ci
1daa6b2fdc Merge remote-tracking branch 'origin/main' into rebranch 2024-05-01 18:15:54 -07:00
Nate Chandler
2ca995177c [NFC] LifetimeCompletion: Lift default a level. 2024-05-01 08:57:01 -07:00
Nate Chandler
5383df755a [NFC] LifetimeCompletion: Clarify modes.
Completion is done along a boundary, either the availability or the
liveness boundary.  Represent which with a type.  Update docs and names.
2024-05-01 08:57:01 -07:00
Ben Barham
bc78809a2e Revert "[SIL] Require TransformIterator support random access"
This reverts commit 095028562e.
2024-04-28 18:17:54 -07:00
swift-ci
e472f47611 Merge remote-tracking branch 'origin/main' into rebranch 2024-04-26 07:14:44 -07:00
Nate Chandler
29d046fa42 [SIL] Add BorrowedValueKind::BeginApplyToken.
The token is a guaranteed value introduced by the begin_apply and
consumed by its end_apply, abort_apply, and end_borrow users.
2024-04-25 17:03:43 -07:00
Nate Chandler
5307ac666e [SIL] Permit end_borrow(begin_apply). 2024-04-25 17:03:41 -07:00
Nate Chandler
121b2faccc [NFC] SIL: Add ValueBase::isBeginApplyToken.
Forwards to the member function of the same name on
MultipleValueInstructionResult.
2024-04-25 17:03:11 -07:00
swift-ci
3ea8b187bb Merge remote-tracking branch 'origin/main' into rebranch 2024-04-25 16:54:34 -07:00
Emil Pedersen
a31d15c438 Merge pull request #72964 from Snowy1803/mem2reg-salvage-store
[DebugInfo] Salvage all stores
2024-04-25 16:52:37 -07:00
Emil Pedersen
584d1db307 [IRGen] [DebugInfo] Ignore autogenerated flag for variables 2024-04-24 18:25:43 -07:00
swift-ci
1cb60c0513 Merge remote-tracking branch 'origin/main' into rebranch 2024-04-23 14:13:45 -07:00
Emil Pedersen
523a769e34 [DebugInfo] [Mem2Reg] Move debug info promotion to salvageDebugInfo 2024-04-23 13:12:21 -07:00
Michael Gottesman
025902fa99 [sil] Add a SILDeclRef field to SILFunction, have SILGen set it, and teach SILFunction how to use the field to get the SourceFile associated with the SILFunction. 2024-04-23 11:45:36 -05:00
swift-ci
45d8b8836d Merge remote-tracking branch 'origin/main' into rebranch 2024-04-22 07:14:47 -07:00
Nate Chandler
d28a12d356 [MoveOnlyAddressChecker] Handle enum deinits.
Previously, the enum representation was fixed to represent the different
cases payloads separately with the unchecked_take_enum_data_addr
instruction consuming all fields but that whose address is obtained.
In a few places, handling for enum deinits was left undone with an
assertion that the enum not have one.

Here, the deinit bit of the enum is shifted to the end.  And the
assertions are replaced with handling.  Finally, the logic for inserting
destroys after switch_enum_addr instructions is fixed.
2024-04-19 12:37:34 -07:00
swift-ci
83f346aafd Merge remote-tracking branch 'origin/main' into rebranch 2024-04-17 17:49:54 -07:00
Michael Gottesman
bfa910dcb1 Merge pull request #72959 from gottesmm/tns-upstream-2
[region-isolation] Do not look through begin_borrow or move_value if they are marked as a var_decl.
2024-04-17 17:42:19 -07:00
Nate Chandler
c43f87101f Merge branch 'main' into rebranch
Conflicts:
      lib/Basic/Platform.cpp

```
diff --git a/lib/Basic/Platform.cpp b/lib/Basic/Platform.cpp
index 240edfa144a..1797c87635f 100644
--- a/lib/Basic/Platform.cpp
+++ b/lib/Basic/Platform.cpp
@@ -200,10 +200,7 @@ StringRef swift::getPlatformNameForTriple(const llvm::Triple &triple) {
   case llvm::Triple::CUDA:
   case llvm::Triple::DragonFly:
   case llvm::Triple::DriverKit:
-<<<<<<< HEAD
   case llvm::Triple::ELFIAMCU:
-=======
->>>>>>> main
   case llvm::Triple::Emscripten:
   case llvm::Triple::Fuchsia:
   case llvm::Triple::HermitCore:
```
2024-04-17 13:32:48 -07:00
Michael Gottesman
3c29997cd1 [region-isolation] Out of an abundance of caution convert isActor -> isAnyActor(). 2024-04-17 13:07:56 -07:00
Adrian Prantl
6357d12cfc Merge pull request #73009 from Snowy1803/debuginfo-small-fixes
[Debuginfo] Small fixes
2024-04-17 00:03:53 +02:00
Emil Pedersen
5512df5837 [SILCloner] Remap debug variable type and scope at the same time (NFC) 2024-04-16 10:28:13 -07:00
swift-ci
5b6eadf416 Merge remote-tracking branch 'origin/main' into rebranch 2024-04-12 13:37:42 -07:00
John McCall
82d9e4cb59 Fix a crash when serializing variadic generic tuple code under -wmo
It seems really unfortunate that we use SILCloner to, basically,
implement a recursive visitor of the types used in a SIL function,
but apparently it's what we do.

Fixes #72117.
2024-04-11 17:22:10 -04:00
eeckstein
e871ae40c5 Merge pull request #71176 from eeckstein/borrowed-from-instruction
SIL: add the borrowed-from instruction
2024-04-10 19:33:12 +02:00
Kuba (Brecka) Mracek
6e4ccca2db Merge pull request #72817 from kubamracek/embedded-print-on-assert
[embedded] In -assert-config Debug, print errors in assertions, preconditions, fatalErrors
2024-04-10 07:52:02 -07:00
Erik Eckstein
e14c1d1f62 SIL, Optimizer: update and handle borrowed-from instructions
Compute, update and handle borrowed-from instruction in various utilities and passes.
Also, used borrowed-from to simplify `gatherBorrowIntroducers` and `gatherEnclosingValues`.
Replace those utilities by `Value.getBorrowIntroducers` and `Value.getEnclosingValues`, which return a lazily computed Sequence of borrowed/enclosing values.
2024-04-10 13:38:10 +02:00
Erik Eckstein
ac4bc89c9a SIL: add the borrowed-from instruction.
It declares from which enclosing values a guaranteed phi argument is borrowed from.
2024-04-10 13:38:10 +02:00
Andrew Trick
38b78ed057 Merge pull request #72866 from atrick/fix-nonescapable-lowering
Fix type lowering of ~Copyable and ~Escapable generics.
2024-04-09 21:56:15 -07:00
Kuba Mracek
1bf38aa780 [embedded] Relax assert in SILLinkerVisitor::maybeAddFunctionToWorklist to allow external forward-declarations even in regular Swift, add tests 2024-04-09 11:36:37 -07:00
Ellie Shin
3bb25dec11 Merge pull request #72606 from apple/elsh/pkg-serialize-tables 2024-04-09 10:06:58 -07:00
Erik Eckstein
a980452e59 Add the experimental attribute @sensitive for struct declarations
The attribute declares that a struct contains "sensitive" data.
It enforces that the contents of such a struct value is zeroed out at the end of its lifetime.
In other words: the content of such a value is not observable in memory after the value's lifetime.

Also add an experimental feature `Sensitive` with which the attribute can be enabled.
2024-04-09 12:01:10 +02:00
Ellie Shin
c44b22a188 Serialize SIL witness-tables and v-tables and their entries if package cmo is
enabled. If two modules are in the same package and package cmo is enabled,
v-table or witness-table calls should not be generated at the use site in the
client module. Modified conformance serialization check to allow serializing
witness thunks.

Also reordered SIL functions bottom-up so the most nested referenced functions
can be serialized first. Allowed serializing a function if a shared definition
(e.g. function `print`). Added a check for resilient mode wrt struct instructions.

Added tests for SIL tables and resilient mode on/off.

rdar://124632670
2024-04-08 13:36:17 -07:00
Ben Barham
095028562e [SIL] Require TransformIterator support random access
`BlockT *LoopBase<BlockT, LoopT>::getLoopPreheader()` was changed in
LLVM 7243607867393a2b8ccd477e95e6f62d00f3206f to use `llvm::size` rather
than the checking that `child_begin() + 1 == child_end()`. `llvm::size`
requires that `std::distance` be O(1) and hence `TransformIterator`
(`swift::SILBasicBlock::succblock_iterator` defined as the child
iterator type in the graph traits for `SILBasicBlock *`) support random
access.

The change to `llvm::size` seems rather pointless, so we could probably
also revert that if need be.
2024-04-08 08:58:59 -07:00
Ben Barham
fc4f59547f [SIL] Add has_iterators_bits to the node options for a SILInstruction list
Originally added in LLVM in 088d272e83259a5d8e577a3d2e62012c42a9f9db
behind a flag, but then the flag was removed in
92eaf036bf22ecc276146cd073208e6a867af8d4.
2024-04-08 08:58:59 -07:00
Andrew Trick
a90b515df9 Fix type lowering of ~Escapable generics.
Factor AbstractionPattern::conformsToKnownProtocol and lower ~Escapable using the same logic as ~Copyable.

Adds support for conditionally Escapable enums.

Correctly sets the SILType::isTrivial flags for conditionally escapable structs and enums in environments (extensions)
that provide an Escapable conformance, such as:

    struct NE<E: ~Escapable> : ~Escapable {}

    extension NE: Escapable {
      func foo() -> Self {
        // Self is both Escapable and trivial here.
        self
      }
    }

Fixes rdar://125950218 ([nonescapable] support conditionally escapable enums)
2024-04-07 22:58:28 -07:00
Emil Pedersen
512ac6cc31 Merge pull request #72860 from Snowy1803/salvage-debug-info-tuple
[DebugInfo] Salvage debug info for tuples
2024-04-05 20:16:24 -07:00