mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[IRGen] Move marker protocol stripping from mangleTypeSymbol to mangleTypeForFlatUniqueTypeRef
The original check introduced by https://github.com/apple/swift/pull/71855 is too broad. For concrete metadata we call the runtime demangler so we need to strip off marker protocols when mangling that string and `mangleTypeForReflection` already does that.
This commit is contained in:
@@ -186,6 +186,9 @@ IRGenMangler::mangleTypeForFlatUniqueTypeRef(CanGenericSignature sig,
|
||||
// mangled name.
|
||||
configureForSymbolicMangling();
|
||||
|
||||
llvm::SaveAndRestore<bool> savedAllowMarkerProtocols(
|
||||
AllowMarkerProtocols, false);
|
||||
|
||||
// We don't make the substitution adjustments above because they're
|
||||
// target-specific and so would break the goal of getting a unique
|
||||
// string.
|
||||
|
||||
@@ -706,9 +706,6 @@ protected:
|
||||
llvm::function_ref<void ()> body);
|
||||
|
||||
std::string mangleTypeSymbol(Type type, const char *Op) {
|
||||
llvm::SaveAndRestore<bool> savedAllowMarkerProtocols(AllowMarkerProtocols,
|
||||
false);
|
||||
|
||||
beginMangling();
|
||||
appendType(type, nullptr);
|
||||
appendOperator(Op);
|
||||
|
||||
@@ -14,7 +14,7 @@ extension Int: P { }
|
||||
extension Array: P where Element: P { }
|
||||
|
||||
// No mention of the marker protocol for runtime type instantiation.
|
||||
// CHECK-LABEL: @"$sSS_yptMD" =
|
||||
// CHECK-LABEL: @"$sSS_15marker_protocol1P_ptMD" =
|
||||
// CHECK-SAME: @"symbolic SS_ypt"
|
||||
|
||||
// CHECK-LABEL: @"$s15marker_protocol1QMp" = {{(dllexport |protected )?}}constant
|
||||
@@ -47,7 +47,7 @@ struct HasMarkers {
|
||||
|
||||
// Note: no mention of marker protocols when forming a dictionary.
|
||||
// CHECK-LABEL: define{{.*}}@"$s15marker_protocol0A12InDictionaryypyF"
|
||||
// CHECK: call ptr @__swift_instantiateConcreteTypeFromMangledName({{.*}} @"$sSS_yptMD")
|
||||
// CHECK: call ptr @__swift_instantiateConcreteTypeFromMangledName({{.*}} @"$sSS_15marker_protocol1P_ptMD")
|
||||
public func markerInDictionary() -> Any {
|
||||
let dict: [String: P] = ["answer" : 42]
|
||||
return dict
|
||||
@@ -92,7 +92,7 @@ let v1 = (any C & P).self
|
||||
let v2 = C.self
|
||||
|
||||
// CHECK-LABEL: define hidden swiftcc void @"$s15marker_protocol23testProtocolCompositionyyF"()
|
||||
// CHECK: [[V1:%.*]] = call ptr @__swift_instantiateConcreteTypeFromMangledName(ptr @"$s15marker_protocol1CCMD")
|
||||
// CHECK: [[V1:%.*]] = call ptr @__swift_instantiateConcreteTypeFromMangledName(ptr @"$s15marker_protocol1P_AA1CCXcMD")
|
||||
// CHECK: [[V2:%.*]] = load ptr, ptr @"$s15marker_protocol2v2AA1CCmvp"
|
||||
func testProtocolComposition() {
|
||||
print(v1 == v2)
|
||||
|
||||
@@ -20,8 +20,8 @@ protocol R { }
|
||||
// Suppress marker protocols when forming existentials at runtime
|
||||
public func takeAnyType<T>(_: T.Type) { }
|
||||
|
||||
// CHECK-LABEL: define {{.*}}@"$s26marker_protocol_backdeploy1Q_AA1RpMa"
|
||||
// CHECK: $s26marker_protocol_backdeploy1Q_AA1RpML
|
||||
// CHECK-LABEL: define {{.*}}@"$ss8Sendable_26marker_protocol_backdeploy1QAB1RpMa"
|
||||
// CHECK: ss8Sendable_26marker_protocol_backdeploy1QAB1RpML
|
||||
// CHECK-NOT: Sendable
|
||||
// CHECK: s26marker_protocol_backdeploy1QMp
|
||||
// CHECK-NOT: Sendable
|
||||
|
||||
@@ -50,4 +50,11 @@ do {
|
||||
|
||||
print((AnyObject & Sendable & Marker).self)
|
||||
// CHECK: AnyObject
|
||||
|
||||
func generic<T>(_: T.Type) {
|
||||
print((D<T> & Sendable).self)
|
||||
}
|
||||
|
||||
generic(Int.self)
|
||||
// CHECK: D<Int>
|
||||
}
|
||||
|
||||
27
test/Interpreter/rdar128667580.swift
Normal file
27
test/Interpreter/rdar128667580.swift
Normal file
@@ -0,0 +1,27 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: split-file %s %t
|
||||
|
||||
// RUN: %target-clang %t/Impl.m -c -o %t/Test.o
|
||||
// RUN: %target-build-swift %t/main.swift -import-objc-header %t/Test.h %t/Test.o -Xfrontend -disable-concrete-type-metadata-mangled-name-accessors -o %t/main
|
||||
// RUN: %target-codesign %t/main
|
||||
// RUN: %target-run %t/main | %FileCheck %s
|
||||
|
||||
// REQUIRES: executable_test
|
||||
// REQUIRES: objc_interop
|
||||
// REQUIRES: concurrency
|
||||
|
||||
//--- Test.h
|
||||
#import "Foundation/Foundation.h"
|
||||
|
||||
@interface Test : NSObject { }
|
||||
@end
|
||||
|
||||
//--- Impl.m
|
||||
#import "Test.h"
|
||||
|
||||
@implementation Test
|
||||
@end
|
||||
|
||||
//--- main.swift
|
||||
print((any Test & Sendable).self)
|
||||
// CHECK: Test
|
||||
Reference in New Issue
Block a user