[PATCH] D15167: [WebAssembly] Add a test for wasm-store-results pass

Derek Schuff via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 2 16:45:23 PST 2015


dschuff updated this revision to Diff 41695.
dschuff added a comment.

- Add comment


http://reviews.llvm.org/D15167

Files:
  lib/Target/WebAssembly/WebAssemblyStoreResults.cpp
  test/CodeGen/WebAssembly/store-results.ll

Index: test/CodeGen/WebAssembly/store-results.ll
===================================================================
--- /dev/null
+++ test/CodeGen/WebAssembly/store-results.ll
@@ -0,0 +1,18 @@
+; RUN: llc < %s -asm-verbose=false | FileCheck %s
+
+; Test that the wasm-store-results pass makes users of stored values use the
+; result of store expressions to reduce get_local/set_local traffic.
+
+target datalayout = "e-p:32:32-i64:64-n32:64-S128"
+target triple = "wasm32-unknown-unknown"
+
+; CHECK-LABEL: single_block:
+; CHECK-NOT: .local
+; CHECK: i32.const $push{{[0-9]+}}=, 0
+; CHECK: i32.store $push[[STORE:[0-9]+]]=, $0, $pop{{[0-9]+}}
+; CHECK: return $pop[[STORE]]{{$}}
+define i32 @single_block(i32* %p) {
+entry:
+  store i32 0, i32* %p
+  ret i32 0
+}
Index: lib/Target/WebAssembly/WebAssemblyStoreResults.cpp
===================================================================
--- lib/Target/WebAssembly/WebAssemblyStoreResults.cpp
+++ lib/Target/WebAssembly/WebAssemblyStoreResults.cpp
@@ -69,7 +69,8 @@
   const MachineRegisterInfo &MRI = MF.getRegInfo();
   MachineDominatorTree &MDT = getAnalysis<MachineDominatorTree>();
 
-  for (auto &MBB : MF)
+  for (auto &MBB : MF) {
+    DEBUG(dbgs() << "Basic Block: " << MBB.getName() << '\n');
     for (auto &MI : MBB)
       switch (MI.getOpcode()) {
       default:
@@ -94,9 +95,12 @@
                         ->getFirstTerminator();
           if (&MI == Where || !MDT.dominates(&MI, Where))
             continue;
+          DEBUG(dbgs() << "Setting operand " << O << " in " << *Where <<
+                " from " << MI <<"\n");
           O.setReg(ToReg);
         }
       }
+  }
 
   return true;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15167.41695.patch
Type: text/x-patch
Size: 1673 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151203/9d31e210/attachment.bin>


More information about the llvm-commits mailing list