When inlining, also look whether we can allocate registers.

arm and x86 currently don't allocate registers for floating point
and long operations, so we can't inline methods with these operations.

Change-Id: I11e4b97ddbe90f4978f2abe1081fb0f849acb811
diff --git a/compiler/optimizing/inliner.cc b/compiler/optimizing/inliner.cc
index 73eb521..493d93f 100644
--- a/compiler/optimizing/inliner.cc
+++ b/compiler/optimizing/inliner.cc
@@ -27,6 +27,7 @@
 #include "mirror/class_loader.h"
 #include "mirror/dex_cache.h"
 #include "nodes.h"
+#include "register_allocator.h"
 #include "ssa_phi_elimination.h"
 #include "scoped_thread_state_change.h"
 #include "thread.h"
@@ -143,6 +144,13 @@
     return false;
   }
 
+  if (!RegisterAllocator::CanAllocateRegistersFor(*callee_graph,
+                                                  compiler_driver_->GetInstructionSet())) {
+    VLOG(compiler) << "Method " << PrettyMethod(method_index, outer_dex_file)
+                   << " cannot be inlined because of the register allocator";
+    return false;
+  }
+
   if (!callee_graph->TryBuildingSsa()) {
     VLOG(compiler) << "Method " << PrettyMethod(method_index, outer_dex_file)
                    << " could not be transformed to SSA";
diff --git a/test/437-inline/src/Main.java b/test/437-inline/src/Main.java
index ccddab7..daabe4e 100644
--- a/test/437-inline/src/Main.java
+++ b/test/437-inline/src/Main.java
@@ -46,6 +46,23 @@
     if ($opt$inline$returnSub(42, 1) != 41) {
       throw new Error();
     }
+
+    // Some architectures used to not be able to allocate registers with
+    // floating point operations. This call is a regression test that we don't
+    // try inlining methods with floats in it on such architectures. The
+    // compiler used to crash after inlining a method it cannot allocate
+    // registers for.
+    tryInlineFloat();
+  }
+
+  public static int tryInlineFloat() {
+    return useFloatMethod();
+  }
+
+  public static float staticFloat = 42.0f;
+
+  public static int useFloatMethod() {
+    return (int)staticFloat;
   }
 
   public static int $opt$inline$returnParameter(int a) {