fix: use correct order in removeUnreachableBlocks (PR #2085)

* Fixing wrong order in removeUnreachableBlocks
* Removing dead code in TestTernary4 test
* Do not clear instructions in detach blocks method
This commit is contained in:
Away
2024-01-21 17:05:02 +01:00
committed by GitHub
parent 61be1d8b0a
commit a19aec9d9f
3 changed files with 3 additions and 5 deletions
@@ -654,13 +654,14 @@ public class BlockProcessor extends AbstractVisitor {
return;
}
toRemove.forEach(BlockSplitter::detachBlock);
mth.getBasicBlocks().removeAll(toRemove);
long notEmptyBlocks = toRemove.stream().filter(block -> !block.getInstructions().isEmpty()).count();
if (notEmptyBlocks != 0) {
int insnsCount = toRemove.stream().mapToInt(block -> block.getInstructions().size()).sum();
mth.addWarnComment("Unreachable blocks removed: " + notEmptyBlocks + ", instructions: " + insnsCount);
}
toRemove.forEach(BlockSplitter::detachBlock);
mth.getBasicBlocks().removeAll(toRemove);
}
private static void clearBlocksState(MethodNode mth) {
@@ -455,7 +455,6 @@ public class BlockSplitter extends AbstractVisitor {
successor.getPredecessors().remove(block);
}
block.add(AFlag.REMOVE);
block.getInstructions().clear();
block.getPredecessors().clear();
block.getSuccessors().clear();
}
@@ -133,8 +133,6 @@
.catchall {:try_start_14 .. :try_end_50} :catchall_4e
throw p1
return-void
.end method
.method private getValueObject(Ljava/lang/String;)Ljava/lang/Object;