[K/N][Tests] Change assertions and runtime assertions modes to default, when optimizationMode=OPT

^KT-64844 Fixed
This commit is contained in:
Vladimir Sukharev
2024-01-09 17:22:02 +01:00
committed by Space Team
parent 2a55aa782d
commit 809d652bdf
3 changed files with 13 additions and 10 deletions
+1
View File
@@ -2,6 +2,7 @@
// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JS_IR
// IGNORE_BACKEND: JS_IR_ES6 // IGNORE_BACKEND: JS_IR_ES6
// IGNORE_BACKEND: JS // IGNORE_BACKEND: JS
// IGNORE_NATIVE: optimizationMode=OPT
// ASSERTIONS_MODE: always-enable // ASSERTIONS_MODE: always-enable
// WITH_STDLIB // WITH_STDLIB
@@ -1,9 +1,6 @@
// TARGET_BACKEND: NATIVE // TARGET_BACKEND: NATIVE
// FILECHECK_STAGE: RemoveRedundantSafepoints // FILECHECK_STAGE: RemoveRedundantSafepoints
// KT-64844
// IGNORE_NATIVE: target=linux_x64 && optimizationMode=OPT
// This test checks: // This test checks:
// - there is only one safepoint per function // - there is only one safepoint per function
// - safepoint function is inlined in OPT mode, unless SMALLBINARY is needed (for ex, watchos_arm32) // - safepoint function is inlined in OPT mode, unless SMALLBINARY is needed (for ex, watchos_arm32)
@@ -55,8 +55,8 @@ internal abstract class BasicCompilation<A : TestCompilationArtifact>(
private fun ArgsBuilder.applyCommonArgs() { private fun ArgsBuilder.applyCommonArgs() {
add("-target", targets.testTarget.name) add("-target", targets.testTarget.name)
optimizationMode.compilerFlag?.let { compilerFlag -> add(compilerFlag) } optimizationMode.compilerFlag?.let { compilerFlag -> add(compilerFlag) }
if (optimizationMode != OptimizationMode.OPT) add("-enable-assertions")
add( add(
"-enable-assertions",
"-Xverify-ir=error" "-Xverify-ir=error"
) )
addFlattened(binaryOptions.entries) { (name, value) -> listOf("-Xbinary=$name=$value") } addFlattened(binaryOptions.entries) { (name, value) -> listOf("-Xbinary=$name=$value") }
@@ -141,7 +141,7 @@ internal abstract class SourceBasedCompilation<A : TestCompilationArtifact>(
targets: KotlinNativeTargets, targets: KotlinNativeTargets,
home: KotlinNativeHome, home: KotlinNativeHome,
classLoader: KotlinNativeClassLoader, classLoader: KotlinNativeClassLoader,
optimizationMode: OptimizationMode, protected val optimizationMode: OptimizationMode,
compilerOutputInterceptor: CompilerOutputInterceptor, compilerOutputInterceptor: CompilerOutputInterceptor,
private val threadStateChecker: ThreadStateChecker, private val threadStateChecker: ThreadStateChecker,
private val sanitizer: Sanitizer, private val sanitizer: Sanitizer,
@@ -218,7 +218,7 @@ internal class LibraryCompilation(
dependencies = CategorizedDependencies(dependencies), dependencies = CategorizedDependencies(dependencies),
expectedArtifact = expectedArtifact expectedArtifact = expectedArtifact
) { ) {
override val binaryOptions get() = BinaryOptions.RuntimeAssertionsMode.defaultForTesting override val binaryOptions get() = BinaryOptions.RuntimeAssertionsMode.defaultForTesting(optimizationMode)
override fun applySpecificArgs(argsBuilder: ArgsBuilder) = with(argsBuilder) { override fun applySpecificArgs(argsBuilder: ArgsBuilder) = with(argsBuilder) {
add( add(
@@ -253,7 +253,7 @@ internal class ObjCFrameworkCompilation(
dependencies = CategorizedDependencies(dependencies), dependencies = CategorizedDependencies(dependencies),
expectedArtifact = expectedArtifact expectedArtifact = expectedArtifact
) { ) {
override val binaryOptions get() = BinaryOptions.RuntimeAssertionsMode.defaultForTesting override val binaryOptions get() = BinaryOptions.RuntimeAssertionsMode.defaultForTesting(optimizationMode)
override fun applySpecificArgs(argsBuilder: ArgsBuilder) = with(argsBuilder) { override fun applySpecificArgs(argsBuilder: ArgsBuilder) = with(argsBuilder) {
add( add(
@@ -356,7 +356,7 @@ internal class ExecutableCompilation(
expectedArtifact = expectedArtifact expectedArtifact = expectedArtifact
) { ) {
private val cacheMode: CacheMode = settings.get() private val cacheMode: CacheMode = settings.get()
override val binaryOptions = BinaryOptions.RuntimeAssertionsMode.chooseFor(cacheMode) override val binaryOptions = BinaryOptions.RuntimeAssertionsMode.chooseFor(cacheMode, optimizationMode)
private val partialLinkageConfig: UsedPartialLinkageConfig = settings.get() private val partialLinkageConfig: UsedPartialLinkageConfig = settings.get()
@@ -552,10 +552,15 @@ internal class CategorizedDependencies(uncategorizedDependencies: Iterable<TestC
private object BinaryOptions { private object BinaryOptions {
object RuntimeAssertionsMode { object RuntimeAssertionsMode {
// Here the 'default' is in the sense the default for testing, not the default for the compiler. // Here the 'default' is in the sense the default for testing, not the default for the compiler.
val defaultForTesting: Map<String, String> = mapOf("runtimeAssertionsMode" to "panic") fun defaultForTesting(optimizationMode: OptimizationMode): Map<String, String> = when (optimizationMode) {
OptimizationMode.OPT -> mapOf()
else -> mapOf("runtimeAssertionsMode" to "panic")
}
val forUseWithCache: Map<String, String> = mapOf("runtimeAssertionsMode" to "ignore") val forUseWithCache: Map<String, String> = mapOf("runtimeAssertionsMode" to "ignore")
fun chooseFor(cacheMode: CacheMode) = if (cacheMode.useStaticCacheForDistributionLibraries) forUseWithCache else defaultForTesting fun chooseFor(cacheMode: CacheMode, optimizationMode: OptimizationMode) =
if (cacheMode.useStaticCacheForDistributionLibraries) forUseWithCache else defaultForTesting(optimizationMode)
} }
} }