Commit Graph

38524 Commits

Author SHA1 Message Date
Evan Wilde
83b044f5fb Migrating LLVM API usage on main
This patch migrates the compiler off of the deprecated LLVM APIs where I
can.

 - APInt::getAllOnesValue -> APInt::getAllOnes
 - APInt::getNullValue -> APInt::getZero
 - APInt::isNullValue -> APInt::isZero
 - APInt::getMinSignedBits -> APInt::getSignificantBits
 - clang::Module::submodule_{begin,end} -> clang::Module::submodules
2023-07-13 11:22:35 -07:00
swift-ci
fb796193db Merge pull request #67280 from nate-chandler/nfc/20230713/1/valuebase-getusers
[SIL] NFC: Added ValueBase::getUsers.
2023-07-13 10:32:53 -07:00
Nate Chandler
8e7d9842ce [SIL] NFC: Added ValueBase::getUsers.
Make iterating user instructions a bit easier.
2023-07-13 08:19:09 -07:00
Slava Pestov
aa026f4d06 Merge pull request #67266 from slavapestov/transform-type-parameter-packs
Fix various places where we didn't handle "bound" pack references correctly
2023-07-13 08:09:04 -04:00
Allan Shortlidge
e973ff941f Merge pull request #67225 from tshortli/allow-usable-from-inline-access-in-default-args
Sema: Allow default arguments to access `@usableFromInline` decls
2023-07-12 20:40:24 -07:00
Xi Ge
45b5b4c13e Merge pull request #67269 from apple/block-list-note
ModuleLoader: emit a note when encountering a blocklisted module interface
2023-07-12 16:55:39 -07:00
Slava Pestov
d0202a7081 AST: Implement Type::transformTypeParameterPacks() 2023-07-12 18:02:14 -04:00
Konrad `ktoso` Malawski
2044cb78cf Merge pull request #66934 from kabiroberai/main 2023-07-13 06:53:23 +09:00
Xi Ge
b697d40fb6 ModuleLoader: emit a note when encountering a blocklisted module interface 2023-07-12 13:53:36 -07:00
Allan Shortlidge
496d29c47f AST: Remove FragileFunctionKind.allowUsableFromInline.
It was effectively always true after allowing default argument expressions to
reference `@usableFromInline` decls.
2023-07-12 12:47:06 -07:00
Alex Lorenz
4d084100ce [cxx-interop] Mark C++ functions with unavailable return type as unavailable
This prevents users from calling functions with unsupported or unavailable return types. This ensures that users don't for example call a function that returns a non-copyable and non-movable type

Fixes https://github.com/apple/swift/issues/64401
2023-07-11 16:40:57 -07:00
Joshua Turcotti
e8111932d9 Merge pull request #67172 from JTurcotti/sil-pass
Add SIL Pass for flow-sensitive, region-based Sendable checking
2023-07-11 15:08:36 -07:00
Rintaro Ishizaki
2b13365f0b Merge pull request #67206 from rintaro/parse-each-self-rdar107450487
[Parse] Accept 'self' after 'each'
2023-07-11 15:02:26 -07:00
Mike Ash
2d238bcea5 Merge pull request #67168 from mikeash/ptrauth-struct-context-descriptors
[Runtime][IRGen] Sign type context descriptor pointers.
2023-07-11 17:03:53 -04:00
Steven Wu
5fb778b7d2 [DependencyScan] Prevent command-line flags added again on re-scan
Add a flag `finalized` to indicate that a module entry in the dependency
cache is finalized and no longer needs to be updated. This prevents the
command-line flags from dependency inputs get added multiple times on
re-scan with the same service.

While during normal compilation, adding the same command-line flags
multiple times are fine, it is bad for caching builds as a new
compilation cache key needs to be computed every time.
2023-07-11 13:46:03 -07:00
Saleem Abdulrasool
b5e3ab55c6 Merge pull request #67200 from compnerd/arm64-spelling
Runtime: add MSVC architecture spelling (NFCI)
2023-07-11 13:37:48 -07: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
Andrew Trick
5e1b9fc7ad Merge pull request #67188 from atrick/membehavior-api
Cleanup and document SIL memory behavior APIs.
2023-07-11 12:49:15 -07:00
Pavel Yaskevich
4760b95282 Merge pull request #67183 from xedin/convert-effects-into-storageRestrictions
[AST/Sema] Implement @storageRestrictions attribute
2023-07-11 11:57:14 -07:00
jturcotti
e7a1747af2 Tweak, improve, and debug the PartitionAnalysis engine until a fairly comprehensive suite of simple tests passes (region_based_sendability.swift) 2023-07-11 11:12:38 -07:00
Joe Groff
631bcabd9e Merge pull request #67205 from jckarter/allocbox-to-stack-move-only-closure-remnants
Arrange for closure bodies promoted by AllocBoxToStack to have their originals removed by MoveOnlyChecker.
2023-07-11 08:42:12 -07:00
Nate Chandler
0675454267 [OwnershipUtils] NFC: Deleted dead declaration.
The two implementations of findPointerEscape were merged back in
https://github.com/apple/swift/pull/66723, so delete the declaration.
2023-07-11 08:23:10 -07:00
Holly Borla
dc92742ccc Merge pull request #67208 from hborla/extension-macro-flag
[Features] Allow ExtensionMacros to be enabled in noasserts builds.
2023-07-11 07:16:32 -07:00
Pavel Yaskevich
62719b05ac Merge pull request #67157 from amritpan/kp-declcontext
[Constraint System] Store key path root, value, and decl context for use across constraint system.
2023-07-10 23:09:09 -07:00
Holly Borla
ff8e3dfef3 [Features] Allow ExtensionMacros to be enabled in noasserts builds. 2023-07-10 16:37:54 -07:00
Amritpan Kaur
1d8e7ef2fe [CSGen] Record keypath for use across constraint system. 2023-07-10 15:54:22 -07:00
Rintaro Ishizaki
ababa1e461 [Parse] Accept 'self' after 'each'
Also move 'repeat', 'each', and 'any' expression parsing to
'parseExprSequenceElement'

rdar://107450487
2023-07-10 15:37:00 -07:00
jturcotti
29bd728f4c Begin to fill in the SendNonSendable SIL pass using a PartitionAnalysis engine, works for some simple examples but needs to address address values in SIL. 2023-07-10 15:20:14 -07:00
jturcotti
aae9f43bda Write PartitionUtils.h, implementing common utilities for manipulating a partition data structure that will be used for flow-sensitive, region-based Sendable checking. 2023-07-10 15:20:14 -07:00
Joe Groff
3d5285be6f Arrange for closure bodies promoted by AllocBoxToStack to have their originals removed by MoveOnlyChecker.
This is an improvement of #67031 which avoids deleting the closure function
body during AllocBoxToStack, which still breaks pass invariants by modifying
functions other than the currently-analyzed function. As a function pass,
AllocBoxToStack also doesn't really know with certainty whether the original
closure function is unused after stack promotion or not. We still want to
eliminate the original when it may contain invalid SIL for move-only values
that rely on the escape analysis for correct semantics, so rather than mark the
original function to be *ignored* during move-only checking, mark it to be
*deleted* by move-only checking if the function is in fact unused at that
point.

If the marked function is still used, we let it pass through move-only
checking normally, which may cause redundant diagnostics but is the right
thing to do since code is still potentially using the closure with escaping
semantics. We should rearrange things to make this situation impossible in
the future.

rdar://110675352
2023-07-10 15:18:16 -07:00
Michael Gottesman
8f64bceb17 Merge pull request #67202 from gottesmm/pr-bf5ceafdd45802deafe22132048f87ea30198725
[reference-bindings] Add Sema checks for inout reference bindings to make sure we can only attach to lvalues
2023-07-10 15:16:55 -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
Michael Gottesman
f2bfa1cbac [reference-bindings] Add Sema checks for inout reference bindings to make sure we can only attach to lvalues
rdar://112029192
2023-07-10 12:47:46 -07:00
Saleem Abdulrasool
39c238a7ea Runtime: add MSVC architecture spelling (NFCI)
Add `_M_ARM64` to mirror `__aarch64__`.
2023-07-10 08:37:19 -07:00
Alex Hoppen
3a0b72620a Merge pull request #63717 from ahoppen/ahoppen/remaining-solver-based 2023-07-09 08:14:43 +02: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
Andrew Trick
5bae8551ff Cleanup and document SIL memory behavior APIs.
This is code that I am fairly familiar with but it still took a day of
investigation to figure out how it is supposed to be used now in the
presence of bridging.

This primarily involved ruling out the possibity that the mid-level
Swift APIs could at some point call into the lower-level C++ APIs.

The biggest problem was that AliasAnalysis::getMemoryBehaviorOfInst()
was declared as a public interface, and it's name indicates that it
computes the memory behavior. But it is just a wrapper around a Swift
API and never actually calls into any of the C++ logic that is
responsible for computing memory behavior!
2023-07-07 20:54:31 -07:00
Mike Ash
fe7e13bba5 [Runtime][IRGen] Sign type context descriptor pointers.
Ensure that context descriptor pointers are signed in the runtime by putting the ptrauth_struct attribute on the types.

We use the new __builtin_ptrauth_struct_key/disc to conditionally apply ptrauth_struct to TrailingObjects based on the signing of the base type, so that pointers to TrailingObjects get signed when used with a context descriptor pointer.

We add new runtime entrypoints that take signed pointers where appropriate, and have the compiler emit calls to the new entrypoints when targeting a sufficiently new OS.

rdar://111480914
2023-07-07 18:10:35 -04:00
Slava Pestov
b19fc60a52 Merge pull request #67180 from slavapestov/type-decoder-one-element-tuple
TypeDecoder: Unwrap unlabeled one-element tuples when expanding pack expansions
2023-07-07 17:14:14 -04:00
Alex Hoppen
ed4dc1becd Change Optional -> llvm::Optional 2023-07-07 21:16:33 +02:00
Slava Pestov
6a4036343f TypeDecoder: Unwrap unlabeled one-element tuples when expanding pack expansions 2023-07-07 14:14:51 -04:00
Alex Hoppen
00eaed3af9 [CodeCompletion] Migrate postfix expr completion to solver-based 2023-07-07 19:51:01 +02:00
Alex Hoppen
6cec68e302 [IDE] Ignore score kinds that represent implicit conversions when solving for code completion
Ignore conversion score increases during code completion to make sure we don't filter solutions that might start receiving the best score based on a choice of the code completion token.
2023-07-07 19:50:46 +02:00
Pavel Yaskevich
d55f737cc5 [ConstraintSystem] NFC: Replace LLVM_NODISCARD with [[nodiscard]] on newly added method 2023-07-07 19:50:46 +02:00
Pavel Yaskevich
e337a3947d [ConstraintSystem] Implement tap expression checking in the solver
Generate a conjunction for each tap expression body as soon as it
gets a contextual type instead of separate post-factum type-checking
via `typeCheckTapBody`.
2023-07-07 19:50:46 +02:00
Pavel Yaskevich
28a39d6df1 [AST] NFC: Add a way to request initialized/accesses properties from init accessor 2023-07-07 10:00:36 -07:00
Pavel Yaskevich
94522ff81a [Sema] InitAccessors: Implement validation of @storageRestrictions attribute 2023-07-07 10:00:36 -07:00
Pavel Yaskevich
9992af593c [Parse] InitAccessors: Implement @storageRestrictions parsing, diagnostics and error recovery 2023-07-07 10:00:36 -07:00
Pavel Yaskevich
9719cd01ef [AST] InitAccessors: Introduce new @storageRestrictions(initializes:accesses:) attribute
This is the replacement for `initializes`, `accesses` attributes.
2023-07-07 10:00:35 -07:00
Amritpan Kaur
8203b439d1 [ConstraintSystem] Track keypath root, value, declcontext
for each keypath expression for constraint system.
2023-07-07 08:47:39 -07:00