Commit Graph

172 Commits

Author SHA1 Message Date
Xi Ge
dd74e1c0ef [Serialization] Add a new front-end argument to specify the path of the group info file. NFC 2016-02-22 20:28:39 -08:00
Dmitri Gribenko
7235595264 Merge pull request #1108 from tinysun212/porting-to-cygwin
Porting to cygwin
2016-02-22 18:53:30 -08:00
Roman Levenstein
949471f629 Use SILOptions to decide if SIL needs to be optimized.
Checking IRGenOptions.Optimize was not the most direct and reliable way to detect if SIL needs to be optimized.
2016-02-21 22:33:23 -08:00
Han Sangjin
e06c7136cb Porting to Cygwin. rebased and squashed 2016-02-22 13:20:21 +09:00
practicalswift
1339b5403b Consistent use of header comment format.
Correct format:
//===--- Name of file - Description ----------------------------*- Lang -*-===//
2016-01-04 13:26:31 +01:00
Chris Lattner
5ce3de8dd6 remove & dial back three old bits of syntax auto-upgrading support:
1. Array type parsing for postfix array types Int[].  We now handle this
   in the parser, but remove the AST representation of this old form.  We
   also stop making vague promises about the future by saying that "fixed
   size arrays aren't supported... yet".  Removal of this fixes a compiler
   crasher too.

2. Remove the special case support for migrating @autoclosure from types
   to parameters, which was Swift 1.0/1.1 syntax.  The world has moved or
   we don't care anymore.

3. Remove upgrade support for # arguments (nee "backtick" arguments), which
   was a Swift 1.x'ism abolished in an effort to simplify method naming
   rules.

NFC on valid code.
2015-12-31 22:29:39 -08:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Nadav Rotem
07d4558c1c [Mangler] Change the Swift mangler into a symbol builder.
This commit changes the Swift mangler from a utility that writes tokens into a
stream into a name-builder that has two phases: "building a name", and "ready".
This clear separation is needed for the implementation of the compression layer.

Users of the mangler can continue to build the name using the mangleXXX methods,
but to access the results the users of the mangler need to call the finalize()
method. This method can write the result into a stream, like before, or return
an std::string.
2015-12-25 21:40:25 -08: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
Andrew Trick
84450b4c43 Reorganize SILOptimizer directories for better discoverability.
(Headers first)

It has been generally agreed that we need to do this reorg, and now
seems like the perfect time. Some major pass reorganization is in the
works.

This does not have to be the final word on the matter. The consensus
among those working on the code is that it's much better than what we
had and a better starting point for future bike shedding.

Note that the previous organization was designed to allow separate
analysis and optimization libraries. It turns out this is an
artificial distinction and not an important goal.
2015-12-11 12:34:51 -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
Daniel Dunbar
778f82939c [Frontend] Escape target names in dependencies output.
- <rdar://problem/23691798> swiftc does not properly quote spaces in output paths in dependency file target names
2015-12-01 00:31:16 -08:00
Argyrios Kyrtzidis
1d5e9e0acd [FixCode] Introduce '-fixit-all' option that, when -fixit-code is enabled, applies all fixits from diagnostics without any filtering.
Swift SVN r31772
2015-09-08 18:30:49 +00:00
Jordan Rose
6e8140b871 Handle debug-crash options in separate functions.
...so they show up in stack traces.

Swift SVN r31592
2015-09-01 00:22:29 +00:00
Jordan Rose
38261ce1f3 Pull the integrated REPL out into a separate source file.
No intended functionality change, although this may make it easier to
get the REPL up and running on Linux. This is still useful for compiler
hackers even if it's not an end-user feature.

Swift SVN r31502
2015-08-26 19:35:27 +00:00
Jordan Rose
d609aa461d Always serialize absolute search paths.
...and always serialize -working-directory for Clang. (But allow it to be
overridden by a later -Xcc -working-directory.)

Not having this has caused plenty of headaches for the debugger, which is the
primary client of this information. We can still get into bad situations with
search paths that don't exist at all (say, when a built framework is transferred
to another computer), but at least we won't fall over in multi-project workspaces.

This isn't an actual command-line option for a few reasons:

- SourceKit is still using frontend options directly, and they'll need something
  like this to fix rdar://problem/21912068.
- We might want to be more formal about passing this to Clang.
- I don't actually like the existence of such an option for users.

We can revisit this later if the scales tip. Fixing the debugging issue is the
priority.

rdar://problem/21857902

Swift SVN r30500
2015-07-22 20:20:33 +00: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
Jordan Rose
59ea2fcdbd Dependencies: Make sure we mark cascading depends-nominal entries correctly.
If any of the member accesses to a type are cascading, we have a cascading
(non-private) dependency on the type itself.

Swift SVN r30287
2015-07-16 23:36:34 +00:00
Jordan Rose
806aac2611 Dependencies: Break out provided members from other ways to provide/extend a type.
There's now a difference between "this file provides a particular type" and
"this file provides members on a particular type". Adding a conformance in
an extension is still considered "providing a type" because it can affect
things besides just lookups.

This modifies the swiftdeps file output (including the members used by a file),
but the driver hasn't been updated to take advantage of this yet.

Swift SVN r30285
2015-07-16 23:36:32 +00:00
Jordan Rose
2441ab0c1e Dependencies: Break out member lookups by the name of the member being looked up.
Right now we just have one notion of providing or using a type (as opposed to a
name). It doesn't matter if you're doing lookups, or checking conformance, or
inheriting from a superclass or protocol -- they're all in the same bucket. I'd
like to split these out so that extending a commonly-used type (like, say, Array)
doesn't cause every file in your target to depend on your extension.

This commit doesn't do anything but start tracking which member names are looked
up. For the other things you can do with a type, it's using a dummy empty name.

Swift SVN r30284
2015-07-16 23:36:31 +00:00
Jordan Rose
c79952389c Dependencies: rename entries in the .swiftdeps file to something sensible.
- (depends|provides)-top-level for top-level names.
- (depends|provides)-nominal for access into nominal types.
- (depends|provides)-dynamic-lookup for @objc members available on AnyObject.
- depends-external for cross-module file-based dependencies.

No functionality change.

Swift SVN r30283
2015-07-16 23:36:26 +00:00
Jordan Rose
cdb5ced75b Fix up r29815 to correctly handle properties in extensions.
My 'declIsPrivate' predicate was too conservative: it saw a PatternBindingDecl,
didn't know what it was, and decided that meant it might not be private. Now it's
actually checking the decl kind and doing something reasonable for non-ValueDecls.

Swift SVN r30282
2015-07-16 23:36:21 +00:00
Chris Lattner
f04d2bb828 Implement <rdar://problem/20336036> QoI: Add cast-removing fixit for "Forced cast from 'T' to 'T' always succeeds"
Swift SVN r29876
2015-07-02 00:28:44 +00:00
Jordan Rose
f8f939d628 [Dependencies] Private extensions should not be considered part of a file's interface.
Swift SVN r29815
2015-06-30 22:37:13 +00:00
Dmitri Hrybenko
3a6ed7759f Adjust to the reshuffle in the LLVMModuleProvider API
Swift SVN r29702
2015-06-25 22:01:40 +00:00
Dmitri Hrybenko
320068c1dd Adjust to the new clang::CompilerInstance API
Swift SVN r29695
2015-06-25 22:01:34 +00:00
Jordan Rose
98ed31fb99 Make -import-underlying-module automatically export that module.
That's how everything behaved anyway. Might as well make it explicit and
stop special-casing it.

I've left in compatibility for modules built with older compilers so that
people using the OS toolchains aren't immediately unable to debug their apps.
As soon as we change the module format in a more significant way, I can take
this out.

Groundwork for rdar://problem/21254367; see next commit.

Swift SVN r29437
2015-06-17 04:47:39 +00:00
Denis Vnukov
507aacf71d Enable auto-applying of a fixit for "Variable 'x' was never mutated; consider changing to 'let' constant" in migrator.
Swift SVN r28664
2015-05-16 16:57:31 +00:00
Denis Vnukov
fdecf29b03 Enable auto-applying of a fixit for "'#' has been removed from Swift; %0 already has an argument label" in migrator.
Swift SVN r28639
2015-05-15 20:45:48 +00:00
Denis Vnukov
e4bb04d6d6 Disabled auto-applying of a fixit for "" in migrator.
This also fixes rdar://20940643: Migrator thinks that Float[]? should be [Float];?



Swift SVN r28565
2015-05-14 15:22:09 +00:00
Jordan Rose
82beaf302d Dependencies: De-duplicate the list of extended nominals.
Very slight improvement for those who like to break their types up into
many extensions.

Swift SVN r28476
2015-05-12 18:18:15 +00:00
Jordan Rose
3ffe42a729 Dependencies: Don't crash if an extension couldn't be resolved.
Swift SVN r28474
2015-05-12 18:18:11 +00:00
Argyrios Kyrtzidis
fcf040402a [fixit] Avoid picking up the fixit which adds a bang.
Adding a bang can be unsafe and may lead to silently adding crashes in user's code.
Err on the side of caution and let the compiler error stand so the user can review the code.

Swift SVN r28467
2015-05-12 14:11:00 +00:00
Argyrios Kyrtzidis
a01e7c27cf [fixit] Apply the 'forced_downcast_coercion' warning automatically.
This can show up when upgrading due to ObjC generics changes.

Swift SVN r28454
2015-05-12 05:14:38 +00:00
Denis Vnukov
52f4f4e573 Apply a fixit for a warning 'parameter_pound_double_up' in migrator
Swift SVN r28322
2015-05-08 18:04:08 +00:00
Doug Gregor
b8995b0aa3 Transform the Module class into ModuleDecl.
Modules occupy a weird space in the AST now: they can be treated like
types (Swift.Int), which is captured by ModuleType. They can be
treated like values for disambiguation (Swift.print), which is
captured by ModuleExpr. And we jump through hoops in various places to
store "either a module or a decl".

Start cleaning this up by transforming Module into ModuleDecl, a
TypeDecl that's implicitly created to describe a module. Subsequent
changes will start folding away the special cases (ModuleExpr ->
DeclRefExpr, name lookup results stop having a separate Module case,
etc.).

Note that the Module -> ModuleDecl typedef is there to limit the
changes needed. Much of this patch is actually dealing with the fact
that Module used to have Ctx and Name public members that now need to
be accessed via getASTContext() and getName(), respectively.

Swift SVN r28284
2015-05-07 21:10:50 +00:00
John McCall
753b101f6a Propagate return values from main() in -interpret mode.
rdar://20809122

Swift SVN r28139
2015-05-04 23:58:34 +00:00
Jordan Rose
95856c05fb If the generated header doesn't change, don't touch the original file.
Mixed-source targets generally include the generated <Product>-Swift.h
header in many Objective-C (.m) source files. Any change to a Swift file
results in the header being touched, which means all the .m files get
recompiled.

This change makes Swift write the generated header to a temporary file
first, then use the previous commit's moveFileIfDifferent to put it in
its final destination.

rdar://problem/20553459

Swift SVN r28042
2015-05-01 17:40:31 +00:00
Chris Lattner
c6aa041fb9 Add parser/ast/sema/sourcekit/etc support for 'unless' statement.
SILGen support still missing.



Swift SVN r27961
2015-04-30 05:55:11 +00:00
Erik Eckstein
03d393ef5c Re-apply r27206: Convert all external function definitions to declarations when compiling with -Onone.
... with disabled test 1_stdlib/Bit.swift for ios.

Most likely the problem of 1_stdlib/Bit.swift (only on armv7) is just uncovered by this change.
Unfortunately I have no possibility to debug the problem on a device. Therefore I filed rdar://problem/20521110




Swift SVN r27274
2015-04-14 07:38:28 +00:00
Argyrios Kyrtzidis
d646c3178c [fixit-code] Apply the fixit for the refutable pattern warning.
Swift SVN r27253
2015-04-13 15:28:29 +00:00
Greg Parker
a42837bee2 Revert r27206.
This broke test 1_stdlib/Bit.swift on armv7.


Swift SVN r27236
2015-04-11 07:28:41 +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
Erik Eckstein
c3b253d305 Convert all external function definitions to declarations when compiling with -Onone.
This avoids that an unoptimized imported function is linked instead the optimized version from the stdlib.
rdar://problem/20485253

It gives considerable performance improvmenets for some benchmarks with -Onone. E.g.
PopFrontUnsafePointer: +281%
ArrayOfPOD: +92%
StrComplexWalk: +91%
ArrayOfGenericPOD: +61%
Several others are within the range of +10% to +30%.

For the implementation I added runSILPassesForOnone() in Passes.cpp.
Here we can add other optimizations for -Onone in the future.



Swift SVN r27206
2015-04-10 09:53:17 +00:00
Luqman Aden
3f83973928 Handle multiple sib inputs.
Swift SVN r26572
2015-03-26 01:21:21 +00:00
Jordan Rose
f74bc7122c Split getAccessibility() into getFormalAccess() and getEffectiveAccess().
Currently a no-op, but effective access for entities within the current
module will soon need to take testability into account. This declaration:

  internal func foo() {}

has a formal access of 'internal', but an effective access of 'public' if
we're in a testable mode.

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

Swift SVN r26472
2015-03-24 02:16:58 +00:00
Jordan Rose
2795a472f8 App extension modules aren't distributed publicly.
Therefore, serialize options for debugging, and expose their internal classes
in the generated header.

rdar://problem/20214578

Swift SVN r26345
2015-03-20 01:36:31 +00:00
Jordan Rose
c9eeed3e2d Remove staging option -enable-private-discriminators.
Private discriminators for everybody!

Swift SVN r25997
2015-03-11 23:07:44 +00:00