Skip to content

[6.0] AST: Remove incorrect optimization from ASTContext::getOpenedExistentialSignature() #72920

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions lib/AST/ASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5867,18 +5867,6 @@ ASTContext::getOpenedExistentialSignature(Type type, GenericSignature parentSig)
assert(parentSig || !constraint->hasTypeParameter() &&
"Interface type here requires a parent signature");

// The opened archetype signature for a protocol type is identical
// to the protocol's own canonical generic signature if there aren't any
// outer generic parameters to worry about.
if (parentSig.isNull()) {
if (const auto protoTy = dyn_cast<ProtocolType>(constraint)) {
return protoTy->getDecl()->getGenericSignature().getCanonicalSignature();
}
}

// Otherwise we need to build a generic signature that captures any outer
// generic parameters. This ensures that we keep e.g. generic superclass
// existentials contained in a well-formed generic context.
auto canParentSig = parentSig.getCanonicalSignature();
auto key = std::make_pair(constraint, canParentSig.getPointer());
auto found = getImpl().ExistentialSignatures.find(key);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// RUN: %target-swift-frontend -emit-sil -O %s -enable-experimental-feature NoncopyableGenerics | %FileCheck %s

protocol P: ~Copyable {}

@_optimize(none)
func f<T: P>(_: T) {}

public struct S: P {
@_optimize(none)
init() {}
}

// CHECK-LABEL: sil @$s44sil_combine_concrete_existential_noncopyable1gyyF : $@convention(thin) () -> () {
// CHECK: [[S_ADDR:%.*]] = alloc_stack $S
// CHECK: [[INIT_FN:%.*]] = function_ref @$s44sil_combine_concrete_existential_noncopyable1SVACycfC : $@convention(method) (@thin S.Type) -> S
// CHECK: [[S:%.*]] = apply [[INIT_FN]]({{%.*}}) : $@convention(method) (@thin S.Type) -> S
// CHECK: store [[S]] to [[S_ADDR]]
// CHECK: [[CALLEE_FN:%.*]] = function_ref @$s44sil_combine_concrete_existential_noncopyable1fyyxAA1PRzlF : $@convention(thin) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> ()
// CHECK: apply [[CALLEE_FN]]<S>([[S_ADDR]])
// CHECK: return

public func g() {
let e: any P = S()
f(e)
}