Fix error in switch rewriting
Bug:
Change-Id: I459fa910250fa456d026e7f3daf122097a3e7dd8
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/CodeRewriter.java b/src/main/java/com/android/tools/r8/ir/optimize/CodeRewriter.java
index 7741fda..59106c8 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/CodeRewriter.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/CodeRewriter.java
@@ -479,6 +479,9 @@
Int2ReferenceSortedMap<BasicBlock> keyToTarget = theSwitch.getKeyToTargetMap();
Set<Value> originalDebugValues = ImmutableSet.copyOf(theSwitch.getDebugValues());
+ // Keep track of the current fallthrough, starting with the original.
+ BasicBlock fallthroughBlock = theSwitch.fallthroughBlock();
+
// Split the switch instruction into its own block and remove it.
iterator.previous();
BasicBlock originalSwitchBlock = iterator.split(code, blocksIterator);
@@ -495,9 +498,6 @@
int nextBlockNumber = code.getHighestBlockNumber() + 1;
LinkedList<BasicBlock> newBlocks = new LinkedList<>();
- // Keep track of the current fallthrough, starting with the original.
- BasicBlock fallthroughBlock = theSwitch.fallthroughBlock();
-
// Build the switch-blocks backwards, to always have the fallthrough block in hand.
for (int i = switches.size() - 1; i >= 0; i--) {
SwitchBuilder switchBuilder = new SwitchBuilder();