Merge pull request #4327 from vkargov/vk-abcremedy
authorvkargov <kargov@gmail.com>
Fri, 12 May 2017 00:02:57 +0000 (17:02 -0700)
committerGitHub <noreply@github.com>
Fri, 12 May 2017 00:02:57 +0000 (17:02 -0700)
[runtime] Abcrem fixes.

mono/mini/abcremoval.c
mono/mini/mini.h
mono/tests/Makefile.am

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;
index e86b807375f7a0605c056cec4f41e56d24a59388..6eb32809205aa44af20d634bfaf7607a344fa0e3 100644 (file)
@@ -595,6 +595,20 @@ extern const gint8 ins_sreg_counts [];
 
 #define mono_bb_first_ins(bb) (bb)->code
 
+/*
+ * Iterate through all used registers in the instruction.
+ * Relies on the existing order of the MONO_INST enum: MONO_INST_{DREG,SREG1,SREG2,SREG3,LEN}
+ * INS is the instruction, IDX is the register index, REG is the pointer to a register.
+ */
+#define MONO_INS_FOR_EACH_REG(ins, idx, reg) for ((idx) = INS_INFO ((ins)->opcode)[MONO_INST_DEST] != ' ' ? MONO_INST_DEST : \
+                                                         (mono_inst_get_num_src_registers (ins) ? MONO_INST_SRC1 : MONO_INST_LEN); \
+                                                 (reg) = (idx) == MONO_INST_DEST ? &(ins)->dreg : \
+                                                         ((idx) == MONO_INST_SRC1 ? &(ins)->sreg1 : \
+                                                          ((idx) == MONO_INST_SRC2 ? &(ins)->sreg2 : \
+                                                           ((idx) == MONO_INST_SRC3 ? &(ins)->sreg3 : NULL))), \
+                                                         idx < MONO_INST_LEN; \
+                                                 (idx) = (idx) > mono_inst_get_num_src_registers (ins) + (INS_INFO ((ins)->opcode)[MONO_INST_DEST] != ' ') ? MONO_INST_LEN : (idx) + 1)
+
 struct MonoSpillInfo {
        int offset;
 };
index fc1259252f3d9750bb61c8073b87f69f36a433dd..dc2bb937cbe4d8905aa01f5230114fc243121aff 100644 (file)
@@ -1221,7 +1221,7 @@ tests: compile-tests
 #
 # Test that no symbols are missed in eglib-remap.h
 #
-OK_G_SYMBOLS='g_list\|g_slist\|g_concat_dir_and_file\|g_Ctoc\'
+OK_G_SYMBOLS='g_list\|g_slist\|g_concat_dir_and_file\|g_Ctoc'
 if NACL_CODEGEN
 test-eglib-remap:
 else