Commit Graph

162 Commits

Author SHA1 Message Date
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Jordan Rose
c40e8d9031 Add frontend option -debug-time-compilation.
This times each phase of compilation, so you can see where time is being
spent. This doesn't cover all of compilation, but does get all the major
work being done.

Note that these times are non-overlapping, and should stay that way.
If we add more timers, they should go in a different timer group, so we
don't end up double-counting.

Based on a patch by @cwillmor---thanks, Chris!

Example output, from an -Onone build using a debug compiler:

===-------------------------------------------------------------------------===
                               Swift compilation
===-------------------------------------------------------------------------===
  Total Execution Time: 8.7215 seconds (8.7779 wall clock)

   ---User Time---   --System Time--   --User+System--   ---Wall Time---  --- Name ---
   2.6670 ( 30.8%)   0.0180 ( 25.3%)   2.6850 ( 30.8%)   2.7064 ( 30.8%)  Type checking / Semantic analysis
   1.9381 ( 22.4%)   0.0034 (  4.8%)   1.9415 ( 22.3%)   1.9422 ( 22.1%)  AST verification
   1.0746 ( 12.4%)   0.0089 ( 12.5%)   1.0834 ( 12.4%)   1.0837 ( 12.3%)  SILGen
   0.8468 (  9.8%)   0.0171 ( 24.0%)   0.8638 (  9.9%)   0.8885 ( 10.1%)  IRGen
   0.6595 (  7.6%)   0.0142 ( 20.0%)   0.6737 (  7.7%)   0.6739 (  7.7%)  LLVM output
   0.6449 (  7.5%)   0.0019 (  2.6%)   0.6468 (  7.4%)   0.6469 (  7.4%)  SIL verification (pre-optimization)
   0.3505 (  4.1%)   0.0023 (  3.2%)   0.3528 (  4.0%)   0.3530 (  4.0%)  SIL optimization
   0.2632 (  3.0%)   0.0005 (  0.7%)   0.2637 (  3.0%)   0.2639 (  3.0%)  SIL verification (post-optimization)
   0.0718 (  0.8%)   0.0021 (  3.0%)   0.0739 (  0.8%)   0.0804 (  0.9%)  Parsing
   0.0618 (  0.7%)   0.0010 (  1.4%)   0.0628 (  0.7%)   0.0628 (  0.7%)  LLVM optimization
   0.0484 (  0.6%)   0.0011 (  1.5%)   0.0495 (  0.6%)   0.0495 (  0.6%)  Serialization (swiftmodule)
   0.0240 (  0.3%)   0.0006 (  0.9%)   0.0246 (  0.3%)   0.0267 (  0.3%)  Serialization (swiftdoc)
   0.0000 (  0.0%)   0.0000 (  0.0%)   0.0000 (  0.0%)   0.0000 (  0.0%)  Name binding
   8.6505 (100.0%)   0.0710 (100.0%)   8.7215 (100.0%)   8.7779 (100.0%)  Total
2015-12-17 15:19:09 -08:00
Argyrios Kyrtzidis
8d9ef80304 [frontend] Introduce a new frontend option '-dump-api-path', which outputs a swift interface file for each compiled source file.
This is primarily intended for use with the stdlib.
2015-12-03 08:44:36 -08:00
Jordan Rose
fbb8d3f9a8 Add "interface hash" for improved incremental builds.
Compute the hash of all interface tokens when parsing; write the
interface hash to the swiftdeps file, or if the -dump-interface-hash
option is passed to the frontend. This hash will be used in incremental
mode to determine whether a file's interface has changed, and therefore
whether dependent files need to be rebuilt in response to the change.

Committed on ChrisW's behalf while he gets his setup unborked.

rdar://problem/15352929

Swift SVN r30477
2015-07-22 00:13:54 +00:00
Devin Coughlin
ea18bc0c0b Rename -dump-trc option to -dump-type-refinement-contexts
As Jordan notes, 'TRC' is not a commonly-known acronym for most Swift compiler developers.

Swift SVN r30414
2015-07-20 21:47:49 +00:00
Devin Coughlin
b427975c39 Add a -dump-trc frontend option to print the type refinement context hierarchy
This is useful for debugging and testing.

Swift SVN r30383
2015-07-19 05:53:27 +00:00
Connor Wakamo
eb36def696 [frontend] Updated the behavior for -import-module so it can be specified multiple times.
Instead of only honoring the last occurrence of -import-module, the frontend now
honors all occurrences of -import-module, making all of the modules specified on
the command line implicitly visible.

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

Swift SVN r27299
2015-04-15 00:22:48 +00:00
Argyrios Kyrtzidis
8b250d6d35 [driver] Remove the 'swift-fixit' symlink and introduce '-emit-fixits-path' frontend option that
writes compiler fixits as source edits.

Driver option '-fixit-code' adds '-emit-fixits-path' for all the frontend invocations.

Swift SVN r27208
2015-04-10 17:33:29 +00:00
Chris Willmore
d3a977d824 <rdar://problem/20402026> Remove scope entry/exit log entries
Don't emit scope entry/exit logging code in instrumentation for
playgrounds if -playground-high-performance option is passed.

Swift SVN r27046
2015-04-06 22:09:20 +00:00
Jordan Rose
c6739b6b6c Add the -enable-testing flag, and serialize it.
This flag indicates that internal APIs within the module should be made
available to client code for testing purposes. Currently does nothing.

Not ready for developer consumption yet, ergo a hidden frontend-only flag.

Part of testability (rdar://problem/17732115)

Swift SVN r26292
2015-03-19 02:20:38 +00:00
Luqman Aden
0c6464aec7 [driver] Add -emit-sibgen option.
Swift SVN r25936
2015-03-10 18:31:08 +00:00
Erik Eckstein
460eea3b95 Let the frontend options handle multiple output files.
This will be needed for split-llvm code generation.
If multiple -o options are specified and only a single output file is needed
(currently always), the last one wins. This is NFC.



Swift SVN r25884
2015-03-09 16:24:52 +00:00
Luqman Aden
34b74cfa1c [driver] Add -emit-sib primary action.
Swift SVN r25783
2015-03-05 19:15:07 +00:00
Manman Ren
d39f8e49a8 [Driver] make Swift accept bitcode input.
Thanks Jordan for reviewing the patches.
rdar://19048891


Swift SVN r25558
2015-02-26 19:31:09 +00:00
Manman Ren
a43db3621f [Driver] add InputFileKind to FrontendOptions.
Separate InputFileKind from SourceFileKind, FrontendOptions will now use
InputFileKind, while Module will use SourceFileKind.

This is in preparation for adding an input file kind for LLVM IR.

rdar://19048891


Swift SVN r25555
2015-02-26 19:13:39 +00:00
Jordan Rose
c97c949fcf Add frontend flag -import-module <name>.
This implicitly adds the named module as an import of every source file
in the module being compiled. This is not intended to be used generally,
but will be useful for playgrounds.

rdar://problem/19605934

Swift SVN r24905
2015-02-02 22:20:13 +00:00
Jordan Rose
8ee17a4d0d Serialize search paths when building an app, for a better debugging experience.
There's also a testing option, -serialize-debugging-options, to force this
extra info to be serialized even for library targets. In the long run we'll
probably write out this information for all targets, but strip it out of
the "public module" when a framework is built. (That way it ends up in the
debug info's copy of the module.)

Incidentally, this commit includes the ability to add search paths to the
Clang importer on the fly, which is most of rdar://problem/16347147.
Unfortunately there's no centralized way to add search paths to both Clang
/and/ Swift at the moment.

Part of rdar://problem/17670778

Swift SVN r24545
2015-01-20 03:02:54 +00:00
Jordan Rose
8612e24e0f -debug-time-function-bodies: dump time spent type-checking each function.
This is a hidden frontend-only option intended for debugging purposes,
mainly for identifying where in a file the type checker is spending most
of its time. Use with "sort -g" to get the top problem functions.

Swift SVN r23789
2014-12-08 23:07:07 +00:00
Jordan Rose
fc09bd4585 Add basic reference tracking based on name lookups.
This tracks top-level qualified and unqualified lookups in the primary
source file, meaning we see all top-level names used in the file. This
is part of the intra-module dependency tracking work that can enable
incremental rebuilds.

This doesn't quite cover all of a file's dependencies. In particular, it
misses cases involving extensions  defined in terms of typealiases, and
it doesn't yet track operator lookups. The whole scheme is also very
dependent on being used to track file-level dependencies; if C is a subclass
of B and B is a subclass of A, C doesn't appear to depend on A. It only
works because changing A will mark B as dirty.

Part of rdar://problem/15353101

Swift SVN r22925
2014-10-24 22:23:03 +00:00
Argyrios Kyrtzidis
0e55e054b9 [Frontend] Allow explicit control for enabling the playground instrumenter.
Related to rdar://18095436

Swift SVN r22915
2014-10-24 17:16:59 +00:00
Jordan Rose
3fcdfd40e9 Remove the "swift/Basic/Optional.h" header.
llvm::Optional lives in "llvm/ADT/Optional.h". Like Clang, we can get
Optional in the 'swift' namespace by including "swift/Basic/LLVM.h".

We're now fully switched over to llvm::Optional!

Swift SVN r22477
2014-10-02 18:51:45 +00:00
Argyrios Kyrtzidis
0de5a66345 [Frontend] Introduce FrontendOptions::NoneAction, when the client wants custom control on how to handle an invocation.
This fixes SourceKit tests after r21537.

Swift SVN r21564
2014-08-29 04:58:37 +00:00
Jordan Rose
fce31decdc Serialize bridging headers into the merged module file.
We do this so that the swiftmodule file contains all info necessary to
reconstruct the AST for debugging purposes. If the swiftmodule file is copied
into a dSYM bundle, it can (in theory) be used to debug a built app months
later. The header is processed with -frewrite-includes so that it includes
any non-modular content; the user will not have to recreate their project
structure and header maps to reload the AST.

There is some extra complexity here: a target with a bridging header
(such as a unit test target) may depend on another target with a bridging
header (such as an app target). This is a rare case, but one we'd like to
still keep working. However, if both bridging headers import some common.h,
we have a problem, because -frewrite-includes will lose the once-ness
of #import. Therefore, we /also/ store the path, size, and mtime of a
bridging header in the swiftmodule, and prefer to use a regular parse from
the original file if it can be located and hasn't been changed.

<rdar://problem/17688408>

Swift SVN r20128
2014-07-18 00:22:53 +00:00
Michael Gottesman
3ba4ca1b31 Add support for printing SIL with SIL entities sorted by name behind the flag -sil-sort-by-output-names.
This significantly reduces the diff size when diffing the standard
library.

Swift SVN r18700
2014-06-04 05:22:52 +00:00
Jordan Rose
2877bd0854 Add support for dependency file generation with -emit-dependencies.
This performs very conservative dependency generation for each compile task
within a full compilation. Any source file, swiftmodule, or Objective-C
header file that is /touched/ gets added to the dependencies list, which
is written out on a per-input basis at the end of compilation.

This does /not/ handle dependencies for the aggregated swiftmodule, swiftdoc,
generated header, or linked binary. This is just the minimum needed to get
Xcode to recognize what needs to be rebuilt when a header or Swift source
file changes. We can revisit this later.

This finishes <rdar://problem/14899639> for now.

Swift SVN r18045
2014-05-14 00:34:11 +00:00
Jordan Rose
67f319b747 [Driver] Hook up -emit-dependencies option, but don't do anything with it yet.
Part of <rdar://problem/14899639>

Swift SVN r18044
2014-05-14 00:34:07 +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
Jordan Rose
cf77de720a Add -import-objc-header option, and wire up the basic infrastructure.
THIS IS NOT READY FOR USE YET.

The new plan for mixed-source non-framework targets is that the Swift
compiler will import an Objective-C header directly, and treat the decls
and imports in that header as explicitly visible to the entire target.
This means users don't have to modularize their headers before bringing
them into Swift.

This commit adds the option and introduces the "imported headers" module
as an implicit import for the source files being compiled. It also directs
the Clang importer to process the given header (using #import, so that it
won't somehow get included twice) and watches for any module imports that
occur as a result of reading that header.

Still to come: import of decls within the header (not within any module),
and proper serialization of cross-references to the header and its imports.

Part of <rdar://problem/16702101>

Swift SVN r17218
2014-05-02 00:55:31 +00:00
Jordan Rose
8699a3b83f Add -import-underlying-module option.
This option implicitly imports the Clang module with the same name as the
module being built into every source file in the module being built.
This will be used for mixed-source framework targets to give Swift code the
same implicit visibility for Objective-C decls in the same module that it
already has for other Swift decls.

<rdar://problem/16701230>

Swift SVN r17053
2014-04-29 23:13:45 +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
Sean Callanan
3b95376949 Added a new AST transformation pass called the
"Playground Transform."  This is an
instrumentation pass that adds calls to a
function called playground_log at locations of
interest.  Roughly speaking, these locations are

- Initialization of variables
- Modification of variables
- Expressions returning values
- Application of mutating methods on objects

The playground transform currently only finds
modifications of variables, but the intent is to
make all of these cases work.

It is enabled by a frontend option, and can
also be invoked by calling

swift::performPlaygroundTransform(SF)

which is the way LLDB, its main client, will
use it.

The frontend option is intended for testing,
and indeed I will add tests for this
transformation in the coming week as I bring
more functionality online.


Swift SVN r14801
2014-03-07 22:59:19 +00:00
Jordan Rose
798e13d15c Wire up -emit-objc-header[-path] options that don't do anything yet.
These options piggyback on the "merge module" phase of the driver
because the header we output needs an entire complete module.

Swift SVN r13800
2014-02-12 01:19:13 +00:00
Michael Gottesman
f88bc1ed3e Teach the frontend how to pass through -Xllvm commands.
This patch allows you to pass through commands to llvm from the driver so now
one can when compiling swift files get debug messages!

Swift SVN r13761
2014-02-10 22:49:56 +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
Jordan Rose
302f9cb50d Disallow importing other Swift source files as modules.
Because this is useful in testing, I've left in a frontend option
-enable-source-import for both swift and swift-ide-test that sidesteps the
module restriction. Right now, though, this is the right thing to avoid
users running into strange issues when they import another file within
their module and Swift treats it as a separate module.

<rdar://problem/15937521>

Swift SVN r13248
2014-01-31 23:01:04 +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
bac31d985a Add '-sil-serialize-all' testing option to the new frontend.
Swift SVN r13190
2014-01-31 01:02:06 +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
Jordan Rose
12fb34d60f Eliminate "Immediate" flag from CompilerInvocation.
This adds some ugliness in the current swift binary because we weren't
bothering to set a requested action before, but it keeps things simpler
elsewhere. (Thanks, Connor.)

Swift SVN r13067
2014-01-28 22:20:13 +00:00
Connor Wakamo
947f3be6e7 [driver] Removed the limited support for -module-source-list.
This option was never honored, and the main functionality that this option
would have implemented has been subsumed by -output-file-map.

Swift SVN r12800
2014-01-22 22:37:21 +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
b0f27de6b8 [frontend] Move InputKind from CompilerInvocation to FrontendOptions, and move handling of -parse-as-library to ParseFrontendArgs().
Swift SVN r12174
2014-01-11 00:33:30 +00:00
Connor Wakamo
044be74855 [frontend] Move ParseStdlib from CompilerInvocation to FrontendOptions, and move handling of -parse-stdlib to ParseFrontendArgs().
Swift SVN r12173
2014-01-11 00:33:30 +00:00
Connor Wakamo
c193138c33 [frontend] Added convenience accessors to determine if a SelectedInput is a filename or a buffer.
Swift SVN r12153
2014-01-10 22:39:06 +00:00
Connor Wakamo
18795f8293 [frontend] Switch from llvm::Optional to swift::Optional for FrontendOptions::PrimaryInput.
Swift SVN r12152
2014-01-10 22:39:06 +00:00
Connor Wakamo
8475eeaad3 [frontend] Make InputKind::Filename the default InputKind for a SelectedInput.
Nearly all uses of this will be to specify a filename, so make that the default.

Swift SVN r12149
2014-01-10 22:39:04 +00:00
Connor Wakamo
e9cc548765 [frontend] Added support in FrontendOptions for denoting the primary input.
When a primary input is specified, output will only be generated for that input. (If a primary input is not specified, output will be generated for the whole module.)
This commit only adds the storage for the primary input; the primary input is not yet honored by the frontend, nor is it possible to specify the primary input.

Swift SVN r12148
2014-01-10 22:39:04 +00:00
Connor Wakamo
d360c2d167 [frontend] Moved InputBuffers from CompilerInvocation to FrontendOptions.
Swift SVN r12147
2014-01-10 22:39:04 +00:00
Connor Wakamo
9861019cc5 [frontend] Add a member function to FrontendOptions which returns whether or not the RequestedAction has output.
Swift SVN r11393
2013-12-17 21:34:24 +00:00