Commit Graph

184017 Commits

Author SHA1 Message Date
Max Desiatov
3f4374b49b Merge branch 'main' into maxd/docc-compiler-docs 2025-05-29 18:12:39 +01:00
Anthony Latsis
9753d23597 Merge pull request #81819 from AnthonyLatsis/neotrygon
Basic: Adjust condition for include after macro removal in upstream LLVM
2025-05-29 15:06:51 +01:00
eeckstein
d29da0a6d9 Merge pull request #81830 from eeckstein/fix-simplify-apply
SimplifyApply: don't do the raw-enum comparison optimization for custom RawRepresentable enums
swift-DEVELOPMENT-SNAPSHOT-2025-05-29-a
2025-05-29 12:58:18 +02:00
Erik Eckstein
1a5ea19a85 SimplifyApply: don't do the raw-enum comparison optimization for custom RawRepresentable enums
Because we don't know what the custom `rawValue` can do.

Fixes a miscompile
rdar://152143111
2025-05-29 08:12:17 +02:00
Erik Eckstein
28985f4d41 Swift AST: add var EnumDecl.hasRawType 2025-05-29 08:12:17 +02:00
Konrad `ktoso` Malawski
8b4740f0cc Merge pull request #81797 from ktoso/wip-handle-public-import-distributed-awareness
[Distributed] account Distributed module use from DA declarations
2025-05-29 08:04:24 +09:00
Anthony Latsis
e7b2bc0d08 Basic: Adjust condition for include after macro removal in upstream LLVM
`HAVE_SYS_RESOURCE_H` was removed in
https://github.com/llvm/llvm-project/pull/123288, so this header is no
longer included at this particular location on rebranch, which breaks
the Linux build, where it is not transitively included either.

Use the same condition as in the use site
(`getChildrenMaxResidentSetSize`) instead.

Also, don't wrap `HAVE_GETRUSAGE` in `defined()` in case it does get
defined to 0.
2025-05-28 23:02:15 +01:00
Arnold Schwaighofer
7ac551636b Merge pull request #81714 from aschwaighofer/se0460
SE-0460: Introduce @specialized attribute
2025-05-28 12:03:48 -07:00
Yuta Saito
94b40d1bde Merge pull request #81799 from kateinoigakukun/yt/unify-wasmllvmruntime-build-dir
[wasm] Unify WasmLLVMRuntimeLibs and WasmThreadsLLVMRuntimeLibs build directories
2025-05-28 23:31:37 +09:00
Konrad `ktoso` Malawski
ff8b9f1453 [Distributed] fix typo in CHECK assertions (#81795)
... in distributed_actor_accessor_thunks_32bit.swift

Spotted a typo while skimming through the test so let's fix it. it
should be CHECK-SAME and not CHECK_SAME which would just do nothing
2025-05-28 00:24:11 -07:00
eeckstein
89bdb311ab Merge pull request #81780 from eeckstein/optimize-enum-comparison
Optimize enum comparisons
2025-05-28 07:01:29 +02:00
Yuta Saito
1592c9e2b3 [wasm] Unify WasmLLVMRuntimeLibs and WasmThreadsLLVMRuntimeLibs build directories
Having separate build product does not make sense and just adds
complexity to manage build directory names.
2025-05-28 04:14:23 +00:00
Konrad 'ktoso' Malawski
3b94f009d6 [Distributed] account Distributed module use from DA declarations
When issuing warnings about an import not needing to be public, we did
not account for the Distributed module MUST be imported when a
distributed actor is declared. This also actually means that a public
distributed actor effectively is a public use of the DistributedActor
protocol

resolves rdar://152129980
2025-05-28 12:54:07 +09:00
Joe Groff
dd59797638 Merge pull request #81617 from jckarter/no-non-escapable-property-descriptors
SILGen: Emit property descriptors for conditionally Copyable and Escapable types.
2025-05-27 19:22:56 -07:00
Marc Prud'hommeaux
cb3293b2e5 Update CI summary table on README to be more compact (#81647)
This PR updates the CI summary table in the README.md to summarize all
architectures for a host to be on the same line with the architecture
specified in the badge itself (rather than a generic "build" label),
thereby enabling the whole CI status to be visible on a single page.

It also adds accessibility labels to each of the CI badges for Global
Accessibility Awareness Month.
2025-05-27 17:23:55 -07:00
Michael Gottesman
6545a00df0 Merge pull request #81785 from gottesmm/pr-1489f56770ad7e22ae73fd5f1bdcc702edabba19
[region-isolation] Add a test showing that we do not infer nonisolated(unsafe) onto named closures.
2025-05-27 14:35:14 -07:00
Konrad `ktoso` Malawski
31b6ae2fcf Merge pull request #80984 from ktoso/task-names-update
[Concurrency][SE-review update] Task names update
2025-05-28 06:23:49 +09:00
Meghana Gupta
1998f416a5 Merge pull request #81678 from meg-gupta/fixsubst
Fix use-after-free on substituting function type involving conditional ~Escapable with Escapable type
2025-05-27 12:47:29 -07:00
Stephen Canon
592d72bba9 Concrete SIMD.init(repeating:) and SIMD.init(lowHalf:highHalf:) optimizations (#81766)
WIP to add more overloads to optimize SIMD codegen on concrete types.
Here we do:

- init(repeating:)
- init(lowHalf:highHalf:)

These are always inlined, even in debug, since LLVM knows how to lower
them to one or two instructions on the targets that we care about.
2025-05-27 15:15:13 -04:00
Michael Gottesman
746414bcd8 Merge pull request #81716 from gottesmm/pr-b82786e1ebbf00a9de46d342f0694a28999bc178
[send-non-sendable] Recurse to the full underlying value computation instead of just the object one when computing the underlying object of an address.
2025-05-27 11:39:48 -07:00
Allan Shortlidge
54e09736ef Merge pull request #81781 from tshortli/member-import-visibility-fixit-implicitly-internal
Sema: Omit `internal` from `MemberImportVisibility` fix-its when appropriate
2025-05-27 11:00:03 -07:00
Steven Wu
2999ab722d Merge pull request #81454 from cachemeifyoucan/clang-scanner-invocation-callback
[DependencyScanning] Avoid extra cc1 arg round-trip to speed up bridging
2025-05-27 10:58:35 -07:00
Saleem Abdulrasool
ba82e8802f Merge pull request #81775 from compnerd/sdk-layout
utils: adjust the "platform" install rules
2025-05-27 10:27:53 -07:00
Michael Gottesman
359eeec746 [region-isolation] Add a test showing that we do not infer nonisolated(unsafe) onto named closures.
The semantics we want is for nonisolated(unsafe) to be inferred onto anonymous
closures. We already have that semantics since we do not look through move_value
[var_decl] or begin_borrow [var_decl]. So even though the underlying
partial_apply will be viewed as nonisolated(unsafe), we will not consider that
when determining the nonisolated(unsafe) for the begin_borrow or move_value that
defined the variable whose value is the partial_apply.
2025-05-27 09:55:00 -07:00
Joe Groff
22eb7e62d9 SILGen: Emit property descriptors for conditionally Copyable and Escapable types.
Key paths can't reference non-escapable or non-copyable storage declarations,
so we don't need to refer to them resiliently, and can elide their property
descriptors.

However, declarations may still be conditionally Copyable and Escapable, and
if so, then they still need a property descriptor for resilient key path
references. When a property or subscript can be used in a context where it
is fully Copyable and Escapable, emit the property descriptor in a generic
environment constrained by the necessary conditional constraints.

Fixes rdar://151628396.
2025-05-27 09:35:40 -07:00
Anthony Latsis
052020668c Merge pull request #81764 from AnthonyLatsis/rebranch-lit
[test] lit.cfg: Wrap all substitutions with capture group refs in `SubstituteCaptures`
2025-05-27 17:34:14 +01:00
Ryan Mansfield
4976be883f Merge pull request #81747 from gottesmm/pr-021007354c4c9e191bcb63c8573c668dc20a40fd
[sil][docs] Add documentation about sil_implicit_leading_param.
2025-05-27 10:48:08 -04:00
Erik Eckstein
ed8922bc8e PerformanceInliner: always inline synthesized enum comparisons if one of the operands is a constant enum
If there is a "constant" enum argument to a synthesized enum comparison, we can always inline it, because most of it will be constant folded anyway.
This ensures the compiler is not creating terrible code for very simple enum comparisons, like
```
   if someEnum == .someCase {
      ...
   }
```

rdar://85677499
2025-05-27 12:11:03 +02:00
Erik Eckstein
c2866b397b Sema: add a @_semantics attribute to synthesized enum comparison functions
So that optimizations can identify and deal with them.
2025-05-27 12:11:03 +02:00
Erik Eckstein
cac594fb86 Optimizer: peephole optimization for raw-value enum comparsions
Optimize (the very inefficient) RawRepresentable comparison function call to a simple compare of enum tags.
For example,
```
  enum E: String {
    case  a, b, c
  }
```
is compared by getting the raw values of both operands and doing a string compare.
This peephole optimizations replaces the call to such a comparison function with a direct compare of the enum tags, which boils down to a single integer comparison instruction.

rdar://151788987
2025-05-27 12:11:03 +02:00
Erik Eckstein
0486f1a7f7 Swift Utils: make StringRef be ExpressibleByStringLiteral 2025-05-27 12:11:03 +02:00
Allan Shortlidge
dbb1d783d9 Sema: Omit internal from MemberImportVisibility fix-its when appropriate.
Omit an explicit access level from `MemberImportVisibility` fix-its under the
following conditions:

- `InternalImportsByDefault` is enabled.
- The required import needs an `internal` access level or lower.
- The module is not yet imported explicitly in any other file.

Resolves rdar://149577615.
2025-05-26 22:56:47 -07:00
Allan Shortlidge
426f48dcd4 Tests: Rename test cases associated with MemberImportVisibility. 2025-05-26 22:56:47 -07:00
Allan Shortlidge
7387f85ba2 Merge pull request #81767 from tshortli/fix-zippered-custom-availability-queries
SILGen: Fix `if #available` for unavailable custom domains in zippered modules
swift-DEVELOPMENT-SNAPSHOT-2025-05-27-a
2025-05-26 22:26:49 -07:00
Saleem Abdulrasool
9040fab1d1 utils: adjust the "platform" install rules
Rename `Install-Platform` to `Install-SDK` as it adjusts the SDK layout.
This is something that we should work towards minimising and ensuring
that the install rules in CMake properly stage the files. In the mean
time, this allows us to properly structure the SDK.

Alter the parameters to avoid the explicit OS, extracting it from the
platform set provided. Additionally provide an SDK identifier to allow
us to handle the experimental SDKs as well.
2025-05-26 13:39:21 -07:00
Ian Anderson
0027779029 Merge pull request #81726 from ian-twilightcoder/remove_darwin_overlay
[CMake][Darwin] Remove support for building the SDK overlays on Apple platforms
2025-05-26 12:19:28 -07:00
eeckstein
ddca2bae98 Merge pull request #81706 from eeckstein/mandatory-temprvalue-elimination
Optimizer: Improve performance of large InlineArrays at Onone
2025-05-26 07:56:42 +02:00
Allan Shortlidge
4aa516aebb SILGen: Fix if #available for unavailable custom domains in zippered modules.
When generating SIL for an `if #available(SomeDomain)` query in code being
compiled for a zippered target, the generated code was mis-compiled if
`SomeDomain` were disabled at compile time. Empty version ranges need to be
handled explicitly by `SILGenFunction::emitZipperedOSVersionRangeCheck()`.

SILGen still miscompiles `if #unavailable` queries generally in code compiled
for a zippered target (rdar://147929876).

Resolves rdar://150888941.
2025-05-25 08:27:12 -07:00
Daniil Kovalev
1e403ecf5c [AutoDiff] Support custom derivatives for @_alwaysEmitIntoClient functions (#78908)
Consider an `@_alwaysEmitIntoClient` function and a custom derivative
defined
for it. Previously, such a combination resulted different errors under
different
circumstances.

Sometimes, there were linker errors due to missing derivative function
symbol -
these occurred when we tried to find the derivative in a module, while
it
should have been emitted into client's code (and it did not happen).

Sometimes, there were SIL verification failures like this:

```
SIL verification failed: internal/private function cannot be serialized or serializable: !F->isAnySerialized() || embedded
```

Linkage and serialization options for the derivative were not handled
properly,
and, instead of PublicNonABI linkage, we had Private one which is
unsupported
for serialization - but we need to serialize `@_alwaysEmitIntoClient`
functions
so the client's code is able to see them.

This patch resolves the issue and adds proper handling of custom
derivatives
of `@_alwaysEmitIntoClient` functions. Note that either both the
function and
its custom derivative or none of them should have
`@_alwaysEmitIntoClient`
attribute, mismatch in this attribute is not supported.

The following cases are handled (assume that in each case client's code
uses
the derivative).

1. Both the function and its derivative are defined in a single file in
   one module.

2. Both the function and its derivative are defined in different files
which
   are compiled to a single module.

3. The function is defined in one module, its derivative is defined in
another
   module.

4. The function and the derivative are defined as members of a protocol
extension in two separate modules - one for the function and one for the
   derivative. A struct conforming the protocol is defined in the third
   module.

5. The function and the derivative are defined as members of a struct
extension in two separate modules - one for the function and one for the
   derivative.

The changes allow to define derivatives for methods of `SIMD`.

Fixes #54445
<!--
If this pull request is targeting a release branch, please fill out the
following form:

https://github.com/swiftlang/.github/blob/main/PULL_REQUEST_TEMPLATE/release.md?plain=1

Otherwise, replace this comment with a description of your changes and
rationale. Provide links to external references/discussions if
appropriate.
If this pull request resolves any GitHub issues, link them like so:

  Resolves <link to issue>, resolves <link to another issue>.

For more information about linking a pull request to an issue, see:

https://docs.github.com/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue
-->

<!--
Before merging this pull request, you must run the Swift continuous
integration tests.
For information about triggering CI builds via @swift-ci, see:

https://github.com/apple/swift/blob/main/docs/ContinuousIntegration.md#swift-ci

Thank you for your contribution to Swift!
-->
swift-DEVELOPMENT-SNAPSHOT-2025-05-26-a
2025-05-25 09:47:15 -04:00
Anthony Latsis
402ace5b68 [test] lit.cfg: Wrap all substitutions with capture group refs in SubstituteCaptures
Since https://github.com/llvm/llvm-project/pull/103042, backslashes in
substitutions are consistently escaped on all platforms before feeding
the substitutions to the regex engine. Make sure all substitutions
containing capture group references are wrapped in `SubstituteCaptures`
to suppress this behavior once main is rebranched.
2025-05-25 14:35:06 +01:00
Saleem Abdulrasool
29a9fb0ecb Merge pull request #81745 from compnerd/summary
utils: fix summary emission with caching
swift-DEVELOPMENT-SNAPSHOT-2025-05-25-a
2025-05-25 02:02:27 -07:00
Henrik G. Olsson
f5fa481205 [Swiftify] Always remove count parameters when possible (#81585)
Previously we did not remove count parameters if any count parameters
were shared between count expressions, or if any count expression
contained operations. Buffer sizes were also just checked to be larger
than or equal than the given count.

We now extract the count from Spans/BufferPointers whenever possible,
and store that value in a variable at the start of the function. If
multiple parameters share the same count, a bounds check is emitted to
make sure that they have the same size. Subspans can be used if one span
is larger than necessary.

The message in the bounds check is changed so that it includes the
expected and actual value, to aid in debugging.

This patch also fixes some incorrect indentation, and adds the
Whitespace.swift test case to act as a regression test in case the
indentation changes, since the other test cases don't use significant
whitespace.

rdar://151488820
rdar://151511090
rdar://146333006
rdar://147715799
2025-05-24 22:08:51 -07:00
Saleem Abdulrasool
331f0982b7 Merge pull request #81763 from compnerd/settings
utils: write SDKSettings for experimental SDKs
2025-05-24 17:48:55 -07:00
Saleem Abdulrasool
e03d6dc967 Merge pull request #81762 from compnerd/normalised
utils: normalise the names as per expectations
2025-05-24 17:48:30 -07:00
Saleem Abdulrasool
5398cc8f90 utils: write SDKSettings for experimental SDKs
Add support to emit the SDKSettings.json for the experimental SDK. This
ensures that the we have the settings available for the tools when using
this SDK.
2025-05-24 08:44:30 -07:00
Saleem Abdulrasool
89042cd8c0 utils: normalise the names as per expectations
Adjust the platform identifier spelling to the expected case.
2025-05-24 08:43:25 -07:00
Ryan Mansfield
cc2189bd05 Merge pull request #78791 from rjmansfield/fix-dwarf-version-legacy
[Driver] Fix -dwarf-version for Darwin toolchains in legacy driver.
2025-05-24 10:47:39 -04:00
Ian Anderson
7c3eaf42a3 Merge pull request #81760 from ian-twilightcoder/nostdimport-tweaks
[Frontend][test] Minor changes from "-nostdimport and -nostdlibimport should remove the default framework search paths"
2025-05-24 04:43:59 -07:00
Ian Anderson
15345ef2d5 [CMake][Darwin] Remove support for building the SDK overlays on Apple platforms
The SDK overlays have been provided in the Apple SDKs for many years, and the interface and implementation has diverged in more recent years such that trying to build the Swift version no longer works. Remove all of the dead code.

rdar://151889154
2025-05-23 23:38:08 -07:00
Ian Anderson
1197e2ef2e [Frontend][test] Minor changes from "-nostdimport and -nostdlibimport should remove the default framework search paths"
Put the SDK path in a SmallString instead of a StringRef for ease of downstream merging.
Simplify the command lines for the search path test.
2025-05-23 23:02:51 -07:00