Mark top of managed stack on helper transitions

To assist with unwind from a helper function, store current SP prior
to helper call in Thread.  NOTE: we may wish to push this into a
trampoline to reduce code expansion.  NOTE #2:  Because any helper
function which can throw will be non-leaf, it will spill lr at the saved
address - 4 (the word immediately below caller's Method*).  To identify
the callsite, load the spilled lr, clear the low bit, subtract 2, and use
that address in the native <-> dalvik mapping to identify the callsite.

Also in this CL are a ralloc fix and some extra SSA logging.

Change-Id: Idd442f0c55413a5146c24709b1db1150604f4554
diff --git a/src/compiler/codegen/RallocUtil.cc b/src/compiler/codegen/RallocUtil.cc
index 1fe680f..76cff17 100644
--- a/src/compiler/codegen/RallocUtil.cc
+++ b/src/compiler/codegen/RallocUtil.cc
@@ -833,7 +833,11 @@
 {
     RegisterInfo* newInfo = getRegInfo(cUnit, newReg);
     RegisterInfo* oldInfo = getRegInfo(cUnit, oldReg);
+    // Target temp status must not change
+    bool isTemp = newInfo->isTemp;
     *newInfo = *oldInfo;
+    // Restore target's temp status
+    newInfo->isTemp = isTemp;
     newInfo->reg = newReg;
 }
 
@@ -1011,7 +1015,12 @@
 {
     RegLocation res = cUnit->regLocation[mir->ssaRep->defs[num]];
 #ifdef SSA_WORKAROUND
-    res.wide = false;
+    if (res.wide) {
+        LOG(WARNING) << "Invalid SSA renaming: " << PrettyMethod(cUnit->method);
+        cUnit->printMe = true;
+        cUnit->dumpCFG = true;
+        res.wide = false;
+    }
 #endif
     assert(!res.wide);
     return res;
@@ -1020,7 +1029,12 @@
 {
     RegLocation res = cUnit->regLocation[mir->ssaRep->uses[num]];
 #ifdef SSA_WORKAROUND
-    res.wide = false;
+    if (res.wide) {
+        LOG(WARNING) << "Invalid SSA renaming: " << PrettyMethod(cUnit->method);
+        cUnit->printMe = true;
+        cUnit->dumpCFG = true;
+        res.wide = false;
+    }
 #endif
     assert(!res.wide);
     return res;
@@ -1035,7 +1049,12 @@
 {
     RegLocation res = cUnit->regLocation[mir->ssaRep->defs[low]];
 #ifdef SSA_WORKAROUND
-    res.wide = true;
+    if (!res.wide) {
+        LOG(WARNING) << "Invalid SSA renaming: " << PrettyMethod(cUnit->method);
+        cUnit->printMe = true;
+        cUnit->dumpCFG = true;
+        res.wide = true;
+    }
 #endif
     assert(res.wide);
     return res;
@@ -1046,7 +1065,12 @@
 {
     RegLocation res = cUnit->regLocation[mir->ssaRep->uses[low]];
 #ifdef SSA_WORKAROUND
-    res.wide = true;
+    if (!res.wide) {
+        LOG(WARNING) << "Invalid SSA renaming: " << PrettyMethod(cUnit->method);
+        cUnit->printMe = true;
+        cUnit->dumpCFG = true;
+        res.wide = true;
+    }
 #endif
     assert(res.wide);
     return res;