[K/N] Fix tests failing because of phase renaming

This commit is contained in:
Pavel Kunyavskiy
2023-02-10 11:45:24 +01:00
committed by Space Team
parent f3fd4b3e01
commit c400a75407
3 changed files with 17 additions and 14 deletions
+6 -3
View File
@@ -357,10 +357,13 @@ The following values are supported:
The following compiler phases control different parts of LLVM pipeline: The following compiler phases control different parts of LLVM pipeline:
1. `LinkBitcodeDependencies`. Linkage of produced bitcode with runtime and some other dependencies. 1. `LinkBitcodeDependencies`. Linkage of produced bitcode with runtime and some other dependencies.
2. `BitcodeOptimization`. Running LLVM optimization pipeline. 2. Running different parts of LLVM optimization pipeline:
1. `MandatoryBitcodeLLVMPostprocessingPhase`: important postprocessing. Disabling can break generated code.
2. `ModuleBitcodeOptimization`: Basic optimization pipeline. Something close to clang -O3
3. `LTOBitcodeOptimization`: LTO pipeline. Slower, but better optimizations, assuming whole program knowlage.
3. `ObjectFiles`. Compilation of bitcode with Clang. 3. `ObjectFiles`. Compilation of bitcode with Clang.
For example, pass `-Xdisable-phases=BitcodeOptimization` to skip optimization pipeline. For example, pass `-Xdisable-phases=LTOBitcodeOptimization` to skip this part of optimization pipeline for faster compilation with slower code.
Note that disabling `LinkBitcodeDependencies` or `ObjectFiles` will break compilation pipeline. Note that disabling `LinkBitcodeDependencies` or `ObjectFiles` will break compilation pipeline.
Compiler takes options for Clang from [konan.properties](konan/konan.properties) file Compiler takes options for Clang from [konan.properties](konan/konan.properties) file
@@ -375,7 +378,7 @@ Please note:
#### Example: replace predefined LLVM pipeline with Clang options. #### Example: replace predefined LLVM pipeline with Clang options.
```shell script ```shell script
CLANG_FLAGS="clangFlags.macos_x64=-cc1 -emit-obj;clangNooptFlags.macos_x64=-O2" CLANG_FLAGS="clangFlags.macos_x64=-cc1 -emit-obj;clangNooptFlags.macos_x64=-O2"
kotlinc-native main.kt -Xdisable-phases=BitcodeOptimization -Xoverride-konan-properties="$CLANG_FLAGS" kotlinc-native main.kt -Xdisable-phases=MandatoryBitcodeLLVMPostprocessingPhase,ModuleBitcodeOptimization,LTOBitcodeOptimization -Xoverride-konan-properties="$CLANG_FLAGS"
``` ```
### Dumping LLVM IR ### Dumping LLVM IR
@@ -62,18 +62,17 @@ internal val RewriteExternalCallsCheckerGlobals = createSimpleNamedCompilerPhase
internal class OptimizationState( internal class OptimizationState(
konanConfig: KonanConfig, konanConfig: KonanConfig,
val module: LLVMModuleRef,
val llvmConfig: LlvmPipelineConfig val llvmConfig: LlvmPipelineConfig
) : BasicPhaseContext(konanConfig) ) : BasicPhaseContext(konanConfig)
internal fun optimizationPipelinePass(name: String, description: String, pipeline: (LlvmPipelineConfig, LoggingContext) -> LlvmOptimizationPipeline) = internal fun optimizationPipelinePass(name: String, description: String, pipeline: (LlvmPipelineConfig, LoggingContext) -> LlvmOptimizationPipeline) =
createSimpleNamedCompilerPhase<OptimizationState, Unit>( createSimpleNamedCompilerPhase<OptimizationState, LLVMModuleRef>(
name = name, name = name,
description = description, description = description,
postactions = getDefaultLlvmModuleActions(), postactions = getDefaultLlvmModuleActions(),
) { context, _ -> ) { context, module ->
pipeline(context.llvmConfig, context).use { pipeline(context.llvmConfig, context).use {
it.execute(context.module) it.execute(module)
} }
} }
@@ -165,12 +164,13 @@ internal fun PhaseEngine<NativeGenerationState>.runBitcodePostProcessing() {
closedWorld = context.llvmModuleSpecification.isFinal, closedWorld = context.llvmModuleSpecification.isFinal,
timePasses = context.config.flexiblePhaseConfig.needProfiling, timePasses = context.config.flexiblePhaseConfig.needProfiling,
) )
useContext(OptimizationState(context.config, context.llvmModule, optimizationConfig)) { useContext(OptimizationState(context.config, optimizationConfig)) {
it.runPhase(MandatoryBitcodeLLVMPostprocessingPhase) val module = this@runBitcodePostProcessing.context.llvmModule
it.runPhase(ModuleBitcodeOptimizationPhase) it.runPhase(MandatoryBitcodeLLVMPostprocessingPhase, module)
it.runPhase(LTOBitcodeOptimizationPhase) it.runPhase(ModuleBitcodeOptimizationPhase, module)
it.runPhase(LTOBitcodeOptimizationPhase, module)
when (context.config.sanitizer) { when (context.config.sanitizer) {
SanitizerKind.THREAD -> it.runPhase(ThreadSanitizerPhase) SanitizerKind.THREAD -> it.runPhase(ThreadSanitizerPhase, module)
SanitizerKind.ADDRESS -> context.reportCompilationError("Address sanitizer is not supported yet") SanitizerKind.ADDRESS -> context.reportCompilationError("Address sanitizer is not supported yet")
null -> {} null -> {}
} }
@@ -6248,7 +6248,7 @@ tasks.register("override_konan_properties0", KonanDriverTest) {
: '-Xoverride-konan-properties=llvmInlineThreshold=76' : '-Xoverride-konan-properties=llvmInlineThreshold=76'
flags = [ flags = [
"-opt", "-opt",
"-Xverbose-phases=BitcodeOptimization", "-Xverbose-phases=MandatoryBitcodeLLVMPostprocessingPhase",
overrides overrides
] ]
compilerMessages = true compilerMessages = true
@@ -6454,7 +6454,7 @@ if (HostManager.@Companion.hostIsMac) {
targetName = "watchos_arm32" targetName = "watchos_arm32"
// Perform check after optimization pipeline because // Perform check after optimization pipeline because
// LLVM might infer attributes. // LLVM might infer attributes.
phaseToCheck = "BitcodeOptimization" phaseToCheck = "LTOBitcodeOptimization"
} }
fileCheckTest("filecheck_redundant_safepoints_removal_smallbinary") { fileCheckTest("filecheck_redundant_safepoints_removal_smallbinary") {