File tree Expand file tree Collapse file tree 4 files changed +30
-10
lines changed Expand file tree Collapse file tree 4 files changed +30
-10
lines changed Original file line number Diff line number Diff line change @@ -2191,11 +2191,18 @@ 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::InternalLinkage,
2196- " _swift_dead_method_stub" );
2200+ linkage, " _swift_dead_method_stub" ,
2201+ &Module);
2202+ ApplyIRLinkage (canLinkOnce ? IRLinkage::InternalLinkOnceODR
2203+ : IRLinkage::Internal)
2204+ .to (stub);
21972205 stub->setAttributes (constructInitialAttributes ());
2198- Module.getFunctionList ().push_back (stub);
21992206 stub->setCallingConv (DefaultCC);
22002207 auto *entry = llvm::BasicBlock::Create (getLLVMContext (), " entry" , stub);
22012208 auto *errorFunc = getDeletedMethodErrorFn ();
Original file line number Diff line number Diff line change 88
99// REQUIRES: concurrency
1010
11+ // Note: Windows uses internal linkage, which puts an extra step symbol before
12+ // _swift_dead_method_stub.
13+ // UNSUPPORTED: OS=windows-msvc
14+
1115//--- A.swift
1216open class C {
1317 private var i : [ ObjectIdentifier : Any ] = [ : ]
1418
1519 private func foo( ) async { }
1620}
1721
18- // CHECK: @"$s1M1CC3foo33_{{.*}}Tu" = hidden global %swift.async_func_pointer <{ {{.*}} @"$s1M1CC1i33_807E3D81CC6CDD898084F3279464DDF9LLSDySOypGvg"
22+ // CHECK: @"$s1M1CC3foo33_{{.*}}Tu" = hidden global %swift.async_func_pointer <{ {{.*}} @_swift_dead_method_stub
1923
20- // CHECK: @"$s1M1CC1i33_807E3D81CC6CDD898084F3279464DDF9LLSDySOypGvs" = hidden alias void (), ptr @"$s1M1CC1i33_807E3D81CC6CDD898084F3279464DDF9LLSDySOypGvg"
21- // CHECK: @"$s1M1CC1i33_807E3D81CC6CDD898084F3279464DDF9LLSDySOypGvM" = hidden alias void (), ptr @"$s1M1CC1i33_807E3D81CC6CDD898084F3279464DDF9LLSDySOypGvg"
24+ // CHECK: @"$s1M1CC1i33_807E3D81CC6CDD898084F3279464DDF9LLSDySOypGvs" = hidden alias void (), ptr @_swift_dead_method_stub
25+ // CHECK: @"$s1M1CC1i33_807E3D81CC6CDD898084F3279464DDF9LLSDySOypGvM" = hidden alias void (), ptr @_swift_dead_method_stub
2226
23- // CHECK: define hidden void @"$s1M1CC1i33_807E3D81CC6CDD898084F3279464DDF9LLSDySOypGvg" ()
27+ // CHECK: define {{(linkonce_odr )?}} hidden void @_swift_dead_method_stub ()
2428// CHECK: entry:
2529// CHECK: tail call void @swift_deletedMethodError()
2630
Original file line number Diff line number Diff line change 11// RUN: %target-swift-frontend -primary-file %s -O -emit-ir | %FileCheck %s
22
3+ // Note: Windows uses internal linkage, which puts an extra step symbol before
4+ // _swift_dead_method_stub.
5+ // UNSUPPORTED: OS=windows-msvc
6+
37// rdar://24121475
48// Ideally, these wouldn't be in the v-table at all; but as long as they
59// are, we need to emit symbols for them.
@@ -8,8 +12,8 @@ class C {
812 init ( i: Int ) { self . i = i }
913}
1014
11- // CHECK: @"$s7zombies1CC1i33_{{.*}}vs" = hidden {{(dllexport )?}}alias void (), ptr @"$s7zombies1CC1i33_45489CBEFBF369AB7AEE3A799A95D78DLLSivg"
15+ // CHECK: @"$s7zombies1CC1i33_{{.*}}vs" = hidden {{(dllexport )?}}alias void (), ptr @_swift_dead_method_stub
1216
13- // CHECK: define hidden void @"$s7zombies1CC1i33_45489CBEFBF369AB7AEE3A799A95D78DLLSivg"()
17+ // CHECK: define {{(linkonce_odr )?}} hidden void @_swift_dead_method_stub
1418// CHECK: entry:
1519// CHECK: tail call void @swift_deletedMethodError()
Original file line number Diff line number Diff line change @@ -56,13 +56,15 @@ public func unnecessary() -> Int64 { 5 }
5656@_neverEmitIntoClient
5757public func unusedYetThere( ) -> Int64 { 5 }
5858
59- public class PointClass {
59+ open class PointClass {
6060 public var x , y : Int
6161
6262 public init ( x: Int , y: Int ) {
6363 self . x = x
6464 self . y = y
6565 }
66+
67+ private func notUsed( ) { }
6668}
6769
6870public protocol Reflectable : AnyObject {
@@ -89,6 +91,9 @@ public func createsExistential() -> any Reflectable {
8991
9092// LIBRARY-IR-NOT: define {{.*}} @"$es27_allocateUninitializedArrayySayxG_BptBwlFSi_Tg5"
9193
94+
95+ // LIBRARY-IR: define linkonce_odr hidden void @_swift_dead_method_stub
96+
9297// LIBRARY-SIL: sil @$e7Library5helloSaySiGyF
9398// LIBRARY-SIL: sil @$e7Library8getArraySaySiGyF : $@convention(thin) () -> @owned Array<Int> {
9499
You can’t perform that action at this time.
0 commit comments