File tree Expand file tree Collapse file tree 3 files changed +11
-5
lines changed Expand file tree Collapse file tree 3 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -2191,11 +2191,17 @@ void IRGenModule::emitVTableStubs() {
21912191
21922192 if (!stub) {
21932193 // Create a single stub function which calls swift_deletedMethodError().
2194+ // Use linkonce_odr hidden to merge these symbols, except on
2195+ // COFF where the linker cannot merge them.
2196+ bool canLinkOnce = !Module.getTargetTriple ().isOSBinFormatCOFF ();
2197+ auto linkage = canLinkOnce ? llvm::GlobalValue::LinkOnceODRLinkage
2198+ : llvm::GlobalValue::InternalLinkage;
21942199 stub = llvm::Function::Create (llvm::FunctionType::get (VoidTy, false ),
2195- llvm::GlobalValue::LinkOnceODRLinkage,
2196- " _swift_dead_method_stub" ,
2200+ linkage, " _swift_dead_method_stub" ,
21972201 &Module);
2198- ApplyIRLinkage (IRLinkage::InternalLinkOnceODR).to (stub);
2202+ ApplyIRLinkage (canLinkOnce ? IRLinkage::InternalLinkOnceODR
2203+ : IRLinkage::Internal)
2204+ .to (stub);
21992205 stub->setAttributes (constructInitialAttributes ());
22002206 stub->setCallingConv (DefaultCC);
22012207 auto *entry = llvm::BasicBlock::Create (getLLVMContext (), " entry" , stub);
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ open class C {
2020// CHECK: @"$s1M1CC1i33_807E3D81CC6CDD898084F3279464DDF9LLSDySOypGvs" = hidden alias void (), ptr @_swift_dead_method_stub
2121// CHECK: @"$s1M1CC1i33_807E3D81CC6CDD898084F3279464DDF9LLSDySOypGvM" = hidden alias void (), ptr @_swift_dead_method_stub
2222
23- // CHECK: define linkonce_odr hidden void @_swift_dead_method_stub()
23+ // CHECK: define {{( linkonce_odr )?}} hidden void @_swift_dead_method_stub()
2424// CHECK: entry:
2525// CHECK: tail call void @swift_deletedMethodError()
2626
Original file line number Diff line number Diff line change @@ -10,6 +10,6 @@ class C {
1010
1111// CHECK: @"$s7zombies1CC1i33_{{.*}}vs" = hidden {{(dllexport )?}}alias void (), ptr @_swift_dead_method_stub
1212
13- // CHECK: define linkonce_odr hidden void @_swift_dead_method_stub
13+ // CHECK: define {{( linkonce_odr )?}} hidden void @_swift_dead_method_stub
1414// CHECK: entry:
1515// CHECK: tail call void @swift_deletedMethodError()
You can’t perform that action at this time.
0 commit comments