[move-only] Add the ability to specify a deinit at the SIL level for a move only type.

Specifically, we get an additional table like thing called sil_moveonlydeinit. It looks as follows:

sil_moveonlydeinit TYPE {
  @FUNC_NAME
}

It always has a single entry.
This commit is contained in:
Michael Gottesman
2022-09-16 11:53:17 -07:00
parent 182df6e80d
commit c54acc83e2
24 changed files with 561 additions and 22 deletions

View File

@@ -11,12 +11,15 @@
//===----------------------------------------------------------------------===//
#define DEBUG_TYPE "serialized-sil-loader"
#include "swift/Serialization/SerializedSILLoader.h"
#include "DeserializeSIL.h"
#include "ModuleFile.h"
#include "swift/Serialization/SerializedModuleLoader.h"
#include "swift/SIL/SILModule.h"
#include "swift/AST/ASTMangler.h"
#include "swift/SIL/SILModule.h"
#include "swift/SIL/SILMoveOnlyDeinit.h"
#include "swift/Serialization/SerializedModuleLoader.h"
#include "swift/Serialization/SerializedSILLoader.h"
#include "llvm/Support/Debug.h"
using namespace swift;
@@ -108,6 +111,18 @@ SILVTable *SerializedSILLoader::lookupVTable(const ClassDecl *C) {
return nullptr;
}
SILMoveOnlyDeinit *
SerializedSILLoader::lookupMoveOnlyDeinit(const NominalTypeDecl *nomDecl) {
Mangle::ASTMangler mangler;
std::string mangledClassName = mangler.mangleNominalType(nomDecl);
for (auto &des : LoadedSILSections) {
if (auto *tbl = des->lookupMoveOnlyDeinit(mangledClassName))
return tbl;
}
return nullptr;
}
SILWitnessTable *SerializedSILLoader::lookupWitnessTable(SILWitnessTable *WT) {
for (auto &Des : LoadedSILSections)
if (auto wT = Des->lookupWitnessTable(WT))