Merge pull request #2736 from xmcclure/more-trampolines
[mono.git] / mono / mini / local-propagation.c
index 5b11f776cf68e710b7ff891bdad6a89ab123c810..2120fa08728e6c39a3863b4ab80ce95dc3c5b499 100644 (file)
@@ -205,8 +205,8 @@ mono_local_cprop (MonoCompile *cfg)
        int initial_max_vregs = cfg->next_vreg;
 
        max = cfg->next_vreg;
-       defs = (MonoInst **)mono_mempool_alloc (cfg->mempool, sizeof (MonoInst*) * cfg->next_vreg + 1);
-       def_index = (gint32 *)mono_mempool_alloc (cfg->mempool, sizeof (guint32) * cfg->next_vreg + 1);
+       defs = (MonoInst **)mono_mempool_alloc (cfg->mempool, sizeof (MonoInst*) * cfg->next_vreg);
+       def_index = (gint32 *)mono_mempool_alloc (cfg->mempool, sizeof (guint32) * cfg->next_vreg);
        cfg->cbb = bb_opt = mono_mempool_alloc0 ((cfg)->mempool, sizeof (MonoBasicBlock));
 
        for (bb = cfg->bb_entry; bb; bb = bb->next_bb) {
@@ -219,22 +219,28 @@ mono_local_cprop (MonoCompile *cfg)
                        int sregs [MONO_MAX_SRC_REGS];
                        int num_sregs, i;
 
-                       if ((ins->dreg != -1) && (ins->dreg < max)) {
-                               defs [ins->dreg] = NULL;
+                       if (ins->dreg != -1) {
 #if SIZEOF_REGISTER == 4
-                               defs [ins->dreg + 1] = NULL;
+                               const char *spec = INS_INFO (ins->opcode);
+                               if (spec [MONO_INST_DEST] == 'l') {
+                                       defs [ins->dreg + 1] = NULL;
+                                       defs [ins->dreg + 2] = NULL;
+                               }
 #endif
+                               defs [ins->dreg] = NULL;
                        }
 
                        num_sregs = mono_inst_get_src_registers (ins, sregs);
                        for (i = 0; i < num_sregs; ++i) {
                                int sreg = sregs [i];
-                               if (sreg < max) {
-                                       defs [sreg] = NULL;
 #if SIZEOF_REGISTER == 4
+                               const char *spec = INS_INFO (ins->opcode);
+                               if (spec [MONO_INST_SRC1 + i] == 'l') {
                                        defs [sreg + 1] = NULL;
-#endif
+                                       defs [sreg + 2] = NULL;
                                }
+#endif
+                               defs [sreg] = NULL;
                        }
                }