Commit Graph

721 Commits

Author SHA1 Message Date
Saleem Abdulrasool
618ced846b Merge pull request #31310 from compnerd/unreachable
sprinkle some `llvm_unreachable` for MSVC (NFC)
2020-04-25 09:44:39 -07:00
swift_jenkins
ed20b9c058 Merge remote-tracking branch 'origin/master' into master-next 2020-04-24 23:58:13 -07:00
Saleem Abdulrasool
fa46f7131c sprinkle some llvm_unreachable for MSVC (NFC)
MSVC does not realize that the switch is exhaustive and requires that
the path is explicitly marked as unreachable.  This silences the C4715
warning ("not all control paths return a value").
2020-04-24 18:59:07 -07:00
Doug Gregor
71e7d6a913 [Dependency scanning] Add implicit Swift and SwiftOnoneSupport dependencies 2020-04-24 12:58:45 -07:00
Doug Gregor
08ec8781aa [Dependency scanning] Emit make-style dependency files.
If requested, produce the normal make-style dependency file from the
fast dependency scanner, using the same dependency-tracking
infrastructure.
2020-04-24 12:58:44 -07:00
Doug Gregor
33cdd61835 Fast dependency scanning for Swift
Implement a new "fast" dependency scanning option,
`-scan-dependencies`, in the Swift frontend that determines all
of the source file and module dependencies for a given set of
Swift sources. It covers four forms of modules:

1) Swift (serialized) module files, by reading the module header
2) Swift interface files, by parsing the source code to find imports
3) Swift source modules, by parsing the source code to find imports
4) Clang modules, using Clang's fast dependency scanning tool

A single `-scan-dependencies` operation maps out the full
dependency graph for the given Swift source files, including all
of the Swift and Clang modules that may need to be built, such
that all of the work can be scheduled up front by the Swift
driver or any other build system that understands this
option. The dependency graph is emitted as JSON, which can be
consumed by these other tools.
2020-04-24 12:58:41 -07:00
swift_jenkins
c2672fe6e9 Merge remote-tracking branch 'origin/master' into master-next 2020-04-19 23:58:17 -07:00
swift_jenkins
563adf9573 Merge remote-tracking branch 'origin/master' into master-next 2020-04-19 21:57:18 -07:00
Robert Widmann
37f016b802 [NFC] Formalize isModuleExternallyConsumed
Yank this parameter and document the historical scope creep of this value.
2020-04-19 21:46:59 -07:00
Robert Widmann
446c6e6682 [NFC] Refactor validateTBDIfNeeded
Inline the conditions for the astGuaranteedToCorrespondToSIL parameter and clean up the logic here to be more const-friendly. Also try to centralize and document the reasons we skip TBD validation.
2020-04-19 16:10:06 -07:00
Robert Widmann
5481631baf Merge remote-tracking branch 'upstream/master' into master-next 2020-04-17 20:27:23 -07:00
Robert Widmann
2ca8e66770 [NFC] Refactor the construction of SILRemarksStreamer
The Remarks Streamer's installation seemed a bit overly complex, so simplify it in a few places:

* Refactor sil-opt to install the remarks options into the SILOptions for the SILModule

This reduces the parameter bloat in createSILRemarkStreamer. All of this data is freely derivable from the SILModule alone.

* Refactor createSILRemarkStreamer into SILRemarkStreamer::create

With the new reduction in parameters, we can hide the internal constructor and introduce a smart constructor that vends a unique pointer to clients.

* setSILRemarkStreamer -> installSILRemarkStreamer

Since the information to create a streamer is now entirely derivable from a module, remove a layer of abstraction and have the module directly construct a streamer for itself.

* Give SILRemarkStreamer its own LLVMContext

The remarks streamer just needs scratch space. It's not actually "installed" in a given context. There no reason to use Swift's Global Context here.

* Give the SILRemarkStreamer ownership of the underlying file stream

The SILModule didn't actually use this member, and it seems like somebody needs to own it, so just give it to the remarks streamer directly.
2020-04-17 14:02:45 -07:00
Robert Widmann
bc31c7fe47 [NFC] Internalize the LLVMContext for LLVM IR Code Generation 2020-04-17 12:22:36 -07:00
Robert Widmann
993c35dcd6 Merge remote-tracking branch 'upstream/master' into contextual-clues 2020-04-17 11:52:53 -07:00
Robert Widmann
85fdc7a555 Merge pull request #31080 from CodaFi/why-I-R-ta
Give IRGenModule Ownership of its LLVMContext
2020-04-17 10:32:46 -07:00
swift_jenkins
88d5c0a16e Merge remote-tracking branch 'origin/master' into master-next 2020-04-17 07:19:05 -07:00
Michael Forster
fae87c96d7 Move interleave(...) to the llvm namespace
This simplifies fixing the master-next build. Upstream LLVM already
has a copy of this function, so on master-next we only need to delete
the Swift copy, reducing the potential for merge conflicts.
2020-04-17 11:20:50 +02:00
Robert Widmann
de304b5bee [NFC] Introduce GeneratedModule
swift::GeneratedModule encapsulates an llvm::Module, llvm::LLVMContext
pair that must live and die together. It has  convenient accessors for
projecting the module and context components. The meat of this type is
the two conversion functions, which transfer ownership of either the
module component to the caller or the module and context to ORCJIT.

This is because ORC enforces an ownership contract that is distinct from
LLVM's rather wild ownership story for modules and their associated
contexts. See http://llvm.org/docs/ORCv2.html#how-to-use-threadsafemodule-and-threadsafecontext
2020-04-16 11:57:44 -07:00
David Ungar
9dcd2b52b2 Allocate LLVMContext in IRGenModule. 2020-04-16 11:57:44 -07:00
swift_jenkins
12a5da6dc6 Merge remote-tracking branch 'origin/master' into master-next 2020-03-31 18:24:02 -07:00
Robert Widmann
a337b67f69 Stage In Flags To Fall Back To Manual Tracking
Request-based incremental dependencies are enabled by default. For the time being, add a flag that will turn them off and switch back to manual dependency tracking.
2020-03-31 16:16:53 -07:00
swift_jenkins
33628bbd7b Merge remote-tracking branch 'origin/master' into master-next 2020-03-30 18:00:36 -07:00
Robert Widmann
58e63f7185 Merge pull request #28313 from owenv/verifier-consumer
[DiagnosticVerifier] Make DiagnosticVerifier a DiagnosticConsumer
2020-03-30 17:46:30 -07:00
Owen Voorhees
465bab002f [DiagnosticVerifier] Make Diagnostic Verifier a DiagnosticConsumer subclass
Update DiagnosticVerifier to respect color flags

Improve DiagnosticVerifier test coverage

verifier updates to support new llvm stable branch
2020-03-28 12:29:53 -07:00
swift_jenkins
acbf5bf9ae Merge remote-tracking branch 'origin/master' into master-next 2020-03-27 15:42:21 -07:00
Owen Voorhees
791312fb74 Turn Educational Notes On-By-Default (#30583)
* [Diagnostics] Turn educational notes on-by-default

* [Diagnostics] Only include educational notes in printed output if -print-educational-notes is passed

* Make -print-educational-notes a driver option

* [Diagnostics] Issue a printed remark if educational notes are available, but disabled

* [docs] Update educational notes documentation and add a contributing guide

* [Diagnostics] Cleanup PrintingDiagnosticConsumer handling of edu notes

* Revert "[Diagnostics] Issue a printed remark if educational notes are available, but disabled"
For now, don't notify users if edu notes are available but disabled. This decision can be reevaluated later.
2020-03-27 15:29:48 -07:00
swift_jenkins
340839a81d Merge remote-tracking branch 'origin/master' into master-next 2020-03-27 12:19:29 -07:00
Hamish Knight
6f212634c8 Add getOperatorDecls to FileUnit and ModuleDecl
Query the SourceLookupCache for the operator decls,
and use ModuleDecl::getOperatorDecls for both
frontend stats and to clean up some code
completion logic.

In addition, this commit switches getPrecedenceGroups
over to querying SourceLookupCache.
2020-03-27 09:44:55 -07:00
swift_jenkins
45a52b0e3d Merge remote-tracking branch 'origin/master' into master-next 2020-03-26 09:37:34 -07:00
Nathan Hawes
a785fa6cee [Frontend][Index] Add frontend option to skip indexing the stdlib (for test performance)
Several tests related to indexing system modules were taking a considerable
amount of time (100+ seconds in the worst case) indexing the standard library.
This adds a frontend option to skip it and updates those tests to pass it.
2020-03-25 14:36:23 -07:00
Michael Forster
345a9147ec Explicit SmallString->std::string conversion.
This is only needed temporarily until commit d7049213 from upstream
LLVM hits the swift/master branch.
2020-03-13 19:16:49 +01:00
Fred Riss
259d78a350 Adapt to llvm.org StringRef API change 2020-03-13 19:08:22 +01:00
Adrian Prantl
41f76322d2 Adapt to upstream header file reshuffling 2020-03-12 10:23:47 -07:00
swift_jenkins
7b39b9f24f Merge remote-tracking branch 'origin/master' into master-next 2020-03-12 00:47:37 -07:00
Xi Ge
df0493c288 PrintAsObjC: allow users to specify bridging header relative path for printing
Compatibility header may #import bridging header if specified with -import-underlying-module.
How these two headers are relative to each other is subject to project setting. To accommodate
this, we should allow users to specify bridging header directory for header generating purposes.

rdar://59110975
2020-03-11 17:09:53 -07:00
swift_jenkins
0436816df9 Merge remote-tracking branch 'origin/master' into master-next 2020-03-03 23:25:09 -08:00
Robert Widmann
ef149d5c86 Merge pull request #30135 from CodaFi/verily-i-depend-on-thee
[Incremental] Introducing: DependencyVerifier
2020-03-03 22:01:38 -08:00
Robert Widmann
f85ec3825f Address review feedback 2020-03-03 16:46:04 -08:00
swift_jenkins
bd6dad611d Merge remote-tracking branch 'origin/master' into master-next 2020-03-03 09:45:13 -08:00
Visoiu Mistrih Francis
aaab1869af Merge pull request #29650 from francisvm/sil-remark-streamer
[Remarks] Add a specialized RemarkStreamer for SIL remarks
2020-03-03 09:30:17 -08:00
swift_jenkins
b930c0ad1f Merge remote-tracking branch 'origin/master' into master-next 2020-03-03 09:00:32 -08:00
Owen Voorhees
69b513afaf [Diagnostics] Updated (experimental) diagnostic printing style (#30027)
* [Diagnostics] Experimental diagnostic printing updates

This new style directly annotates small snippets of code with
error messages, highlights and fix-its. It also uses color more
effectively to highlight important segments.

* [Diagnostics] Stage educational notes and experimental formatting behind separate frontend flags

educational notes -> -enable-educational-notes
formatting -> -enable-experimental-diagnostic-formatting

* [Diagnostics] Refactor expensive line lookups in diag formatting

* [Diagnostics] Refactor some PrintingDiagnosticConsumer code into a flush method

* [Diag-Experimental-Formatting] Custom formatting for Xcode editor placeholders

* [Diag-Experimental-Formatting] Better and more consistent textual description of fix its

* [Diags-Experimental-Formatting] Handle lines with tab characters correctly when rendering highlights and messages

Tabs are converted to 2 spaces for display purposes.

* [Diag-Experimental-Formatting] Refactor byte-to-column mapping for efficiency

* [Diag-Experimental-Formatting] Fix line number indent calculation

* [Diag-Experimental-Formatting] Include indicators of insertions and deletions in the highlight line

Inserts are underlined by green '+' chars, deletions by red '-' chars.

* [Diag-Experimental-Formatting] Change color of indicator arrow for non-ASCII anchored messages
* [Diag-experimental-formatting] Make tests less sensitive to line numbering

* [Diag-Experimental-Formatting] Update tests to allow windows path separators

* [Diag-Experimental-Formatting] Bug fixes for the integrated REPL
2020-03-03 08:48:32 -08:00
Francis Visoiu Mistrih
e724ebab6b [Remarks] Add a specialized RemarkStreamer for SIL remarks
This allows the usage of the whole remark infrastructure developed in
LLVM, which includes a new binary format, metadata in object files, etc.

This gets rid of the YAMLTraits-based remark serialization and does the
plumbing for hooking to LLVM's main remark streamer.

For more about the idea behind LLVM's main remark streamer, see the
docs/Remarks.rst changes in https://reviews.llvm.org/D73676.

The flags are now:

* -save-optimization-record: enable remarks, defaults to YAML
* -save-optimization-record=<format>: enable remarks, use <format> for
serialization
* -save-optimization-record-passes <regex>: only serialize passes that
match <regex>.

The YAMLTraits in swift had a different `flow` setting for the debug
location, resulting in some test changes.
2020-03-02 18:33:20 -08:00
Robert Widmann
6ccba70bb3 [Incremental] Introducing: DependencyVerifier
The DependencyVerifier is a DiagnosticVerifier-alike utility that takes annotations in user code and transforms them into a set of expectations. Those expectations are met by corresponding "obligations", which are constructed by reading the contents of the referenced name tracker associated with the source files for each of the primary inputs to a frontend job. The verifier will then pair off expectations and obligations, and ensure that any remaining unpaired obligations are diagnosed as failures.

This tool will not only ensure the correctness of the referenced name tracker's output, it will provide us with tests that ensure its output is stable, and give us the confidence to replace it with an evaluator-based tracking scheme in the future.

Resolves rdar://59773883
2020-03-02 16:45:37 -08:00
Robert Widmann
d3edb5b15a [Incremental] Plumb -verify-incremental-dependencies Through The Frontend and Driver
When enabled at the driver level, the frontends will inherit the flag. For each frontend that recieves this option, all primaries will have their reference dependencies validated.
2020-03-02 16:45:37 -08:00
swift_jenkins
dd7d819b6a Merge remote-tracking branch 'origin/master' into master-next 2020-02-28 10:40:34 -08:00
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
swift_jenkins
1060fa57ab Merge remote-tracking branch 'origin/master' into master-next 2020-02-27 13:03:50 -08:00