Implement constant folding in the IR backend for JVM
The newly added pass folds the set of constant functions of the current backend, plus IrBuiltIns.
This commit is contained in:
committed by
max-kammerer
parent
7e4d33be24
commit
79fcaae991
+20
@@ -4379,11 +4379,26 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/constants"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@TestMetadata("comparisonFalse.kt")
|
||||
public void testComparisonFalse() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/constants/comparisonFalse.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("comparisonTrue.kt")
|
||||
public void testComparisonTrue() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/constants/comparisonTrue.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("constantsInWhen.kt")
|
||||
public void testConstantsInWhen() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/constants/constantsInWhen.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("divisionByZero.kt")
|
||||
public void testDivisionByZero() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/constants/divisionByZero.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("float.kt")
|
||||
public void testFloat() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/constants/float.kt");
|
||||
@@ -17176,6 +17191,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/primitiveTypes/kt2269.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt2269NotOptimizable.kt")
|
||||
public void testKt2269NotOptimizable() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/primitiveTypes/kt2269NotOptimizable.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt2275.kt")
|
||||
public void testKt2275() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/primitiveTypes/kt2275.kt");
|
||||
|
||||
@@ -1118,6 +1118,11 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
|
||||
runTest("compiler/testData/codegen/bytecodeText/constants/byte.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("floatingPoints.kt")
|
||||
public void testFloatingPoints() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/constants/floatingPoints.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inlineUnsignedIntConstant.kt")
|
||||
public void testInlineUnsignedIntConstant() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/constants/inlineUnsignedIntConstant.kt");
|
||||
@@ -1472,6 +1477,11 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
|
||||
runTest("compiler/testData/codegen/bytecodeText/deadCodeElimination/boxing.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("boxingNotOptimizable.kt")
|
||||
public void testBoxingNotOptimizable() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/deadCodeElimination/boxingNotOptimizable.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("emptyVariableRange.kt")
|
||||
public void testEmptyVariableRange() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/deadCodeElimination/emptyVariableRange.kt");
|
||||
@@ -1501,6 +1511,11 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
|
||||
public void testSimpleConstructorNotRedundant() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/deadCodeElimination/simpleConstructorNotRedundant.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("simpleConstructorNotRedundantNotOptimizable.kt")
|
||||
public void testSimpleConstructorNotRedundantNotOptimizable() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/deadCodeElimination/simpleConstructorNotRedundantNotOptimizable.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/bytecodeText/defaultArguments")
|
||||
@@ -3377,6 +3392,11 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
|
||||
runTest("compiler/testData/codegen/bytecodeText/stringOperations/primitiveToString.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveToStringNotOptimizable.kt")
|
||||
public void testPrimitiveToStringNotOptimizable() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/stringOperations/primitiveToStringNotOptimizable.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("primitivesAsStringTemplates.kt")
|
||||
public void testPrimitivesAsStringTemplates() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/stringOperations/primitivesAsStringTemplates.kt");
|
||||
|
||||
+20
@@ -4379,11 +4379,26 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/constants"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@TestMetadata("comparisonFalse.kt")
|
||||
public void testComparisonFalse() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/constants/comparisonFalse.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("comparisonTrue.kt")
|
||||
public void testComparisonTrue() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/constants/comparisonTrue.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("constantsInWhen.kt")
|
||||
public void testConstantsInWhen() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/constants/constantsInWhen.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("divisionByZero.kt")
|
||||
public void testDivisionByZero() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/constants/divisionByZero.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("float.kt")
|
||||
public void testFloat() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/constants/float.kt");
|
||||
@@ -17176,6 +17191,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/primitiveTypes/kt2269.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt2269NotOptimizable.kt")
|
||||
public void testKt2269NotOptimizable() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/primitiveTypes/kt2269NotOptimizable.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt2275.kt")
|
||||
public void testKt2275() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/primitiveTypes/kt2275.kt");
|
||||
|
||||
+20
@@ -4379,11 +4379,26 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/constants"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true);
|
||||
}
|
||||
|
||||
@TestMetadata("comparisonFalse.kt")
|
||||
public void testComparisonFalse() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/constants/comparisonFalse.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("comparisonTrue.kt")
|
||||
public void testComparisonTrue() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/constants/comparisonTrue.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("constantsInWhen.kt")
|
||||
public void testConstantsInWhen() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/constants/constantsInWhen.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("divisionByZero.kt")
|
||||
public void testDivisionByZero() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/constants/divisionByZero.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("float.kt")
|
||||
public void testFloat() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/constants/float.kt");
|
||||
@@ -17181,6 +17196,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/primitiveTypes/kt2269.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt2269NotOptimizable.kt")
|
||||
public void testKt2269NotOptimizable() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/primitiveTypes/kt2269NotOptimizable.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt2275.kt")
|
||||
public void testKt2275() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/primitiveTypes/kt2275.kt");
|
||||
|
||||
+30
@@ -1118,6 +1118,21 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest {
|
||||
runTest("compiler/testData/codegen/bytecodeText/constants/byte.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("comparisonFalse.kt")
|
||||
public void testComparisonFalse() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/constants/comparisonFalse.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("comparisonTrue.kt")
|
||||
public void testComparisonTrue() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/constants/comparisonTrue.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("floatingPoints.kt")
|
||||
public void testFloatingPoints() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/constants/floatingPoints.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inlineUnsignedIntConstant.kt")
|
||||
public void testInlineUnsignedIntConstant() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/constants/inlineUnsignedIntConstant.kt");
|
||||
@@ -1472,6 +1487,11 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest {
|
||||
runTest("compiler/testData/codegen/bytecodeText/deadCodeElimination/boxing.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("boxingNotOptimizable.kt")
|
||||
public void testBoxingNotOptimizable() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/deadCodeElimination/boxingNotOptimizable.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("emptyVariableRange.kt")
|
||||
public void testEmptyVariableRange() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/deadCodeElimination/emptyVariableRange.kt");
|
||||
@@ -1501,6 +1521,11 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest {
|
||||
public void testSimpleConstructorNotRedundant() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/deadCodeElimination/simpleConstructorNotRedundant.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("simpleConstructorNotRedundantNotOptimizable.kt")
|
||||
public void testSimpleConstructorNotRedundantNotOptimizable() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/deadCodeElimination/simpleConstructorNotRedundantNotOptimizable.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/bytecodeText/defaultArguments")
|
||||
@@ -3377,6 +3402,11 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest {
|
||||
runTest("compiler/testData/codegen/bytecodeText/stringOperations/primitiveToString.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveToStringNotOptimizable.kt")
|
||||
public void testPrimitiveToStringNotOptimizable() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/stringOperations/primitiveToStringNotOptimizable.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("primitivesAsStringTemplates.kt")
|
||||
public void testPrimitivesAsStringTemplates() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/stringOperations/primitivesAsStringTemplates.kt");
|
||||
|
||||
Reference in New Issue
Block a user