Commit Graph

75 Commits

Author SHA1 Message Date
Slava Pestov
9ffe12dad2 SIL: Better error when linker finds SILGen did not emit a conformance
I hit this assert a few times while working on making conformance
emission lazier, so let's at least print out the missing conformance
in question.
2019-04-25 22:22:27 -04:00
Slava Pestov
5062a81e3d AST: Start returning SelfProtocolConformances from ModuleDecl::lookupConformance()
Fixes <rdar://problem/49241923>, <https://bugs.swift.org/browse/SR-10015>.
2019-04-16 23:02:50 -04:00
Slava Pestov
d413806c71 SIL: Simplify SILLinkerVisitor::visitProtocolConformance()
Now that SILModule::lookUpWitnessTable() can create a declaration
if needed, we don't have to call it twice.
2018-12-20 17:36:38 -05:00
Slava Pestov
d7bd07112b SIL: Change the linker to deserialize more lazily
Note that SILModule::lookUpWitnessTable() only attempts to deserialize
the witness table if we already have a declaration. In the
SILLinkerVisitor, we would call lookUpWitnessTable(), see if it returned
null, create a declaration, and if deserializeLazily is true, we would
call lookUpWitnessTable() again; this time, there was a declaration, and
we would deserialize the witness table.

However, if there was already a witness table declaration when we first
called lookUpWitnessTable(), we would trigger deserialization, even if
deserializeLazily is false.

Change the first call to pass false.

I had to update a couple of tests; I believe they were already somewhat
nonsensical.
2018-12-20 17:36:38 -05:00
Slava Pestov
39c93b9f85 SIL: Remove linkage parameter from SILModule::createWitnessTableDeclaration()
All callers were doing the same thing here, so move it inside the
function. Also, change getRootNormalConformance(), which is deprecated,
to getRootConformance().
2018-12-20 17:36:38 -05:00
Arnold Schwaighofer
7e32c68e1d Add new SIL instruction for calling dynamically_replaceable funtions
%0 = dynamic_function_ref @dynamically_replaceable_function
  apply %0()
  Calls a [dynamically_replaceable] function.

  %0 = prev_dynamic_function_ref @dynamic_replacement_function
  apply %0
  Calls the previous implementation that dynamic_replacement_function
  replaced.
2018-11-06 09:53:22 -08:00
Ben Rimmington
1aa41174a9 [SIL Linker] Remove applyInstCalleeIsGeneric 2018-08-31 09:45:57 +01:00
Robert Widmann
014fd952ef [NFC] Silence a bunch of Wunused-variable diagnostics 2018-08-24 15:16:40 -07:00
Slava Pestov
7004f9af13 SIL: Simplify SILLinkerVisitor::visitApplySubstitutions()
We don't have to ask the substitution map to do lookups, just iterate
over the conformances directly.
2018-08-12 23:00:52 -07:00
Michael Gottesman
c2161435fe [gardening] Fix comment header of Link.cpp. NFC.
There was a blank line in the middle of the header...
2018-08-10 12:23:51 -07:00
Bob Wilson
8e330ee344 NFC: Fix indentation around the newly renamed LLVM_DEBUG macro.
Jordan used a sed command to rename DEBUG to LLVM_DEBUG. That caused some
lines to wrap and messed up indentiation for multi-line arguments.
2018-07-21 00:56:18 -07:00
Jordan Rose
cefb0b62ba Replace old DEBUG macro with new LLVM_DEBUG
...using a sed command provided by Vedant:

$ find . -name \*.cpp -print -exec sed -i "" -E "s/ DEBUG\(/ LLVM_DEBUG(/g" {} \;
2018-07-20 14:37:26 -07:00
Slava Pestov
ebb1198d57 AST: There's no longer any reason to pass SubstitutionMap by const reference
SubstitutionMaps are now just a trivial pointer-sized value, so
pass them by value instead.

I did have to move a couple of functors from Type.h to SubstitutionMap.h
to resolve some issues with forward declarations.
2018-05-19 00:45:36 -07:00
Doug Gregor
d457f1c752 [IRGen/SIL] More widespread use of SubstitutionMap. 2018-05-11 13:18:06 -07:00
Slava Pestov
1bc56840e1 SIL: Remove unused LinkingMode::LinkNone 2018-04-17 15:10:41 -07:00
Slava Pestov
a2df485bf3 SIL Linker: Only link non-public functions in LinkNormal mode
LinkNormal mode is used by the mandatory pipeline. It only needs
to deserialize what is necessary for code generation, that is
functions with shared linkage that must be emitted into the client.
2018-04-16 19:31:12 -07:00
Slava Pestov
1bd8ca58a8 SIL Linker: Deserialize HiddenExternal functions
PublicNonABI function declarations deserialize as HiddenExternal,
then become SharedExternal after the body has been deserialized.
So try deserializing HiddenExternal too.

NFC until mandatory inlining is no longer eagerly deserializing.
2018-04-16 16:18:50 -07:00
Andrew Trick
39de8c7aed Revert "Mandatory SIL linker pass" 2018-04-14 16:41:34 -07:00
Slava Pestov
c0aebf633f SIL Linker: Redo calculation of result value of processFunction()
Instead of threading a boolean through the whole visitor, just
set an instance variable when we do deserialize something.

Note that previously, processFunction() almost always returned
true. As a result, the SILLinker pass would call invalidateAnalysis()
for every function with a body. Fixing this changed optimizer
output in one test; this warrants further investigation.
2018-04-13 17:06:33 -07:00
Slava Pestov
2ac1f8a11d SIL Linker: Deserialize HiddenExternal functions
PublicNonABI function declarations deserialize as HiddenExternal,
then become SharedExternal after the body has been deserialized.
So try deserializing HiddenExternal too.

NFC until mandatory inlining is no longer eagerly deserializing.
2018-04-13 14:22:15 -07:00
Slava Pestov
aabbdbe0e6 SIL Linker: Use SILModule::loadFunction()
This means SILLinkerVisitor no longer depends on the SILLoader;
the latter is now just an implementation detail of SILModule.
2018-04-12 18:59:16 -07:00
Slava Pestov
0039f25483 SIL Linker: Clean up processFunction()
Now that addFunctionToWorklist() immediately deserializes,
we can re-use it here.
2018-04-12 18:07:03 -07:00
Slava Pestov
9b483371f4 SIL Linker: Remove one of the two worklists
The second worklist was immediately drained after visiting each

SIL instruction, so it didn't really avoid any recursion.
Simplify the control flow by immediately deserializing the
function and then adding it to the primary worklist.
2018-04-12 18:07:03 -07:00
Slava Pestov
6a01e2d354 SIL Linker: Factor out maybeAddFunctionToWorklist()
The check to see if a function should be added to the worklist was
repeated in a few places.
2018-04-12 18:07:03 -07:00
Slava Pestov
9a40305538 SIL Linker: Remove redundant code from linkInVTable()
SILModule::lookUpVTable() already deserializes the vtable if
necessary, we don't have to do it again here.
2018-04-11 21:24:32 -07:00
Slava Pestov
54e608a427 SIL Linker: Remove processClassDecl()
This was completely dead code. Note that it was adding vtable
entries to the wrong worklist -- any functions on 'Worklist'
are not deserialized, only the functions *they reference* are
deserialized. So adding an external declaration to 'Worklist'
accomplishes nothing.
2018-04-11 20:15:38 -07:00
Slava Pestov
f73699b7a9 SIL Linker: Don't link vtables in LinkNormal mode
Mandatory inlining performs devirtualization, which is able
to deserialize vtables on its own. And since class methods
cannot be @_transparent, we don't have to deserialize any
vtable entries unless we're in LinkAll mode, which indicates
we're running the performance pipeline.
2018-04-11 20:15:36 -07:00
Slava Pestov
755e98dbe5 SIL Linker: Remove unnecessary code from visit{Apply,PartialApply}Inst()
We already handle linking functions in as part of the function_ref;
no need to repeat the same logic in apply and partial_apply.
2018-04-11 20:15:31 -07:00
Slava Pestov
b67783b468 SIL Linker: Also visit conformances of a try_apply
Noticed by inspection.
2018-04-11 20:15:24 -07:00
Joe Groff
c5abef647f SIL: Force Clang-imported protocol conformances to get deserialized when used.
Code may end up indirectly using a witness table for a Clang-imported type by inlining code that used the conformance from another module, in which case we need to ensure we have a local definition at hand in the inlining module so we can have something to link against independently. This needs to be fixed from both sides:

- During serialization, serialize not only witness tables from the current module, but from Clang-imported modules too
- During deserialization, when the SILLinker walks a loaded module, ensure that all shared conformances get deserialized, including those from ApplyInsts and inherited/associated type protocol requirements.

Fixes rdar://problem/38687726.
2018-04-04 14:41:13 -07:00
Slava Pestov
38817f7a2d SIL: Refactor the linker a bit 2018-04-01 02:27:36 -07:00
Mark Lacey
21134efd22 Revert "IRGen: Deserialize SIL witness tables and shared-linkage definitions by need." 2018-03-30 22:14:13 -07:00
Joe Groff
ae2d2973d1 IRGen: Deserialize SIL witness tables and shared-linkage definitions by need.
Code may end up indirectly using a witness table for a Clang-imported type by inlining code that used the conformance from another module, in which case we need to ensure we have a local definition at hand in the inlining module so we can have something to link against independently. This needs to be fixed from both sides:

- During serialization, serialize not only witness tables from the current module, but from Clang-imported modules too, so that their definitions can be used by other modules that inline code from the current module
- During IRGen, when we emit a reference to a SILWitnessTable or SILFunction declaration with shared linkage, attempt to deserialize the definition on demand

Fixes rdar://problem/38687726.
2018-03-30 11:12:58 -07:00
Joe Shajrawi
b258e973e5 SIL Linker: clear the [serialized] flag when deserializing a function into a module that's already had the serialized flag stripped out. 2017-12-14 10:34:34 -08:00
Slava Pestov
c272d41e2f Re-apply "SIL: Remove special meaning for @_semantics("stdlib_binary_only")"
With -sil-serialize-all gone, this no longer means anything; just
don't declare the function as @_inlineable instead.

Fixes <rdar://problem/34564380>.
2017-10-04 14:07:52 -07:00
Jordan Rose
aab5f7aa4f Revert "SIL: Remove special meaning for @_semantics("stdlib_binary_only")" (#12270)
It still affects StdlibUnittest, which is still using -sil-serialize-all.
2017-10-04 12:49:21 -07:00
Slava Pestov
0fad13eeba SIL: Remove special meaning for @_semantics("stdlib_binary_only")
With -sil-serialize-all gone, this no longer means anything; just
don't declare the function as @_inlineable instead.

Fixes <rdar://problem/34564380>.
2017-10-03 13:48:22 -07:00
Slava Pestov
af11149550 SIL: Implement the [serialized] vs [serializable] distinction
This generalizes a hack where re-abstraction thunks become fragile on contact
with fragile functions.

The old policy was:

- [fragile] functions always serialized
- [reabstraction_thunk] transitively referenced from fragile always serialized

The new policy is:

- [serialized] functions always serialized
- [serializable] functions transitively referenced from serialized functions
  are always serialized
- Most kinds of thunks can now be [serializable], allowing them to be shared
  between serialized and non-serialized code without any issues, as long as the
  body of the thunk is sufficiently "simple" (doesn't reference private
  symbols or performs direct access to resilient types)
2017-03-29 20:09:35 -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
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
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
Slava Pestov
c86b5ae427 AST: Header file gardening - include what you use 2017-01-19 20:07:06 -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
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01: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
Erik Eckstein
a01e9d4e41 Remove dead code in SIL linker
... which is not only dead but also broken.
NFC
2016-11-02 10:30:10 -07:00
practicalswift
51281e6fd3 [gardening] Fix spacing. 2016-04-14 09:51:27 +02:00
Roman Levenstein
9234eb3ca7 [sil-linker] Improve the implementation of the hasSILFunction API
It it now possible to check if a function with a given name and a given linkage exists in one of the modules,
even if the current module contains a function with this name but a difference linkage.
This is useful e.g. for performing a lookup of pre-specializations.
2016-04-13 15:46:57 -07:00