Commit Graph

15 Commits

Author SHA1 Message Date
Slava Pestov
9ec80df97e SIL: Remove curried SILDeclRefs 2020-03-19 02:20:21 -04:00
Slava Pestov
866f316e07 SILOptimizer: Simplify dead method elimination
We used to look at the vtable entry's linkage to determine if the
vtable entry was dead, in case the vtable entry linkage was more
visible than the method being overridden.

This hack is no longer needed now that a method override more
visible than its base introduces a new vtable entry.
2019-06-09 15:54:05 -07:00
Erik Eckstein
39bb14b094 change mangling prefix from $S to $s
This is the final ABI mangling prefix

rdar://problem/38471478
2018-09-19 13:55:11 -07:00
Slava Pestov
1831b5471e SIL: Clean up 'early serialization' a bit
- Clear the 'serialized' flag on witness tables and vtables
  after serialization, not just functions. This fixes SIL
  verifier failures if post-serialization SIL is printed
  out and parsed back in.

- Clear the 'serialized' flag when deserializing functions,
  witness tables and vtables in a module that has already
  been serialized. This fixes SIL verifier failures if
  we deserialize more declarations after serializing SIL.

We were seeing SIL verifier failures on bots that run the
tests with the stdlib built with non-standard flags.

Unfortunately I don't have a reduced test case that would
fail in PR testing without these fixes.

Fixes <rdar://problem/36682929>.
2018-01-21 01:35:13 -08:00
Erik Eckstein
cd3d50a5d9 ABI: Change the mangling prefix from _T0 to $S 2018-01-06 13:55:59 -08:00
Erik Eckstein
ca67b43bf2 SIL: Print the '@' prefix for function names in sil_vtables.
This is needed for supporting $-prefixed SIL names and it's also consistent with the witness table syntax.
2018-01-05 11:29:15 -08:00
Pavel Yaskevich
f90d943a29 [Mangling/ABI] NFC: Fix SILOptimizer tests to reflect label mangling changes 2017-12-18 15:45:50 -08:00
Roman Levenstein
74915682cb Update tests after the removal of -sil-serialize-vtables 2017-10-21 19:18:15 -07:00
Slava Pestov
556d35d9b1 SIL: Record whether vtable entries are inherited or overridden
Consider a class hierarchy like the following:

class Base {
  func m1() {}
  func m2() {}
}

class Derived : Base {
  override func m2() {}
  func m3() {}
}

The SIL vtable for 'Derived' now records that the entry for m1
is inherited, the entry for m2 is an override, and the entry
for m3 is a new entry:

sil_vtable Derived {
  #Base.m1!1: (Base) -> () -> () : _T01a4BaseC2m1yyF [inherited]
  #Base.m2!1: (Base) -> () -> () : _T01a7DerivedC2m2yyF [override]
  #Derived.m3!1: (Derived) -> () -> () : _T01a7DerivedC2m3yyF
}

This additional information will allow IRGen to emit the vtable
for Derived resiliently, without referencing the symbol for
the inherited method m1() directly.
2017-08-14 19:50:34 -04:00
Erik Eckstein
789646a15b Demangling: Make demangled names more readable and further reduce the size of the simplified demangled names
The goal here is to make the short demangling as short and readable as possible, also at the cost of omitting some information.
The assumption is that whenever the short demangling is displayed, there is a way for the user to also get the full demangled name if needed.

*) omit <where ...> because it does not give useful information anyway

Deserializer.deserialize<A where ...> () throws -> [A]
--> Deserializer.deserialize<A> () throws -> [A]

*) for multiple specialized functions only emit a single “specialized”

specialized specialized Constructible.create(A.Element) -> Constructible<A>
--> specialized Constructible.create(A.Element) -> Constructible<A>

*) Don’t print function argument types:

foo(Int, Double, named: Int)
--> foo(_:_:named:)

This is a trade-off, because it can lead to ambiguity if there are overloads with different types.

*) make contexts of closures, local functions, etc. more readable by using “<a> in <b>” syntax
This is also done for the full and not only for the simplified demangling.

Renderer.(renderInlines([Inline]) -> String).(closure #1)
--> closure #1 in Renderer.renderInlines

*) change spacing, so that it matches our coding style:

foo <A> (x : A)
--> foo<A>(x: A)
2017-04-13 08:43:28 -07:00
Slava Pestov
e912f27944 AST/SILGen: New mangling for vtable thunks
Simply mangling the derived method is no longer sufficient. Now also
mangle the base method, so that eventually we handle this sort of
scenario:

class Base {
  // introduces: Base.method
  func method(_: Int, _: Int) {}
}

class First : Base {
  // overrides: Base.method
  // introduces: First.method
  override func method(_: Int?, _: Int) {}
}

class Second : First {
  // overrides: Base.method, First.method
  // introduces: Second.method
  override func method(_: Int?, _: Int?) {}
}

Here, the override of Base.method by Second.method and the
override of First.method by Second.method require distinct
manglings even though the derived method (Second.method) is
the same in both cases.

Note that while the new mangling is longer, vtable thunks are
always emitted with private linkage, so with the exception of
the standard library which is built with -sil-serialize-all
they will not affect the size of dylibs.

The standard library itself has very few classes so it doesn't
matter there either.

This patch doesn't actually add any support to introduce new
vtable entries for methods that override; this is coming up
next.
2017-03-23 23:40:52 -07:00
Roman Levenstein
8ad61d5cd6 Use function signatures for SILDeclRefs in witness_tables, vtables and witness_method instructions.
Textual SIL was sometimes ambiguous when SILDeclRefs were used, because the textual representation of SILDeclRefs was the same for functions that have the same name, but different signatures.
2017-01-27 12:16:14 -08:00
Maxim Moiseev
96dc4817f3 Revert "Use function signatures for SILDeclRefs in witness_tables, vtables and witness_method instructions" 2017-01-26 16:28:57 -08:00
Roman Levenstein
bf2dcbf25e Use function signatures for SILDeclRefs in witness_tables, vtables and witness_method instructions.
Textual SIL was sometimes ambiguous when SILDeclRefs were used, because the textual representation of SILDeclRefs was the same for functions that have the same name, but different signatures.
2017-01-26 14:29:59 -08:00
Erik Eckstein
1eb3a0532b DeadFunctionElimination: don’t eliminate public methods which are called via a thunk.
For this we need to store the linkage of the “original” method implementation in the vtable.
Otherwise DeadFunctionElimination thinks that the method implementation is not public but private (which is the linkage of the thunk).

The big part of this change is to extend SILVTable to store the linkage (+ serialization, printing, etc.).

fixes rdar://problem/29841635
2017-01-06 16:06:32 -08:00