Skip to content

Commit 3fcdaaa

Browse files
ddolovovSpace Team
authored and
Space Team
committed
[CLI] Move '-Xverify-ir-visibility-after-inlining' CLI argument
Move '-Xverify-ir-visibility-after-inlining' CLI argument key from `CommonCompilerArguments` to `CommonKlibBasedCompilerArguments` as it makes sense only for KLIBs (and the IR inliner at the first phase of KLIB compilation). ^KT-67298
1 parent 3c4f3a6 commit 3fcdaaa

File tree

9 files changed

+53
-29
lines changed

9 files changed

+53
-29
lines changed

compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArgumentsCopyGenerated.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ fun copyCommonCompilerArguments(from: CommonCompilerArguments, to: CommonCompile
8686
to.verbosePhases = from.verbosePhases?.copyOf()
8787
to.verifyIr = from.verifyIr
8888
to.verifyIrVisibility = from.verifyIrVisibility
89-
to.verifyIrVisibilityAfterInlining = from.verifyIrVisibilityAfterInlining
9089
to.whenGuards = from.whenGuards
9190

9291
return to

compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/CommonKlibBasedCompilerArgumentsCopyGenerated.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ fun copyCommonKlibBasedCompilerArguments(from: CommonKlibBasedCompilerArguments,
1818
to.partialLinkageLogLevel = from.partialLinkageLogLevel
1919
to.partialLinkageMode = from.partialLinkageMode
2020
to.relativePathBases = from.relativePathBases?.copyOf()
21+
to.verifyIrVisibilityAfterInlining = from.verifyIrVisibilityAfterInlining
2122

2223
return to
2324
}

compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -460,19 +460,6 @@ They should be a subset of sources passed as free arguments."""
460460
field = value
461461
}
462462

463-
@Argument(
464-
value = "-Xverify-ir-visibility-after-inlining",
465-
description = """Check for visibility violations in IR when validating it after the function inlining phase.
466-
Only has effect if '-Xverify-ir' is not 'none'.
467-
This flag is deprecated and will soon be removed in favor of '-Xverify-ir-visibility'.
468-
""",
469-
)
470-
var verifyIrVisibilityAfterInlining: Boolean = false
471-
set(value) {
472-
checkFrozen()
473-
field = value
474-
}
475-
476463
@Argument(
477464
value = "-Xprofile-phases",
478465
description = "Profile backend phases."

compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonKlibBasedCompilerArguments.kt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55

66
package org.jetbrains.kotlin.cli.common.arguments
77

8+
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
9+
import org.jetbrains.kotlin.config.AnalysisFlag
810
import org.jetbrains.kotlin.config.DuplicatedUniqueNameStrategy
911
import org.jetbrains.kotlin.config.LanguageFeature
12+
import org.jetbrains.kotlin.config.LanguageVersion
1013

1114
abstract class CommonKlibBasedCompilerArguments : CommonCompilerArguments() {
1215
companion object {
@@ -58,6 +61,19 @@ abstract class CommonKlibBasedCompilerArguments : CommonCompilerArguments() {
5861
field = if (value.isNullOrEmpty()) null else value
5962
}
6063

64+
@Argument(
65+
value = "-Xverify-ir-visibility-after-inlining",
66+
description = """Check for visibility violations in IR when validating it after the function inlining phase.
67+
Only has effect if '-Xverify-ir' is not 'none'.
68+
This flag is deprecated and will soon be removed in favor of '-Xverify-ir-visibility'.
69+
""",
70+
)
71+
var verifyIrVisibilityAfterInlining: Boolean = false
72+
set(value) {
73+
checkFrozen()
74+
field = value
75+
}
76+
6177
@Argument(
6278
value = "-Xklib-no-double-inlining",
6379
description = "Turn off double-inlining mode."
@@ -89,6 +105,8 @@ abstract class CommonKlibBasedCompilerArguments : CommonCompilerArguments() {
89105
field = value
90106
}
91107

108+
109+
92110
override fun configureExtraLanguageFeatures(map: HashMap<LanguageFeature, LanguageFeature.State>) {
93111
super.configureExtraLanguageFeatures(map)
94112
if (irInlinerBeforeKlibSerialization) {

compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JSCompiler.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,8 @@ class K2JSCompiler : CLICompiler<K2JSCompilerArguments>() {
846846
arguments: K2JSCompilerArguments,
847847
services: Services,
848848
) {
849+
configuration.setupCommonKlibArguments(arguments)
850+
849851
val messageCollector = configuration.getNotNull(CommonConfigurationKeys.MESSAGE_COLLECTOR_KEY)
850852

851853
@Suppress("DEPRECATION")

compiler/cli/src/org/jetbrains/kotlin/cli/common/arguments.kt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,6 @@ fun CompilerConfiguration.setupCommonArguments(
5555
}
5656
}
5757

58-
if (arguments.verifyIrVisibilityAfterInlining) {
59-
put(KlibConfigurationKeys.ENABLE_IR_VISIBILITY_CHECKS_AFTER_INLINING, true)
60-
if (irVerificationMode == IrVerificationMode.NONE) {
61-
messageCollector.report(
62-
CompilerMessageSeverity.WARNING,
63-
"'-Xverify-ir-visibility-after-inlining' has no effect unless '-Xverify-ir=warning' or '-Xverify-ir=error' is specified"
64-
)
65-
}
66-
}
67-
6858
val metadataVersionString = arguments.metadataVersion
6959
if (metadataVersionString != null) {
7060
val versionArray = BinaryVersion.parseVersionArray(metadataVersionString)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
3+
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
4+
*/
5+
6+
package org.jetbrains.kotlin.cli.common
7+
8+
import org.jetbrains.kotlin.cli.common.arguments.CommonKlibBasedCompilerArguments
9+
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
10+
import org.jetbrains.kotlin.config.CommonConfigurationKeys
11+
import org.jetbrains.kotlin.config.CompilerConfiguration
12+
import org.jetbrains.kotlin.config.IrVerificationMode
13+
import org.jetbrains.kotlin.config.KlibConfigurationKeys
14+
15+
fun CompilerConfiguration.setupCommonKlibArguments(
16+
arguments: CommonKlibBasedCompilerArguments
17+
) {
18+
val messageCollector = getNotNull(CommonConfigurationKeys.MESSAGE_COLLECTOR_KEY)
19+
20+
if (arguments.verifyIrVisibilityAfterInlining) {
21+
put(KlibConfigurationKeys.ENABLE_IR_VISIBILITY_CHECKS_AFTER_INLINING, true)
22+
23+
val irVerificationMode = get(CommonConfigurationKeys.VERIFY_IR, IrVerificationMode.NONE)
24+
if (irVerificationMode == IrVerificationMode.NONE) {
25+
messageCollector.report(
26+
CompilerMessageSeverity.WARNING,
27+
"'-Xverify-ir-visibility-after-inlining' has no effect unless '-Xverify-ir=warning' or '-Xverify-ir=error' is specified"
28+
)
29+
}
30+
}
31+
}

compiler/testData/cli/jvm/extraHelp.out

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,6 @@ where advanced options include:
239239
-Xverify-ir={none|warning|error}
240240
IR verification mode (no verification by default).
241241
-Xverify-ir-visibility Check for visibility violations in IR when validating it before running any lowerings. Only has effect if '-Xverify-ir' is not 'none'.
242-
-Xverify-ir-visibility-after-inlining
243-
Check for visibility violations in IR when validating it after the function inlining phase.
244-
Only has effect if '-Xverify-ir' is not 'none'.
245-
This flag is deprecated and will soon be removed in favor of '-Xverify-ir-visibility'.
246-
247242
-Xwhen-guards Enable experimental language support for when guards.
248243

249244
Advanced options are non-standard and may be changed or removed without any notice.

native/cli-native/src/org/jetbrains/kotlin/cli/bc/K2Native.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ class K2Native : CLICompiler<K2NativeCompilerArguments>() {
190190
arguments: K2NativeCompilerArguments,
191191
services: Services
192192
) {
193+
configuration.setupCommonKlibArguments(arguments)
193194
configuration.setupFromArguments(arguments)
194195
}
195196

0 commit comments

Comments
 (0)