Commit Graph

928 Commits

Author SHA1 Message Date
Saleem Abdulrasool
a5e6a7f6d9 Merge pull request #78793 from hjyamauchi/emit-reference-dependencies
An attempt to reduce file accesses during the .swiftdeps file generat…
2025-03-29 17:53:55 -07:00
Steven Wu
4115be5e18 [FrontendTool] Use a null diagconsumer for verify instance
Use a null diagnostic consumer in the deterministic verify instance. The
constraint system will skip work if there are no consumer in the
diagnostic engine. Use a null consumer to make sure the same amount of
work is done for two runs.
2025-03-21 13:11:14 -07:00
Tony Allevato
7c258f2057 Merge pull request #79485 from allevato/index-swiftinterface
[Frontend] Support `-index-store-path` for explicit module interface compilation.
2025-02-21 12:55:49 -08:00
Tony Allevato
5fd985256c [Frontend] Support -index-store-path for explicit module interface compilation. 2025-02-19 12:42:48 -05:00
Saleem Abdulrasool
6dc18c0854 Merge pull request #79334 from compnerd/configuration
FrontendTool: print the compiler configuration
2025-02-13 16:20:40 -08:00
Saleem Abdulrasool
2ba2d1bceb FrontendTool: print the compiler configuration
This adds the compiler configuration to the output similar to clang.
This will allow us to identify the compiler build type, e.g.

```
Swift version 6.2-dev (LLVM 47665e034aa6f27, Swift 2b3e5dac59b8632)
Target: x86_64-unknown-windows-msvc
Build config: +unoptimized,+assertions,+expensive-checks,+asan,+hwasan,+msan,+ubsan
```
2025-02-12 14:06:58 -08:00
Rintaro Ishizaki
71b24665fa [ASTDumper] Dump DeclContext
* Include `DeclContext` of the node where possible
* Add 'default-with-decl-contexts' dump style that dumps the dect context
  hierarchy in addition to the AST
* Support `-dump-parse` with `-dump-ast-format json`
2025-02-12 10:53:33 -08:00
Allan Shortlidge
d00e102fd1 Frontend: Remove the -skip-import-in-public-interface flag.
This flag is unsafe since the compiler does not verify that the resulting
public interface will compile with the module import removed. The modern
alternative to this flag is `@_spiOnly import`. Since the flag is no longer
used by any projects it should be removed.

Resolves rdar://134351088.
2025-02-09 18:52:10 -08:00
Tony Allevato
c5f0200680 Merge pull request #79059 from allevato/json-ast-followups
[ASTDumper] Some followups from the initial JSON PR and macro dumping improvements.
2025-02-04 01:13:46 -05:00
Tony Allevato
0d9467e688 Hoist ASTDumpMemberLoading choice up to the frontend call sites. 2025-02-03 11:37:47 -05:00
Meghana Gupta
6f9167c29e Serialize after high level passes for -emit-sib 2025-01-30 17:10:04 -08:00
Tony Allevato
3804110db8 Change parseIfNeeded to an enum to control member loading behavior. 2025-01-30 09:10:15 -05:00
Artem Chikin
41e471288a [Dependency Scanning] Deprecate/Remove batch scanning capability
Batch dependency scanning was added as a mechanism to support multiple compilation contexts within a single module dependency graph.
The Swift compiler and the Explicitly-built modules model has long since abandoned this approach and this code has long been stale. It is time to remove it and its associated C API.
2025-01-28 15:30:39 -08:00
Hiroshi Yamauchi
30d298a70c An attempt to reduce file accesses during the .swiftdeps file generation. 2025-01-22 13:57:47 -08:00
Tony Allevato
a57fb4dfa9 [AST] Add minimal JSON support to ASTDumper.
This only takes the existing AST information and writes it as JSON
instead of S-expressions. Since many of these fields are stringified,
they're not ideal for the kind of analysis clients of the JSON format
would want to do. A future commit will update these values to use a
more structured representation.
2025-01-22 14:26:13 -05:00
Steven Wu
627c64f391 [Caching][NFC] Unify the two cache replay code path
There were two cache replay code exists, one for cache replay from
swift-frontend, the other for replay using C API from libSwiftScan. It
is easy to forget to update one copy when new specialized cache replay
logic is added for some output kinds. Now unify the replay logics to a
single location to avoid confusion. This is a rewrite of the existing
logic and NFCI.
2024-12-19 14:10:46 -08:00
Xi Ge
c868515fae FineModuleTracing: only collect fine-grained tracing for those source files that compiler promises to type check.
rdar://141065994
2024-12-10 16:56:16 -08:00
Xi Ge
4a5d041932 FineModuleTrace: reposition the currently ObjC message specific trace files to be a more general purposed file for tracing fine-grained dependencies. NFC 2024-11-20 12:41:21 -08:00
Allan Shortlidge
239720897a AST: Rename TypeRefinementContext to AvailabilityScope. 2024-11-12 11:34:25 -08:00
Michael Gottesman
4763251427 [sil] Add the ability for the frontend to dump LoweredSIL before IRGen.
This is something that I have wanted to add for a while and have never had the
need to. I need it now to fix a bug in the bots where I am forced to use IRGen
output to test ThunkLowering which causes platform level differences to show up
in the FileCheck output. With this, I can just emit the actual lowered SIL
output and just test it at that level. There are other cases like this where we
are unable to test lowered SIL so we use IRGen creating this brittleness.
Hopefully this stops this problem from showing up in the future.

rdar://138845396
2024-11-01 03:16:55 -07:00
Ben Barham
f59b2f19e6 Merge branch 'main' into 2024-rebranch-to-main 2024-10-28 13:03:35 -07:00
Xi Ge
7bf010777e Frontend: when emitting loaded module trace file, also emit a JSON file tracking Objc method calls issued from the source code. 2024-10-24 17:19:21 -07:00
swift-ci
138625f758 Merge remote-tracking branch 'origin/main' into rebranch 2024-10-18 10:41:34 -07:00
Tony Allevato
bd4cfee965 Merge pull request #76872 from allevato/swift-synthesize-interface-tool
Add a new driver tool/mode to print the synthesized Swift interface for a module.
2024-10-18 13:26:22 -04:00
Tony Allevato
2cfcdd8ed1 Add a new driver tool/mode to print the synthesized Swift interface for a module.
This mode is similar to `swift-symbolgraph-extract`; it takes a subset of compiler
flags to configure the invocation for module loading, as well as a module name
whose contents should be extracted. It does not take any other input files. The
output is a single text file specified by `-o` (or `stdout` if not specified).

While the most common use case for this would be viewing the synthesized Swift
interface for a Clang module, since the implementation simply calls
`swift::ide::printModuleInterface` under the hood, it's usable for any module
that Swift can import. Thus, it could also be used to view a synthesized textual
representation of, say, a compiled `.swiftmodule`.

One could imagine that in the future, we might add more flags to
`swift-synthesize-interface` to modify various `PrintOptions` used when
generating the output, if we think those would be useful.
2024-10-10 15:30:41 -04:00
swift-ci
ec2edb72f0 Merge remote-tracking branch 'origin/main' into rebranch 2024-10-09 14:44:21 -07:00
Tony Allevato
a3961c826d Merge pull request #76933 from allevato/unique-ptr-hardening
[Frontend] Fix a small `unique_ptr` array access.
2024-10-09 17:32:42 -04:00
Tony Allevato
bdf40184ab [Frontend] Fix a small unique_ptr array access.
When the size of the array accessed here is zero, retrieving the
address of the zero-th element here is undefined. When the frontend
is linked against a libc++ that has the `unique_ptr` hardening in
[this commit](18df9d23ea)
enabled, it traps here.

Instead, simply call `.get()` to retrieve the address of the
array, which works even when it is a zero-byte allocation.
2024-10-09 13:54:43 -04:00
swift-ci
9fd863f81e Merge remote-tracking branch 'origin/main' into rebranch 2024-10-08 10:50:24 -07:00
Steven Wu
b326c55d82 [CAS] Full support for make-style dependencies file caching hit
Fully support make-style `.d` dependencies file output by making
following improvements:
* All correct dependency file render when cache hit for a different
  output file location. The dependency file should list the correct
  output path, not the stale output path for the initial compilation
* When enable a path prefix mapper to canonicalize the path, the
  dependency file should render the input file correctly as the input
  file path on disk.

rdar://132250067
2024-09-30 15:53:18 -07:00
swift-ci
a0097bde91 Merge remote-tracking branch 'origin/main' into rebranch 2024-09-21 11:14:00 -07:00
Saleem Abdulrasool
6443619126 Remove swift-indent tool
This removes the implementation of the `swift-indent` tool, its
associated documentation, and utilities. This tool was never completed
and has much better alternatives with `swift-format` which is more
flexible and actually maintained.
2024-09-19 11:21:59 -07:00
swift-ci
5039a2d86c Merge remote-tracking branch 'origin/main' into rebranch 2024-09-18 10:55:29 -07:00
Doug Gregor
49aa0e966f Ensure that SourceFiles always have a backing buffer in the SourceManager
The "buffer ID" in a SourceFile, which is used to find the source file's
contents in the SourceManager, has always been optional. However, the
effectively every SourceFile actually does have a buffer ID, and the
vast majority of accesses to this information dereference the optional
without checking.

Update the handful of call sites that provided `nullopt` as the buffer
ID to provide a proper buffer instead. These were mostly unit tests
and testing programs, with a few places that passed a never-empty
optional through to the SourceFile constructor.

Then, remove optionality from the representation and accessors. It is
now the case that every SourceFile has a buffer ID, simplying a bunch
of code.
2024-09-16 21:46:42 -07:00
swift-ci
f624072420 Merge remote-tracking branch 'origin/main' into rebranch 2024-08-29 03:33:30 -07:00
Hamish Knight
1cb0f8fdd5 [AST] Rename isPrivateStdlibDecl -> isPrivateSystemDecl
This better reflects what we're actually checking
here.
2024-08-28 18:31:51 +01:00
swift-ci
0dc0132511 Merge remote-tracking branch 'origin/main' into rebranch 2024-08-27 08:54:50 -07:00
Allan Shortlidge
b52241e381 Frontend: For whole module compiles, omit filelists from stack dumps.
For batch compile jobs, it's helpful to see which files are considered primary
and that was the original reason why filelist contents were printed in compiler
crash stack dumps. However, for whole module compile jobs, the contents of the
filelist is uninteresting (it's just all the files in the module) and can be
hundreds or thousands of lines long so it often causes important information to
be trimmed from stack dumps received in reproducers.
2024-08-26 16:42:23 -07:00
swift-ci
f3ac36bf77 Merge remote-tracking branch 'origin/main' into rebranch 2024-08-12 23:13:53 -07:00
Allan Shortlidge
9062271185 SILGen: Skip SIL verification and optimization if errors were emitted.
In lazy typechecking mode, errors in the program may only be discovered during
SILGen, which can leave the SIL in a bad state for subsequent stages of
compilation. If errors were detected, skip SIL verification and optimization to
prevent knock-on failures.

Partially reverts https://github.com/swiftlang/swift/pull/75428, which included
a more targeted fix for one of the possible knock-on effects of bad SIL coming
out of SILGen.

Resolves rdar://132107752.
2024-08-12 15:34:59 -07:00
swift-ci
2bf8a521eb Merge remote-tracking branch 'origin/main' into rebranch 2024-08-07 09:53:42 -07:00
Ben Langmuir
1f00ffe42c Revert "[immediate] Load Foundation early enough for bridging" 2024-08-06 16:10:42 -07:00
swift-ci
ef054444fd Merge remote-tracking branch 'origin/main' into rebranch 2024-08-02 01:03:44 -07:00
Ben Langmuir
8a824d70a0 [immediate] Load Foundation early enough for bridging
Foundation needs to be loaded early in the process for Swift's runtime
to properly initialize bridging support; otherwise it may cause issues
like unrecognized selectors. When scripting, load Foundation early in
performFrontend before any swift code runs.

rdar://129528115
2024-08-01 15:02:13 -07:00
Ben Barham
2715d0e9d6 Merge branch 'main' into 20240710-main-to-rebranch
Conflicts:
  - `test/Interop/Cxx/class/method/methods-this-and-indirect-return-irgen-itanium.swift`
    previously fixed on rebranch, now fixed on main (slightly differently).
2024-07-10 20:42:09 -07:00
Shubham Sandeep Rastogi
d443fdd501 Merge pull request #74202 from rastogishubham/MCCASReplay
Add replay support for MCCAS in Swift.
2024-07-10 15:21:51 -07:00
Shubham Sandeep Rastogi
8dabf58993 Add support for MCCAS in replay logic for swift
This patch adds support for MCCAS when a cache hit is encountered when
trying to replay a compilation, and uses the MCCAS serialization code
to materialize the object file that is the main output of the
compilation.
2024-07-10 10:19:10 -07:00
Shubham Sandeep Rastogi
31baf4fb54 Store MCCAS ObjectRef as CASOutputBackend's main output.
This patch stores the MCCAS ObjectRef as the main output of the
CASOutputBackend when MCCAS is enabled.
2024-07-09 13:38:11 -07:00
swift-ci
4fb3c4e0d2 Merge remote-tracking branch 'origin/main' into rebranch 2024-06-28 00:35:37 -07:00
Allan Shortlidge
470baff865 Driver: Remove swift-api-extract.
Now that API descriptions are emitted during module build jobs when
`-emit-api-descriptor-path` is specified and the build system has been updated
to pass that flag when the output is needed, the `swift-api-extract` frontend
alias is no longer used. Delete it and the tests that were specific to invoking
`swift-api-extract`.

Resolves rdar://116537394.
2024-06-27 17:05:32 -07:00