Commit Graph

92 Commits

Author SHA1 Message Date
David Farler
9701d94f15 [Migrator] Add adapter for clang lib/Edit textual edits
This adds an adapter class that wraps Clang's lib/Edit
Commit and EditedSource classes for use in the initial
"syntactic" passes. Once the passes have completed,
the resulting source file is then passed to the Swift compiler
fix-it passes.

rdar://problem/30926261
2017-04-20 10:54:22 -07:00
David Farler
303a3e5824 Start the Migrator library
The Swift 4 Migrator is invoked through either the driver and frontend
with the -update-code flag.

The basic pipeline in the frontend is:

- Perform some list of syntactic fixes (there are currently none).
- Perform N rounds of sema fix-its on the primary input file, currently
  set to 7 based on prior migrator seasons.  Right now, this is just set
  to take any fix-it suggested by the compiler.
- Emit a replacement map file, a JSON file describing replacements to a
  file that Xcode knows how to understand.

Currently, the Migrator maintains a history of migration states along
the way for debugging purposes.

- Add -emit-remap frontend option
  This will indicate the EmitRemap frontend action.
- Don't fork to a separte swift-update binary.
  This is going to be a mode of the compiler, invoked by the same flags.
- Add -disable-migrator-fixits option
  Useful for debugging, this skips the phase in the Migrator that
  automatically applies fix-its suggested by the compiler.
- Add -emit-migrated-file-path option
  This is used for testing/debugging scenarios. This takes the final
  migration state's output text and writes it to the file specified
  by this option.
- Add -dump-migration-states-dir

  This dumps all of the migration states encountered during a migration
  run for a file to the given directory. For example, the compiler
  fix-it migration pass dumps the input file, the output file, and the
  remap file between the two.

  State output has the following naming convention:
  ${Index}-${MigrationPassName}-${What}.${extension}, such as:
  1-FixitMigrationState-Input.swift

rdar://problem/30926261
2017-04-17 16:25:02 -07:00
Maxwell Swadling
93d485e4f7 Changed handleDiagnostic to take a format string and format args instead of the formatted string
This allows diagnostic consumers to modify the way formatting of diagnostics is performed.
rdar://problem/31305854
2017-04-14 11:28:04 -07:00
Jordan Rose
c1e4be1ad2 Catch llvm::report_fatal_error and try to emit a proper diagnostic. (#8639)
This only affects the textual output, but should still improve the
experience when we /do/ hit one of these LLVM errors. In addition to
showing up better in Xcode, it'll also give us a proper
PrettyStackTrace because of the call to abort() instead of exit(1).

(There's a bit of finger-crossing that the act of printing the
diagnostic doesn't cause more errors. I only tested the fallback
path a little.)
2017-04-10 10:40:03 -07:00
Huon Wilson
9e9a0a0436 Merge pull request #8596 from huonw/symbol-list-3
Use IRGen's LinkInfo in TBDGen.
2017-04-07 16:23:51 -07:00
Huon Wilson
fcb88b4084 [TBD] Thread enough through to use UniversalLinkageInfo. 2017-04-06 17:50:57 -07:00
David Farler
65668c9d82 Cache Code Completion results from PCH files
- Add CompilerInvocation::getPCHHash
  This will be used when creating a unique filename for a persistent
  precompiled bridging header.

- Automatically generate and use a precompiled briding header
  When we're given both -import-objc-header and -pch-output-dir
  arguments, we will try to:
  - Validate what we think the PCH filename should be for the bridging
    header, based on the Swift PCH hash and the clang module hash.
    - If we're successful, we'll just use it.
    - If it's out of date or something else is wrong, we'll try to
      emit it.
  - This gives us a single filename which we can `stat` to check for the
    validity of our code completion cache, which is keyed off of module
    name, module filename, and module file age.

- Cache code completion results from imported modules
  If we just have a single .PCH file imported, we can use that file as
  part of the key used to cache declarations in a module.  Because
  multiple files can contribute to the __ObjC module, we've always given
  it the phony filename "<imports>", which never exists, so `stat`-ing it
  always fails and we never cache declarations in it.

  This is extremely problematic for projects with huge bridging headers.
  In the case where we have a single PCH import, this can bring warm code
  completion times down to about 500ms from over 2-3s, so it can provide a
  nice performance win for IDEs.

- Add a new test that performs two code-completion requests with a bridging header.
- Add some -pch-output-dir flags to existing SourceKit tests that import a bridging
  header.

rdar://problem/31198982
2017-04-04 20:44:33 -07:00
Slava Pestov
00d5b45733 Frontend: Add a new -sil-merge-partial-modules flag
Previously we would drop all serialized SIL from partial swiftmodule
files generated while compiling source in non-WMO mode; all that was
missing was linking it in.

This adds a frontend flag, and a test; driver change is coming up
next.

Progress on <rdar://problem/18913977>.
2017-04-03 21:28:40 -07:00
Graydon Hoare
0245c83c4b [Stats] Add -stats-output-dir, wire UnifiedStatsReporter into place. 2017-04-03 18:08:59 -07:00
Graydon Hoare
7c4eea6542 [Timers] Avoid YAML-special characters in timer names. 2017-03-31 22:58:04 -07:00
swift-ci
2c44265ee0 Merge pull request #8359 from graydon/rdar-31044067-missing-dependencies-mark-2 2017-03-29 16:12:23 -07:00
Graydon Hoare
ab2f429348 [Dependencies] Address review comments. 2017-03-29 12:01:23 -07:00
Graydon Hoare
57b3947891 [Dependencies] Sort external file dependencies by more-stable order. 2017-03-28 18:33:04 -07:00
Graydon Hoare
d018521464 [ClangImporter] Collect deps via subclass of clang::DependencyCollector. 2017-03-28 18:33:04 -07:00
Huon Wilson
4eff6f1374 [FrontendTool] -emit-tbd and -validate-tbd-against-ir flags.
These, respectively, write a list of symbols to a file, and compare what
that list would be against the "true" list (the symbol names in the IR).
2017-03-28 16:31:09 -07:00
swift-ci
099effd29b Merge pull request #8119 from huonw/imported-modules 2017-03-20 17:52:41 -07:00
Erik Eckstein
d70bfc5de2 rename namespace NewMangling -> Mangle 2017-03-20 10:09:30 -07:00
Huon Wilson
09cd885140 [Frontend] Handle imports in the C code tied to a Swift module.
The underlying module and/or bridging header are likely to contain
module imports that we need to know about.
2017-03-17 18:46:09 -07:00
Huon Wilson
55b2ba2524 [Frontend] Add -emit-imported-modules: listing modules imported by the current one.
This is purely designed to cheaply compute dependency graphs between
modules, and thus only lists the top-level names (i.e. not submodules)
and doesn't do any form of semantic analysis.
2017-03-17 18:44:03 -07:00
practicalswift
8bd6d36d86 Remove redundant call to get() on smart pointer 2017-02-14 16:11:10 +01:00
Andrew Trick
855918c620 [Lowering] Add an AddressLowering pass. 2017-02-13 17:10:02 -08:00
Hugh Bellamy
f001b7562b Use relatively new LLVM_FALLLTHROUGH instead of our own SWIFT_FALLTHROUGH 2017-02-12 10:47:03 +07:00
Rintaro Ishizaki
384ab780e9 [Diagnostic verifier] Make '<unknown>' check optional
Added frontend option '-verify-ignore-unknown'
2017-02-02 10:49:32 +09:00
Jordan Rose
8145cd0b22 [Serialization] Add a "nested types" lookup table for partial modules.
There's a class of errors in Serialization called "circularity
issues", where declaration A in file A.swift depends on declaration B
in file B.swift, and B also depends on A. In some cases we can manage
to type-check each of these files individually due to the laziness of
'validateDecl', but then fail to merge the "partial modules" generated
from A.swift and B.swift to form a single swiftmodule for the library
(because deserialization is a little less lazy for some things). A
common case of this is when at least one of the declarations is
nested, in which case a lookup to find that declaration needs to load
all the members of the parent type. This gets even worse when the
nested type is defined in an extension.

This commit sidesteps that issue specifically for nested types by
creating a top-level, per-file table of nested types in the "partial
modules". When a type is in the same module, we can then look it up
/without/ importing all other members of the parent type.

The long-term solution is to allow accessing any members of a type
without having to load them all, something we should support not just
for module-merging while building a single target but when reading
from imported modules as well. This should improve both compile time
and memory usage, though I'm not sure to what extent. (Unfortunately,
too many things still depend on the whole members list being loaded.)

Because this is a new code path, I put in a switch to turn it off:
frontend flag -disable-serialization-nested-type-lookup-table

https://bugs.swift.org/browse/SR-3707 (and possibly others)
2017-01-26 15:04:42 -08:00
Graydon Hoare
a95f5da86d [Bridging PCH] Add -emit-pch to Frontend; call emitBridgingPCH. 2017-01-13 15:18:39 -08:00
Brian Gesiak
663b92ece9 [AST] Completely replace Module with ModuleDecl
The typedef `swift::Module` was a temporary solution that allowed
`swift::Module` to be renamed to `swift::ModuleDecl` without requiring
every single callsite to be modified.

Modify all the callsites, and get rid of the typedef.
2017-01-08 00:36:08 -05:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
practicalswift
b253b21014 [gardening] Make sure argument names in comments match the actual parameter names 2016-12-21 22:56:01 +01:00
practicalswift
38be6125e5 [gardening] C++ gardening: Terminate namespaces, fix argument names, ...
Changes:
* Terminate all namespaces with the correct closing comment.
* Make sure argument names in comments match the corresponding parameter name.
* Remove redundant get() calls on smart pointers.
* Prefer using "override" or "final" instead of "virtual". Remove "virtual" where appropriate.
2016-12-17 00:32:42 +01:00
Maxwell Swadling
4497083a0a Updated comment to clarify condition for free 2016-12-15 12:59:46 -08:00
Maxwell Swadling
5f0572ef53 Updated documentation for new less memory frontend 2016-12-15 11:11:06 -08:00
Maxwell Swadling
6af14c05d8 After performIRGeneration but before performLLVM delete the CompilerInstance if possible 2016-12-14 18:49:23 -08:00
Jordan Rose
41974682e6 [FrontendTool] Split out swiftdeps generation into its own file.
No intended functionality change.
2016-12-08 16:15:35 -08:00
Erik Eckstein
5ac0c5b9b7 Mangling: wire up the new mangling in various places in the compiler, but still use the old mangling.
The purpose of this change is to test if the new mangling is equivalent to the old mangling.
Both mangling strings are created, de-mangled and checked if the de-mangle trees are equivalent.
2016-12-05 14:07:05 -08:00
Erik Eckstein
684092d7d1 Mangling: mangler, demangler and remangler classes for the new mangling scheme.
Following classes provide symbol mangling for specific purposes:
*) Mangler: the base mangler class, just providing some basic utilities
*) ASTMangler: for mangling AST declarations
*) SpecializationMangler: to be used in the optimizer for mangling specialized function names
*) IRGenMangler: mangling all kind of symbols in IRGen

All those classes are not used yet, so it’s basically a NFC.

Another change is that some demangler node types are added (either because they were missing or the new demangler needs them).
Those new nodes also need to be handled in the old demangler, but this should also be a NFC as those nodes are not created by the old demangler.

My plan is to keep the old and new mangling implementation in parallel for some time. After that we can remove the old mangler.
Currently the new implementation is scoped in the NewMangling namespace. This namespace should be renamed after the old mangler is removed.
2016-12-02 15:55:30 -08:00
swift-ci
c13af38084 Merge pull request #6008 from nkcsgexi/edits-serialization 2016-12-01 13:29:57 -08:00
Xi Ge
7a58f00b6d [utils] Modify writeEdit() to take multiple edits instead of a single one to help preserve the correct json format. NFC 2016-12-01 12:47:09 -08:00
Roman Levenstein
409d146f17 Reduce memory usage by freeing memory occupied by SILModules after IRGen.
There is no need to keep SILModules around after IRGen has generated LLVM IR from them.
This reduces the compiler memory usage during LLVM code-generation and optimization phases roughly by 15%-20%.
2016-11-29 22:11:59 -08:00
David Farler
30dd1a9047 Merge pull request #5875 from bitjammer/parse-typecheck-flag
Parse typecheck flag
2016-11-28 15:06:50 -08:00
Xi Ge
f1113b2677 [Utils] Expose edit serialization utility for more clients. 2016-11-28 12:55:27 -08:00
David Farler
6d8514b2a3 Add back the -parse flag, which doesn't typecheck 2016-11-28 10:50:55 -08:00
David Farler
b7d17b25ba Rename -parse flag to -typecheck
A parse-only option is needed for parse performance tracking and the
current option also includes semantic analysis.
2016-11-28 10:50:55 -08:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
Brian Gesiak
fc1c81f500 [Frontend] Preserve .swiftdeps files
The Swift compiler uses files with an extension of ".swiftdeps" to store
information about cross-file dependencies. These files are read in at the
start of compilation to compute a dependency graph, and updated as compilation
proceeds. However, because these files are updated on every build, an
issue with dependency analysis is hard to reproduce—the inputs have been
lost.

Address this by renaming swiftdeps files that are about to be
overwritten, to '.swiftdeps~'. This preserves dependency information
from the most recent compilation (but no further back).
2016-11-16 22:51:05 -05:00
Michael Gottesman
e173438d6b [semantic-arc] Even when we are not running diagnostics, run the sil ownership eliminator.
This only happens when we are testing deserialization.
2016-10-29 20:11:08 -07:00
Brian Gesiak
87df087a2d [Frontend] Remove TODO for diagnostics (NFC)
Addresses SR-2683.
2016-09-23 09:01:21 -04:00
Jordan Rose
fea7878806 Auto-apply the new generic parameter fix-it during migration.
Last bit of rdar://problem/27087345.
2016-09-21 18:04:14 -06:00
practicalswift
b19481f887 [gardening] Fix 67 recently introduced typos 2016-09-16 11:16:07 +02:00
Jordan Rose
5746671a19 Add -verify-apply-fixes to accompany -verify.
Enables Chris's auto-apply-fixes mode for -verify: if an expected-*
annotation has the wrong message, or if the expected fix-its are
incorrect, this option will **edit the original file** to update them.

This is a tool for compiler developers only; it doesn't affect
normal diagnostic printing or normal fix-its.
2016-09-15 10:38:43 -07:00
adrian-prantl
d0f16bf9f9 Merge pull request #4697 from adrian-prantl/28231982
Bump the DWARF format to version 4 on Darwin.
2016-09-13 10:13:51 -07:00