Skip to content

Commit ac51ce3

Browse files
committed
[polymorphic-builtins] Enable test during optimize builds.
The confusion here was around a test that was testing the behavior when one /does not/ guard a polymorphic builtin with a _isConcrete. Specifically, without _isConcrete, one gets weird behavior where in debug we crash, but in release we may not due to further inlining/specialization. With _isConcrete, we never crashand get the appropriate behavior. This commit works by changing the current run of the polymorphic builtin test to force -Onone and adds an extra -O run that way we validate both behaviors.
1 parent 8e527ed commit ac51ce3

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

test/Interpreter/polymorphic_builtins.swift

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,25 @@
77

88
// RUN: %empty-directory(%t)
99

10-
// RUN: %target-build-swift-dylib(%t/%target-library-name(mysimd)) -enable-library-evolution %S/../Inputs/polymorphic_builtins.swift -emit-module -emit-module-path %t/mysimd.swiftmodule -module-name mysimd -parse-stdlib
10+
// RUN: %target-build-swift-dylib(%t/%target-library-name(mysimd)) -enable-library-evolution %S/../Inputs/polymorphic_builtins.swift -emit-module -emit-module-path %t/mysimd.swiftmodule -module-name mysimd -parse-stdlib -D DEBUG -Onone
1111
// RUN: %target-codesign %t/%target-library-name(mysimd)
1212

13-
// RUN: %target-build-swift %s -L %t -I %t -lmysimd -parse-stdlib -Xfrontend -disable-access-control -Xfrontend -sil-verify-all %target-rpath(%t) -o %t/a.out
13+
// RUN: %target-build-swift %s -L %t -I %t -lmysimd -parse-stdlib -Xfrontend -disable-access-control -Xfrontend -sil-verify-all %target-rpath(%t) -o %t/a.out -D DEBUG -Onone
1414
// RUN: %target-codesign %t/a.out
1515

1616
// RUN: %target-run %t/a.out %t/%target-library-name(mysimd)
1717

18-
// REQUIRES: executable_test
18+
// RUN: %empty-directory(%t)
1919

20-
// TODO: Re-enable this when optimization is enabled.
21-
//
22-
// REQUIRES: swift_test_mode_optimize_none
20+
// RUN: %target-build-swift-dylib(%t/%target-library-name(mysimd)) -enable-library-evolution %S/../Inputs/polymorphic_builtins.swift -emit-module -emit-module-path %t/mysimd.swiftmodule -module-name mysimd -parse-stdlib -O
21+
// RUN: %target-codesign %t/%target-library-name(mysimd)
22+
23+
// RUN: %target-build-swift %s -L %t -I %t -lmysimd -parse-stdlib -Xfrontend -disable-access-control -Xfrontend -sil-verify-all %target-rpath(%t) -o %t/a.out -O
24+
// RUN: %target-codesign %t/a.out
25+
26+
// RUN: %target-run %t/a.out %t/%target-library-name(mysimd)
27+
28+
// REQUIRES: executable_test
2329

2430
import Swift
2531
import StdlibUnittest
@@ -86,12 +92,16 @@ Tests.test("Indirect Dispatch + Transparent + _isConcrete Guard == OK") {
8692
}
8793

8894
// In this case, we call mul which is unguarded with _isConcrete and thus
89-
// crashes. The stdlib maintainer should have guarded this usage to ensure that
90-
// we did not go down this code path.
95+
// crashes in Debug, but in Release we (after inlining/specialization) /do/
96+
// succeed. This is one reason why _isConcrete is needed.
97+
//
98+
// The stdlib maintainer should have guarded this usage to ensure that we did
99+
// not go down this code path.
91100

92-
Tests.test("Indirect Dispatch + Transparent + No _isConcrete Guard == Crash") {
101+
Tests.test("Indirect Dispatch + Transparent + No _isConcrete Guard == Crash when Debug") {
102+
#if DEBUG
93103
expectCrashLater()
94-
104+
#endif
95105
let inputs: [Int32] = [5,6,7,8]
96106
let expectedOutputs: [Int32] = inputs.map { $0 &* $0 }
97107

0 commit comments

Comments
 (0)