Commit Graph

2104 Commits

Author SHA1 Message Date
Nate Chandler
056fbc44c9 [CoroutineAccessors] Control ABI via flag. 2025-04-10 07:41:37 -07:00
Michael Gottesman
3ff9463957 Make Feature a struct enum so we can put methods on it.
Just noticed this as I was looking at making other changes.
2025-04-05 10:08:29 +01:00
Alastair Houghton
b1c345f1be Merge pull request #80266 from al45tair/custom-executors-take2
[Concurrency] Provide a Swift interface for custom main and global executors.
2025-03-31 09:53:48 +01:00
Doug Gregor
b182c96bd7 Print diagnostic group names by default
Print diagnostic groups as part of the LLVM printer in the same manner as the
Swift one does, always. Make `-print-diagnostic-groups` an inert option, since we
always print diagnostic group names with the `[#GroupName]` syntax.

As part of this, we no longer render the diagnostic group name as part
of the diagnostic *text*, instead leaving it up to the diagnostic
renderer to handle the category appropriately. Update all of the tests
that were depending on `-print-diagnostic-groups` putting it into the
text to instead use the `{{documentation-file=<file name>}}`
diagnostic verification syntax.
2025-03-29 15:40:56 -07:00
Doug Gregor
08b27804f0 Merge pull request #80378 from DougGregor/remove-educational-note-markdown-rendering
[Diagnostics] Remove rendering of educational notes to the terminal
2025-03-28 20:12:44 -07:00
Doug Gregor
7d569b989d [Diagnostics] Remove rendering of educational notes to the terminal
We're moving over to a model where we provide direct links to educational notes /
diagnostic group notes whenever relevant. Rendering the Markdown from these
files to the terminal is less relevant with this approach, so remove it from the
compiler.
2025-03-28 14:12:27 -07:00
Doug Gregor
2c822634dd Point educational notes at education notes / diagnostic groups markdown on Github
Rather than pointing at a Markdown file in the toolchain directory by default,
which won't render well immediately for most users, point at the sources on
GitHub, which will render it properly and will still work from (e.g.)
CI systems where the toolchain content might not be accessible.

Toolchain-aware diagnostic renders can look in the installed toolchain
location (share/doc/swift/diagnostics) for the markdown files for that
specific version of the markdown files.
2025-03-28 13:57:04 -07:00
Alastair Houghton
47fa71787f Revert "Merge pull request #80224 from glessard/revert-79789-custom-executors"
This reverts commit 06f6358067, reversing
changes made to 033f6679e8.
2025-03-28 10:15:07 +00:00
Becca Royal-Gordon
132f49108d Check attributes in @abi attr
This commit compares the attributes on the decl inside the `@abi` attribute to those in the decl it’s attached to, diagnosing ABI-incompatible differences. It also rejects many attributes that don’t need to be specified in the `@abi` attribute, such as ObjC-ness, access control, or ABI-neutral traits like `@discardableResult`, so developers know to remove them.
2025-03-26 10:47:57 -07:00
Kuba Mracek
1476c04761 Fix a 'misleading indentation' warning in CompilerInvocation.cpp 2025-03-25 13:43:36 -07:00
Kuba (Brecka) Mracek
41ae31647a Merge pull request #76045 from kubamracek/mergeable-traps
Add -Xfrontend -mergeable-traps as a way to emit mergeable traps
2025-03-25 07:13:18 -07:00
Kuba Mracek
b08f630c23 Fix incorrect computation of Opts.MergeableTraps 2025-03-24 14:51:43 -07:00
Pavel Yaskevich
8f4220c6fa Merge pull request #80219 from xedin/rdar-145768557
[Concurrency] SE-0466: Replace `UnspecifiedMeansMainActorIsolated` flag with `-default-isolation`
2025-03-24 09:05:07 -07:00
Kuba Mracek
ed5e89a501 Also respect -mergeable-traps when merging cond_fails in SILOptimizer 2025-03-24 09:04:44 -07:00
Kuba Mracek
164b61c83d Add -Xfrontend -mergeable-traps as a way to emit mergeable traps 2025-03-24 09:04:11 -07:00
Pavel Yaskevich
2221c140d2 [Frontend] SE-0466: Add -default-isolation frontend that accepts MainActor and nonisolated 2025-03-23 22:04:32 -07:00
Andrew Trick
afb0de5d3f LifetimeDependence: enable addressable dependencies 2025-03-23 19:00:42 -07:00
Doug Gregor
13f1bea2d3 Merge pull request #80209 from DougGregor/infer-isolated-conformances
Implement experimental feature InferIsolatedConformances
2025-03-22 17:53:20 -07:00
Dario Rexin
06f6358067 Merge pull request #80224 from glessard/revert-79789-custom-executors
Revert "[Concurrency] Provide a Swift interface for custom main and global executors."
2025-03-22 13:49:13 -07:00
Arnold Schwaighofer
05084acb4e Merge pull request #79199 from aschwaighofer/cond_fail_remarks
IRGen: Annotate LLVM IR of condfail with the condfail's message
2025-03-22 03:49:50 -07:00
Alastair Houghton
8b15b05c63 Revert "[Concurrency] Provide a Swift interface for custom main and global executors." 2025-03-22 02:38:11 -07:00
Doug Gregor
083194923c Implement experimental feature InferIsolatedConformances
Introduce the experimental feature InferIsolatedConformances to align
with the upcoming feature proposed in SE-0470. This is a slight
generalization of the main-actor-specific inference that was already
in place for the default-main-actor mode from SE-0466. Note that, as
specified in SE-0470, InferIsolatedConformances is implied by the
default-main-actor mode.
2025-03-21 11:41:46 -07:00
Alastair Houghton
8443b5f76c Merge pull request #79789 from al45tair/custom-executors
[Concurrency] Provide a Swift interface for custom main and global executors.
2025-03-21 09:05:03 +00:00
Arnold Schwaighofer
ee57eed78d IRGen: Annotate LLVM IR of condfail with the condfail's message
`-Xfrontend -enable-cond-fail-message-annotation`
LLVM IR produced by the Swift compiler will add the `annotation`
metadata attribute to the branch instruction generated for cond_fail
builtins.
2025-03-20 08:17:18 -07:00
nate-chandler
39f58de32e Merge pull request #80033 from nate-chandler/verify-each-flag
[IRGen] Add flags to control LLVM verify-each.
2025-03-17 07:35:17 -07:00
Nate Chandler
dd8c715aa6 [IRGen] Add flags to control LLVM verify-each.
Analogous to -sil-verify-all, the new flags cause LLVM verification to
be run after each LLVM optimization pass.
2025-03-14 17:51:43 -07:00
John Hui
76a1742aca [cxx-interop] Use formal C++ interop mode to fix name lookup in module interfaces (#79984)
It is possible for a module interface (e.g., ModuleA) to be generated
with C++ interop disabled, and then rebuilt with C++ interop enabled
(e.g., because ModuleB, which imports ModuleA, has C++ interop enabled).

This circumstance can lead to various issues when name lookup behaves
differently depending on whether C++ interop is enabled, e.g., when
a module name is shadowed by a namespace of the same name---this only
happens in C++ because namespaces do not exist in C. Unfortunately,
naming namespaces the same as a module is a common C++ convention,
leading to many textual interfaces whose fully-qualified identifiers
(e.g., c_module.c_member) cannot be correctly resolved when C++ interop
is enabled (because c_module is shadowed by a namespace of the same
name).

This patch does two things. First, it introduces a new frontend flag,
-formal-cxx-interoperability-mode, which records the C++ interop mode
a module interface was originally compiled with. Doing so allows
subsequent consumers of that interface to interpret it according to the
formal C++ interop mode. Note that the actual "versioning" used by this
flag is very crude: "off" means disabled, and "swift-6" means enabled.
This is done to be compatible with C++ interop compat versioning scheme,
which seems to produce some invalid (but unused) version numbers. The
versioning scheme for both the formal and actual C++ interop modes
should be clarified and fixed in a subsequent patch.

The second thing this patch does is fix the module/namespace collision
issue in module interface files. It uses the formal C++ interop mode to
determine whether it should resolve C++-only decls during name lookup.
For now, the fix is very minimal and conservative: it only filters out
C++ namespaces during unqualified name lookup in an interface that was
originally generated without C++ interop. Doing so should fix the issue
while minimizing the chance for collateral breakge. More cases other
than C++ namespaces should be added in subsequent patches, with
sufficient testing and careful consideration.

rdar://144566922
2025-03-13 23:24:18 -07:00
Artem Chikin
27bac69527 Merge pull request #79930 from artemcm/ClangTargetVariant
[Explicit Module Builds] Add '-clang-target-variant' flag
2025-03-13 07:21:09 -07:00
Alastair Houghton
55afa47bea [Concurrency] More work on the custom executor implementation.
Added an `-executor-factory` argument to the compiler to let you safely
specify the executors you wish to use (by naming a type that returns
them).

Also added some tests of the new functionality.

rdar://141348916
2025-03-13 13:34:41 +00:00
Artem Chikin
e96a690cc7 [Explicit Module Builds] Add '-clang-target-variant' flag
https://github.com/swiftlang/swift/pull/37774 added '-clang-target' which allows us to specify a target triple that only differs from '-target' by the OS version, when we want to provide a different OS version for API availability and type-checking, in order to set a common/unified target triple for the entire Clang module dependency graph, for presenting a unified API surface to the Swift client, serving as a maximum type-checking epoch.

This change adds an equivalent flag for the '-target-variant' configuration, as a mechanism to ensure that the entire module dependency graph presents a consistent os version.
2025-03-11 15:48:06 -07:00
Doug Gregor
7c8e99d4df Suppress memory-safety diagnostic for SwiftONoneSupport
It's a weird beast.
2025-03-10 16:16:43 -07:00
nate-chandler
c0ba520fac Merge pull request #79781 from nate-chandler/general-coro/20250227/1
[CoroutineAccessors] Dispatch and PtrAuth.
2025-03-07 20:08:42 -08:00
Nate Chandler
f5d03a6d11 [CoroutineAccessor] Remove old ABI support.
This was useful during bringup.  Now that retcon.once.dynamic coroutine
splitting is available, it's no longer needed.
2025-03-07 11:40:38 -08:00
Anthony Latsis
6a3903bb53 Revert "Revert "Introduce adoption mode for Swift features""
This reverts commit 393c59c078.
2025-03-05 15:21:01 +00:00
Rintaro Ishizaki
393c59c078 Revert "Introduce adoption mode for Swift features" 2025-03-04 19:13:05 -08:00
Anthony Latsis
2771f36ced LangOptions: Refactor feature state and API to account for adoption mode 2025-03-04 13:43:28 +00:00
Anthony Latsis
2a88419f5c Frontend: Do not suggest mode correction if adoption is not supported 2025-03-04 13:43:28 +00:00
Anthony Latsis
756abb9284 Frontend: Warn if adoption mode is requested but not supported 2025-03-04 13:43:28 +00:00
Anthony Latsis
2abf67872c Frontend: Parse a feature mode specifier 2025-03-04 13:43:28 +00:00
Anthony Latsis
90d1365a42 [NFC] Frontend: Give some variables better names 2025-03-04 13:34:44 +00:00
Andrew Trick
fa64a362a2 Add -Xfrontend -enable-address-dependencies
Temporary option to bootstrap '@'_addressable enforcement.

Once all the SILGen cases are handled, we won't need this option.
2025-03-03 16:21:48 -08:00
Mike Ash
beba678f04 Merge pull request #79302 from mikeash/singleton-metadata-pointer
[IRGen] Emit a pointer from nominal type descriptor to concrete metadata.
2025-02-28 15:24:36 -05:00
nate-chandler
f8b60bb6d2 Merge pull request #79685 from nate-chandler/general-coro/20250227/1
[CoroutineAccessors] Use swiftcorocc if available.
2025-02-28 12:06:54 -08:00
Shubham Sandeep Rastogi
1d28b5ccd1 Merge pull request #79308 from rastogishubham/CallSiteSwift
[DebugInfo]Generate call-site information in swift
2025-02-27 21:08:04 -08:00
Nate Chandler
d1f1b4c86b [CoroutineAccessors] Use swiftcorocc if available.
When it's available, use an open-coded allocator function that returns
an alloca without popping if the allocator is nullptr and otherwise
calls swift_coro_alloc.  When it's not available, use the malloc
allocator in the synchronous context.
2025-02-27 18:20:53 -08:00
Mike Ash
270ddf6bf4 [IRGen] Emit a pointer from nominal type descriptor to concrete metadata.
This allows external tools to locate the metadata pointer without needing to call the accessor function.

This is only useful for non-generic types, so we borrow the HasCanonicalMetadataPrespecializations flag to indicate the presence of this pointer on non-generic types, and it continues to indicate the presence of prespecializations for generic types.

Only emit this pointer for internal/private types with no runtime initialization. Public type metadata can be found with the symbol, and it's not useful for types that require runtime initialization.
2025-02-27 17:48:37 -05:00
Nate Chandler
dd8cbe3e0a [CoroutineAccessors] Use retcon.once variant.
Allocate a coroutine frame in the caller based on the size in the
corresponding "function pointer" and pass it along with an allocator to
the callee.
2025-02-27 07:53:58 -08:00
Shubham Sandeep Rastogi
c2c5eb1334 [DebugInfo]Generate call-site information in swift
This patch adds support for emitting the flag
llvm::DINode::FlagAllCallsDescribed when generating LLVM IR from the
Swift compiler to get call-site information for swift source code.
2025-02-26 14:28:45 -08:00
Doug Gregor
b7b5a2a19d [SE-0458] Enable unsafe expressions / attributes / for..in effects by default
With the acceptance of SE-0458, allow the use of unsafe expressions, the
@safe and @unsafe attributes, and the `unsafe` effect on the for..in loop
in all Swift code.

Introduce the `-strict-memory-safety` flag detailed in the proposal to
enable strict memory safety checking. This enables a new class of
feature, an optional feature (that is *not* upcoming or experimental),
and which can be detected via `hasFeature(StrictMemorySafety)`.
2025-02-26 12:30:07 -08:00
Arnold Schwaighofer
11922d2fde Merge pull request #79546 from kubamracek/expose-flag-to-disable-merge-functions
[IRGen] Expose an -Xfrontend flag to disable the LLVM MergeFunctions pass
2025-02-25 18:17:01 -08:00