Make all progression headers inclusive, and decrement last for

last-exclusive progressions (i.e., "until" progressions and loop over
array indices).

This change makes it possible to correctly implement the handling of
"step" progressions. Computing the last element of a stepped progression
requires that the last is inclusive.

Also invert the while loop (into if + do-while) that is used when
lowering for-loops over progressions that cannot overflow. This keeps
the performance characteristics closer to the ForLoopsLowering in
kotlin-native, since the goal is to converge to this shared version.

Also used IrType instead of KotlinType, where possible.

 https://github.com/JetBrains/kotlin/pull/2390
 https://github.com/JetBrains/kotlin/pull/2305
This commit is contained in:
Mark Punzalan
2019-06-14 00:59:47 -07:00
committed by Mikhael Bogdanov
parent 39f6416757
commit de1e27c584
75 changed files with 1873 additions and 377 deletions
@@ -18867,34 +18867,49 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/ranges/evaluationOrder"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
}
@TestMetadata("forInDownToEvaluationOrder.kt")
public void testForInDownToEvaluationOrder() throws Exception {
runTest("compiler/testData/codegen/box/ranges/evaluationOrder/forInDownToEvaluationOrder.kt");
@TestMetadata("forInDownTo.kt")
public void testForInDownTo() throws Exception {
runTest("compiler/testData/codegen/box/ranges/evaluationOrder/forInDownTo.kt");
}
@TestMetadata("forInRangeLiteralEvaluationOrder.kt")
public void testForInRangeLiteralEvaluationOrder() throws Exception {
runTest("compiler/testData/codegen/box/ranges/evaluationOrder/forInRangeLiteralEvaluationOrder.kt");
@TestMetadata("forInDownToReversed.kt")
public void testForInDownToReversed() throws Exception {
runTest("compiler/testData/codegen/box/ranges/evaluationOrder/forInDownToReversed.kt");
}
@TestMetadata("forInReversedDownToEvaluationOrder.kt")
public void testForInReversedDownToEvaluationOrder() throws Exception {
runTest("compiler/testData/codegen/box/ranges/evaluationOrder/forInReversedDownToEvaluationOrder.kt");
@TestMetadata("forInDownToReversedReversed.kt")
public void testForInDownToReversedReversed() throws Exception {
runTest("compiler/testData/codegen/box/ranges/evaluationOrder/forInDownToReversedReversed.kt");
}
@TestMetadata("forInReversedRangeLiteralEvaluationOrder.kt")
public void testForInReversedRangeLiteralEvaluationOrder() throws Exception {
runTest("compiler/testData/codegen/box/ranges/evaluationOrder/forInReversedRangeLiteralEvaluationOrder.kt");
@TestMetadata("forInRangeLiteral.kt")
public void testForInRangeLiteral() throws Exception {
runTest("compiler/testData/codegen/box/ranges/evaluationOrder/forInRangeLiteral.kt");
}
@TestMetadata("forInReversedUntilEvaluationOrder.kt")
public void testForInReversedUntilEvaluationOrder() throws Exception {
runTest("compiler/testData/codegen/box/ranges/evaluationOrder/forInReversedUntilEvaluationOrder.kt");
@TestMetadata("forInRangeLiteralReversed.kt")
public void testForInRangeLiteralReversed() throws Exception {
runTest("compiler/testData/codegen/box/ranges/evaluationOrder/forInRangeLiteralReversed.kt");
}
@TestMetadata("forInUntilEvaluationOrder.kt")
public void testForInUntilEvaluationOrder() throws Exception {
runTest("compiler/testData/codegen/box/ranges/evaluationOrder/forInUntilEvaluationOrder.kt");
@TestMetadata("forInRangeLiteralReversedReversed.kt")
public void testForInRangeLiteralReversedReversed() throws Exception {
runTest("compiler/testData/codegen/box/ranges/evaluationOrder/forInRangeLiteralReversedReversed.kt");
}
@TestMetadata("forInUntil.kt")
public void testForInUntil() throws Exception {
runTest("compiler/testData/codegen/box/ranges/evaluationOrder/forInUntil.kt");
}
@TestMetadata("forInUntilReversed.kt")
public void testForInUntilReversed() throws Exception {
runTest("compiler/testData/codegen/box/ranges/evaluationOrder/forInUntilReversed.kt");
}
@TestMetadata("forInUntilReversedReversed.kt")
public void testForInUntilReversedReversed() throws Exception {
runTest("compiler/testData/codegen/box/ranges/evaluationOrder/forInUntilReversedReversed.kt");
}
}
@@ -19312,9 +19327,19 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/ranges/forInUntil/forInUntilChar.kt");
}
@TestMetadata("forInUntilChar0.kt")
public void testForInUntilChar0() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInUntil/forInUntilChar0.kt");
@TestMetadata("forInUntilCharMaxValue.kt")
public void testForInUntilCharMaxValue() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInUntil/forInUntilCharMaxValue.kt");
}
@TestMetadata("forInUntilCharMinValue.kt")
public void testForInUntilCharMinValue() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInUntil/forInUntilCharMinValue.kt");
}
@TestMetadata("forInUntilCharMinValueNonConst.kt")
public void testForInUntilCharMinValueNonConst() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInUntil/forInUntilCharMinValueNonConst.kt");
}
@TestMetadata("forInUntilInt.kt")
@@ -19322,6 +19347,21 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/ranges/forInUntil/forInUntilInt.kt");
}
@TestMetadata("forInUntilIntMaxValue.kt")
public void testForInUntilIntMaxValue() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInUntil/forInUntilIntMaxValue.kt");
}
@TestMetadata("forInUntilIntMinValue.kt")
public void testForInUntilIntMinValue() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInUntil/forInUntilIntMinValue.kt");
}
@TestMetadata("forInUntilIntMinValueNonConst.kt")
public void testForInUntilIntMinValueNonConst() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInUntil/forInUntilIntMinValueNonConst.kt");
}
@TestMetadata("forInUntilLesserInt.kt")
public void testForInUntilLesserInt() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInUntil/forInUntilLesserInt.kt");
@@ -19332,19 +19372,19 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/ranges/forInUntil/forInUntilLong.kt");
}
@TestMetadata("forInUntilMaxint.kt")
public void testForInUntilMaxint() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInUntil/forInUntilMaxint.kt");
@TestMetadata("forInUntilLongMaxValue.kt")
public void testForInUntilLongMaxValue() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInUntil/forInUntilLongMaxValue.kt");
}
@TestMetadata("forInUntilMinint.kt")
public void testForInUntilMinint() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInUntil/forInUntilMinint.kt");
@TestMetadata("forInUntilLongMinValue.kt")
public void testForInUntilLongMinValue() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInUntil/forInUntilLongMinValue.kt");
}
@TestMetadata("forInUntilMinlong.kt")
public void testForInUntilMinlong() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInUntil/forInUntilMinlong.kt");
@TestMetadata("forInUntilLongMinValueNonConst.kt")
public void testForInUntilLongMinValueNonConst() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInUntil/forInUntilLongMinValueNonConst.kt");
}
@TestMetadata("forIntInIntUntilSmartcastInt.kt")