Commit Graph

58 Commits

Author SHA1 Message Date
Jordan Rose
465b083ba9 [serialization] Serialize the header path used by -import-objc-header.
This doesn't handle cross-references to decls /loaded/ from the header
just yet, so all that's testable right now is whether the header's imports
are visible from the secondary target (after being imported in response
to loading the serialized module).

More of <rdar://problem/16702101>

Swift SVN r17638
2014-05-07 19:03:21 +00:00
Jordan Rose
a0de0e411d [serialization] Drop swift::serializeToStream and swift::serializeModuleDoc.
All serialization should go through serialize(). We don't currently support
serializing docs without serializing a module.

Also, tidy up how Serializer is used within Serialization.cpp.

Swift SVN r17637
2014-05-07 19:03:19 +00:00
Argyrios Kyrtzidis
796afac0af [Frontend] Rename CompilerInstance::performParse() -> performSema() to make it more clear that it is doing parsing + type checking.
Swift SVN r17597
2014-05-07 02:13:49 +00:00
Argyrios Kyrtzidis
136284430c [Frontend] Separate parse-only functionality into its own function, CompilerInstance::performParseOnly().
Parse-only is a hot path; keep the semantics for it separate from normal parsing, otherwise it is very
easy to introduce something expensive without checking for Invocation.getParseOnly().

Also cleans up a bit CompilerInstance::performParse() as well.

Swift SVN r17596
2014-05-07 02:13:48 +00:00
Joe Groff
4a09c9f9dd Add a -print-clang-stats frontend flag.
Prints stats from the Clang importer's ASTReader.

Swift SVN r17512
2014-05-06 01:08:09 +00:00
Doug Gregor
3d3ff6811a Add a pile of missing #includes exposed by pruning includes in top-of-tree LLVM.
Swift SVN r17157
2014-05-01 14:26:34 +00:00
Dmitri Hrybenko
94698bc469 Fix 80 cols violation
Swift SVN r16623
2014-04-21 20:47:15 +00:00
Ted Kremenek
b285190383 Don't crash when 'swift -frontend' is passed no arguments.
Fixes <rdar://problem/16584079>.

Swift SVN r16200
2014-04-11 05:23:57 +00:00
Enrico Granata
34209113fb The REPL currently tries to "warm up" by running an harmless expression, Void(), before giving the user control
This works, except when you launch it in -parse-stdlib mode, where running that expression fails, because Swift.Void wasn't pulled in, and that failure causes the REPL to quit

This patch passes down the -parse-stdlib flag to the REPL initialization code, such that it does not try to run any warm up code in -parse-stdlib mode



Swift SVN r15968
2014-04-05 00:28:55 +00:00
Dmitri Hrybenko
e50b52fa02 Serializer/Driver: serialize comments to separate .swiftdoc files
The driver infers the filename from the module file by replacing the extension,
and passes the explicit path to the swiftdoc file to the frontend.  But there
is no option in the driver to control emission of swiftdoc (it is always
emitted, and name is always inferred from the swiftmodule name).

The swiftdoc file consists of a single table that maps USRs to {brief comment,
raw comment}.  In order to look up a comment for decl we generate the USR
first.  We hope that the performance hit will not be that bad, because most
declarations come from Clang.  The advantage of this design is that the
swiftdoc file is not locked to the swiftmodule file, and can be updated,
replaced, and even localized.


Swift SVN r14914
2014-03-11 10:42:26 +00:00
Dmitri Hrybenko
f232267f23 Replace llvm::OwningPtr with std::unique_ptr
It looks like llvm::OwningPtr is going to be removed soon.


Swift SVN r14729
2014-03-06 09:47:17 +00:00
Michael Gottesman
29e1a53bbb [deserialization] Deserialize transparent functions lazily iff they will be used in mandatory inlining.
Swift SVN r14490
2014-02-28 01:05:01 +00:00
Michael Gottesman
3ac5018ac9 Revert "Revert r14430: Create two SILLinking steps, one before Diagnostics for transparent functions and the other after Diagnostics for non transparent functions if -sil-link-all is passed in."
This recommits r14446 with necessary changes.

The problem was that after my change SILGen was dumped before sil linking
occured. This change adds back in the code to ensure that sil linking occurs.

Swift SVN r14455
2014-02-27 07:04:51 +00:00
Dave Zarzycki
ce2635d401 Revert r14430: Create two SILLinking steps, one before Diagnostics for transparent functions and the other after Diagnostics for non transparent functions if -sil-link-all is passed in.
Swift SVN r14446
2014-02-27 03:09:55 +00:00
Michael Gottesman
0c755a55a8 Create two SILLinking steps, one before Diagnostics for transparent functions and the other after Diagnostics for non transparent functions if -sil-link-all is passed in.
Swift SVN r14430
2014-02-26 23:47:50 +00:00
Dmitri Hrybenko
73aa816935 Track upstream change in raw_fd_ostream API
The default (F_None) used to mean F_Text, now it is F_Binary, which is arguably
a better default.  It only matters on Windows anyway, so just use F_None (to
mean binary mode) everywhere to allow Swift to be compled with older LLVM as
well as current ToT.


Swift SVN r14312
2014-02-24 21:00:00 +00:00
Dmitri Hrybenko
fef36edc6b Try to fix the build following the LLVM raw_fd_ostream API change
Swift SVN r14304
2014-02-24 17:21:49 +00:00
Jordan Rose
eeda180d81 [PrintAsObjC] Emit the ObjC header after SILGen...
...because doing so might cause more Clang types to be deserialized, which
before led to trying to SILGen un-type-checked auto-generated helpers.

Swift SVN r14017
2014-02-18 00:23:12 +00:00
Jordan Rose
69d849772b Always honor -dump-parse, -dump-ast, or -print-ast even if there were errors.
...though -print-ast seems a bit broken right now.

<rdar://problem/16084143>

Swift SVN r14000
2014-02-17 18:48:09 +00:00
Jordan Rose
c054bea3e4 [PrintAsObjC] Actually call printAsObjC when we pass -emit-objc-header.
Switch the existing tests over to using this.

Swift SVN r13801
2014-02-12 01:19:14 +00:00
Connor Wakamo
9df53c5c71 [frontend] Switch -debug-assert-* from llvm_unreachable() to assert(0).
Swift SVN r13656
2014-02-07 22:30:40 +00:00
Connor Wakamo
9747d87ff6 [frontend] Added a handful of options to force the frontend to assert or crash.
Added -debug-assert-immediately and -debug-crash-immediately, which cause an
llvm_unreachable or LLVM_BUILTIN_TRAP to execute during argument parsing.

Added -debug-assert-after-parse and -debug-crash-after-parse, which cause an
llvm_unreachable or LLVM_BUILTIN_TRAP to execute after calling
CompilerInstance::performParse().

This fixes <rdar://problem/16013025>.

Swift SVN r13653
2014-02-07 22:03:32 +00:00
Mark Lacey
5c696fda8b Make IR generation take an explicit LLVMContext.
Prior to r13134, the modules being constructed for IRGen always used the
LLVM global context due to <rdar://problem/15283227>, but the interface
should really take this as a parameter rather than baking the behavior
into IRGen.

Swift SVN r13260
2014-02-01 01:07:14 +00:00
Michael Gottesman
10efd0b073 Add SILOptions as an argument to runSILDiagnosticPasses.
I am going to use this in a forthcoming patch which creates a special mode
called "ParanoidVerification" which runs the verifier after all passes.
"ParanoidVerification" will be by default off and will be used on the swift-fast
buildbot to help catch bugs which might be hidden by optimizations being run.

Swift SVN r13256
2014-02-01 00:30:53 +00:00
Jordan Rose
6af4dbf0e9 Move SILLinkMode to SILOptions.
SILSerializeAll and EmitVerboseSIL are /not/ being moved because they are
options controlling the output, not about SILGen and SIL passes.

No functionality change.

Swift SVN r13197
2014-01-31 02:34:34 +00:00
Jordan Rose
c7f1064527 Extract '-sil-inline-threshold' from the performance inliner.
Plumbing this through to the inliner necessitated the creation of a
SILOptions class (like FrontendOptions and IRGenOptions). I'll move
more things into this soon.

One change: for compatibility with the new driver, the option must be
specified as "-sil-inline-threshold 50" instead of "-sil-inline-threshold=50".
(We're really trying to be consistent about joined-equals vs. separate
in the new frontend.)

Swift SVN r13193
2014-01-31 01:52:12 +00:00
Jordan Rose
bac31d985a Add '-sil-serialize-all' testing option to the new frontend.
Swift SVN r13190
2014-01-31 01:02:06 +00:00
Jordan Rose
e37d2393d1 Modules containing SIL may not be emitted before SIL diagnostics.
...and probably should not be emitted before optimization passes.
The new frontend got this wrong, and the old one pretended to allow it but
then silently didn't write a module at all.

Swift SVN r13189
2014-01-31 01:02:06 +00:00
Jordan Rose
101fd40076 Rip out -emit-module-for-lldb option.
We ended up not using the wrapper around the module data in the Mach-O.

Swift SVN r13185
2014-01-31 00:02:47 +00:00
Jordan Rose
f165afe1aa Replace "-enable-sil-linking=false" with "-disable-sil-linking".
Also, restructure so that the option isn't declared in a random library file.
(And do the same with "-sil-link-all".)

Part of the migration to the new driver.

Swift SVN r13184
2014-01-31 00:02:46 +00:00
Mark Lacey
d69b305200 Generate IR for inline functions from Clang modules.
Currently only inline functions referenced from Swift source files, or
from the REPL, will get IR generated for them. Inline functions
referenced by other inline functions will require additional effort to
generate properly.

With this change we use the clang::CodeGenerator-created llvm::Module
for all IR generation in Swift. This is perhaps undesirable, but
unavoidable given the interface the public Clang APIs expose, which do
not allow for building a ModuleBuilder that borrows an existing
llvm::Module.

Also unfortunate is the hack to generate a UsedAttr for each imported
inline function, but the public Clang APIs do not provide a way to only
emit deferred decls without emitting other things (e.g. module flags
that conflict with what the Swift IRGen emits). Note that we do not do
IRGen for every inline function in the module - only the ones that the
importer pulls in, which appears to be only those transitively
referenced from Swift code.

Swift SVN r13134
2014-01-30 02:33:37 +00:00
Mark Lacey
5e40837b62 Always pass an llvm::Module* to performIRGeneration().
Previously it would create a new module if one was not passed in. There
are no uses where we do not or cannot provide a module, so it seems
reasonable to make the interface consistently require a module.

Swift SVN r13016
2014-01-27 23:48:49 +00:00
Jordan Rose
c312e51962 Add the ability to serialize modules with LLDB's wrapper info around them.
Currently when compiling with debug info, the AST gets serialized into the
.o file for use by the debugger. However, when we switch to one .o file
per .swift file, this won't really make sense any more. Instead, we should
collect all the ASTs at the end of the build and merge them together, then
write /that/ into the final binary.

This commit handles writing a serialized AST with an LLDB wrapper around it,
so that we can take a merged AST, write it out in the wrapper, and splice it
into the final binary using ld's -sectcreate option.

In the long run, we probably won't need the LLDB wrapper, but for now I'm
trying to disturb as little as possible. (It looks like the layout is
broken on 32-bit platforms, though...there was a problem with 64-bit
relocations in the existing SwiftASTStreamerPass, but nothing ever tried to
/read/ the new layout in 32 bits. I'm holding off on dealing with this
right now.)

Part of <rdar://problem/15786017>

Swift SVN r12667
2014-01-21 23:13:26 +00:00
Connor Wakamo
f5d1f5c0d9 [frontend] Added support for -i in the integrated frontend.
Updated frontend_main() and performCompile() to not reject
FrontendOptions::Immediate and instead call RunImmediately() with the correct
IRGenOptions.

Swift SVN r12522
2014-01-18 00:55:46 +00:00
Connor Wakamo
7043cab15f [frontend] Updated assertion message.
Swift SVN r12521
2014-01-18 00:55:46 +00:00
Connor Wakamo
1a3fe6af86 [frontend] Added support for -repl in the integrated frontend.
Updated the swift_driver target so that it links against swiftImmediate and
CoreFoundation.

Updated frontend_main() and performCompile() to not reject FrontendOptions::REPL
and instead call REPLRunLoop().

Swift SVN r12520
2014-01-18 00:55:45 +00:00
Jordan Rose
8cf19bf152 Don't set a default SDK in the new driver, either.
Goes with r12414.

Swift SVN r12439
2014-01-17 00:15:15 +00:00
Jordan Rose
11008f0ed1 Split diagnostics out into separate files.
Thanks to the way we've set up our diagnostics engine, there's not actually
a reason for /everything/ to get rebuilt when /one/ diagnostic changes.
I've split them up into five categories for now: Parse, Sema, SIL, IRGen,
and Frontend, plus a set of "Common" diagnostics that are used in multiple
areas of the compiler. We can massage this later.

No functionality change, but should speed up compile times!

Swift SVN r12438
2014-01-17 00:15:12 +00:00
Connor Wakamo
3a1810336e [frontend] Implement support for emitting modules with the integrated frontend.
Added support for the -emit-module and -module-output-path options. -emit-module
and -module-output-path function similarly to -serialize-diagnostics and
-serialized-diagnostics-path: notably, -module-output-path implies -emit-module,
but -emit-module can be passed without -module-output-path and a default path
will be determined based on other inputs.

Added support for the -module-link-name option, which specifies the name of the
library to link against when importing the generated module.

Note that support for these options is only implemented in the integrated
frontend; driver-level support for these options is forthcoming.

Swift SVN r12301
2014-01-14 23:38:36 +00:00
Connor Wakamo
00f076daa5 [frontend] Implemented support for emitting serialized diagnostics.
Reworked the -serialize-diagnostics option, so that it is now just a flag
indicating that the frontend should generate serialized diagnostics. The path at
which the diagnostics will be serialized is now specified by the
-serialized-diagnostics-path option, which is a frontend-only option. (The
frontend treats -serialized-diagnostics-path as implying -serialize-diagnostics.)

If -serialize-diagnostics is passed but -serialized-diagnostics-path is not
passed, the frontend will choose an output path from a few default values:

- If the frontend has a non-stdout output path, replace that path's extension
  with .dia.
- If there is a primary input filename, use that input's base name as the base
  name for the serialized diagnostics file.
- Otherwise, use the module name as the base name for the serialized diagnostics
  file.

Added support for setting up a serialized diagnostics DiagnosticConsumer in
frontend_main() if FrontendOptions::SerializedDiagnosticsPath is non-empty.

Swift SVN r12251
2014-01-13 21:38:03 +00:00
Connor Wakamo
c5af8e0269 [frontend] Implement support for primary file mode for post-PrintAST actions.
This, in concert with the driver-level changes to pass -primary-file, enables proper multi-file output in swift_driver.

Swift SVN r12158
2014-01-10 22:39:08 +00:00
Connor Wakamo
5d9e2461ce [frontend] Updated -dump-parse, -dump-ast, and -print-ast to operate on the primary input, if one is specified.
Other modes to follow.

Swift SVN r12157
2014-01-10 22:39:08 +00:00
Connor Wakamo
28d579fd1d [frontend] Add support for running SIL optimization passes in the integrated frontend if the optimization level is not zero.
Swift SVN r11483
2013-12-19 21:40:05 +00:00
Connor Wakamo
53a0acad66 [frontend] Added temporary support for setting MainInputFilename, Triple, and OutputFilename in IRGenOptions.
MainInputFilename and OutputFilename are pulled from the FrontendOptions, while Triple is parsed directly from the ArgList.
Eventually, MainInputFilename and OutputFilename should likely be removed from IRGenOptions, in favor of the values in FrontendOptions, while Triple will be in a separate TargetOptions class.

Swift SVN r11455
2013-12-18 23:42:53 +00:00
Connor Wakamo
8b808311b3 [frontend] Added support for parsing -O.
Swift SVN r11452
2013-12-18 23:42:52 +00:00
Connor Wakamo
39bb2bf2a2 [frontend] Added proper support for parsing -l and -framework.
Moved the responsibility for storing LinkLibraries from CompilerInvocation to the invocation’s IRGenOpts.
Moved the handling of -l and -framework into ParseIRGenArgs.

Swift SVN r11450
2013-12-18 23:42:51 +00:00
Connor Wakamo
9f113b59ca [frontend] In frontend_main(), switch from using a local IRGenOptions to using the CompilerInvocation's.
Swift SVN r11448
2013-12-18 23:42:50 +00:00
Connor Wakamo
59f18f9fc0 Renamed irgen::Options and irgen::OutputKind to IRGenOptions and IRGenOutputKind, and move both out of the irgen namespace now that they're in swiftAST.
Swift SVN r11405
2013-12-18 01:17:09 +00:00
Connor Wakamo
3e81830385 Move "include/swift/IRGen/Options.h" to "include/swift/AST/IRGenOptions.h".
This commit only moves the header file; updating the class so that it is no longer in the irgen namespace will be handled separately.

Swift SVN r11404
2013-12-18 01:17:09 +00:00
Connor Wakamo
b0092c4717 [frontend] Initial support for performing non-EmitObject actions in the integrated frontend.
The integrated frontend now supports:
  - Parse
  - DumpParse
  - DumpAST
  - PrintAST
  - EmitSILGen
  - EmitSIL
  - EmitIR
  - EmitBC
  - EmitAssembly
  - EmitObject

Moved the code for compiling into a separate performCompile() function in frontend_main.cpp, to facilitate using early returns while still supporting the diagnostic verifier.
Added some error output for the REPL, Immediate, and EmitModuleOnly actions, as the integrated frontend does not yet support these actions.

Swift SVN r11387
2013-12-17 18:35:00 +00:00