Files
swift-mirror/test/SILOptimizer/definite_init_hang.swift
Michael Gottesman 3ebd8df493 [gardening] Remove unnecessary -enable-sil-ownership from tests that now just get it from their pattern.
This just eliminates -enable-sil-ownership from all target-swift-frontend and
target-swift-emit-silgen RUN lines. Both of those now include
enable-sil-ownership in their expansion.
2019-03-12 20:39:18 -07:00

61 lines
1.7 KiB
Swift

// RUN: %target-swift-frontend -emit-sil %s -parse-as-library -o /dev/null -verify
var gg: Bool = false
var rg: Int = 0
func f1() { }
func f2() { }
// The old implementation of the LifetimeChecker in DefiniteInitialization had
// an exponential computation complexity in some cases.
// This test should finish in almost no time. With the old implementation it
// took about 8 minutes.
func testit() {
var tp: (a: Int, b: Int, c: Int) // expected-note {{variable defined here}}
tp.a = 1
while gg {
if gg {
rg = tp.a
rg = tp.b // expected-error {{variable 'tp.b' used before being initialized}}
tp.c = 27
}
// Create some control flow.
// With the old implementation each line doubles the computation time.
if gg { f1() } else { f2() }
if gg { f1() } else { f2() }
if gg { f1() } else { f2() }
if gg { f1() } else { f2() }
if gg { f1() } else { f2() }
if gg { f1() } else { f2() }
if gg { f1() } else { f2() }
if gg { f1() } else { f2() }
if gg { f1() } else { f2() }
if gg { f1() } else { f2() }
if gg { f1() } else { f2() }
if gg { f1() } else { f2() }
if gg { f1() } else { f2() }
if gg { f1() } else { f2() }
if gg { f1() } else { f2() }
if gg { f1() } else { f2() }
if gg { f1() } else { f2() }
if gg { f1() } else { f2() }
if gg { f1() } else { f2() }
if gg { f1() } else { f2() }
if gg { f1() } else { f2() }
if gg { f1() } else { f2() }
if gg { f1() } else { f2() }
if gg { f1() } else { f2() }
if gg { f1() } else { f2() }
if gg { f1() } else { f2() }
if gg { f1() } else { f2() }
if gg { f1() } else { f2() }
if gg { f1() } else { f2() }
}
}