Commit Graph

457 Commits

Author SHA1 Message Date
Robert Widmann
a6651a920d Generalize and fix compiler resource freeing before LLVM
Centralize part of the routine that selects which resources to free. Then, add an additional condition for -dump-api-path.

Before, if this option were specified along with -emit-llvm or -c, the compiler would try to rebuild the torn-down ModuleDecl and crash trying to access the torn-down ASTContext.
2020-02-27 17:12:58 -08:00
Robert Widmann
7dd000bdb5 [NFC] Remove the stats reporter parameter from FrontendTool entrypoints
Now that the CompilerInstance owns the stats reporter, use that instead.
2020-02-27 17:12:58 -08:00
Robert Widmann
535bb9bf8f [NFC] UnifiedStatsReporter is owned by CompilerInstance
The lifetime of the UnifiedStatsReporter was not entirely clear from context. Stick it in the CompilerInstance instead so it can live as long as the compile job.

It is critical that its lifetime be extended beyond that of the ASTContext, as the context may be torn down by the time code generation happens, but additional statistics are recorded during LLVM codegen.
2020-02-27 17:12:57 -08:00
Varun Gandhi
2dfd5694fa [NFC] Don't crash when we see an empty filename for a module. (#30099)
Fixes rdar://problem/59769612.
2020-02-27 12:58:47 -08:00
Xi Ge
8c2a041822 Front-end: add an option to not lock interface file when building module
This could help fix a flaky test.

Related to: rdar://58578342
2020-02-25 12:13:14 -08:00
Alexis Laferrière
901392896d [Frontend] Output the private module interface with the SPI info 2020-02-19 14:17:14 -08:00
Brent Royal-Gordon
f8df2f66fd Add mechanism for per-SourceFile overlays
When a “separately imported overlay” is added to a SourceFile, two things happen:

1. The direct import of the underlying module is removed from getImports*() by default. It is only visible if the caller passes ImportFilterKind:: ShadowedBySeparateOverlay. This means that non-module-scoped lookups will search _OverlayModule before searching its re-export UnderlyingModule, allowing it to shadow underlying declarations.

2. When you ask for lookupInModule() to look in the underlying module in that source file, it looks in the overlays instead. This means that UnderlyingModule.foo() can find declarations in _OverlayModule.
2020-02-18 11:07:12 -08:00
Xi Ge
e013f1fb81 TBDGen: add a flag for embedding external symbols in emitted tbd file
Static-linked libraries could add symbols to the final tbd file. We need
this flag to specify additional module names to collect symbols from.

rdar://59399684
2020-02-12 13:47:59 -08:00
swift-ci
9d310503ce Merge remote-tracking branch 'origin/master' into master-rebranch 2020-02-03 19:03:03 -08:00
Brent Royal-Gordon
c964d18467 Add target variant to -print-target-info 2020-02-01 15:33:38 -08:00
swift-ci
9ddff174ce Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-22 18:24:42 -08:00
Xi Ge
366e24ed51 IRGen: don't proceed to IRGen if collecting linker directives failed 2020-01-22 16:22:33 -08:00
swift-ci
11550b4c0c Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-22 09:43:43 -08:00
Varun Gandhi
f6643af650 [Printer] Update printSIL to make sure LLDB doesn't break.
For more context, see:
1. https://github.com/apple/swift/pull/29239 - original PR which introduced
   the change, including an LLDB-side change.
2. The immediately preceding commit, which reverted this change.
3. https://github.com/apple/swift/pull/29350 which revealed some breakage
   caused by the changes in PR 29239 (unrelated to printing).
2020-01-22 09:05:39 -08:00
Varun Gandhi
d9a7a7d49e Revert "[Printer] Conditionally print Clang types in emitted SIL."
This reverts commit a27c5f0a16.
2020-01-22 09:04:52 -08:00
swift-ci
e28c558c72 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-21 09:43:46 -08:00
Varun Gandhi
a27c5f0a16 [Printer] Conditionally print Clang types in emitted SIL.
Hopefully, this helps us debug Clang type mismatches better.
2020-01-17 16:22:39 -08:00
Erik Eckstein
1b312a85bd Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-16 10:39:20 +01:00
Varun Gandhi
8510b9234b [NFC] Add an EmitSortedSIL member to SILOptions for consistency. (#29210)
It is a bit strange to have the FrontendOptions being used in writeSIL
instead of SILOptions, so this PR fixes that.
2020-01-15 16:25:41 -08:00
Robert Widmann
2af598fb52 [Gardening] Const-qualify Many Usages of CompilerInstance
For those operations that do not need to emit diagnostics or manipulate modules, there's no reason to mutate the passed instance.
2020-01-14 09:02:10 -08:00
Robert Widmann
8fe25f7530 [NFC] Remove CompilerInstance::setSILModule
The REPL was using the CompilerInstance to stash this parameter, then it would immediately move it into IRGen.  Drop the setter and pass this data directly.
2020-01-13 22:01:41 -08:00
Robert Widmann
bd57f14661 [NFC] Push const IRGenOptions and SILOptions everywhere 2020-01-13 22:01:41 -08:00
Robert Widmann
d63053d64e [Gardening] Remove more unused parameters 2020-01-13 22:01:41 -08:00
Robert Widmann
5c746fafaa [NFC] Compute remaining IRGen options in the argument parser
Add an extra phase after all the argument parsing has completed that sets inter-option-dependent flags.  This allows for the const-qualification of IRGenOptions, and removes some weird state flipping in FrontendTool.
2020-01-13 22:01:41 -08:00
Robert Widmann
eb61931012 [NFC] Grab the private discriminator for a file in IRGenDebugInfo
This was being done at an odd point in the frontend presumably because by that point the private discriminator had been fully computed.  Instead, push the conditions for generating the prefix data down to debug info generation and stop mutating IRGenOptions::DebugFlag in the frontend.
2020-01-13 22:01:41 -08:00
swift-ci
b03a280b3b Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-13 21:23:26 -08:00
Xi Ge
90f59e4336 TBDGen: teach the compiler to take a json file indicating previous install names
Using the new linker directives $ld$previous requires the compiler to know the previous
install names for the symbols marked as removed. This patch teaches the compiler
to take a path to a Json file specifying the map between module names and previous
install names. Also, these install names can be platform-specific.

Progress towards: rdar://58281536
2020-01-13 17:45:40 -08:00
swift-ci
e280ebe9b7 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-12 21:44:31 -08:00
David Ungar
cc89dad526 Fine-grained and driver fixes.
Restructure fine-grained-dependencies to enable unit testing

Get frontend to emit correct swiftdeps file (fine-grained when needed) and only emit dot file for -emit-fine-grained-dependency-sourcefile-dot-files

Use deterministic order for more information outputs.

Set EnableFineGrainedDependencies consistently in frontend.

Tolerate errors that result in null getExtendedNominal()

Fix memory issue by removing node everywhere.

Break up print routine

Be more verbose so it will compile on Linux.

Sort batchable jobs, too.
2020-01-11 21:57:14 -08:00
Arnold Schwaighofer
0c99cd9734 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-10 08:00:41 -08:00
Saleem Abdulrasool
b483047afe Revert "[Incremental] Dependency fixes in preparation for fine-grained dependencies" 2020-01-09 19:14:47 -08:00
David Ungar
939034a4bb Merge pull request #29009 from davidungar/fine-grained-fixes-post-rb
[Incremental] Dependency fixes in preparation for fine-grained dependencies
2020-01-09 00:57:31 -08:00
Hamish Knight
6b87dce845 Remove DelayedDeclLists from PersistentParserState
Rather than parsing all delayed bodies for
`-dump-parse` once we finish parsing, tell the
parser not to delay any bodies. This then allows
us to remove `DelayedDeclLists` from
PersistentParserState.
2020-01-08 10:54:11 -08:00
Hamish Knight
7e7c799076 [Frontend] Don't perform additional parsing for -verify
Given `-verify` is used for testing, ideally it
shouldn't exhibit different behaviour to an
equivalent invocation without it.
2020-01-08 10:54:10 -08:00
Arnold Schwaighofer
43c24be5cd Merge remote-tracking branch 'upstream/master' into master-next 2020-01-08 06:41:34 -08:00
David Ungar
6fffe724f2 Fine-grained and driver fixes.
Restructure fine-grained-dependencies to enable unit testing

Get frontend to emit correct swiftdeps file (fine-grained when needed) and only emit dot file for -emit-fine-grained-dependency-sourcefile-dot-files

Use deterministic order for more information outputs.

Set EnableFineGrainedDependencies consistently in frontend.

Tolerate errors that result in null getExtendedNominal()

Fix memory issue by removing node everywhere.

Break up print routine

Be more verbose so it will compile on Linux.

Sort batchable jobs, too.
2020-01-04 14:37:06 -08:00
Robert Widmann
96b3b9f0f4 [NFC] Hide SourceFile::Decls
In preparation for installing some stable paths infrastructure here,
hide access to the array of top-level decls.
2020-01-03 14:14:00 -08:00
swift_jenkins
21401ad11f Merge remote-tracking branch 'origin/master' into master-next 2019-12-19 11:59:47 -08:00
Vinicius Vendramini
aebfb53966 Ast dump ignore wmo (#20596)
* Ignore -wmo when passing -dump-ast

* Cleanup on driver diagnostics

* Remove the FIXME.

* Add support for ignoring `-index-file`

* Revert unrelated formatting changes

* Revert back to only ignoring `-wmo`

Ignoring both `-wmo` and `-index-file` will be harder than just `-wmo`. This is because when calling the compiler and passing `-index-file` after `-dump-ast`, the option gets un-ignored by `Driver::buildOutputInfo`. Therefore, we will just ignore `-wmo` for now.

* Add tests, inspired by `Driver/batch_mode_with_WMO_or_index.swift`
2019-12-19 11:47:47 -08:00
swift_jenkins
f898b2bd5e Merge remote-tracking branch 'origin/master' into master-next 2019-12-19 11:19:56 -08:00
Doug Gregor
393c6d35bf Merge pull request #28874 from DougGregor/unversioned-triple
[Driver] Add unversioned triple to the output of -print-target-info.
2019-12-19 11:07:02 -08:00
Doug Gregor
3a9b8bc658 [Driver] Add unversioned triple to the output of -print-target-info.
SwiftPM wants to use the unversioned triple to know where to put
results. Vend this as part of -print-target-info.
2019-12-19 09:10:58 -08:00
swift_jenkins
a812971ee5 Merge remote-tracking branch 'origin/master' into master-next 2019-12-17 15:00:16 -08:00
Xi Ge
3a55c3c96e Front-end: teach the compiler to generate a .c file for $ld$add$os symbols.
When symbols are moved to this module, this module declares them as HIDE
for the OS versions prior to when the move happened. On the other hand, the
original module should declare ADD them for these OS versions. An executable
can choose the right library to link against depending on the deployment target.
This is a walk-around that linker directives cannot specify other install
name per symbol, we should eventually remove this.
2019-12-13 17:22:00 -08:00
Xi Ge
93a83d3f14 IRGen: reuse linker directives collected from tbd gen to emit these symbols to IR 2019-12-12 22:22:28 -08:00
Joe Groff
fb34044408 Merge remote-tracking branch 'origin/master' into master-next 2019-12-10 12:46:41 -08:00
Doug Gregor
f451dc4177 Merge pull request #28646 from DougGregor/print-target-info-paths
[Frontend] Add some paths to the output of -print-target-info.
2019-12-09 10:00:04 -08:00
Doug Gregor
c92600b38b [Frontend] Add some paths to the output of -print-target-info.
Add various target-specific and compiler-determined paths to the output
of `-print-target-info`, such as the runtime resource path, SDK path, and
runtime library paths.
2019-12-08 21:10:30 -08:00
Doug Gregor
179e3c2ab4 Merge pull request #28602 from DougGregor/print-target-triple
[Driver/Frontend] Add -print-target-triple
2019-12-07 10:51:38 -08:00
Doug Gregor
61c83d2415 [Driver] Switch -print-target-triple to -print-target-info and add more info.
Rather than only emitting the target triple, provide additional
information about that particular target, including the module triple
(i.e., what file names will be used for Swift modules for that
triple), the runtime compatibility version if there is one, and
whether linking with rpaths is required for the standard library and
other libraries shipped with Swift. Encode this as JSON so we can
extend it in the future. For now, it looks like this:

```
{
  "target": {
    "triple": "arm64-apple-ios12.0",
    "moduleTriple": "arm64-apple-ios",
    "swiftRuntimeCompatibilityVersion": "5.0",
    "librariesRequireRPath": true
  }
}
```

Which you can deserialize into a TargetInfo instance as defined below:

```
struct Target: Codable {
  /// The target triple.
  var triple: String
  /// The triple used for module file names.
  var moduleTriple: String
  /// If this platform provides the Swift runtime, the Swift language
  version
  /// with which that runtime is compatible.
  var swiftRuntimeCompatibilityVersion: String?
  /// Whether linking against the Swift libraries requires the use of
  rpaths.
  var librariesRequireRPath: Bool
}

struct TargetInfo: Codable {
  var target: Target
}
```

Implements rdar://problem/47095159.
2019-12-06 22:17:29 -08:00