Commit Graph

316 Commits

Author SHA1 Message Date
swift_jenkins
70b3de8660 Merge remote-tracking branch 'origin/main' into next 2021-06-09 11:40:59 -07:00
Erik Eckstein
809ce72e05 libswift: build support for the initial libswift
* add the (still empty) libswift package
* add build support for libswift in CMake
* add libswift to swift-frontend and sil-opt

The build can be controlled with the LIBSWIFT_BUILD_MODE cmake variable: by default it’s “DISABLE”, which means that libswift is not built. If it’s “HOSTTOOLS”, libswift is built with a pre-installed toolchain on the host system.
2021-06-09 11:25:15 +02:00
swift_jenkins
4cdcfa5991 Merge remote-tracking branch 'origin/main' into next 2021-03-02 08:41:25 -08:00
David Zarzycki
09153bf5af [CMake] NFC: Fix building with LLVM's BUILD_SHARED_LIBS 2021-03-02 09:18:44 -05:00
David Zarzycki
d411b2eda1 Unbreak building against apple/main 2021-01-22 11:48:18 -05:00
David Zarzycki
9df236987c Track upstream LLVM
LLVM 1d0676b54c4e3a517719220def96dfdbc26d8048 moved a function.
2020-11-14 07:34:44 -05:00
Nathan Hawes
ded5512cdc Manually merge remote-tracking branch 'upstream/master' into master-next 2020-08-06 10:42:21 -07:00
Saleem Abdulrasool
8d21750ef3 Frontend: support dumping the JIT state
Add a debugging mechanism that enables the JIT to dump the LLVM IR and
object files to enable debugging the JIT.  This makes it easier to debug
the JIT mode failures.  The idea was from Lang Hames!
2020-08-05 09:13:49 -07:00
swift_jenkins
9192927ebc Merge remote-tracking branch 'origin/master' into master-next 2020-07-16 23:18:54 -07:00
Hamish Knight
c0a2ea7d0e Sink linker directive computation into IRGen
With an inverted pipeline, IRGen needs to be able
to compute the linker directives itself, so sink
it down such that it can be computed by the
`IRGenDescriptor`.
2020-07-15 17:46:14 -07:00
Hamish Knight
d05bfa09d6 [IRGen] Lift call to performLLVM out of IRGenRequest
Remove the side-effecting call from IRGenRequest,
instead requiring callers to handle the optimization
and emission of the LLVM module.
2020-07-15 16:46:42 -07:00
Hamish Knight
db7fea4665 Sink linker directive computation into IRGen
With an inverted pipeline, IRGen needs to be able
to compute the linker directives itself, so sink
it down such that it can be computed by the
`IRGenDescriptor`.
2020-07-13 20:42:54 -07:00
Karoy Lorentey
68351d2110 Revert "Merge remote-tracking branch 'origin/master-next'"
This reverts commit 1c9b0908e6, reversing
changes made to 3eb82c1836.
2020-06-08 16:48:38 -07:00
swift_jenkins
8069dd1be9 Merge remote-tracking branch 'origin/master' into master-next 2020-05-07 08:20:47 -07:00
swift_jenkins
6af83c13fc Merge remote-tracking branch 'origin/master' into master-next 2020-05-06 20:04:54 -07:00
Slava Pestov
dd0ce1ad13 Remove the integrated REPL 2020-05-06 22:29:05 -04:00
Slava Pestov
60ce308eba Sema: Only run extension binding once
There's no need to walk all imports of all source files, and bind the
extensions defined therein. The only time that a non-main module
contains source files is when using -enable-source-import, and we
can just explicitly call bindExtensions() in the right place.
2020-05-06 19:19:47 -04:00
swift_jenkins
9b6f01b6d9 Merge remote-tracking branch 'origin/master' into master-next 2020-04-30 20:37:34 -07:00
Daniel Sweeney
ea526c6383 Converting ModuleDecl::ImportedModule from std::pair to a dedicated struct. (#31360) 2020-04-30 20:26:03 -07:00
swift_jenkins
f5510bf1a4 Merge remote-tracking branch 'origin/master' into master-next 2020-04-20 16:57:12 -07:00
Hamish Knight
7f8a0e8a6c Requestify implicit imports
Add ModuleImplicitImportsRequest, which computes
the modules that should be implicitly imported by
each file of a given module. Use this request in
import resolution to add all the necessary
implicit imports.

The request computes the implicit imports by
consulting the ImplicitImportInfo, which ModuleDecl
can now be created with. This allows us to remove
uses of `SourceFile::addImports` in favor of
adding modules needed to be implicitly imported to
the ImplicitImportInfo.
2020-04-20 13:20:35 -07:00
Robert Widmann
5481631baf Merge remote-tracking branch 'upstream/master' into master-next 2020-04-17 20:27:23 -07:00
Robert Widmann
1f2346d381 [NFC] Drastically Reduce The Scope of the Global Context
Delete all of the formalism and infrastructure around maintaining our own copy of the global context. The final frontier is the Builtins, which need to lookup intrinsics in a given scratch context and convert them into the appropriate Swift annotations and types. As these utilities have wormed their way through the compiler, I have decided to leave this alone for now.
2020-04-17 14:02:45 -07:00
Robert Widmann
08fcf7d443 [NFC] Internalize the REPL's LLVMContext
There's no reason the REPL needs to generate its starting module in the
global LLVMContext. Give it a local context.
2020-04-17 12:20:41 -07:00
Robert Widmann
993c35dcd6 Merge remote-tracking branch 'upstream/master' into contextual-clues 2020-04-17 11:52:53 -07:00
Robert Widmann
03b19f3f7e Sequester the REPL's linking machinery
All of this is in service of working around a pile of deficiencies in LLVM's Module Linker, and LLVMContext abstractions. And because we're just gonna scrap this code soon anyways, it's probably not worth the effort to push on these bugs to block the broader cleanup here.

The LLVM Linker currently does not support linking modules allocated in different contexts. This appears to be motivated in part by LLVM's lack of a facility to clone a module from one context to another. This, in turn, appears to be motivated in part by LLVMContext's lack of a robust notion of identity - which makes it harder than it needs to be to detect the mismatch.

However, it is not impossible to clone a module across contexts. We need to get creative and round-trip the module through some serialization layer. Out of convenience, that layer is currently textual IR, though bitcode would work equally well.

Given that it is no longer under the caller's control which LLVMContext we generate code in, put all the above together to arrive at an egregious hack that clones the module into the LLVMContext the REPL expects.
2020-04-16 11:57:44 -07: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
Lang Hames
995c1c986f Merge remote-tracking branch 'upstream/master' into fix-imm-static-inits-merge 2020-03-13 18:36:32 -07:00
Lang Hames
2c083d8d2b [Immediate] Fix static constructor/destructor calls in RunImmediately.
Removes a redundant call to LLJIT::runConstructors and adds a call to
LLJIT::runDestructors.
2020-03-13 14:44:32 -07:00
Brent Royal-Gordon
8c2aeb387c Patch up runConstructors() change in Immediate.cpp 2020-03-06 13:51:15 -08:00
lhames
1d5c008f97 Merge pull request #29863 from lhames/switch-imm-to-lljit
[Immediate] Switch immediate mode from MCJIT to LLJIT.
2020-03-06 09:12:27 -08:00
Lang Hames
17671672ce [Immediate] Switch the JIT codegen opt-level to Default.
This matches MCJIT's default, and may solve some of the linux test failures
seen in https://github.com/apple/swift/pull/29863.
2020-03-05 14:08:09 -08:00
Hamish Knight
011f4f1584 Requestify SourceFile parsing
Add ParseSourceFileRequest that parses a SourceFile
for its top-level decls.
2020-03-03 15:53:18 -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
Hamish Knight
d77cae6720 Move PersistentParserState onto SourceFile
Move the global PersistentParserState from
the CompilerInstance to the source file that code
completion is operating on, only hooking up the
state when it's needed. This will help make it
easier to requestify source file parsing.
2020-03-02 11:22:44 -08:00
Lang Hames
7a0754b127 [Immediate] Switch immediate mode from MCJIT to LLJIT.
LLJIT is a simple LLVM IR JIT. Its interface is similar to MCJIT, but its
implementation is based on LLVM's newer ORC APIs. This initial patch does not
make use of any of LLJIT/ORC's advanced features, but will provide better
diagnostics when JIT'd code fails to link. Once LLJIT has proven usable in
this basic configuration we can start experimenting with more advanced
features, including lazy compilation.
2020-02-14 17:59:23 -08:00
swift-ci
ac3ce0d3c4 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-02-06 13:43:41 -08:00
swift-ci
cf3c4aa3f5 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-02-05 16:06:28 -08:00
Hamish Knight
e5946227da Always mark the initial REPL file as typechecked
We were previously doing this for the REPL, but
not for swift-ide-test. Move the assignment into
the frontend to make sure its always applied, and
inline `createREPLFile` while we're here.
2020-02-05 14:01:20 -08:00
Hamish Knight
312f7ddc50 Parse Swift decls in one shot
Instead of interleaving typechecking and parsing
for SIL files, first parse the file for Swift
decls by skipping over any intermixed SIL decls.
Then we can perform type checking, and finally SIL
parsing where we now skip over Swift decls.

This is an intermediate step to requestifying the
parsing of a source file for its Swift decls.
2020-02-04 13:04:50 -08:00
Mike Ash
cd2b54f74e Merge branch 'master' into master-rebranch 2020-01-24 11:30:32 -05:00
Saleem Abdulrasool
04affa2b9f build: use the new libedit imported library
Use the imported library to track header search path and library search
paths and dependencies rather than replicating that knowledge.
2020-01-23 14:24:06 -08:00
Erik Eckstein
1b312a85bd Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-16 10:39:20 +01: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
6407a4d36f [Gardening] Drop an unused parameter 2020-01-13 22:01:41 -08:00
swift-ci
bc5eca8388 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-10 16:43:42 -08:00
Shoaib Meenai
e606f52ae8 [build] Check for unicode functions in libedit
Some versions of libedit may have histedit.h but not the Unicode
functions. Explicitly check for the Unicode functions in the found
libedit to ensure the check is accurate.

I considered making this a component of the LibEdit package in our find
module, but CMake's documentation [1] says "Packages that find multiple
semi-independent parts (like bundles of libraries) should search for the
components...", and the "multiple semi-independent parts" definitely
isn't the case here; we're just interested in determining if the found
library supports a particular feature.

[1] https://cmake.org/cmake/help/v3.16/manual/cmake-developer.7.html#find-modules
2020-01-10 09:40:18 -08:00