Files
swift-mirror/validation-test/Evolution/test_backward_deploy_enum.swift
Erik Eckstein 5c17f0f6f8 SILCombine: peephole to propagate resilient enum cases
Basically the pattern to optimize is:
    inject_enum_addr %stackloc, #SomeCase
    switch_enum_addr %stackloc ...

This works even if the enum is resilient and the case does not have a payload. As long as we don't have opaque values in SIL we need this peephole to optimize the pattern.
This change fixes the code generation for Float.rounded().

rdar://problem/46353885
2018-12-10 16:14:15 -08:00

40 lines
722 B
Swift

// RUN: %target-resilience-test --backward-deployment
// REQUIRES: executable_test
import StdlibUnittest
import backward_deploy_enum
// <rdar://problem/46438568>
// REQUIRES: rdar46438568
var BackwardDeployEnumTest = TestSuite("BackwardDeployEnum")
func checkIt(_ e: ResilientEnum) -> Int {
switch e {
case .first:
return 1
case .second:
return 2
case .third:
return 3
case .fourth:
return 4
default:
return 5
}
}
BackwardDeployEnumTest.test("ResilientEnum") {
expectEqual(1, checkIt(.first))
expectEqual(2, checkIt(.second))
expectEqual(4, checkIt(.fourth))
expectEqual(5, checkIt(.fifth))
if getVersion() == 1 {
expectEqual(3, checkIt(.third))
}
}
runAllTests()