diff --git a/test/Driver/lit.local.cfg b/test/Driver/lit.local.cfg new file mode 100644 index 0000000000000..ae6a2606f1b41 --- /dev/null +++ b/test/Driver/lit.local.cfg @@ -0,0 +1,2 @@ +if not 'legacy_swift_driver' in config.available_features: + config.unsupported = True diff --git a/test/ModuleInterface/convenience-init-merge-module.swift b/test/ModuleInterface/convenience-init-merge-module.swift new file mode 100644 index 0000000000000..c58a597659986 --- /dev/null +++ b/test/ModuleInterface/convenience-init-merge-module.swift @@ -0,0 +1,44 @@ +// REQUIRES: legacy_swift_driver +// RUN: %empty-directory(%t) + +// Generate the parseable interface of the current file via the merge-modules step +// RUN: %target-build-swift -no-emit-module-separately -emit-module -o %t/Test.swiftmodule -emit-module-interface-path %t/TestMerge.swiftinterface -module-name Test %s + +// Make sure both don't add override for inits shadowing convenience initializers +// RUN: %FileCheck %s < %t/TestMerge.swiftinterface + +// Check we can consume the interface without issue +// RUN: %target-swift-frontend -swift-version 5 -compile-module-from-interface -o %t/Test.swiftmodule %t/TestMerge.swiftinterface + +public class Base { + let x: Int + public init(x: Int) { + self.x = x + } + convenience public init() { + self.init(x: 1) + } +} + +public class Derived: Base { + // CHECK: {{^}} public init(z: Swift.Int) + public init(z: Int) { + super.init(x: z) + } + // CHECK: {{^}} public convenience init() + convenience public init() { + self.init(z: 1) + } +} + +public class Derived2: Base { + // CHECK: {{^}} public init() + public init() { + super.init(x: 1) + } + + // CHECK: {{^}} override public convenience init(x: Swift.Int) + override convenience public init(x: Int) { + self.init() + } +} diff --git a/test/ModuleInterface/convenience-init.swift b/test/ModuleInterface/convenience-init.swift index 0a136d9c221d1..f8a4e63ff7ac8 100644 --- a/test/ModuleInterface/convenience-init.swift +++ b/test/ModuleInterface/convenience-init.swift @@ -1,18 +1,13 @@ // RUN: %empty-directory(%t) -// Generate the parseable interface of the current file via the merge-modules step -// RUN: %target-build-swift -no-emit-module-separately -emit-module -o %t/Test.swiftmodule -emit-module-interface-path %t/TestMerge.swiftinterface -module-name Test %s - // Generate the parseable interface of the current file via a single frontend invocation // RUN: %target-swift-frontend -typecheck -enable-objc-interop -emit-module-interface-path %t/TestSingle.swiftinterface -module-name Test %s // Make sure both don't add override for inits shadowing convenience initializers -// RUN: %FileCheck --check-prefixes=CHECK,SINGLE %s < %t/TestSingle.swiftinterface -// RUN: %FileCheck --check-prefixes=CHECK,MERGE %s < %t/TestMerge.swiftinterface +// RUN: %FileCheck --check-prefixes=CHECK %s < %t/TestSingle.swiftinterface // Check we can consume the interface without issue // RUN: %target-swift-frontend -swift-version 5 -compile-module-from-interface -o %t/Test.swiftmodule %t/TestSingle.swiftinterface -// RUN: %target-swift-frontend -swift-version 5 -compile-module-from-interface -o %t/Test.swiftmodule %t/TestMerge.swiftinterface public class Base { let x: Int @@ -29,8 +24,7 @@ public class Derived: Base { public init(z: Int) { super.init(x: z) } - // MERGE: {{^}} public convenience init() - // SINGLE: {{^}} convenience public init() + // CHECK: {{^}} convenience public init() convenience public init() { self.init(z: 1) } @@ -42,8 +36,7 @@ public class Derived2: Base { super.init(x: 1) } - // MERGE: {{^}} override public convenience init(x: Swift.Int) - // SINGLE: {{^}} override convenience public init(x: Swift.Int) + // CHECK: {{^}} override convenience public init(x: Swift.Int) override convenience public init(x: Int) { self.init() } diff --git a/test/ModuleInterface/enums-layout-merge-module.swift b/test/ModuleInterface/enums-layout-merge-module.swift new file mode 100644 index 0000000000000..610fad2b26b62 --- /dev/null +++ b/test/ModuleInterface/enums-layout-merge-module.swift @@ -0,0 +1,85 @@ +// REQUIRES: legacy_swift_driver +// RUN: %empty-directory(%t) +// RUN: %target-build-swift -no-emit-module-separately -emit-module-interface-path %t/Lib.swiftinterface -emit-module -o %t/unused.swiftmodule -enable-library-evolution -Xfrontend -enable-objc-interop -Xfrontend -disable-objc-attr-requires-foundation-module -swift-version 5 %S/Inputs/enums-layout-helper.swift -module-name Lib +// RUN: %FileCheck -check-prefix CHECK -check-prefix CHECK-MULTI-FILE %S/Inputs/enums-layout-helper.swift < %t/Lib.swiftinterface +// RUN: %target-swift-frontend -enable-objc-interop -compile-module-from-interface %t/Lib.swiftinterface -o %t/compiled-from-interface.swiftmodule -module-name Lib +// RUN: %target-swift-frontend -enable-objc-interop -O -emit-ir -primary-file %s -I %t -Xllvm -swiftmergefunc-threshold=0 | %FileCheck %s + + +import Lib + +// CHECK-LABEL: define{{.+}}testFutureproofEnum +func testFutureproofEnum() -> FutureproofEnum { + // Check a few things in the function to make sure it's getting the case + // representation dynamically. + // CHECK: [[CASE:%.+]] = load i32, ptr @"$s3Lib15FutureproofEnumO1byA2CmFWC" + // CHECK: [[METADATA_RESPONSE:%.+]] = tail call swiftcc %swift.metadata_response @"$s3Lib15FutureproofEnumOMa" + // CHECK: [[METADATA:%.+]] = extractvalue %swift.metadata_response [[METADATA_RESPONSE]], 0 + // CHECK: call void {{%.+}}(ptr noalias %0, i32 [[CASE]], ptr [[METADATA]]) + // CHECK-NEXT: ret void + return .b +} // CHECK-NEXT: {{^}$}} + +// CHECK-LABEL: define{{.+}}testFrozenEnum +func testFrozenEnum() -> FrozenEnum { + // CHECK: ret i8 1 + return .b +} // CHECK-NEXT: {{^}$}} + +// CHECK-LABEL: define{{.+}}testFutureproofObjCEnum +func testFutureproofObjCEnum() -> FutureproofObjCEnum { + // CHECK: ret i{{32|64}} 10 + return .b +} // CHECK-NEXT: {{^}$}} + +// CHECK-LABEL: define{{.+}}testFrozenObjCEnum +func testFrozenObjCEnum() -> FrozenObjCEnum { + // CHECK: ret i{{32|64}} 10 + return .b +} // CHECK-NEXT: {{^}$}} + +// CHECK-LABEL: define{{.+}}testFutureproofUnicodeScalarEnum +func testFutureproofUnicodeScalarEnum() -> FutureproofUnicodeScalarEnum { + // CHECK: [[CASE:%.+]] = load i32, ptr @"$s3Lib28FutureproofUnicodeScalarEnumO1ayA2CmFWC" + // CHECK: [[METADATA_RESPONSE:%.+]] = tail call swiftcc %swift.metadata_response @"$s3Lib28FutureproofUnicodeScalarEnumOMa" + // CHECK: [[METADATA:%.+]] = extractvalue %swift.metadata_response [[METADATA_RESPONSE]], 0 + // CHECK: call void {{%.+}}(ptr noalias %0, i32 [[CASE]], ptr [[METADATA]]) + // CHECK-NEXT: ret void + return .a +} + +// CHECK-LABEL: define{{.+}}testFutureproofIndirectEnum +func testFutureproofIndirectEnum() -> FutureproofIndirectEnum { + // CHECK: [[CASE:%.+]] = load i32, ptr @"$s3Lib23FutureproofIndirectEnumO1cyA2CmFWC" + // CHECK: [[METADATA_RESPONSE:%.+]] = tail call swiftcc %swift.metadata_response @"$s3Lib23FutureproofIndirectEnumOMa" + // CHECK: [[METADATA:%.+]] = extractvalue %swift.metadata_response [[METADATA_RESPONSE]], 0 + // CHECK: call void {{%.+}}(ptr noalias %0, i32 [[CASE]], ptr [[METADATA]]) + // CHECK-NEXT: ret void + return .c +} + +// CHECK-LABEL: define{{.+}}testFrozenIndirectEnum +func testFrozenIndirectEnum() -> FrozenIndirectEnum { + // Whether this is "1" or "2" depends on whether the reserved ObjC tagged + // pointer bit is the top or bottom bit on this platform. + // CHECK: ret i{{32|64}} {{1|2}} + return .c +} + +// CHECK-LABEL: define{{.+}}testFutureproofIndirectCaseEnum +func testFutureproofIndirectCaseEnum() -> FutureproofIndirectCaseEnum { + // CHECK: [[CASE:%.+]] = load i32, ptr @"$s3Lib27FutureproofIndirectCaseEnumO1cyA2CmFWC" + // CHECK: [[METADATA_RESPONSE:%.+]] = tail call swiftcc %swift.metadata_response @"$s3Lib27FutureproofIndirectCaseEnumOMa" + // CHECK: [[METADATA:%.+]] = extractvalue %swift.metadata_response [[METADATA_RESPONSE]], 0 + // CHECK: call void {{%.+}}(ptr noalias %0, i32 [[CASE]], ptr [[METADATA]]) + // CHECK-NEXT: ret void + return .c +} + +// CHECK-LABEL: define{{.+}}testFrozenIndirectCaseEnum +func testFrozenIndirectCaseEnum() -> FrozenIndirectCaseEnum { + // Whether this is "1" or "2" depends on whether the reserved ObjC tagged + // pointer bit is the top or bottom bit on this platform. + // CHECK: ret i{{32|64}} {{1|2}} + return .c +} diff --git a/test/ModuleInterface/enums-layout.swift b/test/ModuleInterface/enums-layout.swift index a1c15b189677b..54fcfedf1cfea 100644 --- a/test/ModuleInterface/enums-layout.swift +++ b/test/ModuleInterface/enums-layout.swift @@ -1,11 +1,4 @@ // RUN: %empty-directory(%t) -// RUN: %target-build-swift -no-emit-module-separately -emit-module-interface-path %t/Lib.swiftinterface -emit-module -o %t/unused.swiftmodule -enable-library-evolution -Xfrontend -enable-objc-interop -Xfrontend -disable-objc-attr-requires-foundation-module -swift-version 5 %S/Inputs/enums-layout-helper.swift -module-name Lib -// RUN: %FileCheck -check-prefix CHECK -check-prefix CHECK-MULTI-FILE %S/Inputs/enums-layout-helper.swift < %t/Lib.swiftinterface -// RUN: %target-swift-frontend -enable-objc-interop -compile-module-from-interface %t/Lib.swiftinterface -o %t/compiled-from-interface.swiftmodule -module-name Lib -// RUN: %target-swift-frontend -enable-objc-interop -O -emit-ir -primary-file %s -I %t -Xllvm -swiftmergefunc-threshold=0 | %FileCheck %s - -// Try again using a single-frontend build. -// RUN: %empty-directory(%t) // RUN: %target-build-swift -whole-module-optimization -emit-module-interface-path %t/Lib.swiftinterface -emit-module -o %t/unused.swiftmodule -enable-library-evolution -Xfrontend -enable-objc-interop -Xfrontend -disable-objc-attr-requires-foundation-module -swift-version 5 %S/Inputs/enums-layout-helper.swift -module-name Lib // RUN: %FileCheck -check-prefix CHECK -check-prefix CHECK-SINGLE-FRONTEND %S/Inputs/enums-layout-helper.swift < %t/Lib.swiftinterface // RUN: %target-swift-frontend -enable-objc-interop -compile-module-from-interface %t/Lib.swiftinterface -o %t/compiled-from-interface.swiftmodule -module-name Lib diff --git a/test/lit.cfg b/test/lit.cfg index 0b251588f60ae..82d6af76a3f13 100644 --- a/test/lit.cfg +++ b/test/lit.cfg @@ -1021,11 +1021,11 @@ if not 'swift_driver' in lit_config.params: config.available_features.add('swift_in_compiler') # Check if we need to run lit tests using the legacy driver or the new driver -# The default for existing test runs is to use the legacy driver. -# The new driver is tested separately. -if os.environ.get('SWIFT_FORCE_TEST_NEW_DRIVER') is None: +# The default for existing test runs is to use the new driver. +if 'SWIFT_FORCE_TEST_OLD_DRIVER' in os.environ: config.environment['SWIFT_USE_OLD_DRIVER'] = '1' config.environment['SWIFT_AVOID_WARNING_USING_OLD_DRIVER'] = '1' + config.available_features.add('legacy_swift_driver') # Enable benchmark testing when the binary is found (has fully qualified path). if config.benchmark_o != 'Benchmark_O':