[IRGen] Erase thunks before emission.

Previously, a call to emitMethodLookupFunction or emitDispatchThunk
would always simply emit a function, even if it had previously been
emitted.  That was a problem since these emissions are triggered by
emitting class type context descriptors which can now be lazily
reemitted upon encountering prespecialized metadata.

Here, that behavior is changed to delete the old body, if any, before
emitting the body again.
This commit is contained in:
Nate Chandler
2020-08-12 18:20:19 -07:00
parent 665100d74f
commit c25c180c08

View File

@@ -102,6 +102,9 @@ static FunctionPointer lookupMethod(IRGenFunction &IGF, SILDeclRef declRef) {
void IRGenModule::emitDispatchThunk(SILDeclRef declRef) { void IRGenModule::emitDispatchThunk(SILDeclRef declRef) {
auto *f = getAddrOfDispatchThunk(declRef, ForDefinition); auto *f = getAddrOfDispatchThunk(declRef, ForDefinition);
if (!f->isDeclaration()) {
f->deleteBody();
}
IRGenFunction IGF(*this, f); IRGenFunction IGF(*this, f);
@@ -163,6 +166,9 @@ IRGenModule::getAddrOfMethodLookupFunction(ClassDecl *classDecl,
void IRGenModule::emitMethodLookupFunction(ClassDecl *classDecl) { void IRGenModule::emitMethodLookupFunction(ClassDecl *classDecl) {
auto *f = getAddrOfMethodLookupFunction(classDecl, ForDefinition); auto *f = getAddrOfMethodLookupFunction(classDecl, ForDefinition);
if (!f->isDeclaration()) {
f->deleteBody();
}
IRGenFunction IGF(*this, f); IRGenFunction IGF(*this, f);