JVM_IR reuse loop variable as index variable should happen after LDL

We can't apply "reuse loop variable as index variable" transformation
before local declarations lowering, otherwise it will affect captured
loop variable behavior, resulting in KT-48626.

Since it's JVM-specific, move it to JvmOptimizationLowering.
This commit is contained in:
Dmitry Petrov
2021-09-06 16:42:02 +03:00
committed by TeamCityServer
parent f62ffeaa0a
commit d9e4dec810
19 changed files with 445 additions and 133 deletions
@@ -5976,11 +5976,21 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
runTest("compiler/testData/codegen/box/controlStructures/forInIterableWithIndex/forInListWithIndex.kt");
}
@TestMetadata("forInListWithIndexBreak.kt")
public void testForInListWithIndexBreak() throws Exception {
runTest("compiler/testData/codegen/box/controlStructures/forInIterableWithIndex/forInListWithIndexBreak.kt");
}
@TestMetadata("forInListWithIndexBreakAndContinue.kt")
public void testForInListWithIndexBreakAndContinue() throws Exception {
runTest("compiler/testData/codegen/box/controlStructures/forInIterableWithIndex/forInListWithIndexBreakAndContinue.kt");
}
@TestMetadata("forInListWithIndexContinue.kt")
public void testForInListWithIndexContinue() throws Exception {
runTest("compiler/testData/codegen/box/controlStructures/forInIterableWithIndex/forInListWithIndexContinue.kt");
}
@TestMetadata("forInListWithIndexNoElementVar.kt")
public void testForInListWithIndexNoElementVar() throws Exception {
runTest("compiler/testData/codegen/box/controlStructures/forInIterableWithIndex/forInListWithIndexNoElementVar.kt");
@@ -20210,6 +20220,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/ranges"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true);
}
@TestMetadata("capturedLoopVar.kt")
public void testCapturedLoopVar() throws Exception {
runTest("compiler/testData/codegen/box/ranges/capturedLoopVar.kt");
}
@TestMetadata("forByteProgressionWithIntIncrement.kt")
public void testForByteProgressionWithIntIncrement() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forByteProgressionWithIntIncrement.kt");
@@ -21144,6 +21159,21 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
runTest("compiler/testData/codegen/box/ranges/forInIndices/forInCollectionTypeParameterIndices.kt");
}
@TestMetadata("forInListIndices.kt")
public void testForInListIndices() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInIndices/forInListIndices.kt");
}
@TestMetadata("forInListIndicesBreak.kt")
public void testForInListIndicesBreak() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInIndices/forInListIndicesBreak.kt");
}
@TestMetadata("forInListIndicesContinue.kt")
public void testForInListIndicesContinue() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInIndices/forInListIndicesContinue.kt");
}
@TestMetadata("forInNonOptimizedIndices.kt")
public void testForInNonOptimizedIndices() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInIndices/forInNonOptimizedIndices.kt");
@@ -5382,11 +5382,21 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/controlStructures/forInIterableWithIndex/forInListWithIndex.kt");
}
@TestMetadata("forInListWithIndexBreak.kt")
public void testForInListWithIndexBreak() throws Exception {
runTest("compiler/testData/codegen/box/controlStructures/forInIterableWithIndex/forInListWithIndexBreak.kt");
}
@TestMetadata("forInListWithIndexBreakAndContinue.kt")
public void testForInListWithIndexBreakAndContinue() throws Exception {
runTest("compiler/testData/codegen/box/controlStructures/forInIterableWithIndex/forInListWithIndexBreakAndContinue.kt");
}
@TestMetadata("forInListWithIndexContinue.kt")
public void testForInListWithIndexContinue() throws Exception {
runTest("compiler/testData/codegen/box/controlStructures/forInIterableWithIndex/forInListWithIndexContinue.kt");
}
@TestMetadata("forInListWithIndexNoElementVar.kt")
public void testForInListWithIndexNoElementVar() throws Exception {
runTest("compiler/testData/codegen/box/controlStructures/forInIterableWithIndex/forInListWithIndexNoElementVar.kt");
@@ -19616,6 +19626,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/ranges"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
}
@TestMetadata("capturedLoopVar.kt")
public void testCapturedLoopVar() throws Exception {
runTest("compiler/testData/codegen/box/ranges/capturedLoopVar.kt");
}
@TestMetadata("forByteProgressionWithIntIncrement.kt")
public void testForByteProgressionWithIntIncrement() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forByteProgressionWithIntIncrement.kt");
@@ -20550,6 +20565,21 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/ranges/forInIndices/forInCollectionTypeParameterIndices.kt");
}
@TestMetadata("forInListIndices.kt")
public void testForInListIndices() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInIndices/forInListIndices.kt");
}
@TestMetadata("forInListIndicesBreak.kt")
public void testForInListIndicesBreak() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInIndices/forInListIndicesBreak.kt");
}
@TestMetadata("forInListIndicesContinue.kt")
public void testForInListIndicesContinue() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInIndices/forInListIndicesContinue.kt");
}
@TestMetadata("forInNonOptimizedIndices.kt")
public void testForInNonOptimizedIndices() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInIndices/forInNonOptimizedIndices.kt");
@@ -5362,11 +5362,21 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/controlStructures/forInIterableWithIndex/forInListWithIndex.kt");
}
@TestMetadata("forInListWithIndexBreak.kt")
public void testForInListWithIndexBreak() throws Exception {
runTest("compiler/testData/codegen/box/controlStructures/forInIterableWithIndex/forInListWithIndexBreak.kt");
}
@TestMetadata("forInListWithIndexBreakAndContinue.kt")
public void testForInListWithIndexBreakAndContinue() throws Exception {
runTest("compiler/testData/codegen/box/controlStructures/forInIterableWithIndex/forInListWithIndexBreakAndContinue.kt");
}
@TestMetadata("forInListWithIndexContinue.kt")
public void testForInListWithIndexContinue() throws Exception {
runTest("compiler/testData/codegen/box/controlStructures/forInIterableWithIndex/forInListWithIndexContinue.kt");
}
@TestMetadata("forInListWithIndexNoElementVar.kt")
public void testForInListWithIndexNoElementVar() throws Exception {
runTest("compiler/testData/codegen/box/controlStructures/forInIterableWithIndex/forInListWithIndexNoElementVar.kt");
@@ -19646,6 +19656,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/ranges"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true);
}
@TestMetadata("capturedLoopVar.kt")
public void testCapturedLoopVar() throws Exception {
runTest("compiler/testData/codegen/box/ranges/capturedLoopVar.kt");
}
@TestMetadata("forByteProgressionWithIntIncrement.kt")
public void testForByteProgressionWithIntIncrement() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forByteProgressionWithIntIncrement.kt");
@@ -20580,6 +20595,21 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/ranges/forInIndices/forInCollectionTypeParameterIndices.kt");
}
@TestMetadata("forInListIndices.kt")
public void testForInListIndices() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInIndices/forInListIndices.kt");
}
@TestMetadata("forInListIndicesBreak.kt")
public void testForInListIndicesBreak() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInIndices/forInListIndicesBreak.kt");
}
@TestMetadata("forInListIndicesContinue.kt")
public void testForInListIndicesContinue() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInIndices/forInListIndicesContinue.kt");
}
@TestMetadata("forInNonOptimizedIndices.kt")
public void testForInNonOptimizedIndices() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInIndices/forInNonOptimizedIndices.kt");
@@ -12647,6 +12647,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/ranges"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true, "stepped/unsigned");
}
@TestMetadata("capturedLoopVar.kt")
public void testCapturedLoopVar() throws Exception {
runTest("compiler/testData/codegen/box/ranges/capturedLoopVar.kt");
}
@TestMetadata("forByteProgressionWithIntIncrement.kt")
public void testForByteProgressionWithIntIncrement() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forByteProgressionWithIntIncrement.kt");
@@ -13071,6 +13076,21 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
runTest("compiler/testData/codegen/box/ranges/forInIndices/forInCollectionTypeParameterIndices.kt");
}
@TestMetadata("forInListIndices.kt")
public void testForInListIndices() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInIndices/forInListIndices.kt");
}
@TestMetadata("forInListIndicesBreak.kt")
public void testForInListIndicesBreak() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInIndices/forInListIndicesBreak.kt");
}
@TestMetadata("forInListIndicesContinue.kt")
public void testForInListIndicesContinue() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInIndices/forInListIndicesContinue.kt");
}
@TestMetadata("forInNonOptimizedIndices.kt")
public void testForInNonOptimizedIndices() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInIndices/forInNonOptimizedIndices.kt");