[llvm] r253626 - Split the argument unscheduling loop in the WebAssembly register

Eric Christopher via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 19 16:34:56 PST 2015


Author: echristo
Date: Thu Nov 19 18:34:54 2015
New Revision: 253626

URL: http://llvm.org/viewvc/llvm-project?rev=253626&view=rev
Log:
Split the argument unscheduling loop in the WebAssembly register
coloring pass. Turn the logic into "look for an insert point and
then move things past the insert point".

No functional change intended.

Modified:
    llvm/trunk/lib/Target/WebAssembly/WebAssemblyRegColoring.cpp

Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyRegColoring.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyRegColoring.cpp?rev=253626&r1=253625&r2=253626&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyRegColoring.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyRegColoring.cpp Thu Nov 19 18:34:54 2015
@@ -98,20 +98,30 @@ bool WebAssemblyRegColoring::runOnMachin
 
   // FIXME: If scheduling has moved an ARGUMENT virtual register, move it back,
   // and recompute liveness. This is a temporary hack.
-  bool SawNonArg = false;
   bool MovedArg = false;
   MachineBasicBlock &EntryMBB = MF.front();
-  for (auto MII = EntryMBB.begin(); MII != EntryMBB.end(); ) {
-    MachineInstr *MI = &*MII++;
+  MachineBasicBlock::iterator InsertPt = EntryMBB.end();
+  // Look for the first NonArg instruction.
+  for (auto MII = EntryMBB.begin(), MIE = EntryMBB.end(); MII != MIE; ++MII) {
+    MachineInstr *MI = MII;
+    if (MI->getOpcode() != WebAssembly::ARGUMENT_I32 &&
+        MI->getOpcode() != WebAssembly::ARGUMENT_I64 &&
+        MI->getOpcode() != WebAssembly::ARGUMENT_F32 &&
+        MI->getOpcode() != WebAssembly::ARGUMENT_F64) {
+      InsertPt = MII;
+      break;
+    }
+  }
+  // Now move any argument instructions later in the block
+  // to before our first NonArg instruction.
+  for (auto I = InsertPt, E = EntryMBB.end(); I != E; ++I) {
+    MachineInstr *MI = I;
     if (MI->getOpcode() == WebAssembly::ARGUMENT_I32 ||
         MI->getOpcode() == WebAssembly::ARGUMENT_I64 ||
         MI->getOpcode() == WebAssembly::ARGUMENT_F32 ||
         MI->getOpcode() == WebAssembly::ARGUMENT_F64) {
-      EntryMBB.insert(EntryMBB.begin(), MI->removeFromParent());
-      if (SawNonArg)
-        MovedArg = true;
-    } else {
-      SawNonArg = true;
+      EntryMBB.insert(InsertPt, MI->removeFromParent());
+      MovedArg = true;
     }
   }
   if (MovedArg) {




More information about the llvm-commits mailing list