Commit Graph

1187 Commits

Author SHA1 Message Date
Xi Ge
9a91075509 Serialization: Add an error when group information for a specific source file is not found. 2016-03-09 17:09:34 -08:00
Xi Ge
09cd9c1f9d ModulePrinting: Fix several issues pointed by Ben. 2016-03-08 18:34:38 -08:00
Ben Langmuir
92a91810e4 Make getGroupDecl static 2016-03-08 18:04:55 -08:00
Xi Ge
c84f667676 [Serialization] Serialize the source order of Decls appearing in their original source file.
We used to think the source order is preserved after de-serialization; however, this seems to be
not the case.
2016-03-08 12:18:10 -08:00
Xi Ge
7a3276738b Re-apply "ModulePrinter: Print decls from the same source file near each other."
This reverts commit 1db83907e3.
2016-03-08 12:18:10 -08:00
Xi Ge
1db83907e3 Revert "ModulePrinter: Print decls from the same source file near each other."
This reverts commit a5c9072344 for mysterious bot test failure.
2016-03-07 23:33:23 -08:00
Xi Ge
a5c9072344 ModulePrinter: Print decls from the same source file near each other. 2016-03-07 22:51:50 -08:00
Chris Lattner
fe9fe47b7e Implement support for generic typealiases. 2016-03-07 22:20:16 -08:00
Chris Lattner
868a795566 Introduce a new class between TypeDecl and NominalTypeDecl named GenericTypeDecl.
This factors the DeclContext and generic signature behavior out of NTD, allowing
it to be reused in the future.  NFC.
2016-03-04 23:09:15 -08:00
Joe Groff
be71ab28e2 SIL: Add an MarkUninitializedBehavior instruction for behavior DI.
This instruction creates a "virtual" address to represent a property with a behavior that supports definite initialization. The instruction holds references to functions that perform the initialization and 'set' logic for the property. It will be DI's job to rewrite assignments into this virtual address into calls to the initializer or setter based on the initialization state of the property at the time of assignment.
2016-03-03 15:04:38 -08:00
Xi Ge
65a3aade7e [SourceKit] Cursor info: for extension decls, the cursor info query always returns the extended nominal's group name. 2016-03-02 17:30:11 -08:00
Roman Levenstein
ada88e104d Fix build failures when building a debug and/or non-optimized version of the standard library.
No pre-specializations will be emitted in this case.
2016-02-29 13:31:56 -08:00
swiftix
6ccf5da2df Merge pull request #1469 from swiftix/wip-has-sil-funciton
Implement a more light-weight approach to perform lookups of existing pre-specializations
2016-02-27 08:11:09 -08:00
Roman Levenstein
fe1bf25323 Serialize only declarations of pre-specializations.
Only declarations of whitelisted pre-specializations from with public linkage need
to be serialized as they will be used by UsePrespecializations pass during -Onone
compilations to check for availability of concrete pre-specializations.

The bodies of these functions are not required as they cannot be used anyways,
because they may refer to symbols with non-public linkage.
2016-02-26 22:10:59 -08:00
Roman Levenstein
94c3ae4c3c Add APIs to check if a function with a given name exists and to invalidate a SIL linker entry for a function.
These APIs are useful e.g. for quickly finding pre-specialisations by their names.
The existence check is very light-weight and does not try to deserialize bodies of SIL functions.
2016-02-26 22:10:59 -08:00
Adrian Prantl
310b0433a9 Reapply "Serialize debug scope and location info in the SIL assembler language.""
This ireapplies commit 255c52de9f.

Original commit message:

Serialize debug scope and location info in the SIL assembler language.
At the moment it is only possible to test the effects that SIL
optimization passes have on debug information by observing the
effects of a full .swift -> LLVM IR compilation. This change enable us
to write targeted testcases for single SIL optimization passes.

The new syntax is as follows:

 sil-scope-ref ::= 'scope' [0-9]+
 sil-scope ::= 'sil_scope' [0-9]+ '{'
                 sil-loc
                 'parent' scope-parent
                 ('inlined_at' sil-scope-ref )?
               '}'
 scope-parent ::= sil-function-name ':' sil-type
 scope-parent ::= sil-scope-ref
 sil-loc ::= 'loc' string-literal ':' [0-9]+ ':' [0-9]+

Each instruction may have a debug location and a SIL scope reference
at the end.  Debug locations consist of a filename, a line number, and
a column number.  If the debug location is omitted, it defaults to the
location in the SIL source file.  SIL scopes describe the position
inside the lexical scope structure that the Swift expression a SIL
instruction was generated from had originally. SIL scopes also hold
inlining information.

<rdar://problem/22706994>
2016-02-26 13:28:57 -08:00
Adrian Prantl
255c52de9f Revert "Serialize debug scope and location info in the SIL assembler language."
Temporarily reverting while updating the validation test suite.

This reverts commit c9927f66f0.
2016-02-26 11:51:57 -08:00
Adrian Prantl
c9927f66f0 Serialize debug scope and location info in the SIL assembler language.
At the moment it is only possible to test the effects that SIL
optimization passes have on debug information by observing the
effects of a full .swift -> LLVM IR compilation. This change enable us
to write targeted testcases for single SIL optimization passes.

The new syntax is as follows:

 sil-scope-ref ::= 'scope' [0-9]+
 sil-scope ::= 'sil_scope' [0-9]+ '{'
                 sil-loc
                 'parent' scope-parent
                 ('inlined_at' sil-scope-ref )?
               '}'
 scope-parent ::= sil-function-name ':' sil-type
 scope-parent ::= sil-scope-ref
 sil-loc ::= 'loc' string-literal ':' [0-9]+ ':' [0-9]+

Each instruction may have a debug location and a SIL scope reference
at the end.  Debug locations consist of a filename, a line number, and
a column number.  If the debug location is omitted, it defaults to the
location in the SIL source file.  SIL scopes describe the position
inside the lexical scope structure that the Swift expression a SIL
instruction was generated from had originally. SIL scopes also hold
inlining information.

<rdar://problem/22706994>
2016-02-26 10:46:29 -08:00
Xi Ge
48754aabfa Module groups: Respect IDE's conventions, use '/' as sub-group indicators. 2016-02-25 18:03:39 -08:00
Xi Ge
a1d885c348 Module groups: if group name collector is enabled, we continuously serialize doc-comment table for comment-free decls to preserve the group information. 2016-02-24 21:05:26 -08:00
Xi Ge
2db856e5f9 Simplify some code, NFC. 2016-02-24 16:21:42 -08:00
Xi Ge
00646c1ffa Save some copies by twining. NFC 2016-02-24 11:35:17 -08:00
Xi Ge
f4ff65eb57 Module groups: Teach group info parser to handle sub-groups recursively. 2016-02-23 13:57:48 -08:00
Todd Fiala
ceb58eac1e Merge branch 'master' of ssh://github.com/apple/swift 2016-02-22 22:00:10 -08:00
Todd Fiala
8ff40a3a22 Revert "Move pre-specializations of popular types away from the standard library."
This reverts commit 4d4c2cdba9.
2016-02-22 21:18:32 -08:00
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
Roman Levenstein
4d4c2cdba9 Move pre-specializations of popular types away from the standard library.
Pre-specializations were only used by Onone builds, but were kept inside the standard library dylyb anyways. This commit moves all the pre-specializations into a dedicated Swift module and a dynamic library, which are only used by Onone builds.

This reduces the code size of libswiftCore.dylib by 5%.
2016-02-22 07:54:44 -08:00
Joe Groff
a1ef412815 Sema/SILGen: Get property behavior implementations to codegen.
Fix some interface type/context type confusion in the AST synthesis from the previous patch, add a unique private mangling for behavior protocol conformances, and set up SILGen to emit the conformances when property declarations with behaviors are visited. Disable synthesis of the struct memberwise initializer if any instance properties use behaviors; codegen will need to be redesigned here.
2016-02-20 15:01:06 -08:00
Xi Ge
3921517d36 Revert "Add an assertion to make sure all stdlib files are grouped."
This reverts commit 0934cebb61.
2016-02-20 14:56:26 -08:00
Xi Ge
0934cebb61 Add an assertion to make sure all stdlib files are grouped. 2016-02-20 13:10:06 -08:00
practicalswift
65e041aa2c [gardening] Fix recently introduced typo: "correctlly" → "correctly" 2016-02-20 07:28:25 +01:00
Xi Ge
450391f28f [Serialization] Use the new group mechanism and update tests accordingly. 2016-02-19 17:21:28 -08:00
Xi Ge
766cbe8976 [Serialization] Add a group name collector that reads a Json file exists in the same directory with the source code. 2016-02-19 17:21:28 -08:00
Xi Ge
920a955965 [Serialization] Add a parser to interpret the Json file that specifies stdlib's grouping structure. 2016-02-19 17:21:28 -08:00
Adrian Prantl
8e1d6c013b Make SILDebugLocation a value member of SILInstruction again.
The overhead of uniquing the locations in a Densemap isn't worth any of
the potential memory savings: While this adds an extra pointer and
unsigned to each SILInstruction, any extra memory is completely lost in
the noise (measured on a release -emit-ir build of the x86_64 stdlib).
This is not too surpising as the ratio between SILInstructions and unique
SILLocations is not very high and the DenseMap also needs space.

<rdar://problem/22706994>
2016-02-19 13:41:54 -08:00
Adrian Prantl
40c7a1abee Separate underlying storage and location kind in SILLocation and
remove the mixed concept that was SILFileLocation.
Also add support for a third type of underlying storage that will be used
for deserialized debug lcoations from textual SIL.

NFC

<rdar://problem/22706994>
2016-02-19 11:16:48 -08:00
John McCall
e249fd680e Destructure result types in SIL function types.
Similarly to how we've always handled parameter types, we
now recursively expand tuples in result types and separately
determine a result convention for each result.

The most important code-generation change here is that
indirect results are now returned separately from each
other and from any direct results.  It is generally far
better, when receiving an indirect result, to receive it
as an independent result; the caller is much more likely
to be able to directly receive the result in the address
they want to initialize, rather than having to receive it
in temporary memory and then copy parts of it into the
target.

The most important conceptual change here that clients and
producers of SIL must be aware of is the new distinction
between a SILFunctionType's *parameters* and its *argument
list*.  The former is just the formal parameters, derived
purely from the parameter types of the original function;
indirect results are no longer in this list.  The latter
includes the indirect result arguments; as always, all
the indirect results strictly precede the parameters.
Apply instructions and entry block arguments follow the
argument list, not the parameter list.

A relatively minor change is that there can now be multiple
direct results, each with its own result convention.
This is a minor change because I've chosen to leave
return instructions as taking a single operand and
apply instructions as producing a single result; when
the type describes multiple results, they are implicitly
bound up in a tuple.  It might make sense to split these
up and allow e.g. return instructions to take a list
of operands; however, it's not clear what to do on the
caller side, and this would be a major change that can
be separated out from this already over-large patch.

Unsurprisingly, the most invasive changes here are in
SILGen; this requires substantial reworking of both call
emission and reabstraction.  It also proved important
to switch several SILGen operations over to work with
RValue instead of ManagedValue, since otherwise they
would be forced to spuriously "implode" buffers.
2016-02-18 01:26:28 -08:00
Jordan Rose
c9f3b080e5 [Serialization] Stop using DeclID et al for "the next available ID".
This is effectively fallout from 36a44cf3 where we switched representations of DeclID
and friends, but when I went to add ++ and -- to llvm::PointerEmbeddedInt I realized
it wasn't really intended to be mutated in place, i.e. it doesn't make sense to
increment a DeclID. Represent counters as plain integers instead that get converted
to DeclID when they are first used.
2016-02-17 10:10:40 -08:00
Slava Pestov
5e020e62da Nuke more trivial usages of getDeclaredTypeInContext(), NFC 2016-02-16 23:08:57 -08:00
practicalswift
2db2ae672f Remove unused variable SourceOrder
After this commit:

```
$ git grep SourceOrder
$
```
2016-02-14 22:09:06 +01:00
Jordan Rose
6272941c5c Rename "build configurations" to "conditional compilation blocks".
...because "build configuration" is already the name of an Xcode feature.

- '#if' et al are "conditional compilation directives".
- The condition is a "conditional compilation expression", or just
  "condition" if it's obvious.
- The predicates are "platform conditions" (including 'swift(>=...)')
- The options set with -D are "custom conditional compilation flags".
  (Thanks, Kevin!)

I left "IfConfigDecl" as is, as well as SourceKit's various "BuildConfig"
settings because some of them are part of the SourceKit request format.
We can change these in follow-up commits, or not.

rdar://problem/19812930
2016-02-12 11:09:26 -08:00
Daniel Duan
efe230774b [AST] rename some isXXX methods to getAsXXX
There's a group of methods in `DeclContext` with names that start with *is*,
such as `isClassOrClassExtensionContext()`. These names suggests a boolean
return value, while the methods actually return a type declaration. This
patch replaces the *is* prefix with *getAs* to better reflect their interface.
2016-02-11 16:23:40 -08:00
Jordan Rose
e7e0a87db2 Merge pull request #1254 from jrose-apple/Fixnum
Replace uses of llvm::Fixnum with llvm::PointerEmbeddedInt.
2016-02-11 13:06:45 -08:00
Xi Ge
9aa3d01101 [Serialization] Avoid serializing source orders, trust deserialized decls in preserving such order. rdar://24610992
Thank Jordan for suggesting this.
2016-02-11 12:24:38 -08:00
Jordan Rose
36a44cf308 Replace uses of llvm::Fixnum with llvm::PointerEmbeddedInt.
The two types are nearly identical, and Fixnum is only in the Swift branches of LLVM,
not in mainline LLVM.

I do want to add ++ to PointerEmbeddedInt and fix some of this ugliness, but that'll
have to go through LLVM review, so it might take a bit.
2016-02-11 09:52:07 -08:00
Xi Ge
767fba9c92 Rename BriefAndRawComment to CommentInfo. NFC 2016-02-10 19:27:21 -08:00
Xi Ge
98734f588a [Serialization] Serialize and deserialize source order in module doc files. 2016-02-10 17:46:49 -08:00
Doug Gregor
293d130272 [Omit needless words] Add a flag -enable-strip-ns-prefix to control NS stripping
Stripping "NS" is a massively invasive change; separate it out into
another flag.
2016-02-08 22:41:16 -08:00
Xi Ge
329345077b [SourceKit] Add a new query to collect all group names from a module.
Input:
  Request Id: 'source.request.module.groups'
  Required field: 'key.modulename'

Output:
  Array of group names in that module, if any.
2016-02-08 17:22:10 -08:00
Ben Langmuir
cfff55e989 [InterfaceGen] Fix deserializing submodule ImportDecls
Use the isScoped() bit to distinguish scoped imports from submodule
imports (both of which are split by null bytes in the string) so that we
don't try to lookup a submodule name as if it were a decl (leading to
assertion failures when it wasn't found).

This fixes interface generation of swift modules that import clang
submodules.

rdar://problem/24534122
2016-02-08 17:00:23 -08:00