[turbofan] Handle void returns in instruction selector.
authortitzer <titzer@chromium.org>
Tue, 4 Aug 2015 13:13:54 +0000 (06:13 -0700)
committerCommit bot <commit-bot@chromium.org>
Tue, 4 Aug 2015 13:14:16 +0000 (13:14 +0000)
R=jarin@chromium.org
BUG=

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

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

src/compiler/instruction-selector.cc
test/cctest/compiler/test-run-machops.cc

index 4981f64..fde7ba3 100644 (file)
@@ -1000,9 +1000,13 @@ void InstructionSelector::VisitGoto(BasicBlock* target) {
 void InstructionSelector::VisitReturn(Node* value) {
   DCHECK_NOT_NULL(value);
   OperandGenerator g(this);
-  Emit(kArchRet, g.NoOutput(),
-       g.UseLocation(value, linkage()->GetReturnLocation(),
-                     linkage()->GetReturnType()));
+  if (linkage()->GetIncomingDescriptor()->ReturnCount() == 0) {
+    Emit(kArchRet, g.NoOutput());
+  } else {
+    Emit(kArchRet, g.NoOutput(),
+         g.UseLocation(value, linkage()->GetReturnLocation(),
+                       linkage()->GetReturnType()));
+  }
 }
 
 
index b1fc369..10e9e9f 100644 (file)
@@ -82,6 +82,13 @@ TEST(CodeGenInt32Binop) {
 }
 
 
+TEST(CodeGenNop) {
+  RawMachineAssemblerTester<void> m;
+  m.Return(m.Int32Constant(0));
+  m.GenerateCode();
+}
+
+
 #if V8_TURBOFAN_BACKEND_64
 static Node* Int64Input(RawMachineAssemblerTester<int64_t>* m, int index) {
   switch (index) {