Commit Graph

1537 Commits

Author SHA1 Message Date
swift-ci
c45695815b Merge remote-tracking branch 'origin/master' into master-next 2017-04-03 23:48:33 -07:00
Slava Pestov
37491e63ac AST: Refactor existential type accessors on TypeBase and CanType 2017-04-03 23:14:25 -07:00
swift-ci
dab1477d3d Merge remote-tracking branch 'origin/master' into master-next 2017-04-03 01:28:32 -07:00
Slava Pestov
ca5d80bd1a IRGen: Fix -sil-serialize-all linkage issue
External private definitions coming from a -sil-serialize-all
module must be effectively public at the LLVM level too, fixing
a linker error when referencing closures from a deserialized
function body.
2017-04-02 23:44:31 -07:00
swift-ci
e522821ba7 Merge remote-tracking branch 'origin/master' into master-next 2017-03-31 01:28:32 -07:00
Slava Pestov
8aa7e6e120 IRGen: Private linkage for metadata patterns
More ABI lockdown / symbol table shrinkage.
2017-03-31 00:16:25 -07:00
swift-ci
d199dc147e Merge remote-tracking branch 'origin/master' into master-next 2017-03-30 20:48:31 -07:00
Slava Pestov
a24f8a576b IRGen: value witness tables and lazy metadata cache variables never need to be public
This simplifies TBDGen too, even though it's still TBD.
2017-03-30 17:58:45 -07:00
swift-ci
f89ec6273f Merge remote-tracking branch 'origin/master' into master-next 2017-03-29 20:08:29 -07:00
Slava Pestov
8fe8b89b0f SIL: Terminology change: [fragile] => [serialized]
Also, add a third [serializable] state for functions whose bodies we
*can* serialize, but only do so if they're referenced from another
serialized function.

This will be used for bodies synthesized for imported definitions,
such as init(rawValue:), etc, and various thunks, but for now this
change is NFC.
2017-03-29 16:47:28 -07:00
Saleem Abdulrasool
15565c116a Adjust for SVN r298393 2017-03-22 07:44:03 -07:00
Erik Eckstein
7dba148726 IRGen: Private witness table utilities should have private linkage. 2017-03-21 17:53:17 -07:00
Erik Eckstein
a16beaea3c Remove the now usused ConformanceCollector utility.
It was used for dead witness table elimination. But this is done now by lazy emission in IRGen.
Also update DeadFunctionElimination.
NFC.
2017-03-15 10:18:18 -07:00
Erik Eckstein
1144bf0a95 IRGen: fix comment 2017-03-14 13:27:19 -07:00
John McCall
897f5ab7c5 Restore CanType-based micro-optimizations.
This reverts commit 5036806e5a.
However, it preserves a pair of changes to the SIL optimizer
relating to walking through optional types.
2017-03-14 11:38:11 -04:00
Slava Pestov
5036806e5a AST: Remove some unnecessary getCanonicalType() calls 2017-03-13 02:24:36 -07:00
Erik Eckstein
41c17a5b0c IRGen: emit type metadata and (value) witness tables lazily.
This gives big code size wins for unused types and also for types, which are never used in a generic context.
Also it reduces the amount of symbols in the symbol table.
The size wins heavily depend on the project. I have seen binary size reductions from 0 to 20% on real world projects.

rdar://problem/30119960
2017-03-10 12:50:43 -08:00
Arnold Schwaighofer
80732ead34 Non-witness implementations of init_existential_addr, deinit_existential_addr, open_existential_addr, copy_addr, destory_addr
For the boxed existential variant.
2017-03-09 17:22:35 -08:00
Slava Pestov
30f5254cb2 IRGen: Kill uncurryLevel some more 2017-03-08 13:54:31 -08:00
John McCall
d61d966451 Use ConstantInitBuilder in most kinds of metadata emission.
This is NFC in intent, but I had to restructure the code to emit more
of the lists "inline", which means I inevitably altered some IRGen
emission patterns in ways that are visible to tests:

- GenClass emits property/ivar/whatever descriptors in a somewhat
  different order.

- An ext method type list is now emitted as just an array, not a struct
  containing only that array.

- Protocol descriptors are no longer emitted as packed structs.

I was sorely tempted to stop using packed structs for all the metadata
emission, but didn't really want to update that many tests in one go.
2017-03-06 14:18:47 -05:00
John McCall
ec667cae55 Adopt ConstantInitBuilder in a few places. 2017-03-06 14:18:47 -05:00
John McCall
fe7915d09e Rework a number of SIL and IRGen witness-table abstractions
to correctly handle generalized protocol requirements.

The major missing pieces here are that the conformance search
algorithms in both the AST (type substitution) and IRGen
(witness table reference emission) need to be rewritten to
back-track requirement sources, and the AST needs to actually
represent this stuff in NormalProtocolConformances instead
of just doing ???.

The new generality isn't tested yet; I'm looking into that,
but I wanted to get the abstractions in place first.
2017-03-02 01:34:13 -05:00
Erik Eckstein
13134ec25c IRGen: remove the now unused LinkEntity Kind TypeMangling 2017-02-22 16:00:20 -08:00
Erik Eckstein
8c99bf280a IRGen: remove an unused function 2017-02-22 09:19:10 -08:00
Roman Levenstein
1180c3d5da Do not automatically map Swfit @effects(readonly) to LLVM's readonly attribute
Swift's readonly and readnone should not be automatically mapped to LLVM's readonly.
Swift SIL optimizer relies on @effects(readonly) to remove e.g. dead code remaining
from initializers of strings or dictionaries of variables that are not used. But
those initializers are often not really readonly in terms of LLVM IR. For
example, the Dictionary.init() is marked as @effects(readonly) in Swift, but it
does invoke reference-counting operations. As a result, it leads to miscompiles
and runtime crashes.

In the future, we may add the functionality to analyze the body of the function
and if we can prove that is really readonly, we can map it to the LLVM readonly
attribute.

I checked that removal of this mapping does not affect the performance of any of
our existing benchmarks.

Fixes rdar://problem/28830504
2017-02-17 16:55:33 -08:00
Hugh Bellamy
f001b7562b Use relatively new LLVM_FALLLTHROUGH instead of our own SWIFT_FALLTHROUGH 2017-02-12 10:47:03 +07:00
Erik Eckstein
7fb871a7c6 Disable dead conformance elimination for now.
There are still several open issues (e.g. asserts in IRGen) and it seems to be hard to fix them.
Most likely we’ll go for a different approach at all.
2017-02-01 10:30:30 -08:00
Andrew Trick
1abeddcc5d [SILType] SILFunctionConventions API.
Separate formal lowered types from SIL types.
The SIL type of an argument will depend on the SIL module's conventions.
The module conventions are determined by the SIL stage and LangOpts.

Almost NFC, but specialized manglings are broken incidentally as a result of
fixes to the way passes handle book-keeping of aruments. The mangler is fixed in
the subsequent commit.

Otherwise, NFC is intended, but quite possible do to rewriting the logic in many
places.
2017-01-26 15:35:48 -08:00
Erik Eckstein
db255b90b5 Fix an assertion in IRGen while checking for escaping metatypes.
rdar://problem/30146045

Sorry, no test file for this. I couldn’t come up with a reduced test case.
2017-01-23 10:35:28 -08:00
Slava Pestov
703a63fc96 Merge pull request #6908 from slavapestov/sema-substitution-fixes
Sema fixes for SE-0110
2017-01-19 20:36:45 -08:00
Slava Pestov
7b5cf4ab7d Merge pull request #3841 from tinysun212/pr-swiftc-cygwin-2
[swiftc] Fixed for Cygwin
2017-01-19 20:17:47 -08:00
Slava Pestov
c86b5ae427 AST: Header file gardening - include what you use 2017-01-19 20:07:06 -08:00
Erik Eckstein
89c9ff5ca0 SIL: ConformanceCollector utility for collecting all conformances which are used by a SIL instruction.
Also verify the correctness of ConformanceCollector in IRGen by checking if IRGen does not use a conformance which is not collected by the utility.
2017-01-19 09:41:09 -08:00
Erik Eckstein
cb0ebae078 Derive the SIL linkage of a witness table from the minimum of the protocol’s and conforming type’s visibility.
For example, if an internal type conforms to a public protocol, the witness table should get internal linkage.
Previously we only considered the visibility of the protocol.

Fragile witness tables still have to get public symbol linkage. This is now handled in IRGen (like we do it for functions).
2017-01-19 07:58:10 -08:00
Erik Eckstein
7dab73e980 Don’t try to de-serialize witness tables in IRGen 2017-01-19 07:58:10 -08:00
Han Sangjin
b8dd577693 [swiftc] Fixed for Cygwin
Fixed for the difference of Cygwin with other Windows variants (MSVC,
Itanium, MinGW).

- The platform name is renamed to "cygwin" from "windows" which is used
  for searching the standard libraries.

- The consideration for DLL storage class (DllExport/DllImport) is not
  required for Cygwin and MinGW. There is no problem when linking in
  these environment.

- Cygwin should use large memory model as default.(This may be changed
  if someone ports to 32bit)

- Cygwin and MinGW should use the autolink feature in the sameway of
  Linux due to the linker's limit.
2017-01-19 05:48:24 +09:00
Bob Wilson
eeb0f08988 Merge remote-tracking branch 'origin/master' into master-next 2017-01-17 10:45:44 -08:00
Adrian Prantl
bb55c6d8a6 Clean up the constructors of DebugTypeInfo
and ensure that the DeclContext of the SILFunction is used when
mangling substituted archetypes found in inlined variable declarations
that have been reparented into the caller

<rdar://problem/28859432>
2017-01-13 15:56:27 -08:00
Bob Wilson
37e7d1c627 Merge remote-tracking branch 'origin/master' into master-next 2017-01-08 17:07:46 -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
Bob Wilson
78b28243ff Merge remote-tracking branch 'origin/master' into master-next 2017-01-03 14:22:59 -08: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
Bob Wilson
13da3fa8b1 Merge remote-tracking branch 'origin/master' into master-next 2016-12-04 18:16:09 -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
Bob Wilson
c08a96a880 Update references to UTF* types and functions to match llvm r282822.
The content of LLVM's "Support/ConvertUTF.h" header was moved into the
"llvm" namespace. Update this code to match.
2016-10-13 17:05:51 -07:00
Slava Pestov
53b3a69a9a Runtime: Fix dynamic casts to support resilient protocols
If a protocol witness table requires instantiation, the runtime
needs to call the witness table accessor when looking up the
conformance in swift_conformsToProtocol().

We had a bit of code for this already, but it wasn't fully
hooked up. Change IRGen to emit a reference to the witness table
accessor rather than the witness table itself if the witness
table needs instantiation, and add support to the runtime for
calling the accessor.
2016-09-30 18:28:11 -07:00
Slava Pestov
30b1efa87b IRGen: Emit superclass information for remote reflection
In order to perform associated type lookups for an inherited
conformance of a derived class, the reflection library needs
to know superclasses of all classes.

Previously we had no way of recovering this information
(short of some kind of reverse lookup in the metadata cache).
Oops!

To avoid causing problems with old/new compiler vs old/new
libswiftRemoteMirrors.dylib, this introduces the new record
in a backward-compatible way: we emit a fake AnyObject
conformance with a fake 'super' associated type to store
the superclass of a class.

Not yet hooked up in the reflection library itself.
2016-09-24 02:17:46 -07:00
Erik Eckstein
34a4e6df0a SIL: add new instructions to support tail-allocated arrays in SIL.
The new instructions are: ref_tail_addr, tail_addr and a new attribute [ tail_elems ] for alloc_ref.
For details see docs/SIL.rst

As these new instructions are not generated so far, this is a NFC.
2016-09-16 11:02:19 -07:00
Dmitri Gribenko
fbb3cf35a5 Revert "New SIL instructions to support tail-allocated arrays in SIL." 2016-09-15 00:25:25 -07:00