add register allocator regression test
authordcarney <dcarney@chromium.org>
Thu, 15 Jan 2015 08:55:51 +0000 (00:55 -0800)
committerCommit bot <commit-bot@chromium.org>
Thu, 15 Jan 2015 08:56:10 +0000 (08:56 +0000)
BUG=

Review URL: https://codereview.chromium.org/852633002

Cr-Commit-Position: refs/heads/master@{#26068}

test/unittests/compiler/register-allocator-unittest.cc

index 12dedbd..e198c74 100644 (file)
@@ -432,6 +432,40 @@ TEST_F(RegisterAllocatorTest, RegressionSpillTwice) {
 }
 
 
+TEST_F(RegisterAllocatorTest, RegressionLoadConstantBeforeSpill) {
+  StartBlock();
+  // Fill registers.
+  VReg values[kDefaultNRegs];
+  for (size_t i = arraysize(values); i > 0; --i) {
+    values[i - 1] = Define(Reg(static_cast<int>(i - 1)));
+  }
+  auto c = DefineConstant();
+  auto to_spill = Define(Reg());
+  EndBlock(Jump(1));
+
+  {
+    StartLoop(1);
+
+    StartBlock();
+    // Create a use for c in second half of prev block's last gap
+    Phi(c);
+    for (size_t i = arraysize(values); i > 0; --i) {
+      Phi(values[i - 1]);
+    }
+    EndBlock(Jump(1));
+
+    EndLoop();
+  }
+
+  StartBlock();
+  // Force c to split within to_spill's definition.
+  EmitI(Reg(c));
+  EmitI(Reg(to_spill));
+  EndBlock(Last());
+
+  Allocate();
+}
+
 }  // namespace compiler
 }  // namespace internal
 }  // namespace v8