Commit Graph

4303 Commits

Author SHA1 Message Date
Joe Shajrawi
ee5ed7bdc6 [IRGen] Code Size Reduction: Outline Copy/Consume (Loadable) Enum 2016-12-22 17:08:15 -08:00
Arnold Schwaighofer
79150371f8 Merge pull request #6447 from aschwaighofer/irgen_fix_external_arg_coersion
IRGen: Make sure that there is enough stack space allocated for coerced external arguments
2016-12-22 13:00:16 -08:00
Kevin Ballard
4d95406d5a Merge pull request #6450 from kballard/init_method_family
[PrintAsObjC] Add SWIFT_METHOD_FAMILY(init) when required
2016-12-22 10:52:11 -08:00
Arnold Schwaighofer
d4aac4f47c IRGen: Make sure that there is enough stack space allocated for coerced external
arguments.

The allocated space needs to be the max of the expected argument type size and
the size of the type we coerce from.

rdar://28858437
2016-12-22 10:02:08 -08:00
practicalswift
9c738f6b58 Merge pull request #6438 from practicalswift/i-heard-you-like-partitions
[gardening] Fix partiion^H^H^H^H^Hitions^H^H^H^H^H^Htitions.
2016-12-22 15:18:36 +01:00
Kevin Ballard
f3e946872d Stop using islower()
`islower` is locale-sensitive, we should be using `clang::isLowercase`
instead.
2016-12-21 17:52:19 -08:00
practicalswift
d88c188d47 Merge pull request #6443 from practicalswift/argument-names
[gardening] Make sure argument names in comments match the actual parameter names
2016-12-21 23:25:29 +01:00
practicalswift
cc6fe4f3b2 Merge pull request #6441 from practicalswift/
[gardening] Fix accidental double and triple spaces.
2016-12-21 22:59:46 +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
ce7a10474f [gardening] Fix accidental double and triple spaces. 2016-12-21 22:13:56 +01:00
practicalswift
fe3b9968fc [gardening] Fix partiion^H^H^H^H^Hitions^H^H^H^H^H^Htitions.
By being less creative in the ways we spell "partition" :-)
2016-12-21 21:36:24 +01:00
practicalswift
f05a338e9a [gardening] Prefer (!foo) to (foo == false). Fix typo. 2016-12-21 21:25:58 +01:00
Arnold Schwaighofer
0ac2371bdf Merge pull request #6436 from aschwaighofer/fix_irgen_of_delayed_existential_buffer_init
IRGen: A lowered address can either be the address in a container or a regular address
2016-12-21 11:18:12 -08:00
Arnold Schwaighofer
ebf63def8e IRGen: A lowered address can either be the address in a container or a regular address
When we optimize existential buffer allocation we stored a ContainedAddress (container and
uninitialized address) if we delay the buffer allocation to the first copy_addr [init].
2016-12-21 10:01:03 -08:00
Saleem Abdulrasool
27bf54328f IRGen: adjust DI for SVN r288683
The original implementation of DW_OP_bit_piece was using the wrong base for the
offset.  To accommodate a fix for that, the old operation was renamed.  Use the
new migration name.

(cherry picked from commit 100eaf889e)
2016-12-21 09:11:37 -08:00
Arnold Schwaighofer
4166e2b56e Merge pull request #6425 from aschwaighofer/fix_assert_alloc_stack_hoisting
Remove to strict assert
2016-12-20 17:41:26 -08:00
Arnold Schwaighofer
9a2582f7a4 Remove to strict assert
unreachable exits don't need an dealloc_stack and so there can be alloc_stack
instructions without a matching dealloc_stack
2016-12-20 17:02:26 -08:00
Vedant Kumar
a064157d99 [Coverage] Fix UB in use of the CoverageMappingWriter API
Passing {FileID} into the CoverageMappingWriter constructor causes UB.
The ArrayRef constructed from the initializer list becomes invalid once
the constructor returns, because the lifetime of the initializer list
expires. Use an alternate ArrayRef constructor which outlives the
CoverageMappingWriter instance.

This commit also re-reenables coverage_smoke.swift.

rdar://problem/29591622
2016-12-20 16:51:38 -08:00
Arnold Schwaighofer
a87f34372e Rename SILFunction::entryBB to getEntryBlock 2016-12-20 07:51:55 -08:00
Arnold Schwaighofer
4773e89118 Use preprocess macro instead of manually adding IRGen passes. 2016-12-20 07:51:55 -08:00
Arnold Schwaighofer
f1c2dcf1fa Add an alloc_stack hoisting pass.
Hoist alloc_stack instructions of 'generic' or resilient type to the entry
block. At the same time also perform a very simple stack coloring analysis.
This does not use a true liveness-analysis yet but rather employs some simple
conservative checks to see whether the live ranges of two alloc_stacks might
interfere.

AllocStackHoisting is an IRGen SIL pass. This allows for using IRGen's type
lowering information. Furthermore, hoisting and merging the alloc_stack
instructions this late does not interfere with SIL optimizations because the
resulting SIL never gets serialized.
2016-12-20 07:51:55 -08:00
Arnold Schwaighofer
f38c912878 Add support of a IRGen lowering SIL pipeline.
This pipeline is run as part of IRGen and has access to the IRGenModule.

Passes that run as part of this pipeline can query for the IRGenModule.

We will use it for the AllocStackHoisting pass. It wants to know if a type is of
non-fixed size.

To break the cyclic dependency between IRGen -> SILOptimizer -> IRGen that would
arise from the SILPassManager having to know about the createIRGENPASS()
function IRGen passes instead of exposing this function dynamically have to add
themselves to the pass manager.
2016-12-20 07:51:47 -08:00
Arnold Schwaighofer
cd1037b799 IRGen: Allocate generic/resilient values on the stack instead of on the heap
Allocate buffers for local generic/resilient values on the stack. alloc_stack
instructions in the entry block are translated using a dynamic alloca
instruction with variables size. All other alloc_stack instructions in addition
use llvm's stacksave/restore instrinsics to reset the stack (they could be
executed multiple times and with varying sizes).
2016-12-20 07:24:02 -08:00
Joe Groff
2e0cb9c0a2 Runtime: getDynamicType can't drill into existentials when producing a concrete metatype.
For a value of an opaque generic type `<T> x: T`, the language currently defines `type(of: x)` and `T.self` as both producing a type `T.Type`, and the result of substituting an existential type by `T == P` gives `P.Protocol`, so the `type(of:)` operation on `x` can only give the concrete protocol metatype when `x` is an existential in this case. The optimizer understood this rule, but the runtime did not, causing SR-3304.
2016-12-19 11:03:52 -08:00
Slava Pestov
fb0f372e94 AST: Move mapType{In,OutOf}Context() out of ArchetypeBuilder and clean up headers
- The DeclContext versions of these methods have equivalents
  on the DeclContext class; use them instead.

- The GenericEnvironment versions of these methods are now
  static methods on the GenericEnvironment class. Note that
  these are not made redundant by the instance methods on
  GenericEnvironment, since the static methods can also be
  called with a null GenericEnvironment, in which case they
  just assert that the type is fully concrete.

- Remove some unnecessary #includes of ArchetypeBuilder.h
  and GenericEnvironment.h. Now changes to these files
  result in a lot less recompilation.
2016-12-18 19:55:41 -08:00
practicalswift
64309623c0 [gardening] Initialize doneBB to nullptr to avoid calling IGF.Builder.CreateBr(…) and IGF.Builder.emitBlock(…) with uninitialized arguments.
Tighten scope for notDoneBB.
2016-12-18 19:35:42 +01:00
practicalswift
b9b2c81e40 [gardening] C++ gardening: Argument names. Overrides. End-of-namespace. 2016-12-18 18:04:01 +01:00
practicalswift
9d0b2abfc2 [gardening] Normalize end-of-namespace comments 2016-12-17 22:29:07 +01:00
Michael Gottesman
96c63e9e76 Merge pull request #6324 from practicalswift/cpp-gardening
[gardening] C++ gardening: Terminate namespaces, fix argument names, …
2016-12-16 23:30:33 -08:00
Joe Groff
4444d83756 SIL: Lower captures to boxes with an appropriate generic context.
Officially kick SILBoxType over to be "nominal" in its layout, with generic layouts structurally parameterized only by formal types. Change SIL to lower a capture to a nongeneric box when possible, or a box capturing the enclosing generic context when necessary.
2016-12-16 20:23:25 -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
practicalswift
d848cfff85 Merge pull request #6304 from practicalswift/remove-unused-nextprev
[gardening] Remove never read variable CacheEntry *nextPrev
2016-12-16 19:41:14 +01:00
Slava Pestov
2c6b9f71b6 AST: Change TypeAliasDecls to store an interface type as their underlying type
- TypeAliasDecl::getAliasType() is gone. Now, getDeclaredInterfaceType()
  always returns the NameAliasType.

- NameAliasTypes now always desugar to the underlying type as an
  interface type.

- The NameAliasType of a generic type alias no longer desugars to an
  UnboundGenericType; call TypeAliasDecl::getUnboundGenericType() if you
  want that.

- The "lazy mapTypeOutOfContext()" hack for deserialized TypeAliasDecls
  is gone.

- The process of constructing a synthesized TypeAliasDecl is much simpler
  now; instead of calling computeType(), setInterfaceType() and then
  setting the recursive properties in the right order, just call
  setUnderlyingType(), passing it either an interface type or a
  contextual type.

  In particular, many places weren't setting the recursive properties,
  such as the ClangImporter and deserialization. This meant that queries
  such as hasArchetype() or hasTypeParameter() would return incorrect
  results on NameAliasTypes, which caused various subtle problems.

- Finally, add some more tests for generic typealiases, most of which
  fail because they're still pretty broken.
2016-12-15 22:46:15 -08:00
Slava Pestov
a384b2a677 Don't call VarDecl::getType() on deserialized VarDecls 2016-12-15 22:46:15 -08:00
Jordan Rose
d4baacfb92 Merge pull request #6289 from mxswd/less-memory
After performIRGeneration but before performLLVM delete the CompilerInstance if possible
2016-12-15 15:05:12 -08:00
Erik Eckstein
ad8a6d2a00 Mangling: remove unnecessary size check in assert condition 2016-12-15 14:08:11 -08:00
Maxwell Swadling
5f0572ef53 Updated documentation for new less memory frontend 2016-12-15 11:11:06 -08:00
practicalswift
50b99df4cc [gardening] Remove never read variable CacheEntry *nextPrev 2016-12-15 11:17:54 +01:00
Michael Gottesman
6213550239 [semantic-sil] Create copy_unowned_value.
This was in the first high level ARC instruction proposal, but I have not needed
it until now. The use case for this is to ahandle strong_retain_unowned (which
takes in an unowned value, asserts it is still alive, performs a strong_retain,
and returns the @owned value). This @owned value needs a destroy_value.

rdar://29671437
2016-12-14 19:22:24 -08:00
Maxwell Swadling
6af14c05d8 After performIRGeneration but before performLLVM delete the CompilerInstance if possible 2016-12-14 18:49:23 -08:00
Saleem Abdulrasool
100eaf889e IRGen: adjust DI for SVN r288683
The original implementation of DW_OP_bit_piece was using the wrong base for the
offset.  To accommodate a fix for that, the old operation was renamed.  Use the
new migration name.
2016-12-13 14:43:35 -08:00
Bob Wilson
deddf19aae Merge remote-tracking branch 'origin/master' into master-next 2016-12-13 10:23:03 -08:00
Slava Pestov
b9335e72cd IRGen: Fix regression when pattern matching against an existential with associated types
Now, we need to just *ban* this case when we're in Swift 4 mode, but
to keep existing code working, add a hack.

Fixes <rdar://problem/29605388>.
2016-12-12 17:29:26 -08:00
Michael Gottesman
66cff7e37e [semantic-arc] Add StoreBorrowInst and BeginBorrowInst. 2016-12-12 13:06:18 -08:00
swift-ci
630b79b4ce Merge pull request #6176 from jckarter/sil-box-get-field-type-module 2016-12-09 16:42:23 -08:00
Joe Groff
3871cda205 Push SILBoxType::getFieldType into SIL and make it take a SILModule.
Applying nontrivial generic arguments to a nontrivial SIL layout requires lowered SILType substitution, which requires a SILModule. NFC yet, just an API change.
2016-12-09 16:21:13 -08:00
Hugh Bellamy
83787e216a Change friend class to friend in GenProto.cpp 2016-12-09 23:17:44 +00:00
swift-ci
71cd65bd16 Merge pull request #6165 from jckarter/remove-get-box-type 2016-12-09 12:10:26 -08:00
swift-ci
bf79a65484 Merge pull request #6163 from hughbe/irgen-clang-cl 2016-12-09 11:51:38 -08:00
Joe Groff
585ccd59c1 Remove SILBoxType::getBoxedType.
Move the few remaining usages to getFieldType. Removing the old API lets us progress in fully adopting nontrivial layouts in SILGen.
2016-12-09 11:10:03 -08:00