Commit Graph

63 Commits

Author SHA1 Message Date
Hugh Bellamy
f001b7562b Use relatively new LLVM_FALLLTHROUGH instead of our own SWIFT_FALLTHROUGH 2017-02-12 10:47:03 +07:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Erik Eckstein
8284688ab1 BasicCalleeAnalysis: fix the handling of allocator class methods.
It can result in a runtime crash.
This comes up when using required initializers.

fixes rdar://problem/29398625
2017-01-04 14:39:10 -08:00
Slava Pestov
064fda52d2 AST: Remove Type::getCanonicalTypeOrNull()
Not sure why but this was another "toxic utility method".
Most of the usages fell into one of three categories:

- The base value was always non-null, so we could just call
  getCanonicalType() instead, making intent more explicit

- The result was being compared for equality, so we could
  skip canonicalization and call isEqual() instead, removing
  some boilerplate

- Utterly insane code that made no sense

There were only a couple of legitimate uses, and even there
open-coding the conditional null check made the code clearer.

Also while I'm at it, make the SIL open archetypes tracker
more typesafe by passing around ArchetypeType * instead of
Type and CanType.
2017-01-04 01:08:29 -08:00
Jordan Rose
81e2638c09 [SILOpt] Don't do callee analysis on destructors of imported classes. (#6313)
If by chance we haven't imported the members of a particular class,
SIL should not fault them in if at all possible.

The test case was a pain to come up with; it involves a class using
a forward-declared protocol that's actually defined in Swift /in a
non-primary file/, where that protocol is never mentioned in the
primary file and the class's members are never accessed otherwise.

rdar://problem/29535170
2016-12-21 13:13:56 -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
Graydon Hoare
a5c1fb4e2a [Compile Perf] Add scale-test for BasicCalleeAnalysis, rdar://29279532 2016-11-17 11:58:58 -08:00
Roman Levenstein
4433ad9c3c [sil-optimizer] Teach analysis passes that some instructions besides apply may result in a function call.
For example, strong_release may call a destructor. This information will be used e.g. by the escape analysis.
As destructors are potential calles now, FunctionOrder analysis will make sure that they will be scheduled for optimizations before their callers.
2016-09-15 22:10:25 -07:00
Slava Pestov
772cf3a2fa SIL Optimizer: More principled substitution remapping in devirtualizer
When devirtualizing witness method and class method calls, we
transform apply instructions operating on the result of a SIL
witness_method or class_method instruction to direct calls of
a function_ref.

The generic signature of the dynamic call site might not match
the generic signature of the static thunk, so the substitution
list from the dynamic apply instruction cannot be used directly;
instead, we must transform it to a substitution list suitable
for the static thunk.

- With witness methods, the method is called using the protocol
  requirement's signature, <Self : P, ...>, however the
  witness thunk has a generic signature derived from the
  concrete witness.

  For example, the requirement might have a signature
  <Self : P, T>, where the concrete witness thunk might
  have a signature <X, Y>, where the concrete conforming type
  is G<X, Y>.

  At the call site, we substitute Self := G<X', Y'>; however
  to be able to call the witness thunk directly, we need to
  form substitutions X := X' and Y := Y'.

- A similar situation occurs with class methods when the
  dynamically-dispatched call is performed against a derived
  class, but devirtualization actually finds the method on a
  base class of the derived class.

  The base class may have a different number of generic
  parameters than the derived class, either because the
  derived class makes some generic parameters of the base
  class concrete, or if the derived class introduces new
  generic parameters of its own.

In both cases, we need to consider the generic signature of the
dynamic call site (the protocol requirement or the derived
class method) as well as the generic signature of the static
thunk, and carefully remap the substitutions from one form
into another.

Previously the optimizer would implicitly rely on substitutions
being in AllArchetypes order, in particular that concatenating
outer substitutions with inner substitutions makes sense.

This assumption is about to go away, so this patch refactors
the optimizer to use some new abstractions for remapping
substitution lists.
2016-09-06 11:51:13 -07:00
Mark Lacey
921dededad Use a bump pointer allocator in the callee set creation.
Shaves about 19% of the time from the construction of these sets. The
SmallVector size was chosen to minimize the number of dynamic
allocations we end up doing while building the stdlib. This should be a
reasonable size for most projects, too. It's a bit wasteful in space,
but the total amount of allocated space here is pretty small to begin
with.
2016-05-11 17:07:27 -07:00
practicalswift
1339b5403b Consistent use of header comment format.
Correct format:
//===--- Name of file - Description ----------------------------*- Lang -*-===//
2016-01-04 13:26:31 +01:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Andrew Trick
739b0e9c56 Reorganize SILOptimizer directories for better discoverability.
(libraries now)

It has been generally agreed that we need to do this reorg, and now
seems like the perfect time. Some major pass reorganization is in the
works.

This does not have to be the final word on the matter. The consensus
among those working on the code is that it's much better than what we
had and a better starting point for future bike shedding.

Note that the previous organization was designed to allow separate
analysis and optimization libraries. It turns out this is an
artificial distinction and not an important goal.
2015-12-11 15:14:23 -08:00