Skip to content

Commit 3ad2777

Browse files
committed
[IRGen] Erase nonoverride descriptor on emission.
Previously, emitting the descriptor for a nonoverride method always simply emitted, even if it had previously been emitted. That was not a problem before, but is now that class type context descriptors can be reemitted upon encountering metadata prespecializations. Here, the behavior is changed to delete the old definition before emitting the new definition.
1 parent c25c180 commit 3ad2777

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/IRGen/GenMeta.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,10 @@ static void buildMethodDescriptorFields(IRGenModule &IGM,
300300

301301
void IRGenModule::emitNonoverriddenMethodDescriptor(const SILVTable *VTable,
302302
SILDeclRef declRef) {
303+
auto entity = LinkEntity::forMethodDescriptor(declRef);
304+
305+
auto *var = cast<llvm::GlobalVariable>(getAddrOfLLVMVariable(entity, ConstantInit(), DebugTypeInfo()));
306+
var->setInitializer(nullptr);
303307

304308
ConstantInitBuilder ib(*this);
305309
ConstantStructBuilder sb(ib.beginStruct(MethodDescriptorStructTy));
@@ -308,7 +312,6 @@ void IRGenModule::emitNonoverriddenMethodDescriptor(const SILVTable *VTable,
308312

309313
auto init = sb.finishAndCreateFuture();
310314

311-
auto entity = LinkEntity::forMethodDescriptor(declRef);
312315
getAddrOfLLVMVariable(entity, init, DebugTypeInfo());
313316
}
314317

0 commit comments

Comments
 (0)