Commit Graph

806 Commits

Author SHA1 Message Date
Huon Wilson
754d74ab8f Merge pull request #8753 from huonw/open-public-class-methods
Only `open`, not `public`, classes need public symbols
2017-04-14 13:35:00 -07:00
Slava Pestov
db58e02cb2 Sema: Hook up layout constraints to the solver
There were various problems with layout constraints either
being ignored or handled incorrectly. Now that I've exercised
this support with an upcoming patch, there are some fixes
here.

Also, introduce a new ExistentialLayout::getLayoutConstriant()
which returns a value for existentials which are class-constrained
but don't have a superclass or any class-constrained protocols;
an example would be AnyObject, or AnyObject & P for some
non-class protocol P.

NFC for now, since these layout-constrained existentials cannot
be constructed yet.
2017-04-13 21:17:05 -07:00
Huon Wilson
b59f95418c [SIL] Extract ClassVisibility from SILFunction to SubclassScope in SILLinkage. 2017-04-13 14:17:29 -07:00
Roman Levenstein
01e0ffd6c7 [eager-specializer] Handle functions with don’t have return basic blocks
This situation often happens if a function invokes a NoReturn function like fatalError.

Resolves rdar://31566966
2017-04-12 09:18:18 -07:00
practicalswift
5e255e07d7 [gardening] Remove redundant logic 2017-04-11 23:04:55 +02:00
Andrew Trick
be1881aa1f Remove redundant Transform.getName() definitions.
At some point, pass definitions were heavily macro-ized. Pass
descriptive names were added in two places. This is not only redundant
but a source of confusion. You could waste a lot of time grepping for
the wrong string. I removed all the getName() overrides which, at
around 90 passes, was a fairly significant amount of code bloat.

Any pass that we want to be able to invoke by name from a tool
(sil-opt) or pipeline plan *should* have unique type name, enum value,
commend-line string, and name string. I removed a comment about the
various inliner passes that contradicted that.

Side note: We should be consistent with the policy that a pass is
identified by its type. We have a couple passes, LICM and CSE, which
currently violate that convention.
2017-04-09 15:20:28 -07:00
Slava Pestov
ebe0c83795 Capture Promotion: Fix use-after-free 2017-04-02 19:55:19 -07:00
Michael Gottesman
bd225f9fc4 [capture-promotion] Update capture-promotion for semantic-sil.
rdar://29870610
2017-04-02 11:44:14 -07:00
Michael Gottesman
22d7ad3f44 [gardening] Use macros and a detail enum to make some code more compact. 2017-04-02 10:51:48 -07:00
Michael Gottesman
6ade74a809 [capture-promotion] Extract scanning the box for interesting uses into its own helper function and use a higher order function instead of a loop. 2017-04-02 04:04:26 -07:00
Michael Gottesman
f79cc8e238 [capture-promotion] Refactor out into methods the handling in project_box, partial_apply to helper functions. 2017-04-02 04:04:26 -07:00
Michael Gottesman
19b6de625d [capture-promotion] Change isNonEscapingUse to use a visitor. 2017-03-31 09:48:53 -07:00
Michael Gottesman
c37367284c [capture-promotion] Change recursion to use a real stack instead of function stacks. 2017-03-30 20:16:08 -07:00
Michael Gottesman
c81977454b [capture-promotion] Add debugging messages to capture promotion. 2017-03-30 17:04:10 -07:00
Michael Gottesman
3af929eafd Merge pull request #8447 from gottesmm/gardening_and_camelcasing
[gardening] camelCase helper functions correctly.
2017-03-30 16:58:11 -07:00
Michael Gottesman
65b523a115 [gardening] camelCase helper functions correctly. 2017-03-30 15:52:08 -07:00
Roman Levenstein
7887eb30a3 [sil-capture-promotion] Properly handle generic SILBoxTypes.
- Use SILFunction::getTypeLowering, because it knows how to handle generic contexts properly
- Map interface types into context
- Fix a use-after-release runtime bug, uncovered by recent Erik's changes.

Fixes rdar://31309883.
2017-03-30 14:09:54 -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
Roman Levenstein
4e2262944d Extend the representation of layout constraints
- Add support for _Class and _NativeClass layout constraints, which are supposed to represent T: Superclass and P: class constraints in the future.
- Use the re-factoring to also reduce the number of dynamic allocations when creating layout constraints. Simple non-parametrized layout constraints are now represented as statically allocated singletons (static members of LayoutConstraintInfo).
2017-03-22 16:37:38 -07:00
Erik Eckstein
d70bfc5de2 rename namespace NewMangling -> Mangle 2017-03-20 10:09:30 -07:00
Erik Eckstein
1625345b90 Remove the old mangler.
NFC
2017-03-17 16:10:36 -07:00
practicalswift
26a67fe538 [gardening] Remove unused variable CanGenericSig 2017-03-17 08:19:36 +01:00
swift-ci
49078dd6be Merge pull request #8114 from eeckstein/remove-conformancecollector 2017-03-15 15:23:22 -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
Roman Levenstein
b6c546b585 [capture-propagation] Support generic partial_apply instructions 2017-03-15 08:27:33 -07:00
Greg Parker
44135ae69a Revert "[sil-capture-propagation] Switch to the new notifyAddFunction API" 2017-03-15 00:49:07 -07:00
Roman Levenstein
78f5211164 [capture-propagation] Support generic partial_apply instructions 2017-03-14 17:40:58 -07:00
Greg Parker
5c01a65a40 Revert "[sil-capture-propagation] Support generic partial_apply instructions" 2017-03-14 17:32:42 -07:00
Roman Levenstein
ea3d69130c Merge pull request #8081 from swiftix/wip-capture-propagation-generics
[sil-capture-propagation] Support generic partial_apply instructions
2017-03-14 17:09:12 -07:00
Erik Eckstein
0e068ea15c Add some comments and remove dead while-loop.
Thanks @atrick for reviewing!
2017-03-14 13:00:55 -07:00
Erik Eckstein
a0079ba5be SIL optimizations: Implement the new API for analysis invalidation.
There are now separate functions for function addition and deletion instead of InvalidationKind::Function.
Also, there is a new function for witness/vtable invalidations.

rdar://problem/29311657
2017-03-14 13:00:54 -07:00
Erik Eckstein
ef4b5e1efe ClosureSpecializer: small refactoring
Get rid of the utility class ClosureSpecializer.
NFC.
2017-03-14 13:00:54 -07:00
John McCall
3c5de5fa0a Preserve type canonicality better in several places and
idiomatize some uses of SILType::getSwiftRValueType().
2017-03-14 14:59:43 -04:00
Roman Levenstein
2905ee1cf4 [capture-propagation] Support generic partial_apply instructions 2017-03-14 08:40:29 -07:00
Erik Eckstein
5e80555c9b demangler: put the demangler into a separate library
Previously it was part of swiftBasic.

The demangler library does not depend on llvm (except some header-only utilities like StringRef). Putting it into its own library makes sure that no llvm stuff will be linked into clients which use the demangler library.

This change also contains other refactoring, like moving demangler code into different files. This makes it easier to remove the old demangler from the runtime library when we switch to the new symbol mangling.

Also in this commit: remove some unused API functions from the demangler Context.

fixes rdar://problem/30503344
2017-03-09 13:42:43 -08:00
Slava Pestov
97fce6cb79 SILOptimizer: Always create SILFunctions with a generic environment 2017-03-04 17:36:47 -08:00
Saleem Abdulrasool
0c56998576 SIL: IWYU cl edition
Include llvm/Support/CommandLine.h when using llvm::cl.
2017-03-04 14:20:51 -08:00
Slava Pestov
0f4a7d246f AST: Remove GenericSignature::getAllDependentTypes()
This was a remnant of the old generics implementation, where
all nested types were expanded into an AllArchetypes list.

For quite some time, this method no longer returned *all*
dependent types, only those with generic requirements on
them, and all if its remaining uses were a bit convoluted.

- In the generic specialization code, we used this to mangle
  substitutions for generic parameters that are not subject
  to a concrete same-type constraint.

  A new GenericSignature::getSubstitutableParams()
  function handles this use-case instead. It is similar
  to getGenericParams(), but only returns generic parameters
  which require substitution.

  In the future, SubstitutionLists will only store replacement
  types for these generic parameters, instead of the list of
  types that we used to produce from getAllDependentTypes().

- In specialization mangling and speculative devirtualization,
  we relied on SubstitutionLists having the same size and
  order as getAllDependentTypes(). It's better to turn the
  SubstitutionList into a SubstitutionMap instead, and do lookups
  into the map.

- In the SIL parser, we were making a pass over the generic
  requirements before looking at getAllDependentTypes();
  enumeratePairedRequirements() gives the correct information
  upfront.

- In SIL box serialization, we don't serialize the size of the
  substitution list, since it's available from the generic
  signature. Add a GenericSignature::getSubstitutionListSize()
  method, but that will go away soon once SubstitionList
  serialization only serializes replacement types for generic
  parameters.

- A few remaining uses now call enumeratePairedRequirements()
  directly.
2017-03-02 22:57:52 -08:00
Slava Pestov
e305a4d32f SILOptimizer: Add support for generic closures to CapturePromotion
Previously this pass would bail out if the closure had any
parameters or results of generic type.

First of all, this was a workaround for an old SILGen limitation,
where closures in generic context would inherit a generic
signature even if they did not capture generic types, which
inhibited optimizations.

Second, capture promotion doesn't really do anything special with
generics at all, but it used a TypeSubstCloner and would apply
substitutions from the call site to the cloned function; this is
not the behavior we want here. Simply switching the pass to use a
SILCloner instead of a TypeSubstCloner appears to be sufficient
in order to allow generic boxes to be promoted too.

Fixes <rdar://problem/28948735>.
2017-02-28 20:52:19 -08:00
Mikio Takeuchi
488d531846 Enhance -assume-single-threaded option (SR-3945) 2017-02-27 12:17:53 +09:00
Erik Eckstein
437d4da38d Demangling: Remove StringRef-versions of demangling functions from demangle_wrappers because they are now available in Demangle itself.
This is just refactoring. NFC.
2017-02-24 15:19:18 -08:00
Erik Eckstein
465e343a4f CapturePropagation: handle convert_function and try_apply.
This handles cases where we pass a non-throwing closure to a function (e.g. a re-abstraction thunk) which accepts a throwing closure.

Fixes at least part of rdar://problem/30596064
2017-02-21 11:32:47 -08:00
Roman Levenstein
fc7b9e1081 [sil-linker] Minor clean-ups of function lookup code in SILModule and SIL linker. NFC.
Stop using SILLinkage::Private as a flag for "linkage doesn't matter". Use Optional instead.
2017-02-14 08:15:51 -08:00
Jordan Rose
1c60910198 Revert "Merge pull request #6092 from swiftix/wip-generics-inlining-flag-4"
This reverts commit 1b3d29a163, reversing
changes made to b32424953e.

We're seeing a handful of issues from turning on inlining of generics,
so I'm reverting to unblock the bots.
2017-02-13 10:52:17 -08:00
Slava Pestov
890958ebfd SILOptimizer: Fix bug in closure specialization with resilient build
Fixes <rdar://problem/30480013>.
2017-02-12 23:39:07 -08:00
Roman Levenstein
199e76d6d4 Fixes for a lookup of functions by name
Among other things it fixes a bug in the function signature optimization where it would use an already existing mangled name for a different function
2017-02-10 18:07:30 -08:00
Roman Levenstein
ec4f28eff2 Teach EagerSpecializer how to use the new form of the @_specialize attribute
In addition to supporting the creation of full specializations, the EagerSpecializer changes contain some code for generating the layout-constrained partial specializations as well.
2017-02-08 01:08:09 -08:00
Roman Levenstein
26c963f27b Generic specializer API changes to prepare for the new @_specialize attribute and partial specializations. 2017-02-07 23:16:00 -08:00
Slava Pestov
3519e0cd25 AST: Introduce new SubstitutionList type to replace ArrayRef<Substitution>
SubstitutionList is going to be a more compact representation of
a SubstitutionMap, suitable for inline allocation inside another
object.

For now, it's just a typedef for ArrayRef<Substitution>.
2017-02-06 21:36:33 -08:00
Adrian Prantl
4d1ae142c6 Remove the redundant DeclCtx field in SILFunction.
In all cases the DeclCtx field was supposed to be initialized from the
SILLocation of the function, so we can save one pointer per
SILFunction.

There is one test case change where a different (more precise)
diagnostic is being generated after this change.
2017-02-06 11:07:50 -08:00