Skip to content

Commit a7b4e0f

Browse files
authored
Merge pull request #17539 from huonw/tbd-thunk-specialization
[SILOptimizer] Properly disconnect the signature optimized function from a parent class.
2 parents 33e547c + 85424c0 commit a7b4e0f

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

lib/SILOptimizer/FunctionSignatureTransforms/FunctionSignatureOpts.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,11 +496,14 @@ void FunctionSignatureTransform::createFunctionSignatureOptimizedFunction() {
496496
NewFGenericEnv = nullptr;
497497
}
498498

499+
// The specialized function is an internal detail, so we need to disconnect it
500+
// from a parent class, if one exists, thus the override of the
501+
// classSubclassScope.
499502
TransformDescriptor.OptimizedFunction = M.createFunction(
500503
linkage, Name, NewFTy, NewFGenericEnv, F->getLocation(), F->isBare(),
501504
F->isTransparent(), F->isSerialized(), F->getEntryCount(), F->isThunk(),
502-
F->getClassSubclassScope(), F->getInlineStrategy(), F->getEffectsKind(),
503-
nullptr, F->getDebugScope());
505+
/*classSubclassScope=*/SubclassScope::NotApplicable,
506+
F->getInlineStrategy(), F->getEffectsKind(), nullptr, F->getDebugScope());
504507
SILFunction *NewF = TransformDescriptor.OptimizedFunction.get();
505508
if (!F->hasQualifiedOwnership()) {
506509
NewF->setUnqualifiedOwnership();

test/TBD/specialization.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ open class Foo {
1717
}
1818

1919
open class Bar<T> {
20+
public init() {
21+
bar()
22+
}
23+
2024
@inline(never)
2125
fileprivate func bar() {}
2226
}
@@ -28,8 +32,14 @@ public func f() {
2832
}
2933

3034

35+
// Generic specialization, from the foo call in f
3136
// CHECK-LABEL: // specialized Foo.foo<A>(_:)
3237
// CHECK-NEXT: sil private [noinline] @$S14specialization3FooC3foo33_A6E3E43DB6679655BDF5A878ABC489A0LLyyxmlFSi_Tg5Tf4dd_n : $@convention(thin) () -> ()
3338

39+
// Function signature specialization, from the bar call in Bar.init
40+
// CHECK-LABEL: // specialized Bar.bar()
41+
// CHECK-NEXT: sil private [noinline] @$S14specialization3BarC3bar33_A6E3E43DB6679655BDF5A878ABC489A0LLyyFTf4d_n : $@convention(thin) () -> () {
42+
43+
// Generic specialization, from the bar call in f
3444
// CHECK-LABEL: // specialized Bar.bar()
3545
// CHECK-NEXT: sil private [noinline] @$S14specialization3BarC3bar33_A6E3E43DB6679655BDF5A878ABC489A0LLyyFSi_Tg5Tf4d_n : $@convention(thin) () -> ()

0 commit comments

Comments
 (0)