Make moves from argument registers block moves to argument registers

Bug: 126273993
Change-Id: I72b5c0184ead2d5b0a857aa46303750e4b4561ab
diff --git a/src/main/java/com/android/tools/r8/ir/regalloc/RegisterMove.java b/src/main/java/com/android/tools/r8/ir/regalloc/RegisterMove.java
index fb681b9..92992e8 100644
--- a/src/main/java/com/android/tools/r8/ir/regalloc/RegisterMove.java
+++ b/src/main/java/com/android/tools/r8/ir/regalloc/RegisterMove.java
@@ -25,7 +25,7 @@
   }
 
   public RegisterMove(int dst, TypeLatticeElement type, Instruction definition) {
-    assert definition.isOutConstant() || definition.isArgument();
+    assert definition.isOutConstant();
     this.dst = dst;
     this.src = LiveIntervals.NO_REGISTER;
     this.definition = definition;
diff --git a/src/main/java/com/android/tools/r8/ir/regalloc/SpillMoveSet.java b/src/main/java/com/android/tools/r8/ir/regalloc/SpillMoveSet.java
index 0d25746..aad705f 100644
--- a/src/main/java/com/android/tools/r8/ir/regalloc/SpillMoveSet.java
+++ b/src/main/java/com/android/tools/r8/ir/regalloc/SpillMoveSet.java
@@ -353,9 +353,18 @@
       // Use rematerialization when possible and otherwise generate moves.
       if (move.from.isSpilledAndRematerializable()) {
         assert allocator.unadjustedRealRegisterFromAllocated(move.to.getRegister()) < 256;
-        scheduler.addMove(
-            new RegisterMove(move.to.getRegister(), move.type, move.from.getValue().definition));
-      } else if (move.to.getRegister() != move.from.getRegister()) {
+        Instruction definition = move.from.getValue().definition;
+        if (definition.isOutConstant()) {
+          scheduler.addMove(new RegisterMove(move.to.getRegister(), move.type, definition));
+          continue;
+        } else {
+          // The src value is an argument, so we must create a register move that has a src
+          // register, using the code below, to ensure that other moves that have the argument
+          // register as dest are blocked by this move.
+          assert definition.isArgument();
+        }
+      }
+      if (move.to.getRegister() != move.from.getRegister()) {
         // In case the runtime might have a bound-check elimination bug we make sure to define all
         // indexing constants with an actual const instruction rather than a move. This appears to
         // avoid a bug where the index variable could end up being uninitialized.