#include <alloca.h>
#endif
-#define USE_ORIGINAL_VARS
#define CREATE_PRUNED_SSA
//#define DEBUG_SSA 1
#define NEW_PHI(cfg,dest,val) do { \
- (dest) = mono_mempool_alloc0 ((cfg)->mempool, sizeof (MonoInst)); \
- (dest)->opcode = OP_PHI; \
- (dest)->inst_c0 = (val); \
- (dest)->dreg = (dest)->sreg1 = (dest)->sreg2 = -1; \
+ MONO_INST_NEW ((cfg), (dest), OP_PHI); \
+ (dest)->inst_c0 = (val); \
} while (0)
typedef struct {
}
}
- ins->opcode = OP_NOP;
- ins->dreg = -1;
+ NULLIFY_INS (ins);
}
}
}
MonoInst *src_var = get_vreg_to_inst (cfg, def->sreg1);
if (src_var && !(src_var->flags & (MONO_INST_VOLATILE|MONO_INST_INDIRECT)))
add_to_dce_worklist (cfg, info, MONO_VARINFO (cfg, src_var->inst_c0), &work_list);
- def->opcode = OP_NOP;
- def->dreg = def->sreg1 = def->sreg2 = -1;
+ NULLIFY_INS (def);
info->reg = -1;
} else if ((def->opcode == OP_ICONST) || (def->opcode == OP_I8CONST) || MONO_IS_ZERO (def)) {
- def->opcode = OP_NOP;
- def->dreg = def->sreg1 = def->sreg2 = -1;
+ NULLIFY_INS (def);
info->reg = -1;
} else if (MONO_IS_PHI (def)) {
int j;
MonoMethodVar *u = MONO_VARINFO (cfg, get_vreg_to_inst (cfg, def->inst_phi_args [j])->inst_c0);
add_to_dce_worklist (cfg, info, u, &work_list);
}
- def->opcode = OP_NOP;
- def->dreg = def->sreg1 = def->sreg2 = -1;
+ NULLIFY_INS (def);
info->reg = -1;
}
else if (def->opcode == OP_NOP) {
if (bb != h)
continue;
MONO_BB_FOR_EACH_INS_SAFE (bb, n, ins) {
- gboolean is_class_init = FALSE;
-
/*
* Try to move instructions out of loop headers into the preceeding bblock.
*/
- if (ins->opcode == OP_VOIDCALL) {
- MonoCallInst *call = (MonoCallInst*)ins;
-
- if (call->fptr_is_patch) {
- MonoJumpInfo *ji = (MonoJumpInfo*)call->fptr;
-
- if (ji->type == MONO_PATCH_INFO_CLASS_INIT)
- is_class_init = TRUE;
- }
- }
- if (ins->opcode == OP_LDLEN || ins->opcode == OP_STRLEN || ins->opcode == OP_CHECK_THIS || ins->opcode == OP_AOTCONST || is_class_init) {
+ if (ins->opcode == OP_LDLEN || ins->opcode == OP_STRLEN || ins->opcode == OP_CHECK_THIS || ins->opcode == OP_AOTCONST || ins->opcode == OP_GENERIC_CLASS_INIT) {
gboolean skip;
int sreg;
else
sreg = -1;
if (sreg != -1) {
- skip = FALSE;
- MonoInst *tins;
+ MonoInst *tins, *var;
+ skip = FALSE;
for (tins = ins->prev; tins; tins = tins->prev) {
const char *spec = INS_INFO (tins->opcode);
}
if (skip)
continue;
+ var = get_vreg_to_inst (cfg, sreg);
+ if (var && (var->flags & (MONO_INST_VOLATILE|MONO_INST_INDIRECT)))
+ continue;
ins->sreg1 = sreg;
}