JVM: be more careful when removing unused constants

1. if an argument of a `pop` cannot be removed, then all other potential
   arguments of that `pop` can't be removed either, and the same applies
   to other `pop`s that touch them;
2. the same is true for primitive conversions, but this is even trickier
   to implement correctly, so I simply did the same thing as with
   boxing operators: replace the conversion itself with a `pop` and keep
   the argument as-is.

Somehow this actually removes *more* redundant primitive type conversions
than the old code in a couple bytecode text tests, so I've patched them
to kind of use the value, forcing the instructions to stay.

 #KT-46921 Fixed
This commit is contained in:
pyos
2021-05-26 15:10:45 +02:00
committed by Alexander Udalov
parent 2f60ce21a0
commit 34878d17eb
8 changed files with 113 additions and 118 deletions
@@ -23110,6 +23110,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
public void testKt20844() throws Exception {
runTest("compiler/testData/codegen/box/optimizations/kt20844.kt");
}
@TestMetadata("kt46921.kt")
public void testKt46921() throws Exception {
runTest("compiler/testData/codegen/box/optimizations/kt46921.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/package")