Commit Graph

1057 Commits

Author SHA1 Message Date
swift-ci
d754c3ede9 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-07 10:13:42 -07:00
swift-ci
93c42f7a75 Merge pull request #68370 from meg-gupta/fwdops
Add new apis to ForwardingOperation
2023-09-07 10:08:11 -07:00
Meghana Gupta
bacfdbd0b0 Add ForwardingOperation::visitForwardedValues api 2023-09-07 01:17:16 -07:00
Meghana Gupta
79ca1eb1f7 Add ForwardingOperation::getSingleForwardingOperand api 2023-09-07 00:35:14 -07:00
swift-ci
f52fc06ac7 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-06 18:14:46 -07:00
zoecarver
2d61de8364 [embedded] Introduce RuntimeEffect::Existential and guard diagnostics on embedded feature being enabled. 2023-09-06 10:48:17 -07:00
Sophia Poirier
86d368f364 Merge remote-tracking branch 'upstream/main' into fix-rebranch-automerger 2023-08-31 14:10:52 -07:00
Michael Gottesman
37d60a08bb [move-only] Rename mark_must_check -> mark_unresolved_non_copyable_value.
I was originally hoping to reuse mark_must_check for multiple types of checkers.
In practice, this is not what happened... so giving it a name specifically to do
with non copyable types makes more sense and makes the code clearer.

Just a pure rename.
2023-08-30 22:29:30 -07:00
swift-ci
392f0263da Merge remote-tracking branch 'origin/main' into rebranch 2023-08-25 20:33:22 -07:00
Meghana Gupta
47b728ee63 Merge pull request #68151 from meg-gupta/printmodule
Add -sil-print-module-on-error
2023-08-25 20:23:42 -07:00
Meghana Gupta
74d5c401f2 Add -sil-print-module-on-error 2023-08-25 13:53:00 -07:00
Nate Chandler
6ccd08b4e0 Merge branch 'main' into rebranch.
Resolve conflicts introduced in
https://github.com/apple/swift/pull/67944 as follows:

```
diff --git a/include/swift/Runtime/RuntimeFunctions.def b/include/swift/Runtime/RuntimeFunctions.def
index 3c973b5884b..44cde707d17 100644
--- a/include/swift/Runtime/RuntimeFunctions.def
+++ b/include/swift/Runtime/RuntimeFunctions.def
@@ -2537,16 +2537,10 @@ FUNCTION(AutoDiffCreateLinearMapContextWithType,
          swift_autoDiffCreateLinearMapContextWithType, SwiftCC,
          DifferentiationAvailability,
          RETURNS(RefCountedPtrTy),
-<<<<<<< HEAD
-         ARGS(SizeTy),
+         ARGS(TypeMetadataPtrTy),
          ATTRS(NoUnwind),
          EFFECT(AutoDiff),
          MEMEFFECTS(ArgMemOnly))
-=======
-         ARGS(TypeMetadataPtrTy),
-         ATTRS(NoUnwind, ArgMemOnly),
-         EFFECT(AutoDiff))
->>>>>>> public-github/main

 // void *swift_autoDiffProjectTopLevelSubcontext(AutoDiffLinearMapContext *);
 FUNCTION(AutoDiffProjectTopLevelSubcontext,
@@ -2563,16 +2557,10 @@ FUNCTION(AutoDiffAllocateSubcontextWithType,
          swift_autoDiffAllocateSubcontextWithType, SwiftCC,
          DifferentiationAvailability,
          RETURNS(Int8PtrTy),
-<<<<<<< HEAD
-         ARGS(RefCountedPtrTy, SizeTy),
+         ARGS(RefCountedPtrTy, TypeMetadataPtrTy),
          ATTRS(NoUnwind),
          EFFECT(AutoDiff),
          MEMEFFECTS(ArgMemOnly))
-=======
-         ARGS(RefCountedPtrTy, TypeMetadataPtrTy),
-         ATTRS(NoUnwind, ArgMemOnly),
-         EFFECT(AutoDiff))
->>>>>>> public-github/main
```
2023-08-24 16:24:32 -07:00
Kshitij Jain
d5a3e2e630 [AutoDiff] Fixes memory leaks in autodiff linear map context allocation builtins (#67944)
When the differentiating a function containing loops, we allocate a linear map context object on the heap. This context object may store non-trivial objects, such as closures, that need to be released explicitly. Fix the autodiff linear map context allocation builtins to correctly release such objects and not just free the memory they occupy.
2023-08-24 13:57:10 -07:00
swift-ci
d466ece668 Merge remote-tracking branch 'origin/main' into rebranch 2023-08-21 11:55:11 -07:00
Hamish Knight
7982e4bd7e [AST] Handle null in printDeclDescription
Sink down the null Decl printing into
`printDeclDescription` such that all callers
benefit from it.

This is an attempt at fixing at least the secondary
crash in rdar://113491294, it does not address the
underlying crash.
2023-08-21 15:35:16 +01:00
swift-ci
9d38c6b53e Merge remote-tracking branch 'origin/main' into rebranch 2023-08-17 14:34:52 -07:00
Nate Chandler
7bddaf36a0 [SIL] Added tuple_pack_extract.
The new instruction is needed for opaque values mode to allow values to
be extracted from tuples containing packs which will appear for example
as function arguments.
2023-08-16 11:15:05 -07:00
swift-ci
525350af1b Merge remote-tracking branch 'origin/main' into rebranch 2023-08-10 22:14:25 -07:00
Michael Gottesman
33eedc1574 Merge pull request #67874 from gottesmm/pr-179e2ec3ed29bb0d8c35dc99f710a18571a0a24e
[sil] Convert AddressWalker from using virtual methods to use CRTP and add a transitive -> endpoint user API
2023-08-10 17:18:27 -07:00
Michael Gottesman
308a6fed58 Move AddressWalker::walk into the header and eliminate AddressWalker.cpp. 2023-08-10 12:58:50 -07:00
swift-ci
a4bb99bd1b Merge remote-tracking branch 'origin/main' into rebranch 2023-08-09 07:15:49 -07:00
Nate Chandler
f938287710 [SIL] Added unowned_copy_value. 2023-08-08 15:49:17 -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
Becca Royal-Gordon
3eebc6dddb Merge branch 'main' into rebranch
# Conflicts:
#	lib/SILOptimizer/Differentiation/Common.cpp
2023-08-04 15:09:50 -07:00
Michael Gottesman
c9be4bda49 Merge pull request #67677 from gottesmm/borrowed-base-silgenlvalue
[move-only] Ensure that we properly nest accesses to base values if the base is noncopyable or the accessor result is noncopyable.
2023-08-04 12:26:19 -07:00
Michael Gottesman
c3d2276241 [silgen] Eliminate two more cases around subscripts where we were not borrowing.
Also, the store_borrow work in the previous patch caused some additional issues
to crop up. I fixed them in this PR and added some tests in the process.
2023-08-02 11:09:31 -07:00
swift-ci
2919af9fa7 Merge remote-tracking branch 'origin/main' into rebranch 2023-08-01 13:36:46 -07:00
Joe Groff
984b4f2387 Merge pull request #67633 from jckarter/raw-layout-initialization
Fix `@_rawLayout` initialization to avoid spurious lifetime ends.
2023-08-01 13:34:29 -07:00
Joe Groff
9b783560ad Fix @_rawLayout initialization to avoid spurious lifetime ends.
We can't really treat them as always-initialized because that makes move checking
think that there's a value to destroy even on initialization, causing deinits to
run on uninitialized memory. Remove my previous hack, and use a `zeroInitializer`
to initialize the value state when emitting `init`, which is where we really need
the bootstrapping-into-initialized behavior. rdar://113057256
2023-08-01 08:34:02 -07:00
swift-ci
1ead4ffed7 Merge remote-tracking branch 'origin/main' into rebranch 2023-07-28 10:57:58 -07:00
Nate Chandler
e5d87f75a8 [SIL] Add source formal type to checked_cast_br.
It is necessary for opaque values where for casts that will newly start
out as checked_cast_brs and be lowered to checked_cast_addr_brs, since
the latter has the source formal type, IRGen relies on being able to
access it, and there's no way in general to obtain the source formal
type from the source lowered type.
2023-07-27 15:04:15 -07:00
swift-ci
1969199a8e Merge remote-tracking branch 'origin/main' into rebranch 2023-07-26 23:13:08 -07:00
Evan Wilde
4105b927dd Fixing header locations and changes
This patch fixes a handful of header references that moved, or were
transitively included and aren't anymore.
2023-07-25 12:28:28 -07:00
Evan Wilde
309aed4925 Add SmallSetVector replacement
llvm::SmallSetVector changed semantics
(https://reviews.llvm.org/D152497) resulting in build failures in Swift.
The old semantics allowed usage of types that did not have an
`operator==` because `SmallDenseSet` uses `DenseSetInfo<T>::isEqual` to
determine equality. The new implementation switched to using
`std::find`, which internally uses `operator==`. This type is used
pretty frequently with `swift::Type`, which intentionally deletes
`operator==` as it is not the canonical type and therefore cannot be
compared in normal circumstances.

This patch adds a new type-alias to the Swift namespace that provides
the old semantic behavior for `SmallSetVector`. I've also gone through
and replaced usages of `llvm::SmallSetVector` with the
`Swift::SmallSetVector` in places where we're storing a type that
doesn't implement or explicitly deletes `operator==`. The changes to
`llvm::SmallSetVector` should improve compile-time performance, so I
left the `llvm::SmallSetVector` where possible.
2023-07-25 12:28:27 -07:00
Nate Chandler
a1d10997da [SIL] Promoted least-common ancestor to Dominance.
It's a general purpose helper and there will soon be another user.
2023-07-24 16:57:14 -07:00
eeckstein
b9d0aa34e1 Merge pull request #67395 from eeckstein/redundant-load-elimination
Optimizer: re-implement the RedundantLoadElimination pass in Swift
2023-07-21 13:58:19 +02:00
Erik Eckstein
5b3c34b9e7 fix a linking problem in swift-frontend
Sometimes when building the SwiftCompilerSources with a host compiler, linking fails with unresolved symbols for DenseMap and unique_ptr destroys.
This looks like a problem with C++ interop: the compiler thinks that destructors for some Analysis classes are materialized in the SwiftCompilerSources, but they are not.
Explicitly defining those destructors fixes the problem.
2023-07-21 08:01:31 +02:00
Erik Eckstein
ab2202cc50 AliasAnalysis: look through begin_cow_mutation and end_cow_mutation when getting the root of a reference 2023-07-21 07:19:56 +02:00
Erik Eckstein
ee3d702019 Swift SIL: add NominalTypeDecl.isStructWithUnreferenceableStorage 2023-07-21 07:19:12 +02:00
swift-ci
089df84044 Merge pull request #67219 from nate-chandler/nfc/20230711/1/ownership-utils-cleanups
[OwnershipUtils] NFC: Two small cleanups.
2023-07-11 13:10:22 -07:00
Nate Chandler
194904f854 [OwnershipUtils] NFC: Deduplicated implementation.
The only difference between visitLocalScopeEndingUses and
getLocalScopeEndingInstructions is that the former evaluates a lambda
with each `Operand *` and the latter adds `->getUser()` to a
SmallVectorImpl for each.  So factor the latter through the former and
add the users to the SmallVectorImpl in the lambda.
2023-07-11 08:22:59 -07:00
Kuba (Brecka) Mracek
2961cafb05 Merge pull request #66844 from kubamracek/static-init-structs
Allow using structs with trivial initializers in globals that require static initialization (e.g. @_section attribute)
2023-07-10 15:11:55 -07:00
Kuba Mracek
145f12f6a3 Allow using structs with trivial initializers in globals that require static initialization (e.g. @_section attribute)
Before this change, if a global variable is required to be statically initialized (e.g. due to @_section attribute), we don't allow its type to be a struct, only a scalar type works. This change improves on that by teaching MandatoryPerformanceOptimizations pass to inline struct initializer calls into initializer of globals, as long as they are simple enough so that we can be sure that we don't trigger recursive/infinite inlining.
2023-07-08 19:26:59 -07:00
Michael Gottesman
823f008c99 Merge pull request #67145 from gottesmm/pr-694caf05ac09f8c08fb766c7589fe060c927f528
[move-only] Ban partial reinitialization after consuming a value.
2023-07-06 05:24:12 -07:00
Michael Gottesman
69a03c93f9 [move-only] Ban partial reinitialization after consuming a value.
This is similar to our ban on partial consuming a value for this release. The
reason for this is that, one can achieve a similar affect as partial consumption
via a consumption of the entire value and then a partial reinitialization. Example:

```swift
struct X : ~Copyable { var i = 5, var i2 = Klass() }
var x = X()
_ = consume x
x.i = 5
```

in the case above, we now have a value that is in a partially initialized state.

We still allow for move only types to have their fields initialized as long as
there is an intervening init.

rdar://111498740
2023-07-05 20:26:26 -07:00
Nate Chandler
22df319549 [Test] Ensourced fieldsensitive-multidefuse...
-liverange.  Moved the test next to the code it calls.
2023-07-04 11:52:14 -07:00
Nate Chandler
0c17600380 [Test] Ensourced accesspath-base.
Moved the test next to the code it calls.
2023-07-04 11:52:14 -07:00
Nate Chandler
50f2a0250f [Test] Ensourced ossa-lifetime-completion.
Moved the test next to the code it calls.
2023-07-04 11:52:13 -07:00
Nate Chandler
906a4b9d86 [Test] Ensourced extended-liveness.
Moved the test next to the code it calls.
2023-07-04 11:52:13 -07:00