From cbabfc0fe24f431240565e9664ee0c75877b9d3b Mon Sep 17 00:00:00 2001 From: Wojciech Litewka Date: Tue, 5 Mar 2024 13:09:58 +0100 Subject: [PATCH] [IR] Drop ir.ir2cfg module #KTI-952 Fixed #KT-65773 Related --- .space/CODEOWNERS | 2 - compiler/build.gradle.kts | 1 - compiler/ir/ir.ir2cfg/build.gradle.kts | 18 -- .../ir2cfg/builders/BasicBlockBuilder.kt | 31 --- .../ir2cfg/builders/BlockConnectorBuilder.kt | 29 --- .../builders/ControlFlowGraphBuilder.kt | 37 ---- .../ir2cfg/generators/BasicBlockImpl.kt | 36 ---- .../ir2cfg/generators/ControlFlowGraphImpl.kt | 28 --- .../ir2cfg/generators/FunctionBuilder.kt | 110 ---------- .../ir2cfg/generators/FunctionGenerator.kt | 201 ------------------ .../ir2cfg/generators/GeneralBlockBuilder.kt | 35 --- .../generators/GeneralConnectorBuilder.kt | 43 ---- .../ir2cfg/generators/JoinBlockConnector.kt | 30 --- .../ir2cfg/generators/SplitBlockConnector.kt | 30 --- .../kotlin/ir2cfg/graph/BasicBlock.kt | 34 --- .../kotlin/ir2cfg/graph/BlockConnector.kt | 34 --- .../jetbrains/kotlin/ir2cfg/graph/CfgNode.kt | 24 --- .../kotlin/ir2cfg/graph/ControlFlowGraph.kt | 32 --- .../kotlin/ir2cfg/nodes/CfgIrElement.kt | 21 -- .../kotlin/ir2cfg/nodes/MergeCfgElement.kt | 37 ---- .../kotlin/ir2cfg/util/ControlFlowRenderer.kt | 79 ------- compiler/testData/ir/irCfg/expressionFun.kt | 1 - compiler/testData/ir/irCfg/expressionFun.txt | 14 -- compiler/testData/ir/irCfg/expressionUnit.kt | 1 - compiler/testData/ir/irCfg/expressionUnit.txt | 14 -- compiler/testData/ir/irCfg/loop/digitCount.kt | 11 - .../testData/ir/irCfg/loop/digitCount.txt | 68 ------ compiler/testData/ir/irCfg/loop/factorial.kt | 7 - compiler/testData/ir/irCfg/loop/factorial.txt | 51 ----- compiler/testData/ir/irCfg/loop/isPerfect.kt | 9 - compiler/testData/ir/irCfg/loop/isPerfect.txt | 89 -------- compiler/testData/ir/irCfg/returnUnit.kt | 3 - compiler/testData/ir/irCfg/returnUnit.txt | 14 -- compiler/testData/ir/irCfg/sequentialFun.kt | 4 - compiler/testData/ir/irCfg/sequentialFun.txt | 18 -- compiler/testData/ir/irCfg/simpleFun.kt | 1 - compiler/testData/ir/irCfg/simpleFun.txt | 12 -- compiler/testData/ir/irCfg/simpleReturn.kt | 3 - compiler/testData/ir/irCfg/simpleReturn.txt | 14 -- compiler/testData/ir/irCfg/when/cascadeIf.kt | 1 - compiler/testData/ir/irCfg/when/cascadeIf.txt | 57 ----- compiler/testData/ir/irCfg/when/emptyWhen.kt | 3 - compiler/testData/ir/irCfg/when/emptyWhen.txt | 27 --- .../testData/ir/irCfg/when/expressionIf.kt | 1 - .../testData/ir/irCfg/when/expressionIf.txt | 42 ---- compiler/testData/ir/irCfg/when/ifChain.kt | 14 -- compiler/testData/ir/irCfg/when/ifChain.txt | 175 --------------- compiler/testData/ir/irCfg/when/whenReturn.kt | 10 - .../testData/ir/irCfg/when/whenReturn.txt | 95 --------- compiler/tests-common/build.gradle.kts | 1 - .../kotlin/ir/AbstractIrCfgTestCase.kt | 61 ------ .../tests-compiler-utils/build.gradle.kts | 1 - .../generators/GenerateJUnit3CompilerTests.kt | 5 - .../kotlin/ir/IrCfgTestCaseGenerated.java | 127 ----------- settings.gradle | 2 - 55 files changed, 1848 deletions(-) delete mode 100644 compiler/ir/ir.ir2cfg/build.gradle.kts delete mode 100644 compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/builders/BasicBlockBuilder.kt delete mode 100644 compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/builders/BlockConnectorBuilder.kt delete mode 100644 compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/builders/ControlFlowGraphBuilder.kt delete mode 100644 compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/generators/BasicBlockImpl.kt delete mode 100644 compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/generators/ControlFlowGraphImpl.kt delete mode 100644 compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/generators/FunctionBuilder.kt delete mode 100644 compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/generators/FunctionGenerator.kt delete mode 100644 compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/generators/GeneralBlockBuilder.kt delete mode 100644 compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/generators/GeneralConnectorBuilder.kt delete mode 100644 compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/generators/JoinBlockConnector.kt delete mode 100644 compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/generators/SplitBlockConnector.kt delete mode 100644 compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/graph/BasicBlock.kt delete mode 100644 compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/graph/BlockConnector.kt delete mode 100644 compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/graph/CfgNode.kt delete mode 100644 compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/graph/ControlFlowGraph.kt delete mode 100644 compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/nodes/CfgIrElement.kt delete mode 100644 compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/nodes/MergeCfgElement.kt delete mode 100644 compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/util/ControlFlowRenderer.kt delete mode 100644 compiler/testData/ir/irCfg/expressionFun.kt delete mode 100644 compiler/testData/ir/irCfg/expressionFun.txt delete mode 100644 compiler/testData/ir/irCfg/expressionUnit.kt delete mode 100644 compiler/testData/ir/irCfg/expressionUnit.txt delete mode 100644 compiler/testData/ir/irCfg/loop/digitCount.kt delete mode 100644 compiler/testData/ir/irCfg/loop/digitCount.txt delete mode 100644 compiler/testData/ir/irCfg/loop/factorial.kt delete mode 100644 compiler/testData/ir/irCfg/loop/factorial.txt delete mode 100644 compiler/testData/ir/irCfg/loop/isPerfect.kt delete mode 100644 compiler/testData/ir/irCfg/loop/isPerfect.txt delete mode 100644 compiler/testData/ir/irCfg/returnUnit.kt delete mode 100644 compiler/testData/ir/irCfg/returnUnit.txt delete mode 100644 compiler/testData/ir/irCfg/sequentialFun.kt delete mode 100644 compiler/testData/ir/irCfg/sequentialFun.txt delete mode 100644 compiler/testData/ir/irCfg/simpleFun.kt delete mode 100644 compiler/testData/ir/irCfg/simpleFun.txt delete mode 100644 compiler/testData/ir/irCfg/simpleReturn.kt delete mode 100644 compiler/testData/ir/irCfg/simpleReturn.txt delete mode 100644 compiler/testData/ir/irCfg/when/cascadeIf.kt delete mode 100644 compiler/testData/ir/irCfg/when/cascadeIf.txt delete mode 100644 compiler/testData/ir/irCfg/when/emptyWhen.kt delete mode 100644 compiler/testData/ir/irCfg/when/emptyWhen.txt delete mode 100644 compiler/testData/ir/irCfg/when/expressionIf.kt delete mode 100644 compiler/testData/ir/irCfg/when/expressionIf.txt delete mode 100644 compiler/testData/ir/irCfg/when/ifChain.kt delete mode 100644 compiler/testData/ir/irCfg/when/ifChain.txt delete mode 100644 compiler/testData/ir/irCfg/when/whenReturn.kt delete mode 100644 compiler/testData/ir/irCfg/when/whenReturn.txt delete mode 100644 compiler/tests-common/tests/org/jetbrains/kotlin/ir/AbstractIrCfgTestCase.kt delete mode 100644 compiler/tests-gen/org/jetbrains/kotlin/ir/IrCfgTestCaseGenerated.java diff --git a/.space/CODEOWNERS b/.space/CODEOWNERS index 6a224329934..7515fc8dd53 100644 --- a/.space/CODEOWNERS +++ b/.space/CODEOWNERS @@ -80,7 +80,6 @@ /compiler/ir/backend.wasm/ "Kotlin Wasm" /compiler/ir/ir.actualization/ "Kotlin Compiler Core" "Kotlin Common Backend" Simon.Ogorodnik /compiler/ir/ir.interpreter/ "Kotlin Common Backend" -/compiler/ir/ir.ir2cfg/ Mikhail.Glukhikh /compiler/ir/ir.psi2ir/ "Kotlin JVM" /compiler/ir/ir.tree/ "Kotlin Common Backend" /compiler/ir/ir.objcinterop/ "Kotlin Native" @@ -154,7 +153,6 @@ # UNKNOWN: /compiler/testData/integration/ /compiler/testData/ir/closureAnnotator/ "Kotlin JVM" /compiler/testData/ir/interpreter/ "Kotlin Common Backend" -/compiler/testData/ir/irCfg/ "Kotlin JVM" /compiler/testData/ir/irText/ "Kotlin Compiler Core" /compiler/testData/ir/klibLayout/ "Kotlin Common Backend" /compiler/testData/ir/sourceRanges/ "Kotlin Compiler Core" diff --git a/compiler/build.gradle.kts b/compiler/build.gradle.kts index 0b0d368660c..b7e82270449 100644 --- a/compiler/build.gradle.kts +++ b/compiler/build.gradle.kts @@ -24,7 +24,6 @@ dependencies { testApi(projectTests(":compiler:fir:raw-fir:light-tree2fir")) testApi(projectTests(":compiler:fir:analysis-tests:legacy-fir-tests")) testApi(projectTests(":generators:test-generator")) - testApi(project(":compiler:ir.ir2cfg")) testApi(project(":compiler:ir.tree")) // used for deepCopyWithSymbols call that is removed by proguard from the compiler TODO: make it more straightforward testApi(project(":kotlin-scripting-compiler")) diff --git a/compiler/ir/ir.ir2cfg/build.gradle.kts b/compiler/ir/ir.ir2cfg/build.gradle.kts deleted file mode 100644 index 54095aee0ab..00000000000 --- a/compiler/ir/ir.ir2cfg/build.gradle.kts +++ /dev/null @@ -1,18 +0,0 @@ - -plugins { - kotlin("jvm") - id("jps-compatible") -} - -dependencies { - api(project(":compiler:util")) - api(project(":compiler:frontend")) - api(project(":compiler:ir.tree")) -} - -optInToUnsafeDuringIrConstructionAPI() - -sourceSets { - "main" { projectDefault() } - "test" {} -} diff --git a/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/builders/BasicBlockBuilder.kt b/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/builders/BasicBlockBuilder.kt deleted file mode 100644 index 8858c1736a6..00000000000 --- a/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/builders/BasicBlockBuilder.kt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2010-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.ir2cfg.builders - -import org.jetbrains.kotlin.ir.IrStatement -import org.jetbrains.kotlin.ir2cfg.graph.BasicBlock - -interface BasicBlockBuilder { - - val incoming: BlockConnectorBuilder? - - fun add(element: IrStatement) - - val last: IrStatement? - - fun build(): BasicBlock -} \ No newline at end of file diff --git a/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/builders/BlockConnectorBuilder.kt b/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/builders/BlockConnectorBuilder.kt deleted file mode 100644 index 19438754dc0..00000000000 --- a/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/builders/BlockConnectorBuilder.kt +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2010-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.ir2cfg.builders - -import org.jetbrains.kotlin.ir2cfg.graph.BasicBlock -import org.jetbrains.kotlin.ir2cfg.graph.BlockConnector - -interface BlockConnectorBuilder { - - fun addNext(basicBlock: BasicBlock) - - fun addPrevious(basicBlock: BasicBlock) - - fun build(): BlockConnector -} \ No newline at end of file diff --git a/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/builders/ControlFlowGraphBuilder.kt b/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/builders/ControlFlowGraphBuilder.kt deleted file mode 100644 index 2b1111e9a1a..00000000000 --- a/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/builders/ControlFlowGraphBuilder.kt +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2010-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.ir2cfg.builders - -import org.jetbrains.kotlin.ir.IrStatement -import org.jetbrains.kotlin.ir2cfg.graph.ControlFlowGraph - -interface ControlFlowGraphBuilder { - // Add element to the builder pointer - fun add(element: IrStatement) - - // Move builder pointer to element without changing graph - fun move(to: IrStatement) - - // Connect builder pointer with the given element and move pointer to this element - fun jump(to: IrStatement) - - // Connect from with to and move pointer to the destination - fun jump(to: IrStatement, from: IrStatement) - - // Build CFG from builder - fun build(): ControlFlowGraph -} \ No newline at end of file diff --git a/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/generators/BasicBlockImpl.kt b/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/generators/BasicBlockImpl.kt deleted file mode 100644 index 1abb2c40bb8..00000000000 --- a/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/generators/BasicBlockImpl.kt +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2010-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.ir2cfg.generators - -import org.jetbrains.kotlin.ir.IrStatement -import org.jetbrains.kotlin.ir2cfg.graph.BasicBlock -import org.jetbrains.kotlin.ir2cfg.graph.BlockConnector - -class BasicBlockImpl(override val elements: List) : BasicBlock { - - override var incoming: BlockConnector? = null - internal set(arg) { - if (field != null) throw AssertionError("Incoming connector cannot be changed after being set") - field = arg - } - - override var outgoing: BlockConnector? = null - internal set(arg) { - if (field != null) throw AssertionError("Outgoing connector cannot be changed after being set") - field = arg - } -} \ No newline at end of file diff --git a/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/generators/ControlFlowGraphImpl.kt b/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/generators/ControlFlowGraphImpl.kt deleted file mode 100644 index 427922de963..00000000000 --- a/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/generators/ControlFlowGraphImpl.kt +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2010-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.ir2cfg.generators - -import org.jetbrains.kotlin.ir.declarations.IrFunction -import org.jetbrains.kotlin.ir2cfg.graph.BasicBlock -import org.jetbrains.kotlin.ir2cfg.graph.BlockConnector -import org.jetbrains.kotlin.ir2cfg.graph.ControlFlowGraph - -class ControlFlowGraphImpl( - override val function: IrFunction, - override val blocks: List, - override val connectors: List -) : ControlFlowGraph \ No newline at end of file diff --git a/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/generators/FunctionBuilder.kt b/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/generators/FunctionBuilder.kt deleted file mode 100644 index ba8dff36343..00000000000 --- a/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/generators/FunctionBuilder.kt +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright 2010-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.ir2cfg.generators - -import org.jetbrains.kotlin.ir.IrStatement -import org.jetbrains.kotlin.ir.declarations.IrFunction -import org.jetbrains.kotlin.ir2cfg.builders.BasicBlockBuilder -import org.jetbrains.kotlin.ir2cfg.builders.BlockConnectorBuilder -import org.jetbrains.kotlin.ir2cfg.builders.ControlFlowGraphBuilder -import org.jetbrains.kotlin.ir2cfg.graph.BasicBlock -import org.jetbrains.kotlin.ir2cfg.graph.BlockConnector -import org.jetbrains.kotlin.ir2cfg.graph.ControlFlowGraph - -class FunctionBuilder(val function: IrFunction) : ControlFlowGraphBuilder { - - private val blockBuilderMap = mutableMapOf() - - private var currentBlockBuilder: BasicBlockBuilder? = null - - private val blocks = mutableListOf() - - private val connectorBuilderMap = mutableMapOf() - - private fun createBlockBuilder(after: BlockConnectorBuilder?): BasicBlockBuilder { - val result = GeneralBlockBuilder(after) - currentBlockBuilder = result - return result - } - - private fun BasicBlockBuilder.shiftTo(element: IrStatement) { - blockBuilderMap.remove(last) - add(element) - blockBuilderMap[element] = this - } - - override fun add(element: IrStatement) { - val blockBuilder = currentBlockBuilder ?: createBlockBuilder(connectorBuilderMap[element]) - blockBuilder.shiftTo(element) - } - - override fun move(to: IrStatement) { - val blockBuilder = blockBuilderMap[to] - ?: connectorBuilderMap[to]?.let { createBlockBuilder(it) } - ?: throw AssertionError("Function generator may move to an element only to the end of a block or to connector") - currentBlockBuilder = blockBuilder - } - - override fun jump(to: IrStatement) { - val blockBuilder = currentBlockBuilder - ?: throw AssertionError("Function generator: no default block builder for jump") - val block = blockBuilder.build() - blocks.add(block) - blockBuilderMap.values.remove(blockBuilder) - currentBlockBuilder = null - val nextConnectorBuilder = connectorBuilderMap[to] ?: GeneralConnectorBuilder(to) - nextConnectorBuilder.addPrevious(block) - val previousConnectorBuilder = blockBuilder.incoming - previousConnectorBuilder?.addNext(block) - connectorBuilderMap[to] = nextConnectorBuilder - move(to) - } - - override fun jump(to: IrStatement, from: IrStatement) { - currentBlockBuilder = blockBuilderMap[from] - if (currentBlockBuilder == null) { - val blockBuilder = connectorBuilderMap[from]?.let { createBlockBuilder(it) } - ?: throw AssertionError("Function generator may jump after an element only to the end of a block or to connector") - currentBlockBuilder = blockBuilder - } - jump(to) - } - - override fun build(): ControlFlowGraph { - for (blockBuilder in blockBuilderMap.values) { - if (currentBlockBuilder == blockBuilder) { - currentBlockBuilder = null - } - val block = blockBuilder.build() - blocks.add(block) - blockBuilder.incoming?.addNext(block) - } - val connectors = mutableListOf() - for (connectorBuilder in connectorBuilderMap.values) { - connectors.add(connectorBuilder.build()) - } - for (connector in connectors) { - for (previous in connector.previousBlocks) { - (previous as? BasicBlockImpl)?.outgoing = connector - } - for (next in connector.nextBlocks) { - (next as? BasicBlockImpl)?.incoming = connector - } - } - return ControlFlowGraphImpl(function, blocks, connectors) - } -} diff --git a/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/generators/FunctionGenerator.kt b/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/generators/FunctionGenerator.kt deleted file mode 100644 index 03c72883a9b..00000000000 --- a/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/generators/FunctionGenerator.kt +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -package org.jetbrains.kotlin.ir2cfg.generators - -import org.jetbrains.kotlin.ir.IrElement -import org.jetbrains.kotlin.ir.IrStatement -import org.jetbrains.kotlin.ir.declarations.IrFunction -import org.jetbrains.kotlin.ir.declarations.IrVariable -import org.jetbrains.kotlin.ir.expressions.* -import org.jetbrains.kotlin.ir.types.isNothing -import org.jetbrains.kotlin.ir.util.dump -import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.ir2cfg.graph.ControlFlowGraph -import org.jetbrains.kotlin.ir2cfg.nodes.MergeCfgElement - -class FunctionGenerator(val function: IrFunction) { - - val builder = FunctionBuilder(function) - - val exit = MergeCfgElement(function, "Function exit") - - val loopEntries = mutableMapOf() - - val loopExits = mutableMapOf() - - fun generate(): ControlFlowGraph { - val visitor = FunctionVisitor() - function.accept(visitor, true) - return builder.build() - } - - inner class FunctionVisitor : IrElementVisitor { - - private inline fun IE.process(includeSelf: Boolean = true) = this.accept(this@FunctionVisitor, includeSelf) - - override fun visitFunction(declaration: IrFunction, data: Boolean): IrStatement? { - if (data) { - builder.add(declaration) - } - val result = declaration.body?.process() ?: if (data) declaration else null - if (result != null && !result.isNothing()) { - builder.jump(exit, from = result) - } - return result - } - - private fun IrStatementContainer.process(): IrStatement? { - var result: IrStatement? = null - for (statement in statements) { - result = statement.process() - } - return result - } - - private fun IrElement?.isNothing() = this is IrExpression && type.isNothing() - - override fun visitBlockBody(body: IrBlockBody, data: Boolean): IrStatement? { - return body.process() - } - - override fun visitContainerExpression(expression: IrContainerExpression, data: Boolean): IrStatement? { - return expression.process() ?: expression - } - - override fun visitVariable(declaration: IrVariable, data: Boolean): IrStatement? { - declaration.initializer?.process() - return if (data) { - builder.add(declaration) - declaration - } else null - } - - override fun visitReturn(expression: IrReturn, data: Boolean): IrStatement? { - expression.value.process() - if (data) { - builder.add(expression) - } - builder.jump(exit) - return expression - } - - override fun visitExpressionBody(body: IrExpressionBody, data: Boolean): IrStatement? { - return body.expression.process() - } - - override fun visitExpression(expression: IrExpression, data: Boolean): IrStatement? { - if (data) { - builder.add(expression) - } - return expression - } - - override fun visitWhen(expression: IrWhen, data: Boolean): IrStatement? { - if (data) { - builder.add(expression) - } - val whenExit = MergeCfgElement(expression, "When exit") - val branches = expression.branches - for (branch in branches) { - val condition = branch.condition - condition.process(includeSelf = false) - builder.jump(condition) - } - for (branch in branches) { - val result = branch.result - builder.move(branch.condition) - if (!result.process().isNothing()) { - builder.jump(whenExit) - } else { - builder.move(branch.condition) - } - } - return whenExit - } - - override fun visitWhileLoop(loop: IrWhileLoop, data: Boolean): IrStatement? { - if (data) { - builder.add(loop) - } - val exit = MergeCfgElement(loop, "While exit") - loopExits[loop] = exit - val entry = MergeCfgElement(loop, "While entry") - loopEntries[loop] = entry - builder.jump(entry) - val condition = loop.condition - condition.process(includeSelf = false) - builder.jump(condition) - val body = loop.body - if (!body?.process().isNothing()) { - builder.jump(entry) - } - builder.jump(exit, from = condition) - return exit - } - - override fun visitDoWhileLoop(loop: IrDoWhileLoop, data: Boolean): IrStatement? { - if (data) { - builder.add(loop) - } - val exit = MergeCfgElement(loop, "Do..while exit") - loopExits[loop] = exit - val entry = MergeCfgElement(loop, "Do..while entry") - loopEntries[loop] = entry - builder.jump(entry) - val body = loop.body - val condition = loop.condition - if (!body?.process().isNothing()) { - condition.process(includeSelf = false) - builder.jump(condition) - builder.jump(entry, from = condition) - builder.jump(exit, from = condition) - } - builder.move(exit) - return exit - } - - override fun visitBreak(jump: IrBreak, data: Boolean): IrStatement? { - if (data) { - builder.add(jump) - } - builder.jump(loopExits[jump.loop] ?: throw AssertionError("Loop exit not found for ${jump.loop.dump()}")) - return jump - } - - override fun visitContinue(jump: IrContinue, data: Boolean): IrStatement? { - if (data) { - builder.add(jump) - } - builder.jump(loopEntries[jump.loop] ?: throw AssertionError("Loop entry not found for ${jump.loop.dump()}")) - return jump - } - - override fun visitMemberAccess(expression: IrMemberAccessExpression<*>, data: Boolean): IrStatement? { - expression.dispatchReceiver?.process() - expression.extensionReceiver?.process() - val callee = expression.symbol.owner as IrFunction - for (valueParameter in callee.valueParameters) { - expression.getValueArgument(valueParameter.index)?.process() - } - if (data) { - builder.add(expression) - } - return expression - } - - override fun visitTypeOperator(expression: IrTypeOperatorCall, data: Boolean): IrStatement? { - expression.argument.process() - if (data) { - builder.add(expression) - } - return expression - } - - override fun visitElement(element: IrElement, data: Boolean): IrStatement? { - TODO("not implemented") - } - } -} \ No newline at end of file diff --git a/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/generators/GeneralBlockBuilder.kt b/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/generators/GeneralBlockBuilder.kt deleted file mode 100644 index f66810ef80c..00000000000 --- a/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/generators/GeneralBlockBuilder.kt +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2010-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.ir2cfg.generators - -import org.jetbrains.kotlin.ir.IrStatement -import org.jetbrains.kotlin.ir2cfg.builders.BasicBlockBuilder -import org.jetbrains.kotlin.ir2cfg.builders.BlockConnectorBuilder - -class GeneralBlockBuilder(override val incoming: BlockConnectorBuilder?) : BasicBlockBuilder { - - private val elements = mutableListOf() - - override fun add(element: IrStatement) { - elements.add(element) - } - - override val last: IrStatement? - get() = elements.lastOrNull() - - override fun build() = BasicBlockImpl(elements.toList()) -} \ No newline at end of file diff --git a/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/generators/GeneralConnectorBuilder.kt b/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/generators/GeneralConnectorBuilder.kt deleted file mode 100644 index cd71aa202ca..00000000000 --- a/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/generators/GeneralConnectorBuilder.kt +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2010-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.ir2cfg.generators - -import org.jetbrains.kotlin.ir.IrStatement -import org.jetbrains.kotlin.ir2cfg.builders.BlockConnectorBuilder -import org.jetbrains.kotlin.ir2cfg.graph.BasicBlock - -class GeneralConnectorBuilder(private val element: IrStatement) : BlockConnectorBuilder { - - private val next = linkedSetOf() - - private val previous = linkedSetOf() - - override fun addNext(basicBlock: BasicBlock) { - next.add(basicBlock) - } - - override fun addPrevious(basicBlock: BasicBlock) { - previous.add(basicBlock) - } - - override fun build() = when { - next.size <= 1 -> JoinBlockConnector(previous.toList(), element, next.firstOrNull()) - previous.size == 1 -> SplitBlockConnector(previous.single(), element, next.toList()) - else -> throw AssertionError("Connector should have either exactly one previous block or no more than one next block, " + - "actual previous = ${previous.size}, next = ${next.size}") - } -} \ No newline at end of file diff --git a/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/generators/JoinBlockConnector.kt b/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/generators/JoinBlockConnector.kt deleted file mode 100644 index e87c7203729..00000000000 --- a/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/generators/JoinBlockConnector.kt +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2010-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.ir2cfg.generators - -import org.jetbrains.kotlin.ir.IrStatement -import org.jetbrains.kotlin.ir2cfg.graph.BasicBlock -import org.jetbrains.kotlin.ir2cfg.graph.BlockConnector - -class JoinBlockConnector( - override val previousBlocks: List, - override val element: IrStatement, - next: BasicBlock? -) : BlockConnector { - - override val nextBlocks = listOfNotNull(next) -} \ No newline at end of file diff --git a/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/generators/SplitBlockConnector.kt b/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/generators/SplitBlockConnector.kt deleted file mode 100644 index c5e3d1d8e23..00000000000 --- a/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/generators/SplitBlockConnector.kt +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2010-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.ir2cfg.generators - -import org.jetbrains.kotlin.ir.IrStatement -import org.jetbrains.kotlin.ir2cfg.graph.BasicBlock -import org.jetbrains.kotlin.ir2cfg.graph.BlockConnector - -class SplitBlockConnector( - previous: BasicBlock, - override val element: IrStatement, - override val nextBlocks: List -) : BlockConnector { - - override val previousBlocks = listOf(previous) -} \ No newline at end of file diff --git a/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/graph/BasicBlock.kt b/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/graph/BasicBlock.kt deleted file mode 100644 index 2f07eca6133..00000000000 --- a/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/graph/BasicBlock.kt +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2010-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.ir2cfg.graph - -import org.jetbrains.kotlin.ir.IrStatement - -interface BasicBlock : CfgNode { - - val elements: List - - val incoming: BlockConnector? - - val outgoing: BlockConnector? - - override val predecessors: List - get() = listOfNotNull(incoming) - - override val successors: List - get() = listOfNotNull(outgoing) -} \ No newline at end of file diff --git a/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/graph/BlockConnector.kt b/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/graph/BlockConnector.kt deleted file mode 100644 index e479f563cd3..00000000000 --- a/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/graph/BlockConnector.kt +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2010-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.ir2cfg.graph - -import org.jetbrains.kotlin.ir.IrStatement - -interface BlockConnector : CfgNode { - - val previousBlocks: List - - val element: IrStatement - - val nextBlocks: List - - override val predecessors: List - get() = previousBlocks - - override val successors: List - get() = nextBlocks -} \ No newline at end of file diff --git a/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/graph/CfgNode.kt b/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/graph/CfgNode.kt deleted file mode 100644 index 315d5f8c088..00000000000 --- a/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/graph/CfgNode.kt +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2010-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.ir2cfg.graph - -interface CfgNode { - - val predecessors: List - - val successors: List -} \ No newline at end of file diff --git a/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/graph/ControlFlowGraph.kt b/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/graph/ControlFlowGraph.kt deleted file mode 100644 index e7dc6a31178..00000000000 --- a/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/graph/ControlFlowGraph.kt +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2010-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.ir2cfg.graph - -import org.jetbrains.kotlin.ir.declarations.IrFunction - -interface ControlFlowGraph { - - val function: IrFunction - - // First block is the entry point - val blocks: List - - val connectors: List - - val nodes: List - get() = blocks + connectors -} \ No newline at end of file diff --git a/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/nodes/CfgIrElement.kt b/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/nodes/CfgIrElement.kt deleted file mode 100644 index 58bb33a6cee..00000000000 --- a/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/nodes/CfgIrElement.kt +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright 2010-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.ir2cfg.nodes - -import org.jetbrains.kotlin.ir.IrStatement - -interface CfgIrElement : IrStatement \ No newline at end of file diff --git a/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/nodes/MergeCfgElement.kt b/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/nodes/MergeCfgElement.kt deleted file mode 100644 index 93abcc02ed1..00000000000 --- a/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/nodes/MergeCfgElement.kt +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2010-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.ir2cfg.nodes - -import org.jetbrains.kotlin.ir.IrElement -import org.jetbrains.kotlin.ir.util.dump -import org.jetbrains.kotlin.ir.visitors.IrElementTransformer -import org.jetbrains.kotlin.ir.visitors.IrElementVisitor - -class MergeCfgElement(val from: IrElement, val name: String) : CfgIrElement { - override val startOffset = from.startOffset - override val endOffset = from.endOffset - - override fun accept(visitor: IrElementVisitor, data: D) = visitor.visitElement(this, data) - - override fun transform(transformer: IrElementTransformer, data: D): IrElement = accept(transformer, data) - - override fun acceptChildren(visitor: IrElementVisitor, data: D) = Unit - - override fun transformChildren(transformer: IrElementTransformer, data: D) = Unit - - override fun toString() = "$name: ${from.dump()}" -} diff --git a/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/util/ControlFlowRenderer.kt b/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/util/ControlFlowRenderer.kt deleted file mode 100644 index 0fd026fed1e..00000000000 --- a/compiler/ir/ir.ir2cfg/src/org/jetbrains/kotlin/ir2cfg/util/ControlFlowRenderer.kt +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2010-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.ir2cfg.util - -import org.jetbrains.kotlin.ir.IrElement -import org.jetbrains.kotlin.ir.util.dump -import org.jetbrains.kotlin.ir2cfg.graph.BasicBlock -import org.jetbrains.kotlin.ir2cfg.graph.BlockConnector -import org.jetbrains.kotlin.ir2cfg.graph.ControlFlowGraph -import org.jetbrains.kotlin.ir2cfg.nodes.MergeCfgElement - -private fun IrElement.cfgDump() = when (this) { - is MergeCfgElement -> "$this" - else -> dump() -} - -fun BasicBlock.dump(builder: StringBuilder = StringBuilder(), indent: String = ""): String { - for ((index, element) in elements.withIndex()) { - builder.append(indent) - builder.append(String.format("%3d ", index + 1)) - val dump = element.cfgDump() - builder.appendLine(dump.lines().first()) - } - return builder.toString() -} - -fun BlockConnector.dump(builder: StringBuilder = StringBuilder(), indent: String = ""): String { - builder.append(indent) - val dump = element.cfgDump() - builder.appendLine(dump.lines().first()) - return builder.toString() -} - -fun ControlFlowGraph.dump(): String { - val connectorIndex = hashMapOf() - for ((index, connector) in connectors.withIndex()) { - connectorIndex[connector] = index - } - val blockIndex = hashMapOf() - for ((index, block) in blocks.withIndex()) { - blockIndex[block] = index - } - val builder = StringBuilder() - for ((index, block) in blocks.withIndex()) { - builder.appendLine("BB $index") - val incoming = block.incoming - if (incoming != null) { - builder.appendLine(incoming.previousBlocks.joinToString(prefix = "INCOMING <- BB ") { blockIndex[it].toString() }) - incoming.dump(builder, " ") - } - builder.appendLine("CONTENT") - block.dump(builder, " ") - val outgoing = block.outgoing - if (outgoing != null) { - if (outgoing.nextBlocks.isEmpty()) { - builder.appendLine("OUTGOING -> NONE") - } - else { - builder.appendLine(outgoing.nextBlocks.joinToString(prefix = "OUTGOING -> BB ") { blockIndex[it].toString() }) - } - outgoing.dump(builder, " ") - } - } - return builder.toString() -} \ No newline at end of file diff --git a/compiler/testData/ir/irCfg/expressionFun.kt b/compiler/testData/ir/irCfg/expressionFun.kt deleted file mode 100644 index 4ce098c4774..00000000000 --- a/compiler/testData/ir/irCfg/expressionFun.kt +++ /dev/null @@ -1 +0,0 @@ -fun foo(arg: Int) = arg \ No newline at end of file diff --git a/compiler/testData/ir/irCfg/expressionFun.txt b/compiler/testData/ir/irCfg/expressionFun.txt deleted file mode 100644 index 218817acc25..00000000000 --- a/compiler/testData/ir/irCfg/expressionFun.txt +++ /dev/null @@ -1,14 +0,0 @@ -// FILE: /expressionFun.kt -// FUN: foo -BB 0 -CONTENT - 1 FUN name:foo visibility:public modality:FINAL <> (arg:kotlin.Int) returnType:kotlin.Int - 2 GET_VAR 'arg: kotlin.Int declared in .foo' type=kotlin.Int origin=null - 3 RETURN type=kotlin.Nothing from='public final fun foo (arg: kotlin.Int): kotlin.Int declared in ' -OUTGOING -> NONE - Function exit: FUN name:foo visibility:public modality:FINAL <> (arg:kotlin.Int) returnType:kotlin.Int - -// END FUN: foo - -// END FILE: /expressionFun.kt - diff --git a/compiler/testData/ir/irCfg/expressionUnit.kt b/compiler/testData/ir/irCfg/expressionUnit.kt deleted file mode 100644 index 44ce3c5bd0a..00000000000 --- a/compiler/testData/ir/irCfg/expressionUnit.kt +++ /dev/null @@ -1 +0,0 @@ -fun foo() = Unit \ No newline at end of file diff --git a/compiler/testData/ir/irCfg/expressionUnit.txt b/compiler/testData/ir/irCfg/expressionUnit.txt deleted file mode 100644 index f682188a03a..00000000000 --- a/compiler/testData/ir/irCfg/expressionUnit.txt +++ /dev/null @@ -1,14 +0,0 @@ -// FILE: /expressionUnit.kt -// FUN: foo -BB 0 -CONTENT - 1 FUN name:foo visibility:public modality:FINAL <> () returnType:kotlin.Unit - 2 GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit - 3 RETURN type=kotlin.Nothing from='public final fun foo (): kotlin.Unit declared in ' -OUTGOING -> NONE - Function exit: FUN name:foo visibility:public modality:FINAL <> () returnType:kotlin.Unit - -// END FUN: foo - -// END FILE: /expressionUnit.kt - diff --git a/compiler/testData/ir/irCfg/loop/digitCount.kt b/compiler/testData/ir/irCfg/loop/digitCount.kt deleted file mode 100644 index 2220daf7e70..00000000000 --- a/compiler/testData/ir/irCfg/loop/digitCount.kt +++ /dev/null @@ -1,11 +0,0 @@ -fun digitCountInNumber(n: Int, m: Int): Int { - var count = 0 - var number = n - do { - if (m == number % 10) { - count++ - } - number /= 10 - } while (number > 0) - return count -} diff --git a/compiler/testData/ir/irCfg/loop/digitCount.txt b/compiler/testData/ir/irCfg/loop/digitCount.txt deleted file mode 100644 index 71e76ecfa14..00000000000 --- a/compiler/testData/ir/irCfg/loop/digitCount.txt +++ /dev/null @@ -1,68 +0,0 @@ -// FILE: /digitCount.kt -// FUN: digitCountInNumber -BB 0 -CONTENT - 1 FUN name:digitCountInNumber visibility:public modality:FINAL <> (n:kotlin.Int, m:kotlin.Int) returnType:kotlin.Int - 2 CONST Int type=kotlin.Int value=0 - 3 VAR name:count type:kotlin.Int [var] - 4 GET_VAR 'n: kotlin.Int declared in .digitCountInNumber' type=kotlin.Int origin=null - 5 VAR name:number type:kotlin.Int [var] - 6 DO_WHILE label=null origin=DO_WHILE_LOOP -OUTGOING -> BB 1 - Do..while entry: DO_WHILE label=null origin=DO_WHILE_LOOP -BB 1 -INCOMING <- BB 0, 4 - Do..while entry: DO_WHILE label=null origin=DO_WHILE_LOOP -CONTENT - 1 WHEN type=kotlin.Unit origin=IF - 2 GET_VAR 'm: kotlin.Int declared in .digitCountInNumber' type=kotlin.Int origin=null - 3 GET_VAR 'var number: kotlin.Int [var] declared in .digitCountInNumber' type=kotlin.Int origin=null - 4 CONST Int type=kotlin.Int value=10 - 5 CALL 'public final fun rem (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PERC -OUTGOING -> BB 2 - CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ -BB 2 -INCOMING <- BB 1 - CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ -CONTENT - 1 GET_VAR 'var count: kotlin.Int [var] declared in .digitCountInNumber' type=kotlin.Int origin=POSTFIX_INCR - 2 VAR IR_TEMPORARY_VARIABLE name:tmp0 type:kotlin.Int [val] - 3 SET_VAR 'var count: kotlin.Int [var] declared in .digitCountInNumber' type=kotlin.Unit origin=POSTFIX_INCR - 4 GET_VAR 'val tmp0: kotlin.Int [val] declared in .digitCountInNumber' type=kotlin.Int origin=null - 5 TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit -OUTGOING -> BB 3 - When exit: WHEN type=kotlin.Unit origin=IF -BB 3 -INCOMING <- BB 2 - When exit: WHEN type=kotlin.Unit origin=IF -CONTENT - 1 SET_VAR 'var number: kotlin.Int [var] declared in .digitCountInNumber' type=kotlin.Unit origin=DIVEQ - 2 GET_VAR 'var number: kotlin.Int [var] declared in .digitCountInNumber' type=kotlin.Int origin=null - 3 CONST Int type=kotlin.Int value=0 -OUTGOING -> BB 4, 5 - CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT -BB 4 -INCOMING <- BB 3 - CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT -CONTENT -OUTGOING -> BB 1 - Do..while entry: DO_WHILE label=null origin=DO_WHILE_LOOP -BB 5 -INCOMING <- BB 3 - CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT -CONTENT -OUTGOING -> BB 6 - Do..while exit: DO_WHILE label=null origin=DO_WHILE_LOOP -BB 6 -INCOMING <- BB 5 - Do..while exit: DO_WHILE label=null origin=DO_WHILE_LOOP -CONTENT - 1 GET_VAR 'var count: kotlin.Int [var] declared in .digitCountInNumber' type=kotlin.Int origin=null - 2 RETURN type=kotlin.Nothing from='public final fun digitCountInNumber (n: kotlin.Int, m: kotlin.Int): kotlin.Int declared in ' -OUTGOING -> NONE - Function exit: FUN name:digitCountInNumber visibility:public modality:FINAL <> (n:kotlin.Int, m:kotlin.Int) returnType:kotlin.Int - -// END FUN: digitCountInNumber - -// END FILE: /digitCount.kt - diff --git a/compiler/testData/ir/irCfg/loop/factorial.kt b/compiler/testData/ir/irCfg/loop/factorial.kt deleted file mode 100644 index b3ed56563ab..00000000000 --- a/compiler/testData/ir/irCfg/loop/factorial.kt +++ /dev/null @@ -1,7 +0,0 @@ -fun factorial(i: Int): Int { - var result = 1 - for (j in 2..i) { - result *= j - } - return result -} \ No newline at end of file diff --git a/compiler/testData/ir/irCfg/loop/factorial.txt b/compiler/testData/ir/irCfg/loop/factorial.txt deleted file mode 100644 index fd6ebd451d3..00000000000 --- a/compiler/testData/ir/irCfg/loop/factorial.txt +++ /dev/null @@ -1,51 +0,0 @@ -// FILE: /factorial.kt -// FUN: factorial -BB 0 -CONTENT - 1 FUN name:factorial visibility:public modality:FINAL <> (i:kotlin.Int) returnType:kotlin.Int - 2 CONST Int type=kotlin.Int value=1 - 3 VAR name:result type:kotlin.Int [var] - 4 CONST Int type=kotlin.Int value=2 - 5 GET_VAR 'i: kotlin.Int declared in .factorial' type=kotlin.Int origin=null - 6 CALL 'public final fun rangeTo (other: kotlin.Int): kotlin.ranges.IntRange [operator] declared in kotlin.Int' type=kotlin.ranges.IntRange origin=RANGE - 7 CALL 'public open fun iterator (): kotlin.collections.IntIterator [fake_override,operator] declared in kotlin.ranges.IntRange' type=kotlin.collections.IntIterator origin=FOR_LOOP_ITERATOR - 8 VAR FOR_LOOP_ITERATOR name:tmp0_iterator type:kotlin.collections.IntIterator [val] - 9 WHILE label=null origin=FOR_LOOP_INNER_WHILE -OUTGOING -> BB 1 - While entry: WHILE label=null origin=FOR_LOOP_INNER_WHILE -BB 1 -INCOMING <- BB 0, 2 - While entry: WHILE label=null origin=FOR_LOOP_INNER_WHILE -CONTENT - 1 GET_VAR 'val tmp0_iterator: kotlin.collections.IntIterator [val] declared in .factorial' type=kotlin.collections.IntIterator origin=null -OUTGOING -> BB 2, 3 - CALL 'public abstract fun hasNext (): kotlin.Boolean [fake_override,operator] declared in kotlin.collections.IntIterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT -BB 2 -INCOMING <- BB 1 - CALL 'public abstract fun hasNext (): kotlin.Boolean [fake_override,operator] declared in kotlin.collections.IntIterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT -CONTENT - 1 GET_VAR 'val tmp0_iterator: kotlin.collections.IntIterator [val] declared in .factorial' type=kotlin.collections.IntIterator origin=null - 2 CALL 'public final fun next (): kotlin.Int [operator] declared in kotlin.collections.IntIterator' type=kotlin.Int origin=FOR_LOOP_NEXT - 3 VAR FOR_LOOP_VARIABLE name:j type:kotlin.Int [val] - 4 SET_VAR 'var result: kotlin.Int [var] declared in .factorial' type=kotlin.Unit origin=MULTEQ -OUTGOING -> BB 1 - While entry: WHILE label=null origin=FOR_LOOP_INNER_WHILE -BB 3 -INCOMING <- BB 1 - CALL 'public abstract fun hasNext (): kotlin.Boolean [fake_override,operator] declared in kotlin.collections.IntIterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT -CONTENT -OUTGOING -> BB 4 - While exit: WHILE label=null origin=FOR_LOOP_INNER_WHILE -BB 4 -INCOMING <- BB 3 - While exit: WHILE label=null origin=FOR_LOOP_INNER_WHILE -CONTENT - 1 GET_VAR 'var result: kotlin.Int [var] declared in .factorial' type=kotlin.Int origin=null - 2 RETURN type=kotlin.Nothing from='public final fun factorial (i: kotlin.Int): kotlin.Int declared in ' -OUTGOING -> NONE - Function exit: FUN name:factorial visibility:public modality:FINAL <> (i:kotlin.Int) returnType:kotlin.Int - -// END FUN: factorial - -// END FILE: /factorial.kt - diff --git a/compiler/testData/ir/irCfg/loop/isPerfect.kt b/compiler/testData/ir/irCfg/loop/isPerfect.kt deleted file mode 100644 index 34ba793f678..00000000000 --- a/compiler/testData/ir/irCfg/loop/isPerfect.kt +++ /dev/null @@ -1,9 +0,0 @@ -fun isPerfect(n: Int): Boolean { - var sum = 1 - for (m in 2..n/2) { - if (n % m > 0) continue - sum += m - if (sum > n) break - } - return sum == n -} \ No newline at end of file diff --git a/compiler/testData/ir/irCfg/loop/isPerfect.txt b/compiler/testData/ir/irCfg/loop/isPerfect.txt deleted file mode 100644 index 23f4bc1424f..00000000000 --- a/compiler/testData/ir/irCfg/loop/isPerfect.txt +++ /dev/null @@ -1,89 +0,0 @@ -// FILE: /isPerfect.kt -// FUN: isPerfect -BB 0 -CONTENT - 1 FUN name:isPerfect visibility:public modality:FINAL <> (n:kotlin.Int) returnType:kotlin.Boolean - 2 CONST Int type=kotlin.Int value=1 - 3 VAR name:sum type:kotlin.Int [var] - 4 CONST Int type=kotlin.Int value=2 - 5 GET_VAR 'n: kotlin.Int declared in .isPerfect' type=kotlin.Int origin=null - 6 CONST Int type=kotlin.Int value=2 - 7 CALL 'public final fun div (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=DIV - 8 CALL 'public final fun rangeTo (other: kotlin.Int): kotlin.ranges.IntRange [operator] declared in kotlin.Int' type=kotlin.ranges.IntRange origin=RANGE - 9 CALL 'public open fun iterator (): kotlin.collections.IntIterator [fake_override,operator] declared in kotlin.ranges.IntRange' type=kotlin.collections.IntIterator origin=FOR_LOOP_ITERATOR - 10 VAR FOR_LOOP_ITERATOR name:tmp0_iterator type:kotlin.collections.IntIterator [val] - 11 WHILE label=null origin=FOR_LOOP_INNER_WHILE -OUTGOING -> BB 1 - While entry: WHILE label=null origin=FOR_LOOP_INNER_WHILE -BB 1 -INCOMING <- BB 0, 3, 6 - While entry: WHILE label=null origin=FOR_LOOP_INNER_WHILE -CONTENT - 1 GET_VAR 'val tmp0_iterator: kotlin.collections.IntIterator [val] declared in .isPerfect' type=kotlin.collections.IntIterator origin=null -OUTGOING -> BB 2, 7 - CALL 'public abstract fun hasNext (): kotlin.Boolean [fake_override,operator] declared in kotlin.collections.IntIterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT -BB 2 -INCOMING <- BB 1 - CALL 'public abstract fun hasNext (): kotlin.Boolean [fake_override,operator] declared in kotlin.collections.IntIterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT -CONTENT - 1 GET_VAR 'val tmp0_iterator: kotlin.collections.IntIterator [val] declared in .isPerfect' type=kotlin.collections.IntIterator origin=null - 2 CALL 'public final fun next (): kotlin.Int [operator] declared in kotlin.collections.IntIterator' type=kotlin.Int origin=FOR_LOOP_NEXT - 3 VAR FOR_LOOP_VARIABLE name:m type:kotlin.Int [val] - 4 WHEN type=kotlin.Unit origin=IF - 5 GET_VAR 'n: kotlin.Int declared in .isPerfect' type=kotlin.Int origin=null - 6 GET_VAR 'val m: kotlin.Int [val] declared in .isPerfect' type=kotlin.Int origin=null - 7 CALL 'public final fun rem (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PERC - 8 CONST Int type=kotlin.Int value=0 -OUTGOING -> BB 3, 4 - CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT -BB 3 -INCOMING <- BB 2 - CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT -CONTENT - 1 CONTINUE label=null loop.label=null -OUTGOING -> BB 1 - While entry: WHILE label=null origin=FOR_LOOP_INNER_WHILE -BB 4 -INCOMING <- BB 2 - CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT -CONTENT - 1 SET_VAR 'var sum: kotlin.Int [var] declared in .isPerfect' type=kotlin.Unit origin=PLUSEQ - 2 WHEN type=kotlin.Unit origin=IF - 3 GET_VAR 'var sum: kotlin.Int [var] declared in .isPerfect' type=kotlin.Int origin=null - 4 GET_VAR 'n: kotlin.Int declared in .isPerfect' type=kotlin.Int origin=null -OUTGOING -> BB 5, 6 - CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT -BB 5 -INCOMING <- BB 4 - CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT -CONTENT - 1 BREAK label=null loop.label=null -OUTGOING -> BB 8 - While exit: WHILE label=null origin=FOR_LOOP_INNER_WHILE -BB 6 -INCOMING <- BB 4 - CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT -CONTENT -OUTGOING -> BB 1 - While entry: WHILE label=null origin=FOR_LOOP_INNER_WHILE -BB 7 -INCOMING <- BB 1 - CALL 'public abstract fun hasNext (): kotlin.Boolean [fake_override,operator] declared in kotlin.collections.IntIterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT -CONTENT -OUTGOING -> BB 8 - While exit: WHILE label=null origin=FOR_LOOP_INNER_WHILE -BB 8 -INCOMING <- BB 5, 7 - While exit: WHILE label=null origin=FOR_LOOP_INNER_WHILE -CONTENT - 1 GET_VAR 'var sum: kotlin.Int [var] declared in .isPerfect' type=kotlin.Int origin=null - 2 GET_VAR 'n: kotlin.Int declared in .isPerfect' type=kotlin.Int origin=null - 3 CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ - 4 RETURN type=kotlin.Nothing from='public final fun isPerfect (n: kotlin.Int): kotlin.Boolean declared in ' -OUTGOING -> NONE - Function exit: FUN name:isPerfect visibility:public modality:FINAL <> (n:kotlin.Int) returnType:kotlin.Boolean - -// END FUN: isPerfect - -// END FILE: /isPerfect.kt - diff --git a/compiler/testData/ir/irCfg/returnUnit.kt b/compiler/testData/ir/irCfg/returnUnit.kt deleted file mode 100644 index e3b44cd6a51..00000000000 --- a/compiler/testData/ir/irCfg/returnUnit.kt +++ /dev/null @@ -1,3 +0,0 @@ -fun foo() { - return Unit -} \ No newline at end of file diff --git a/compiler/testData/ir/irCfg/returnUnit.txt b/compiler/testData/ir/irCfg/returnUnit.txt deleted file mode 100644 index 503a77bbc39..00000000000 --- a/compiler/testData/ir/irCfg/returnUnit.txt +++ /dev/null @@ -1,14 +0,0 @@ -// FILE: /returnUnit.kt -// FUN: foo -BB 0 -CONTENT - 1 FUN name:foo visibility:public modality:FINAL <> () returnType:kotlin.Unit - 2 GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit - 3 RETURN type=kotlin.Nothing from='public final fun foo (): kotlin.Unit declared in ' -OUTGOING -> NONE - Function exit: FUN name:foo visibility:public modality:FINAL <> () returnType:kotlin.Unit - -// END FUN: foo - -// END FILE: /returnUnit.kt - diff --git a/compiler/testData/ir/irCfg/sequentialFun.kt b/compiler/testData/ir/irCfg/sequentialFun.kt deleted file mode 100644 index 940d511eeb7..00000000000 --- a/compiler/testData/ir/irCfg/sequentialFun.kt +++ /dev/null @@ -1,4 +0,0 @@ -fun foo(arg: Int): Int { - val dbl = arg * 2 - return dbl -} \ No newline at end of file diff --git a/compiler/testData/ir/irCfg/sequentialFun.txt b/compiler/testData/ir/irCfg/sequentialFun.txt deleted file mode 100644 index d8e0ae818a8..00000000000 --- a/compiler/testData/ir/irCfg/sequentialFun.txt +++ /dev/null @@ -1,18 +0,0 @@ -// FILE: /sequentialFun.kt -// FUN: foo -BB 0 -CONTENT - 1 FUN name:foo visibility:public modality:FINAL <> (arg:kotlin.Int) returnType:kotlin.Int - 2 GET_VAR 'arg: kotlin.Int declared in .foo' type=kotlin.Int origin=null - 3 CONST Int type=kotlin.Int value=2 - 4 CALL 'public final fun times (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=MUL - 5 VAR name:dbl type:kotlin.Int [val] - 6 GET_VAR 'val dbl: kotlin.Int [val] declared in .foo' type=kotlin.Int origin=null - 7 RETURN type=kotlin.Nothing from='public final fun foo (arg: kotlin.Int): kotlin.Int declared in ' -OUTGOING -> NONE - Function exit: FUN name:foo visibility:public modality:FINAL <> (arg:kotlin.Int) returnType:kotlin.Int - -// END FUN: foo - -// END FILE: /sequentialFun.kt - diff --git a/compiler/testData/ir/irCfg/simpleFun.kt b/compiler/testData/ir/irCfg/simpleFun.kt deleted file mode 100644 index 59281f1b0bb..00000000000 --- a/compiler/testData/ir/irCfg/simpleFun.kt +++ /dev/null @@ -1 +0,0 @@ -fun foo() {} \ No newline at end of file diff --git a/compiler/testData/ir/irCfg/simpleFun.txt b/compiler/testData/ir/irCfg/simpleFun.txt deleted file mode 100644 index a5e25325c86..00000000000 --- a/compiler/testData/ir/irCfg/simpleFun.txt +++ /dev/null @@ -1,12 +0,0 @@ -// FILE: /simpleFun.kt -// FUN: foo -BB 0 -CONTENT - 1 FUN name:foo visibility:public modality:FINAL <> () returnType:kotlin.Unit -OUTGOING -> NONE - Function exit: FUN name:foo visibility:public modality:FINAL <> () returnType:kotlin.Unit - -// END FUN: foo - -// END FILE: /simpleFun.kt - diff --git a/compiler/testData/ir/irCfg/simpleReturn.kt b/compiler/testData/ir/irCfg/simpleReturn.kt deleted file mode 100644 index 0083baaa06a..00000000000 --- a/compiler/testData/ir/irCfg/simpleReturn.kt +++ /dev/null @@ -1,3 +0,0 @@ -fun foo() { - return -} \ No newline at end of file diff --git a/compiler/testData/ir/irCfg/simpleReturn.txt b/compiler/testData/ir/irCfg/simpleReturn.txt deleted file mode 100644 index 5caf13402ee..00000000000 --- a/compiler/testData/ir/irCfg/simpleReturn.txt +++ /dev/null @@ -1,14 +0,0 @@ -// FILE: /simpleReturn.kt -// FUN: foo -BB 0 -CONTENT - 1 FUN name:foo visibility:public modality:FINAL <> () returnType:kotlin.Unit - 2 GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit - 3 RETURN type=kotlin.Nothing from='public final fun foo (): kotlin.Unit declared in ' -OUTGOING -> NONE - Function exit: FUN name:foo visibility:public modality:FINAL <> () returnType:kotlin.Unit - -// END FUN: foo - -// END FILE: /simpleReturn.kt - diff --git a/compiler/testData/ir/irCfg/when/cascadeIf.kt b/compiler/testData/ir/irCfg/when/cascadeIf.kt deleted file mode 100644 index 736e63eb7c0..00000000000 --- a/compiler/testData/ir/irCfg/when/cascadeIf.kt +++ /dev/null @@ -1 +0,0 @@ -fun compare(x: Int, y: Int) = if (x > y) 1 else if (x < y) -1 else 0 \ No newline at end of file diff --git a/compiler/testData/ir/irCfg/when/cascadeIf.txt b/compiler/testData/ir/irCfg/when/cascadeIf.txt deleted file mode 100644 index c4bd49357fd..00000000000 --- a/compiler/testData/ir/irCfg/when/cascadeIf.txt +++ /dev/null @@ -1,57 +0,0 @@ -// FILE: /cascadeIf.kt -// FUN: compare -BB 0 -CONTENT - 1 FUN name:compare visibility:public modality:FINAL <> (x:kotlin.Int, y:kotlin.Int) returnType:kotlin.Int - 2 WHEN type=kotlin.Int origin=IF - 3 GET_VAR 'x: kotlin.Int declared in .compare' type=kotlin.Int origin=null - 4 GET_VAR 'y: kotlin.Int declared in .compare' type=kotlin.Int origin=null -OUTGOING -> BB 1, 3 - CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT -BB 1 -INCOMING <- BB 0 - CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT -CONTENT - 1 GET_VAR 'x: kotlin.Int declared in .compare' type=kotlin.Int origin=null - 2 GET_VAR 'y: kotlin.Int declared in .compare' type=kotlin.Int origin=null -OUTGOING -> BB 2, 4 - CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT -BB 2 -INCOMING <- BB 1 - CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT -CONTENT -OUTGOING -> BB 5 - CONST Boolean type=kotlin.Boolean value=true -BB 3 -INCOMING <- BB 0 - CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT -CONTENT - 1 CONST Int type=kotlin.Int value=1 -OUTGOING -> BB 6 - When exit: WHEN type=kotlin.Int origin=IF -BB 4 -INCOMING <- BB 1 - CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT -CONTENT - 1 CONST Int type=kotlin.Int value=-1 -OUTGOING -> BB 6 - When exit: WHEN type=kotlin.Int origin=IF -BB 5 -INCOMING <- BB 2 - CONST Boolean type=kotlin.Boolean value=true -CONTENT - 1 CONST Int type=kotlin.Int value=0 -OUTGOING -> BB 6 - When exit: WHEN type=kotlin.Int origin=IF -BB 6 -INCOMING <- BB 3, 4, 5 - When exit: WHEN type=kotlin.Int origin=IF -CONTENT - 1 RETURN type=kotlin.Nothing from='public final fun compare (x: kotlin.Int, y: kotlin.Int): kotlin.Int declared in ' -OUTGOING -> NONE - Function exit: FUN name:compare visibility:public modality:FINAL <> (x:kotlin.Int, y:kotlin.Int) returnType:kotlin.Int - -// END FUN: compare - -// END FILE: /cascadeIf.kt - diff --git a/compiler/testData/ir/irCfg/when/emptyWhen.kt b/compiler/testData/ir/irCfg/when/emptyWhen.kt deleted file mode 100644 index 98c25237275..00000000000 --- a/compiler/testData/ir/irCfg/when/emptyWhen.kt +++ /dev/null @@ -1,3 +0,0 @@ -fun empty() = when { - else -> 42 -} \ No newline at end of file diff --git a/compiler/testData/ir/irCfg/when/emptyWhen.txt b/compiler/testData/ir/irCfg/when/emptyWhen.txt deleted file mode 100644 index cae38f0a720..00000000000 --- a/compiler/testData/ir/irCfg/when/emptyWhen.txt +++ /dev/null @@ -1,27 +0,0 @@ -// FILE: /emptyWhen.kt -// FUN: empty -BB 0 -CONTENT - 1 FUN name:empty visibility:public modality:FINAL <> () returnType:kotlin.Int - 2 WHEN type=kotlin.Int origin=WHEN -OUTGOING -> BB 1 - CONST Boolean type=kotlin.Boolean value=true -BB 1 -INCOMING <- BB 0 - CONST Boolean type=kotlin.Boolean value=true -CONTENT - 1 CONST Int type=kotlin.Int value=42 -OUTGOING -> BB 2 - When exit: WHEN type=kotlin.Int origin=WHEN -BB 2 -INCOMING <- BB 1 - When exit: WHEN type=kotlin.Int origin=WHEN -CONTENT - 1 RETURN type=kotlin.Nothing from='public final fun empty (): kotlin.Int declared in ' -OUTGOING -> NONE - Function exit: FUN name:empty visibility:public modality:FINAL <> () returnType:kotlin.Int - -// END FUN: empty - -// END FILE: /emptyWhen.kt - diff --git a/compiler/testData/ir/irCfg/when/expressionIf.kt b/compiler/testData/ir/irCfg/when/expressionIf.kt deleted file mode 100644 index 575dc2f31fd..00000000000 --- a/compiler/testData/ir/irCfg/when/expressionIf.kt +++ /dev/null @@ -1 +0,0 @@ -fun max(x: Int, y: Int) = if (x > y) x else y \ No newline at end of file diff --git a/compiler/testData/ir/irCfg/when/expressionIf.txt b/compiler/testData/ir/irCfg/when/expressionIf.txt deleted file mode 100644 index 99b06e1e1df..00000000000 --- a/compiler/testData/ir/irCfg/when/expressionIf.txt +++ /dev/null @@ -1,42 +0,0 @@ -// FILE: /expressionIf.kt -// FUN: max -BB 0 -CONTENT - 1 FUN name:max visibility:public modality:FINAL <> (x:kotlin.Int, y:kotlin.Int) returnType:kotlin.Int - 2 WHEN type=kotlin.Int origin=IF - 3 GET_VAR 'x: kotlin.Int declared in .max' type=kotlin.Int origin=null - 4 GET_VAR 'y: kotlin.Int declared in .max' type=kotlin.Int origin=null -OUTGOING -> BB 1, 2 - CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT -BB 1 -INCOMING <- BB 0 - CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT -CONTENT -OUTGOING -> BB 3 - CONST Boolean type=kotlin.Boolean value=true -BB 2 -INCOMING <- BB 0 - CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT -CONTENT - 1 GET_VAR 'x: kotlin.Int declared in .max' type=kotlin.Int origin=null -OUTGOING -> BB 4 - When exit: WHEN type=kotlin.Int origin=IF -BB 3 -INCOMING <- BB 1 - CONST Boolean type=kotlin.Boolean value=true -CONTENT - 1 GET_VAR 'y: kotlin.Int declared in .max' type=kotlin.Int origin=null -OUTGOING -> BB 4 - When exit: WHEN type=kotlin.Int origin=IF -BB 4 -INCOMING <- BB 2, 3 - When exit: WHEN type=kotlin.Int origin=IF -CONTENT - 1 RETURN type=kotlin.Nothing from='public final fun max (x: kotlin.Int, y: kotlin.Int): kotlin.Int declared in ' -OUTGOING -> NONE - Function exit: FUN name:max visibility:public modality:FINAL <> (x:kotlin.Int, y:kotlin.Int) returnType:kotlin.Int - -// END FUN: max - -// END FILE: /expressionIf.kt - diff --git a/compiler/testData/ir/irCfg/when/ifChain.kt b/compiler/testData/ir/irCfg/when/ifChain.kt deleted file mode 100644 index 6ea0fc912ef..00000000000 --- a/compiler/testData/ir/irCfg/when/ifChain.kt +++ /dev/null @@ -1,14 +0,0 @@ -fun minBiRoot(a: Double, b: Double, c: Double): Double { - if (a == 0.0) { - if (b == 0.0) return 1.0 - val bc = -c / b - if (bc < 0.0) return 2.0 - return -bc - } - val d = b * b - 4 * a * c - if (d < 0.0) return 3.0 - val y1 = (-b + d) / (2 * a) - val y2 = (-b - d) / (2 * a) - val y3 = if (y1 > y2) y1 else y2 - return if (y3 < 0.0) 4.0 else -y3 -} \ No newline at end of file diff --git a/compiler/testData/ir/irCfg/when/ifChain.txt b/compiler/testData/ir/irCfg/when/ifChain.txt deleted file mode 100644 index 34cc796aafd..00000000000 --- a/compiler/testData/ir/irCfg/when/ifChain.txt +++ /dev/null @@ -1,175 +0,0 @@ -// FILE: /ifChain.kt -// FUN: minBiRoot -BB 0 -CONTENT - 1 FUN name:minBiRoot visibility:public modality:FINAL <> (a:kotlin.Double, b:kotlin.Double, c:kotlin.Double) returnType:kotlin.Double - 2 WHEN type=kotlin.Unit origin=IF - 3 GET_VAR 'a: kotlin.Double declared in .minBiRoot' type=kotlin.Double origin=null - 4 CONST Double type=kotlin.Double value=0.0 -OUTGOING -> BB 1, 6 - CALL 'public final fun ieee754equals (arg0: kotlin.Double?, arg1: kotlin.Double?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ -BB 1 -INCOMING <- BB 0 - CALL 'public final fun ieee754equals (arg0: kotlin.Double?, arg1: kotlin.Double?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ -CONTENT - 1 WHEN type=kotlin.Unit origin=IF - 2 GET_VAR 'b: kotlin.Double declared in .minBiRoot' type=kotlin.Double origin=null - 3 CONST Double type=kotlin.Double value=0.0 -OUTGOING -> BB 2, 3 - CALL 'public final fun ieee754equals (arg0: kotlin.Double?, arg1: kotlin.Double?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ -BB 2 -INCOMING <- BB 1 - CALL 'public final fun ieee754equals (arg0: kotlin.Double?, arg1: kotlin.Double?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ -CONTENT - 1 CONST Double type=kotlin.Double value=1.0 - 2 RETURN type=kotlin.Nothing from='public final fun minBiRoot (a: kotlin.Double, b: kotlin.Double, c: kotlin.Double): kotlin.Double declared in ' -OUTGOING -> NONE - Function exit: FUN name:minBiRoot visibility:public modality:FINAL <> (a:kotlin.Double, b:kotlin.Double, c:kotlin.Double) returnType:kotlin.Double -BB 3 -INCOMING <- BB 1 - CALL 'public final fun ieee754equals (arg0: kotlin.Double?, arg1: kotlin.Double?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ -CONTENT - 1 GET_VAR 'c: kotlin.Double declared in .minBiRoot' type=kotlin.Double origin=null - 2 CALL 'public final fun unaryMinus (): kotlin.Double [operator] declared in kotlin.Double' type=kotlin.Double origin=UMINUS - 3 GET_VAR 'b: kotlin.Double declared in .minBiRoot' type=kotlin.Double origin=null - 4 CALL 'public final fun div (other: kotlin.Double): kotlin.Double [operator] declared in kotlin.Double' type=kotlin.Double origin=DIV - 5 VAR name:bc type:kotlin.Double [val] - 6 WHEN type=kotlin.Unit origin=IF - 7 GET_VAR 'val bc: kotlin.Double [val] declared in .minBiRoot' type=kotlin.Double origin=null - 8 CONST Double type=kotlin.Double value=0.0 -OUTGOING -> BB 4, 5 - CALL 'public final fun less (arg0: kotlin.Double, arg1: kotlin.Double): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT -BB 4 -INCOMING <- BB 3 - CALL 'public final fun less (arg0: kotlin.Double, arg1: kotlin.Double): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT -CONTENT - 1 CONST Double type=kotlin.Double value=2.0 - 2 RETURN type=kotlin.Nothing from='public final fun minBiRoot (a: kotlin.Double, b: kotlin.Double, c: kotlin.Double): kotlin.Double declared in ' -OUTGOING -> NONE - Function exit: FUN name:minBiRoot visibility:public modality:FINAL <> (a:kotlin.Double, b:kotlin.Double, c:kotlin.Double) returnType:kotlin.Double -BB 5 -INCOMING <- BB 3 - CALL 'public final fun less (arg0: kotlin.Double, arg1: kotlin.Double): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT -CONTENT - 1 GET_VAR 'val bc: kotlin.Double [val] declared in .minBiRoot' type=kotlin.Double origin=null - 2 CALL 'public final fun unaryMinus (): kotlin.Double [operator] declared in kotlin.Double' type=kotlin.Double origin=UMINUS - 3 RETURN type=kotlin.Nothing from='public final fun minBiRoot (a: kotlin.Double, b: kotlin.Double, c: kotlin.Double): kotlin.Double declared in ' -OUTGOING -> NONE - Function exit: FUN name:minBiRoot visibility:public modality:FINAL <> (a:kotlin.Double, b:kotlin.Double, c:kotlin.Double) returnType:kotlin.Double -BB 6 -INCOMING <- BB 0 - CALL 'public final fun ieee754equals (arg0: kotlin.Double?, arg1: kotlin.Double?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ -CONTENT - 1 GET_VAR 'b: kotlin.Double declared in .minBiRoot' type=kotlin.Double origin=null - 2 GET_VAR 'b: kotlin.Double declared in .minBiRoot' type=kotlin.Double origin=null - 3 CALL 'public final fun times (other: kotlin.Double): kotlin.Double [operator] declared in kotlin.Double' type=kotlin.Double origin=MUL - 4 CONST Int type=kotlin.Int value=4 - 5 GET_VAR 'a: kotlin.Double declared in .minBiRoot' type=kotlin.Double origin=null - 6 CALL 'public final fun times (other: kotlin.Double): kotlin.Double [operator] declared in kotlin.Int' type=kotlin.Double origin=MUL - 7 GET_VAR 'c: kotlin.Double declared in .minBiRoot' type=kotlin.Double origin=null - 8 CALL 'public final fun times (other: kotlin.Double): kotlin.Double [operator] declared in kotlin.Double' type=kotlin.Double origin=MUL - 9 CALL 'public final fun minus (other: kotlin.Double): kotlin.Double [operator] declared in kotlin.Double' type=kotlin.Double origin=MINUS - 10 VAR name:d type:kotlin.Double [val] - 11 WHEN type=kotlin.Unit origin=IF - 12 GET_VAR 'val d: kotlin.Double [val] declared in .minBiRoot' type=kotlin.Double origin=null - 13 CONST Double type=kotlin.Double value=0.0 -OUTGOING -> BB 7, 8 - CALL 'public final fun less (arg0: kotlin.Double, arg1: kotlin.Double): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT -BB 7 -INCOMING <- BB 6 - CALL 'public final fun less (arg0: kotlin.Double, arg1: kotlin.Double): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT -CONTENT - 1 CONST Double type=kotlin.Double value=3.0 - 2 RETURN type=kotlin.Nothing from='public final fun minBiRoot (a: kotlin.Double, b: kotlin.Double, c: kotlin.Double): kotlin.Double declared in ' -OUTGOING -> NONE - Function exit: FUN name:minBiRoot visibility:public modality:FINAL <> (a:kotlin.Double, b:kotlin.Double, c:kotlin.Double) returnType:kotlin.Double -BB 8 -INCOMING <- BB 6 - CALL 'public final fun less (arg0: kotlin.Double, arg1: kotlin.Double): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT -CONTENT - 1 GET_VAR 'b: kotlin.Double declared in .minBiRoot' type=kotlin.Double origin=null - 2 CALL 'public final fun unaryMinus (): kotlin.Double [operator] declared in kotlin.Double' type=kotlin.Double origin=UMINUS - 3 GET_VAR 'val d: kotlin.Double [val] declared in .minBiRoot' type=kotlin.Double origin=null - 4 CALL 'public final fun plus (other: kotlin.Double): kotlin.Double [operator] declared in kotlin.Double' type=kotlin.Double origin=PLUS - 5 CONST Int type=kotlin.Int value=2 - 6 GET_VAR 'a: kotlin.Double declared in .minBiRoot' type=kotlin.Double origin=null - 7 CALL 'public final fun times (other: kotlin.Double): kotlin.Double [operator] declared in kotlin.Int' type=kotlin.Double origin=MUL - 8 CALL 'public final fun div (other: kotlin.Double): kotlin.Double [operator] declared in kotlin.Double' type=kotlin.Double origin=DIV - 9 VAR name:y1 type:kotlin.Double [val] - 10 GET_VAR 'b: kotlin.Double declared in .minBiRoot' type=kotlin.Double origin=null - 11 CALL 'public final fun unaryMinus (): kotlin.Double [operator] declared in kotlin.Double' type=kotlin.Double origin=UMINUS - 12 GET_VAR 'val d: kotlin.Double [val] declared in .minBiRoot' type=kotlin.Double origin=null - 13 CALL 'public final fun minus (other: kotlin.Double): kotlin.Double [operator] declared in kotlin.Double' type=kotlin.Double origin=MINUS - 14 CONST Int type=kotlin.Int value=2 - 15 GET_VAR 'a: kotlin.Double declared in .minBiRoot' type=kotlin.Double origin=null - 16 CALL 'public final fun times (other: kotlin.Double): kotlin.Double [operator] declared in kotlin.Int' type=kotlin.Double origin=MUL - 17 CALL 'public final fun div (other: kotlin.Double): kotlin.Double [operator] declared in kotlin.Double' type=kotlin.Double origin=DIV - 18 VAR name:y2 type:kotlin.Double [val] - 19 WHEN type=kotlin.Double origin=IF - 20 GET_VAR 'val y1: kotlin.Double [val] declared in .minBiRoot' type=kotlin.Double origin=null - 21 GET_VAR 'val y2: kotlin.Double [val] declared in .minBiRoot' type=kotlin.Double origin=null -OUTGOING -> BB 9, 10 - CALL 'public final fun greater (arg0: kotlin.Double, arg1: kotlin.Double): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT -BB 9 -INCOMING <- BB 8 - CALL 'public final fun greater (arg0: kotlin.Double, arg1: kotlin.Double): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT -CONTENT -OUTGOING -> BB 11 - CONST Boolean type=kotlin.Boolean value=true -BB 10 -INCOMING <- BB 8 - CALL 'public final fun greater (arg0: kotlin.Double, arg1: kotlin.Double): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT -CONTENT - 1 GET_VAR 'val y1: kotlin.Double [val] declared in .minBiRoot' type=kotlin.Double origin=null -OUTGOING -> BB 12 - When exit: WHEN type=kotlin.Double origin=IF -BB 11 -INCOMING <- BB 9 - CONST Boolean type=kotlin.Boolean value=true -CONTENT - 1 GET_VAR 'val y2: kotlin.Double [val] declared in .minBiRoot' type=kotlin.Double origin=null -OUTGOING -> BB 12 - When exit: WHEN type=kotlin.Double origin=IF -BB 12 -INCOMING <- BB 10, 11 - When exit: WHEN type=kotlin.Double origin=IF -CONTENT - 1 VAR name:y3 type:kotlin.Double [val] - 2 WHEN type=kotlin.Double origin=IF - 3 GET_VAR 'val y3: kotlin.Double [val] declared in .minBiRoot' type=kotlin.Double origin=null - 4 CONST Double type=kotlin.Double value=0.0 -OUTGOING -> BB 13, 14 - CALL 'public final fun less (arg0: kotlin.Double, arg1: kotlin.Double): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT -BB 13 -INCOMING <- BB 12 - CALL 'public final fun less (arg0: kotlin.Double, arg1: kotlin.Double): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT -CONTENT -OUTGOING -> BB 15 - CONST Boolean type=kotlin.Boolean value=true -BB 14 -INCOMING <- BB 12 - CALL 'public final fun less (arg0: kotlin.Double, arg1: kotlin.Double): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT -CONTENT - 1 CONST Double type=kotlin.Double value=4.0 -OUTGOING -> BB 16 - When exit: WHEN type=kotlin.Double origin=IF -BB 15 -INCOMING <- BB 13 - CONST Boolean type=kotlin.Boolean value=true -CONTENT - 1 GET_VAR 'val y3: kotlin.Double [val] declared in .minBiRoot' type=kotlin.Double origin=null - 2 CALL 'public final fun unaryMinus (): kotlin.Double [operator] declared in kotlin.Double' type=kotlin.Double origin=UMINUS -OUTGOING -> BB 16 - When exit: WHEN type=kotlin.Double origin=IF -BB 16 -INCOMING <- BB 14, 15 - When exit: WHEN type=kotlin.Double origin=IF -CONTENT - 1 RETURN type=kotlin.Nothing from='public final fun minBiRoot (a: kotlin.Double, b: kotlin.Double, c: kotlin.Double): kotlin.Double declared in ' -OUTGOING -> NONE - Function exit: FUN name:minBiRoot visibility:public modality:FINAL <> (a:kotlin.Double, b:kotlin.Double, c:kotlin.Double) returnType:kotlin.Double - -// END FUN: minBiRoot - -// END FILE: /ifChain.kt - diff --git a/compiler/testData/ir/irCfg/when/whenReturn.kt b/compiler/testData/ir/irCfg/when/whenReturn.kt deleted file mode 100644 index b692e1f2dab..00000000000 --- a/compiler/testData/ir/irCfg/when/whenReturn.kt +++ /dev/null @@ -1,10 +0,0 @@ -fun toString(grade: String): String { - when (grade) { - "A" -> return "Excellent" - "B" -> return "Good" - "C" -> return "Mediocre" - "D" -> return "Fair" - else -> return "Failure" - } - return "???" -} \ No newline at end of file diff --git a/compiler/testData/ir/irCfg/when/whenReturn.txt b/compiler/testData/ir/irCfg/when/whenReturn.txt deleted file mode 100644 index 8068c49704b..00000000000 --- a/compiler/testData/ir/irCfg/when/whenReturn.txt +++ /dev/null @@ -1,95 +0,0 @@ -// FILE: /whenReturn.kt -// FUN: toString -BB 0 -CONTENT - 1 FUN name:toString visibility:public modality:FINAL <> (grade:kotlin.String) returnType:kotlin.String - 2 GET_VAR 'grade: kotlin.String declared in .toString' type=kotlin.String origin=null - 3 VAR IR_TEMPORARY_VARIABLE name:tmp0_subject type:kotlin.String [val] - 4 WHEN type=kotlin.Unit origin=WHEN - 5 GET_VAR 'val tmp0_subject: kotlin.String [val] declared in .toString' type=kotlin.String origin=null - 6 CONST String type=kotlin.String value="A" -OUTGOING -> BB 1, 5 - CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ -BB 1 -INCOMING <- BB 0 - CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ -CONTENT - 1 GET_VAR 'val tmp0_subject: kotlin.String [val] declared in .toString' type=kotlin.String origin=null - 2 CONST String type=kotlin.String value="B" -OUTGOING -> BB 2, 6 - CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ -BB 2 -INCOMING <- BB 1 - CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ -CONTENT - 1 GET_VAR 'val tmp0_subject: kotlin.String [val] declared in .toString' type=kotlin.String origin=null - 2 CONST String type=kotlin.String value="C" -OUTGOING -> BB 3, 7 - CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ -BB 3 -INCOMING <- BB 2 - CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ -CONTENT - 1 GET_VAR 'val tmp0_subject: kotlin.String [val] declared in .toString' type=kotlin.String origin=null - 2 CONST String type=kotlin.String value="D" -OUTGOING -> BB 4, 8 - CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ -BB 4 -INCOMING <- BB 3 - CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ -CONTENT -OUTGOING -> BB 9, 10 - CONST Boolean type=kotlin.Boolean value=true -BB 5 -INCOMING <- BB 0 - CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ -CONTENT - 1 CONST String type=kotlin.String value="Excellent" - 2 RETURN type=kotlin.Nothing from='public final fun toString (grade: kotlin.String): kotlin.String declared in ' -OUTGOING -> NONE - Function exit: FUN name:toString visibility:public modality:FINAL <> (grade:kotlin.String) returnType:kotlin.String -BB 6 -INCOMING <- BB 1 - CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ -CONTENT - 1 CONST String type=kotlin.String value="Good" - 2 RETURN type=kotlin.Nothing from='public final fun toString (grade: kotlin.String): kotlin.String declared in ' -OUTGOING -> NONE - Function exit: FUN name:toString visibility:public modality:FINAL <> (grade:kotlin.String) returnType:kotlin.String -BB 7 -INCOMING <- BB 2 - CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ -CONTENT - 1 CONST String type=kotlin.String value="Mediocre" - 2 RETURN type=kotlin.Nothing from='public final fun toString (grade: kotlin.String): kotlin.String declared in ' -OUTGOING -> NONE - Function exit: FUN name:toString visibility:public modality:FINAL <> (grade:kotlin.String) returnType:kotlin.String -BB 8 -INCOMING <- BB 3 - CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ -CONTENT - 1 CONST String type=kotlin.String value="Fair" - 2 RETURN type=kotlin.Nothing from='public final fun toString (grade: kotlin.String): kotlin.String declared in ' -OUTGOING -> NONE - Function exit: FUN name:toString visibility:public modality:FINAL <> (grade:kotlin.String) returnType:kotlin.String -BB 9 -INCOMING <- BB 4 - CONST Boolean type=kotlin.Boolean value=true -CONTENT - 1 CONST String type=kotlin.String value="Failure" - 2 RETURN type=kotlin.Nothing from='public final fun toString (grade: kotlin.String): kotlin.String declared in ' -OUTGOING -> NONE - Function exit: FUN name:toString visibility:public modality:FINAL <> (grade:kotlin.String) returnType:kotlin.String -BB 10 -INCOMING <- BB 4 - CONST Boolean type=kotlin.Boolean value=true -CONTENT - 1 CONST String type=kotlin.String value="???" - 2 RETURN type=kotlin.Nothing from='public final fun toString (grade: kotlin.String): kotlin.String declared in ' -OUTGOING -> NONE - Function exit: FUN name:toString visibility:public modality:FINAL <> (grade:kotlin.String) returnType:kotlin.String - -// END FUN: toString - -// END FILE: /whenReturn.kt - diff --git a/compiler/tests-common/build.gradle.kts b/compiler/tests-common/build.gradle.kts index cd3562964fd..fcdbb76fd40 100644 --- a/compiler/tests-common/build.gradle.kts +++ b/compiler/tests-common/build.gradle.kts @@ -32,7 +32,6 @@ dependencies { testApi(project(":compiler:fir:checkers:checkers.wasm")) testApi(project(":compiler:fir:java")) testApi(project(":compiler:fir:entrypoint")) - testApi(project(":compiler:ir.ir2cfg")) testApi(project(":compiler:frontend")) testApi(project(":compiler:frontend.java")) testApi(project(":compiler:util")) diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/ir/AbstractIrCfgTestCase.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/ir/AbstractIrCfgTestCase.kt deleted file mode 100644 index 9c686703196..00000000000 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/ir/AbstractIrCfgTestCase.kt +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2010-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.ir - -import org.jetbrains.kotlin.ir.declarations.IrFile -import org.jetbrains.kotlin.ir.declarations.IrFunction -import org.jetbrains.kotlin.ir.declarations.IrModuleFragment -import org.jetbrains.kotlin.ir.declarations.path -import org.jetbrains.kotlin.ir2cfg.generators.FunctionGenerator -import org.jetbrains.kotlin.ir2cfg.util.dump -import org.jetbrains.kotlin.test.KotlinTestUtils -import java.io.File - -abstract class AbstractIrCfgTestCase : AbstractIrGeneratorTestCase() { - - private fun IrFile.cfgDump(): String { - val builder = StringBuilder() - for (declaration in this.declarations) { - if (declaration is IrFunction) { - builder.appendLine("// FUN: ${declaration.name}") - val cfg = FunctionGenerator(declaration).generate() - builder.appendLine(cfg.dump()) - builder.appendLine("// END FUN: ${declaration.name}") - } - } - return builder.toString() - } - - private fun IrModuleFragment.cfgDump(): String { - val builder = StringBuilder() - for (file in this.files) { - builder.appendLine("// FILE: ${file.path}") - builder.appendLine(file.cfgDump()) - builder.appendLine("// END FILE: ${file.path}") - builder.appendLine() - } - return builder.toString() - } - - override fun doTest(wholeFile: File, testFiles: List) { - val irModule = generateIrModule(false) - val irModuleDump = irModule.cfgDump() - val expectedPath = wholeFile.canonicalPath.replace(".kt", ".txt") - val expectedFile = File(expectedPath) - KotlinTestUtils.assertEqualsToFile(expectedFile, irModuleDump) - } -} \ No newline at end of file diff --git a/compiler/tests-compiler-utils/build.gradle.kts b/compiler/tests-compiler-utils/build.gradle.kts index d85f9507d3d..36f278c4488 100644 --- a/compiler/tests-compiler-utils/build.gradle.kts +++ b/compiler/tests-compiler-utils/build.gradle.kts @@ -13,7 +13,6 @@ dependencies { testApi(project(":compiler:util")) testApi(project(":compiler:tests-mutes")) testApi(project(":compiler:backend")) - testApi(project(":compiler:ir.ir2cfg")) testApi(project(":compiler:frontend")) testApi(project(":compiler:frontend.java")) testApi(project(":compiler:util")) diff --git a/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit3CompilerTests.kt b/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit3CompilerTests.kt index d3ad0c2483b..c4110c3f7f4 100644 --- a/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit3CompilerTests.kt +++ b/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit3CompilerTests.kt @@ -26,7 +26,6 @@ import org.jetbrains.kotlin.generators.impl.generateTestGroupSuite import org.jetbrains.kotlin.generators.util.TestGeneratorUtil import org.jetbrains.kotlin.generators.util.TestGeneratorUtil.KT_OR_KTS_WITHOUT_DOTS_IN_NAME import org.jetbrains.kotlin.integration.AbstractAntTaskTest -import org.jetbrains.kotlin.ir.AbstractIrCfgTestCase import org.jetbrains.kotlin.jvm.compiler.* import org.jetbrains.kotlin.jvm.compiler.ir.* import org.jetbrains.kotlin.jvm.compiler.javac.AbstractLoadJavaUsingJavacTest @@ -110,10 +109,6 @@ fun generateJUnit3CompilerTests(args: Array, mainClassName: String?) { model("codegen/customScript", pattern = "^(.*)$", targetBackend = TargetBackend.JVM_IR) } - testClass { - model("ir/irCfg") - } - testClass { model("codegen/topLevelMemberInvocation", extension = null, recursive = false) } diff --git a/compiler/tests-gen/org/jetbrains/kotlin/ir/IrCfgTestCaseGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/ir/IrCfgTestCaseGenerated.java deleted file mode 100644 index fdc86c67d30..00000000000 --- a/compiler/tests-gen/org/jetbrains/kotlin/ir/IrCfgTestCaseGenerated.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -package org.jetbrains.kotlin.ir; - -import com.intellij.testFramework.TestDataPath; -import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; -import org.jetbrains.kotlin.test.KotlinTestUtils; -import org.jetbrains.kotlin.test.util.KtTestUtil; -import org.jetbrains.kotlin.test.TestMetadata; -import org.junit.runner.RunWith; - -import java.io.File; -import java.util.regex.Pattern; - -/** This class is generated by {@link org.jetbrains.kotlin.test.generators.GenerateCompilerTestsKt}. DO NOT MODIFY MANUALLY */ -@SuppressWarnings("all") -@TestMetadata("compiler/testData/ir/irCfg") -@TestDataPath("$PROJECT_ROOT") -@RunWith(JUnit3RunnerWithInners.class) -public class IrCfgTestCaseGenerated extends AbstractIrCfgTestCase { - private void runTest(String testDataFilePath) { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - - public void testAllFilesPresentInIrCfg() { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irCfg"), Pattern.compile("^(.+)\\.kt$"), null, true); - } - - @TestMetadata("expressionFun.kt") - public void testExpressionFun() { - runTest("compiler/testData/ir/irCfg/expressionFun.kt"); - } - - @TestMetadata("expressionUnit.kt") - public void testExpressionUnit() { - runTest("compiler/testData/ir/irCfg/expressionUnit.kt"); - } - - @TestMetadata("returnUnit.kt") - public void testReturnUnit() { - runTest("compiler/testData/ir/irCfg/returnUnit.kt"); - } - - @TestMetadata("sequentialFun.kt") - public void testSequentialFun() { - runTest("compiler/testData/ir/irCfg/sequentialFun.kt"); - } - - @TestMetadata("simpleFun.kt") - public void testSimpleFun() { - runTest("compiler/testData/ir/irCfg/simpleFun.kt"); - } - - @TestMetadata("simpleReturn.kt") - public void testSimpleReturn() { - runTest("compiler/testData/ir/irCfg/simpleReturn.kt"); - } - - @TestMetadata("compiler/testData/ir/irCfg/loop") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Loop extends AbstractIrCfgTestCase { - private void runTest(String testDataFilePath) { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - - public void testAllFilesPresentInLoop() { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irCfg/loop"), Pattern.compile("^(.+)\\.kt$"), null, true); - } - - @TestMetadata("digitCount.kt") - public void testDigitCount() { - runTest("compiler/testData/ir/irCfg/loop/digitCount.kt"); - } - - @TestMetadata("factorial.kt") - public void testFactorial() { - runTest("compiler/testData/ir/irCfg/loop/factorial.kt"); - } - - @TestMetadata("isPerfect.kt") - public void testIsPerfect() { - runTest("compiler/testData/ir/irCfg/loop/isPerfect.kt"); - } - } - - @TestMetadata("compiler/testData/ir/irCfg/when") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class When extends AbstractIrCfgTestCase { - private void runTest(String testDataFilePath) { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - - public void testAllFilesPresentInWhen() { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irCfg/when"), Pattern.compile("^(.+)\\.kt$"), null, true); - } - - @TestMetadata("cascadeIf.kt") - public void testCascadeIf() { - runTest("compiler/testData/ir/irCfg/when/cascadeIf.kt"); - } - - @TestMetadata("emptyWhen.kt") - public void testEmptyWhen() { - runTest("compiler/testData/ir/irCfg/when/emptyWhen.kt"); - } - - @TestMetadata("expressionIf.kt") - public void testExpressionIf() { - runTest("compiler/testData/ir/irCfg/when/expressionIf.kt"); - } - - @TestMetadata("ifChain.kt") - public void testIfChain() { - runTest("compiler/testData/ir/irCfg/when/ifChain.kt"); - } - - @TestMetadata("whenReturn.kt") - public void testWhenReturn() { - runTest("compiler/testData/ir/irCfg/when/whenReturn.kt"); - } - } -} diff --git a/settings.gradle b/settings.gradle index 0e74111e91b..00878cfad5a 100644 --- a/settings.gradle +++ b/settings.gradle @@ -70,7 +70,6 @@ include ":benchmarks", ":compiler:ir.tree", ":compiler:ir.tree:tree-generator", ":compiler:ir.psi2ir", - ":compiler:ir.ir2cfg", ":compiler:ir.objcinterop", ":compiler:ir.backend.common", ":compiler:ir.actualization", @@ -699,7 +698,6 @@ project(':kotlin-ant').projectDir = "$rootDir/ant" as File project(':compiler:ir.tree').projectDir = "$rootDir/compiler/ir/ir.tree" as File project(':compiler:ir.tree:tree-generator').projectDir = "$rootDir/compiler/ir/ir.tree/tree-generator" as File project(':compiler:ir.psi2ir').projectDir = "$rootDir/compiler/ir/ir.psi2ir" as File -project(':compiler:ir.ir2cfg').projectDir = "$rootDir/compiler/ir/ir.ir2cfg" as File project(':compiler:ir.objcinterop').projectDir = "$rootDir/compiler/ir/ir.objcinterop" as File project(':compiler:ir.backend.common').projectDir = "$rootDir/compiler/ir/backend.common" as File project(':compiler:ir.actualization').projectDir = "$rootDir/compiler/ir/ir.actualization" as File