Commit Graph

1187 Commits

Author SHA1 Message Date
ken0nek
fcd8fcee91 Convert [Cc]an not -> [Cc]annot 2015-12-23 00:55:48 +09:00
Jordan Rose
144e993bd9 [Serialization] Add assertions to track down a SIL deserialization issue.
The issue: we're apparently not keeping the archetypes in an instruction in sync
with the archetypes used in the SIL function's generic signature. This apparently
isn't the problem, but it's a good assertion to have, if a little ad hoc.

(The actual issue is rdar://problem/23892955.)
2015-12-21 17:42:13 -08:00
Dmitri Gribenko
6a66b3cff8 Merge pull request #561 from practicalswift/typos-again
[Typo] Replace PR#514-525 with one large PR
2015-12-18 03:37:02 -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
Argyrios Kyrtzidis
042efbfb26 [AST] Introduce internal attribute '_migration_id'.
It's intended use is to keep track of stdlib changes for migration purposes.
2015-12-16 21:28:38 -08:00
practicalswift
8ab8847684 Fix typos. 2015-12-16 22:09:32 +01:00
Slava Pestov
dfbb580de3 AST: Store the GenericSignature in the AbstractFunctionDecl, NFC
For better or worse, the type of a function can end up as ErrorType,
and the generic signature was not stored anywhere else, causing
crashes from orphaned generic type parameters.

This patch is the first in a series to make this more robust by
storing the generic signature before the interface type is computed.
2015-12-14 13:29:52 -08:00
practicalswift
c6e8459187 Fix typos. 2015-12-14 11:13:30 +01:00
Dmitri Gribenko
78a568b4bd Merge pull request #499 from practicalswift/fix-typos-3
Fix typos (3 of 30)
2015-12-13 16:20:07 -08:00
practicalswift
8a9d99ea93 Fix typo: assocativity → associativity 2015-12-14 00:11:15 +01:00
practicalswift
ef849258c6 Fix typo: ambigous → ambiguous 2015-12-13 23:56:40 +01:00
Erik Eckstein
94d2c2fcd0 Remove a wrong TODO comment. 2015-12-11 10:00:49 -08:00
swiftix
54dcae48fc Revert "Fix TODO by removing unneeded ShouldSerializeAll parameters." 2015-12-11 08:29:31 -08:00
swiftix
dac9e9526c Revert "Adding missing changes on the Pull Request #402" 2015-12-11 08:28:15 -08:00
Gabriel Peart
5d9e1e9715 Adding missing changes on the Pull Request #402
Pushing missing classes from the previous Pull Request
2015-12-11 13:55:45 +01:00
Gabriel Peart
971f399374 Fix TODO by removing unneeded ShouldSerializeAll parameters. 2015-12-11 09:07:16 +01:00
John McCall
5fddd4a704 Remove the autorelease_return and strong_retain_autoreleased instructions.
There's a buggy SIL verifier check that was previously tautological,
and it turns out that it's violated, apparently harmlessly.  Since it
was already doing nothing, I've commented it out temporarily while
I figure out the right way to fix SILGen to get the invariant right.
2015-12-09 14:50:20 -08:00
John McCall
bdb4b896a2 Move ObjC-compatible unowned references to the new runtime
functions.

Take the code for the old, broken reference-counting
implementation and delete it with prejudice.
2015-12-08 16:20:32 -08:00
Joe Groff
b1667ec705 SIL: Introduce a new @inout_aliasable parameter convention.
Modeling nonescaping captures as @inout parameters is wrong, because captures are allowed to share state, unlike 'inout' parameters, which are allowed to assume to some degree that there are no aliases during the parameter's scope. To model this, introduce a new @inout_aliasable parameter convention to indicate an indirect parameter that can be written to, not only by the current function, but by well-typed, well-synchronized aliasing accesses too. (This is unrelated to our discussions of adding a "type-unsafe-aliasable" annotation to pointer_to_address to allow for safe pointer punning.)
2015-12-08 14:35:47 -08:00
Nadav Rotem
4bc6248319 Fix an unused variable warning in deserialization. 2015-12-07 09:32:24 -08:00
Michael Gottesman
1e5aa72f2d Add in clang-format changes that I forgot to commit with the previous commit (sorry).
I clang-formatted the previous commit, but forgot to amend the changes.
2015-12-06 16:29:52 -08:00
Michael Gottesman
302632cefb Make SILFunction::create() private and change all direct uses of SILFunction::create() to instead use SILMod.getOrCreateFunction().
This centralizes the entrypoints for creating SILFunctions. Creating a
SILFunction is intimately tied to a specific SILModule, so it makes sense to
either centralize the creation on SILModule or SILFunction. Since a SILFunction
is in a SILModule, it seems more natural to put it on SILModule.

I purposely created a new override on SILMod that exactly matches the signature
of SILFunction::create so that beyond the extra indirection through SILMod, this
change should be NFC. We can refactor individual cases in later iterations of
refactoring.
2015-12-06 16:23:44 -08:00
Leo Shimonaka
70e66973ee Fix spelling error in documentation / comments / method name 2015-12-05 00:28:08 -05:00
Roger Z
fbbc25aba2 whitespace and capitalization for TODO's 2015-12-03 15:56:26 -05:00
Simone Ferrini
ce4031f240 Removed unnecessary semicolons 2015-12-03 21:24:40 +01:00
Nadav Rotem
5f3f1a31c7 Revert "[Serialization] Fix a bug in the serialization of shared functions."
This reverts commit 422d46638e.

Jordan said that this change is incorrect. I am reverting the patch and plan to
investigate why we are deserializing shared_external functions with no body.
2015-11-29 08:25:44 -08:00
Nadav Rotem
422d46638e [Serialization] Fix a bug in the serialization of shared functions.
We do not allow external declarations with shared visibility. This commit makes
the serializer translate shared_external linkage to public_external because the
serialized functions will be available at runtime.

rdar://21989088
2015-11-28 03:04:56 -08:00
Nadav Rotem
5542bc3792 [Serialization] Fix a bug in the serialization of resilient functions
The SIL serializer can decide not to serialize the body of functions in the SIL
module, and only emit a declaration.  If we keep the original linkage kind
(public, private, etc) then the deserialized module won't pass verification
because we do not allow internal functions to have external declarations. This
commit changes the linkage kind for the functions that the serializer decides to
emit as a declaration (without a body).

rdar://21989088
2015-11-28 03:04:56 -08:00
Adrian Prantl
8ab1e2dd50 Unify debug scope and location handling in SILInstruction and SILBuilder.
The drivers for this change are providing a simpler API to SIL pass
authors, having a more efficient of the in-memory representation,
and ruling out an entire class of common bugs that usually result
in hard-to-debug backend crashes.

Summary
-------

SILInstruction

Old                   New
+---------------+     +------------------+    +-----------------+
|SILInstruction |     |SILInstruction    |    |SILDebugLocation |
+---------------+     +------------------+    +-----------------+
| ...           |     | ...              |    | ...             |
|SILLocation    |     |SILDebugLocation *| -> |SILLocation      |
|SILDebugScope *|     +------------------+    |SILDebugScope *  |
+---------------+                             +-----------------+

We’re introducing a new class SILDebugLocation which represents the
combination of a SILLocation and a SILDebugScope.
Instead of storing an inline SILLocation and a SILDebugScope pointer,
SILInstruction now only has one SILDebugLocation pointer. The APIs of
SILBuilder and SILDebugLocation guarantees that every SILInstruction
has a nonempty SILDebugScope.

Developer-visible changes include:

SILBuilder
----------

In the old design SILBuilder populated the InsertedInstrs list to
allow setting the debug scopes of all built instructions in bulk
at the very end (as the responsibility of the user). In the new design,
SILBuilder now carries a "current debug scope" state and immediately
sets the debug scope when an instruction is inserted.
This fixes a use-after-free issue with with SIL passes that delete
instructions before destroying the SILBuilder that created them.

Because of this, SILBuilderWithScopes no longer needs to be a template,
which simplifies its call sites.

SILInstruction
--------------

It is neither possible or necessary to manually call setDebugScope()
on a SILInstruction any more. The function still exists as a private
method, but is only used when splicing instructions from one function
to another.

Efficiency
----------

In addition to dropping 20 bytes from each SILInstruction,
SILDebugLocations are now allocated in the SILModule's bump pointer
allocator and are uniqued by SILBuilder. Unfortunately repeat compiles
of the standard library already vary by about 5% so I couldn’t yet
produce reliable numbers for how much this saves overall.

rdar://problem/22017421
2015-11-19 09:31:26 -08:00
Joe Groff
fbd2e4d872 Rename @asmname to @_silgen_name.
This reflects the fact that the attribute's only for compiler-internal use, and isn't really equivalent to C's asm attribute, since it doesn't change the calling convention to be C-compatible.
2015-11-17 14:13:48 -08:00
Xi Ge
9586337981 [Parser] Allow FuncDecl to record the locations of accessor keywords, e.g. set, get, etc. 2015-11-03 18:13:32 -08:00
Erik Eckstein
ee988e21cb SIL: Add stack attributes to alloc_ref and dealloc_ref.
For details see docs/SIL.rst.
This is needed for the stack promotion optimization.



Swift SVN r32908
2015-10-27 15:29:20 +00:00
Slava Pestov
76f1168adf Remove dealloc_ref's [constructor] form since its no longer needed
Swift SVN r32688
2015-10-14 22:50:09 +00:00
Slava Pestov
7cc59e01d7 SIL: Add DeallocPartialRefInst
This instruction destroys instance variables in a partially-initialized
object, then frees it.

Swift SVN r32661
2015-10-13 19:56:20 +00:00
Slava Pestov
090d723763 SIL: Remove null_class instruction
Swift SVN r32605
2015-10-11 02:11:22 +00:00
Andrew Trick
c20370a664 Remove the last remnants of unchecked_ref_bit_cast
Swift SVN r32598
2015-10-10 05:42:57 +00:00
Andrew Trick
665e5169d5 Add unchecked_ref_cast_addr SIL instruction.
Swift SVN r32587
2015-10-10 03:39:32 +00:00
Doug Gregor
2feed84c91 Sketch out the interface to an iterative, lazy type checker.
This is all effectively NFC, but lays out the shape of the iterative
type checker: requests are packaged up in TypeCheckRequest, we can
check whether the request has been satisfied already (isSatisfied),
enumerate its dependencies (enumerateDependenciesOf) in terms of other
TypeCheckRequests, and satisfy a request (satisfy).

Lazily-computed semantic information is captured directly in the
AST, but has been set aside in its own structure to allow us to
experiment with moving it into a lookaside table.

The only request that exists now is to type-check the superclass of
the given class. It currently performs unhealthy recursion into the
existing type checker. As we detangle dependencies, this recursion
between the IterativeTypeChecker and the TypeChecker can go away.

Swift SVN r32558
2015-10-09 17:18:36 +00:00
Doug Gregor
0b2b0df907 Clean up canonicalization of GenericSignatures. NFC
GenericSignature's factory method determining whether the signature
was canonical based solely on whether the types in the parameters and
requirments were canonical. While that is currently true (for legacy
reasons), it is wrong: canonicalization also needs to canonicalize
requirements, including same-type requirements, as is currently done
in the canonical signature "for mangling". Move the "this is
canonical" dependency to the point where the canonical signature is
actually computed, so we can change the definition of canonical
signatures later.

While we're here, don't eagerly compute the canonical generic
signature in GenericSignature::getASTContext().

Swift SVN r32309
2015-09-29 22:05:47 +00:00
Jordan Rose
ea9117c18d [ClangImporter] Prefer -Xcc options, then -F search paths, then -I paths.
This makes Swift (a) more likely to prefer frameworks over bare headers,
reducing potential issues with non-modular headers, and (b) more likely
to fail in the same way as LLDB if the -Xcc options also contain or affect
search paths.

rdar://problem/22413525

Swift SVN r31950
2015-09-15 00:14:08 +00:00
Michael Gottesman
0606d5843a Remove calls to raw_svector_ostream::flush()
This function is deleted since LLVM r244928.

Swift SVN r31798
2015-09-09 04:37:13 +00:00
Jordan Rose
7ec4c4fef3 Don't suggest using 'xcrun' when not on OS X.
Also, suggest "xcrun swiftc" instead of "xcrun swift" on OS X, since
"swift" already infers SDKs and we shouldn't get into this situation.
(We shouldn't get into it on non-OS-X either thanks to the previous
commit, but just in case.)

rdar://problem/22440615

Swift SVN r31535
2015-08-27 18:47:26 +00:00
Jordan Rose
babdb9e9f9 Delay loading the witnesses of a protocol conformance.
Apart from being general compile-time goodness, this helps break a
circularity issue involving serialization cross-references and the
Clang importer.

The test is being added to validation-tests because it relies on
several levels of non-laziness in the compiler, all of which we'd
like to fix. It's making sure we don't regress here, but it isn't
actually verifying this change in particular.

rdar://problem/22364953

Swift SVN r31455
2015-08-25 21:47:18 +00:00
Doug Gregor
00040112cd Eliminate special handling of deserialized inherited protocols.
Now that we have the inheritance lists hanging around, use them: it
makes the conformance lookup table use the same code whether we're
deserializing the conformances or parsing them.

Swift SVN r31383
2015-08-21 17:51:26 +00:00
Doug Gregor
cab320296d Stop recording protocol lists in nominal types.
The conformance lookup table is responsible for answering queries
about the protocols to which a particular nominal type conforms, so
stop storing (redundant and incorrect) protocol lists on the ASTs for
nominal types. Protocol types still store the list of protocols that
they inherit, however.

As a drive-by, stop lying about the number of bits that ProtocolDecl
uses on top of NominalTypeDecl, and move the overflow bits down into
ProtocolDecl itself so we don't bloat Decl unnecessarily.

Swift SVN r31381
2015-08-21 17:51:23 +00:00
Jordan Rose
3e0cf08daa [Serialization] Support factory initializers.
These never appear in Swift code, but they can appear when serializing the
full output of SILGen ("SIB" format) because that includes code synthesized
for imported Clang declarations.

rdar://problem/22098491

Swift SVN r31364
2015-08-20 19:28:22 +00:00
Jordan Rose
340716da16 Fix deserialization of SIL alloc_ref_dynamic.
Swift SVN r31363
2015-08-20 19:28:20 +00:00
Doug Gregor
ee7803a87a Eliminate the list of protocols from ExtensionDecl. NFC
Swift SVN r31349
2015-08-19 21:33:52 +00:00
Doug Gregor
83cb1e69bb Serialize the list of inherited types for all nominal types.
This provides better AST fidelity through module files and further
reduces our dependencies on storing a list of protocols on nominal
type declarations.

Swift SVN r31345
2015-08-19 21:10:45 +00:00
Doug Gregor
dd68b9fc59 Start serializing the "inherited" list of extension declarations.
This improves the fidelity of the AST printed from a loaded module, as
well as consistency in the AST. Also teach the Clang importer to add
"inherited" clauses, providing better fidelity for the mapping from
Objective-C to Swift.

With trivial update to SDKAnalyzer test.

Swift SVN r31344
2015-08-19 21:10:42 +00:00