Change how we rewind instructions in Air's O0 register allocator
https://bugs.webkit.org/show_bug.cgi?id=241687

Reviewed by Mark Lam.

* Source/JavaScriptCore/b3/air/AirAllocateRegistersAndStackAndGenerateCode.cpp:
(JSC::B3::Air::GenerateAndAllocateRegisters::generate):

Canonical link: https://commits.webkit.org/251611@main


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@295606 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/JavaScriptCore/b3/air/AirAllocateRegistersAndStackAndGenerateCode.cpp b/Source/JavaScriptCore/b3/air/AirAllocateRegistersAndStackAndGenerateCode.cpp
index f85f072..7585f34 100644
--- a/Source/JavaScriptCore/b3/air/AirAllocateRegistersAndStackAndGenerateCode.cpp
+++ b/Source/JavaScriptCore/b3/air/AirAllocateRegistersAndStackAndGenerateCode.cpp
@@ -590,6 +590,7 @@
             context.indexInBlock = instIndex;
 
             Inst& inst = block->at(instIndex);
+            Inst instCopy = inst;
 
             m_namedUsedRegs = RegisterSet();
             m_namedDefdRegs = RegisterSet();
@@ -753,26 +754,7 @@
                 if (!success) {
                     RELEASE_ASSERT(!isReplayingSameInst); // We should only need to do the below at most once per inst.
 
-                    // We need to capture the register state before we start spilling things
-                    // since we may have multiple arguments that are the same register.
-                    IndexMap<Reg, Tmp> allocationSnapshot = currentAllocation;
-
-                    // We rewind this Inst to be in its previous state, however, if any arg admits stack,
-                    // we move to providing that arg in stack form. This will allow us to fully allocate
-                    // this inst when we rewind.
-                    inst.forEachTmpFast([&] (Tmp& tmp) {
-                        if (!tmp.isReg())
-                            return;
-                        if (isDisallowedRegister(tmp.reg()))
-                            return;
-                        Tmp originalTmp = allocationSnapshot[tmp.reg()];
-                        if (originalTmp.isReg()) {
-                            ASSERT(tmp.reg() == originalTmp.reg());
-                            // This means this Inst referred to this reg directly. We leave these as is.
-                            return;
-                        }
-                        tmp = originalTmp;
-                    });
+                    inst = instCopy;
                     inst.forEachArg([&] (Arg& arg, Arg::Role, Bank, Width) {
                         if (arg.isTmp() && !arg.tmp().isReg() && inst.admitsStack(arg)) {
                             Tmp tmp = arg.tmp();