Skip to content

Commit c25c180

Browse files
committed
[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.
1 parent 665100d commit c25c180

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Diff for: lib/IRGen/GenThunk.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ static FunctionPointer lookupMethod(IRGenFunction &IGF, SILDeclRef declRef) {
102102

103103
void IRGenModule::emitDispatchThunk(SILDeclRef declRef) {
104104
auto *f = getAddrOfDispatchThunk(declRef, ForDefinition);
105+
if (!f->isDeclaration()) {
106+
f->deleteBody();
107+
}
105108

106109
IRGenFunction IGF(*this, f);
107110

@@ -163,6 +166,9 @@ IRGenModule::getAddrOfMethodLookupFunction(ClassDecl *classDecl,
163166

164167
void IRGenModule::emitMethodLookupFunction(ClassDecl *classDecl) {
165168
auto *f = getAddrOfMethodLookupFunction(classDecl, ForDefinition);
169+
if (!f->isDeclaration()) {
170+
f->deleteBody();
171+
}
166172

167173
IRGenFunction IGF(*this, f);
168174

0 commit comments

Comments
 (0)