Merge pull request #363 from JamesB7/system-security2
[mono.git] / mono / mini / decompose.c
index 7885bf9f1e6d2bbbb09491a0419c85381aaa7ceb..72a4a99898fc23a1afc31390d354b39a1b26ec40 100644 (file)
@@ -5,6 +5,7 @@
  *   Zoltan Varga (vargaz@gmail.com)
  *
  * (C) 2002 Ximian, Inc.
+ * Copyright 2011 Xamarin, Inc (http://www.xamarin.com)
  */
 
 #include "mini.h"
@@ -1527,6 +1528,7 @@ mono_decompose_soft_float (MonoCompile *cfg)
                                                MonoCallInst *call2;
                                                MonoInst *iargs [1];
                                                MonoInst *conv;
+                                               GSList *l;
 
                                                /* Convert the call into a call returning an int */
                                                MONO_INST_NEW_CALL (cfg, call2, OP_CALL);
@@ -1547,6 +1549,10 @@ mono_decompose_soft_float (MonoCompile *cfg)
                                                call2->inst.dreg = mono_alloc_ireg (cfg);
                                                MONO_ADD_INS (cfg->cbb, (MonoInst*)call2);
 
+                                               /* Remap OUTARG_VT instructions referencing this call */
+                                               for (l = call->outarg_vts; l; l = l->next)
+                                                       ((MonoInst*)(l->data))->inst_p0 = call2;
+
                                                /* FIXME: Optimize this */
 
                                                /* Emit an r4->r8 conversion */
@@ -1580,8 +1586,18 @@ mono_decompose_soft_float (MonoCompile *cfg)
 
                                        /* Convert fcompare+fbcc to icall+icompare+beq */
 
+                                       if (!ins->next) {
+                                               /* The branch might be optimized away */
+                                               NULLIFY_INS (ins);
+                                               break;
+                                       }
+
                                        info = mono_find_jit_opcode_emulation (ins->next->opcode);
-                                       g_assert (info);
+                                       if (!info) {
+                                               /* The branch might be optimized away */
+                                               NULLIFY_INS (ins);
+                                               break;
+                                       }
 
                                        /* Create dummy MonoInst's for the arguments */
                                        MONO_INST_NEW (cfg, iargs [0], OP_ARG);