Merge pull request #4327 from vkargov/vk-abcremedy
[mono.git] / mono / mini / abcremoval.c
index 2d8b5267ae03cadcdab157404b2b59232e57f743..c5d5f4dfb34f92459d610fb9ee02032010067340 100644 (file)
@@ -905,7 +905,7 @@ evaluate_relation_with_target_variable (MonoVariableRelationsEvaluationArea *are
                        
                        current_context = father_context;
                        while (current_context != last_context) {
-                               int index = father_context - area->contexts;
+                               int index = current_context - area->contexts;
                                MonoRelationsEvaluationStatus *current_status = &(area->statuses [index]);
                                *current_status = (MonoRelationsEvaluationStatus)(*current_status | recursive_status);
                                current_context = current_context->father;
@@ -1300,10 +1300,22 @@ mono_perform_abc_removal (MonoCompile *cfg)
 
                for (ins = bb->code; ins; ins = ins->next) {
                        const char *spec = INS_INFO (ins->opcode);
+                       gint32 idx, *reg;
                        
                        if (spec [MONO_INST_DEST] == ' ' || MONO_IS_STORE_MEMBASE (ins))
                                continue;
 
+                       MONO_INS_FOR_EACH_REG (ins, idx, reg) {
+                               MonoInst *var = get_vreg_to_inst (cfg, *reg);
+                               if (var && (!MONO_VARINFO (cfg, var->inst_c0)->def))
+                                               break;
+                       }
+                       if (idx < MONO_INST_LEN) {
+                               if (TRACE_ABC_REMOVAL)
+                                       printf ("Global register %d is not in the SSA form, skipping.\n", *reg);
+                               continue;
+                       }
+
                        if (spec [MONO_INST_DEST] == 'i') {
                                MonoIntegerValueKind effective_value_kind;
                                MonoRelationsEvaluationRange range;