Commit Graph

1778 Commits

Author SHA1 Message Date
Sam Pyankov
809f72fde6 Merge pull request #85394 from sepy97/register-module-dependency
Add new flag to enable dependency scanning without importing in the frontend
2025-11-12 14:52:59 -08:00
Steven Wu
22ca80e4fd Merge pull request #85375 from cachemeifyoucan/eng/PR-164208526
[CAS] Support legacy prefix map option
2025-11-10 10:52:28 -08:00
Mike Ash
cc8e6fd877 Merge pull request #85260 from mikeash/client-rr-library-rename
[Runtime] Rename ClientRetainRelease library to SwiftDirectRuntime.
2025-11-08 12:40:27 -05:00
Egor Zhdan
744c57737b Merge pull request #85395 from egorzhdan/egorzhdan/fixup-clang-access-flag
[cxx-interop] Fix-up `-emit-clang-header-min-access` flag
2025-11-08 02:41:02 -08:00
Semen Pyankov
b23044c19c Add new flag to enable dependency scanning without importing in the frontend 2025-11-07 18:36:05 -08:00
Egor Zhdan
0afa1aff2f [cxx-interop] Fix-up -emit-clang-header-min-access flag
This fixes a minor issue with the flag: its argument is not a actually a file system path (`ArgumentIsPath`).
2025-11-07 15:47:30 -08:00
Mike Ash
1898b01ce6 [Runtime] Rename ClientRetainRelease library to SwiftDirectRuntime.
This library will likely become home to other fast-path-in-client functions, so give it a more general name.
2025-11-07 16:36:29 -05:00
Steven Wu
23b42cf6c9 [CAS] Support legacy prefix map option
Bring back legacy prefix map option to allow an older swift-driver to
work with newer swift-frontend. For old swift-driver, it will always
send the old style prefix map option, so the new compiler needs to
support that.

rdar://164208526
2025-11-06 20:35:10 -08:00
Dylan Sturgeon
4b4f9f18fc Add an option for symbol graph to support long module names. (#83782)
Currently symbol graphs are always written in files that contain 1 to 2
module names. It's possible for Swift module names to be very long, so
combining 2 of them in file name like `module1@module2...` in the same
path component means the name can be too long for some file systems. The
new option `-symbol-graph-shorten-output-names` changes the symbol graph
output files to use a MD5 hash of the module name(s) as the filename and
outputs an additional JSON file with the original names mapped to the
real filename. The module names JSON can be used to construct a VFS
overlay with the original naming scheme.

fix #83723

I considered using vfsoverlay, which seems like a viable solution, but
the vfsoverlay options don't seem to apply to any of the outputs from
the compiler. When I set an overlay to remap the symbol graph file
outputs, the remapped external paths aren't used so the root problem of
too long file names remains.
2025-11-06 19:30:44 -08:00
Becca Royal-Gordon
2504beeccc Merge pull request #85043 from beccadax/mod-squad-interface
[SE-0491] Conditionally emit module selectors into swiftinterfaces
2025-11-03 19:08:09 -08:00
Adrian Prantl
457a2d3325 Merge pull request #85100 from adrian-prantl/163302154
Add a -debug-module-path frontend option
2025-11-03 12:30:55 -08:00
Steven Wu
a0553cf007 Merge pull request #85254 from cachemeifyoucan/eng/PR-fix-swift-driver-flag
[Options] Add missing `-sil-output-dir` and `ir-output-dir` flag
2025-10-31 18:20:40 -07:00
Becca Royal-Gordon
9454c0aaa4 Emit module selectors in swiftinterfaces
This support is currently opt-in and can be disabled by a blocklist.
2025-10-31 16:48:06 -07:00
Steven Wu
8d0fd383a0 [Options] Add missing -sil-output-dir and ir-output-dir flag
The swift-driver flags need to be declared in Options.td. Add the
missing driver flags in swift-driver#1995
2025-10-31 12:57:47 -07:00
Steven Wu
eae4555213 [CAS] Add -no-cache-compile-job frontend option
Add a negative frontend to turn off compilation caching. This allows
turn off compilation caching by just appending argument.

rdar://162547707
2025-10-31 11:03:05 -07:00
Mike Ash
93fae78e04 [IRGen][Runtime] Add emit-into-client retain/release calls for Darwin ARM64.
This is currently disabled by default. Building the client library can be enabled with the CMake option SWIFT_BUILD_CLIENT_RETAIN_RELEASE, and using the library can be enabled with the flags -Xfrontend -enable-client-retain-release.

To improve retain/release performance, we build a static library containing optimized implementations of the fast paths of swift_retain, swift_release, and the corresponding bridgeObject functions. This avoids going through a stub to make a cross-library call.

IRGen gains awareness of these new functions and emits calls to them when the functionality is enabled and the target supports them. Two options are added to force use of them on or off: -enable-client-retain-release and -disable-client-retain-release. When enabled, the compiler auto-links the static library containing the implementations.

The new calls also use LLVM's preserve_most calling convention. Since retain/release doesn't need a large number of scratch registers, this is mostly harmless for the implementation, while allowing callers to improve code size and performance by spilling fewer registers around refcounting calls. (Experiments with an even more aggressive calling convention preserving x2 and up showed an insignificant savings in code size, so preserve_most seems to be a good middle ground.)

Since the implementations are embedded into client binaries, any change in the runtime's refcounting implementation needs to stay compatible with this new fast path implementation. This is ensured by having the implementation use a runtime-provided mask to check whether it can proceed into its fast path. The mask is provided as the address of the absolute symbol _swift_retainRelease_slowpath_mask_v1. If that mask ANDed with the object's current refcount field is non-zero, then we take the slow path. A future runtime that changes the refcounting implementation can adjust this mask to match, or set the mask to all 1s to disable the old embedded fast path entirely (as long as the new representation never uses 0 as a valid refcount field value).

As part of this work, the overall approach for bridgeObjectRetain is changed slightly. Previously, it would mask off the spare bits from the native pointer and then call through to swift_retain. This either lost the spare bits in the return value (when tail calling swift_retain) which is problematic since it's supposed to return its parameter, or it required pushing a stack frame which is inefficient. Now, swift_retain takes on the responsibility of masking off spare bits from the parameter and preserving them in the return value. This is a trivial addition to the fast path (just a quick mask and an extra register for saving the original value) and makes bridgeObjectRetain quite a bit more efficient when implemented correctly to return the exact value it was passed.

The runtime's implementations of swift_retain/release are now also marked as preserve_most so that they can be tail called from the client library. preserve_most is compatible with callers expecting the standard calling convention so this doesn't break any existing clients. Some ugly tricks were needed to prevent the compiler from creating unnecessary stack frames with the new calling convention. Avert your eyes.

To allow back deployment, the runtime now has aliases for these functions called swift_retain_preservemost and swift_release_preservemost. The client library brings weak definitions of these functions that save the extra registers and call through to swift_retain/release. This allows them to work correctly on older runtimes, with a small performance penalty, while still running at full speed on runtimes that have the new preservemost symbols.

Although this is only supported on Darwin at the moment, it shouldn't be too much work to adapt it to other ARM64 targets. We need to ensure the assembly plays nice with the other platforms' assemblers, and make sure the implementation is correct for the non-ObjC-interop case.

rdar://122595871
2025-10-27 12:00:28 -04:00
Adrian Prantl
cb4efa0839 Add a -debug-module-path frontend option
This new option allows the Driver to pass the path to a compilation
job's own binary swiftmodule artifact to the frontend. The compiler
then stores this path in the debug info, to allow clients like LLDB to
unambiguously know which binary Swift module belongs to which compile
unit.

rdar://163302154
2025-10-23 17:10:50 -07:00
Gabor Horvath
adca01b1e5 [cxx-interop] Add flag to set minimum access level for reverse interop
rdar://159211965
2025-10-20 10:27:50 -07:00
Ryan Mansfield
c314fc1582 Merge pull request #84296 from rjmansfield/emit-verbose-asm
Add frontend option -verbose-asm to emit verbose assembly.
2025-10-17 12:40:42 -04:00
Henrik G. Olsson
f83752dd14 Merge pull request #84870 from hnrklssn/verify-ignore-macro-note
[DiagnosticVerifier] Add -verify-ignore-macro-note
2025-10-14 19:41:31 -07:00
Henrik G. Olsson
da55801862 [DiagnosticVerifier] Add -verify-ignore-macro-note
The _SwiftifyImport macro is emitted into an unnamed buffer and then
parsed, pretending it was in the header all along. This makes it hard to
add `expected-note` comments for `diag::in_macro_expansion` when they
point here. That's okay, because the macro expansion has already been
pointed out by `expected-expansion` directives. But
-verify-ignore-unrelated is too blunt of a tool, so this adds
-verify-ignore-macro-note to ignore these specific diagnostics.
2025-10-13 18:35:46 -07:00
Erik Eckstein
65e4c10113 Optimizer: remove the obsolete SpeculativeDevirtualization pass
This pass has been disabled since a very long time (because it's terrible for code size).
It does not work for OSSA. Therefore it cannot be enabled anymore (as is) once we have OSSA throughout the pipeline.
So it's time to completely remove it.
2025-10-13 10:49:17 +02:00
Doug Gregor
ce5b1a126d Merge pull request #84392 from rjmansfield/sil-ir-extra-outputs
Add frontend options to write SIL and LLVM IR as additional compilation output
2025-10-10 12:09:38 -07:00
Chirag Ramani
5179bc9609 Add IRPGO and CSIRPGO options to Swift (#84335)
This PR introduces three new instrumentation flags and plumbs them
through to IRGen:

1. `-ir-profile-generate` - enable IR-level instrumentation.
2. `-cs-profile-generate` - enable context-sensitive IR-level
instrumentation.
3. `-ir-profile-use` - IR-level PGO input profdata file to enable
profile-guided optimization (both IRPGO and CSIRPGO)

**Context:**
https://forums.swift.org/t/ir-level-pgo-instrumentation-in-swift/82123

**Swift-driver PR:** https://github.com/swiftlang/swift-driver/pull/1992

**Tests and validation:**
This PR includes ir level verification tests, also checks few edge-cases
when `-ir-profile-use` supplied profile is either missing or is an
invalid IR profile.

However, for argument validation, linking, and generating IR profiles
that can later be consumed by -cs-profile-generate, I’ll need
corresponding swift-driver changes. Those changes are being tracked in
https://github.com/swiftlang/swift-driver/pull/1992
2025-10-09 17:41:47 -07:00
Allan Shortlidge
1a86cd9c26 AST: Introduce a Swift runtime availability domain.
Add support for the `Swift` availability domain, which represents availability
with respect to the Swift runtime. Use of this domain is restricted by the
experimental feature `SwiftRuntimeAvailability`.
2025-10-08 17:31:57 -07:00
Ryan Mansfield
4cc2940619 Add frontend option -verbose-asm to emit verbose assembly.
This enables the option by default to aid readability with
-emit-assembly.
2025-10-08 16:01:13 -04:00
John Hui
312caa3a82 Merge pull request #84723 from j-hui/suppress-notes
[Diagnostics] Add -suppress-notes flag
2025-10-07 11:18:22 -07:00
eeckstein
401a2ac2bc Merge pull request #84704 from eeckstein/closure-specialization
ClosureSpecialization: support for OSSA and a big overhaul
2025-10-07 06:59:08 +02:00
John Hui
d68ca8de1e [Diagnostics] Add -suppress-notes flag
We already have -suppress-warnings and -suppress-remarks; this patch
adds support for suppressing notes too. Doing so is useful for -verify
tests where we don't really care about the emitted notes.
2025-10-06 17:05:57 -07:00
Ryan Mansfield
ba0ce8aea6 Add frontend options to write SIL and LLVM IR as additional compilation output.
This commit adds -sil-output-path and -ir-output-path frontend options that
allow generating SIL and LLVM IR files as supplementary outputs during normal
compilation.

These options can be useful for debugging and analysis tools
workflows that need access to intermediate compilation artifacts
without requiring separate compiler invocations.

Expected behaviour:

Primary File mode:
 - SIL: Generates one .sil file per source file
 - IR: Generates one .ll file per source file

Single-threaded WMO mode:
 - SIL: Generates one .sil file for the entire module
 - IR: Generates one .ll file for the entire module

Multi-threaded WMO mode:
 - SIL: Generates one .sil file for the entire module
 - IR: Generates separate .ll files per source file

File Maps with WMO:
 - Both SIL and IR outputs using first entry's naming, which is
   consistent with the behaviour of other supplementary outputs.

rdar://160297898
2025-10-06 15:45:49 -04:00
Erik Eckstein
8efafc7e3b Optimizer: remove the -experimental-swift-based-closure-specialization option 2025-10-06 12:02:48 +02:00
Henrik G. Olsson
e0c65b7c44 [DiagnosticVerifier] Add -verify-ignore-unrelated flag
This adds the implementation required for later changing the default
behaviour of the -verify flag to error when diagnostics are emitted
in buffers other than the main file and files added with
-verify-additional-file. To keep the current behaviour, use the flag
-verify-ignore-unrelated. This flag is added as a no-op so that tests
can start using it before the new behaviour is enabled by default.
2025-10-04 12:40:59 -07:00
Mishal Shah
03a599c5be Merge pull request #84606 from swiftlang/rebranch
Merge clang 21.x rebranch into main
2025-10-02 20:17:05 -07:00
Doug Gregor
c4527dc47d Merge pull request #84580 from DougGregor/static-build-configure 2025-09-30 20:47:04 -07:00
Doug Gregor
ae8f9d8234 Add -print-static-build-config to print a static build conformance
Introduce the ability to form a `StaticBuildConfiguration` from
language options. Add a frontend option `-print-static-build-config`
to then print that static build configuration as JSON in a manner that
can be decoded into a `StaticBuildConfiguration`.

Most of the change here is in sinking the bridged ASTContext queries
of language options into a new BridgedLangOptions. The printing of the
static build configuration only has a LangOptions (not an ASTContext),
so this refactoring is required for printing.
2025-09-29 18:42:14 -07:00
swift-ci
d5a03fa0e4 Merge remote-tracking branch 'origin/main' into rebranch 2025-09-26 22:36:42 -07:00
Erik Eckstein
2f124cf564 Remove the -enable-ossa-modules option.
OSSA modules are enabled by default.
The compiler still accepts this option but it has no effect.
2025-09-26 08:01:08 +02:00
swift-ci
9372966674 Merge remote-tracking branch 'origin/main' into rebranch 2025-09-22 23:16:05 -07:00
Doug Gregor
90a5a0f87d Merge pull request #84410 from DougGregor/internal-import-bridging-header 2025-09-22 23:09:07 -07:00
Doug Gregor
87cbe5d2a9 Clean up help text for new option 2025-09-22 17:10:55 -07:00
swift-ci
2deb2f9a87 Merge remote-tracking branch 'origin/main' into rebranch 2025-09-19 22:17:53 -07:00
Kavon Farvardin
889baf7f2c Merge pull request #84411 from kavon/copyprop-onone
sil: provide ability to run CopyPropagation in -Onone
2025-09-19 22:09:59 -07:00
swift-ci
ce0f17aeac Merge remote-tracking branch 'origin/main' into rebranch 2025-09-19 21:35:40 -07:00
Henrik G. Olsson
7fcc72f108 Merge pull request #81859 from swiftlang/swiftify-inherit-imports
[MacrosOnImports][Swiftify] Copy module imports from clang node's module to its Swift macro SourceFile
2025-09-19 21:21:09 -07:00
Doug Gregor
2383d7ab2d Introduce "-internal" variant of bridging header import flags
The flags "-import-bridging-header" and "-import-pch" import a bridging
header, treating the contents as a public import. Introduce
"internal-" variants of both flags that provide the same semantics,
but are intended to treat the imported contents as if they came in
through an internal import. This is just plumbing of the options for
the moment.
2025-09-19 16:49:11 -07:00
Doug Gregor
ffa6d65f12 [Options] Make -import-bridging-header the canonical spelling instead of -import-objc-header
This command-line option hasn't been Objective-C specific ever, really.
Make the language-independent spelling the primary one to make that
more obvious.
2025-09-19 16:49:11 -07:00
Kavon Farvardin
4a943d464d sil: provide ability to run CopyPropagation in -Onone
This does not enable it by default. Use either of the flags:

```
-enable-copy-propagation
-enable-copy-propagation=always
```

to enable it in -Onone. The previous frontend flag
`-enable-copy-propagation=true` has been renamed to
`-enable-copy-propagation=optimizing`, which is currently default.

rdar://107610971
2025-09-19 16:23:19 -07:00
swift-ci
647f66ad2b Merge remote-tracking branch 'origin/main' into rebranch 2025-09-19 14:18:04 -07:00
Slava Pestov
21e34e3189 Merge pull request #84400 from slavapestov/prepared-overloads-flag
Sema: Add -solver-{enable,disable}-prepared-overloads frontend flags
2025-09-19 17:13:23 -04:00
Slava Pestov
2deb5ff0a5 Sema: Add -solver-{enable,disable}-prepared-overloads frontend flags 2025-09-18 15:05:43 -04:00