* Patrik Torstensson (Patrik.Torstesson at gmail.com)
*
* (C) 2005 Ximian, Inc. http://www.ximian.com
+ * Copyright 2011 Xamarin Inc. http://www.xamarin.com
*/
#include "mini.h"
OP_CMOV_LGT_UN
};
-static int
+static G_GNUC_UNUSED int
br_to_br_un (int opcode)
{
switch (opcode) {
static void
replace_out_block_in_code (MonoBasicBlock *bb, MonoBasicBlock *orig, MonoBasicBlock *repl) {
MonoInst *ins;
+
+#if defined(__native_client_codegen__)
+ /* Need to maintain this flag for the new block because */
+ /* we can't jump indirectly to a non-aligned block. */
+ if (orig->flags & BB_INDIRECT_JUMP_TARGET)
+ {
+ repl->flags |= BB_INDIRECT_JUMP_TARGET;
+ }
+#endif
for (ins = bb->code; ins != NULL; ins = ins->next) {
switch (ins->opcode) {
bb->has_array_access |= bbn->has_array_access;
bb->extended |= bbn->extended;
+ /* Compute prev_bb if possible to avoid the linear search below */
+ prev_bb = NULL;
+ for (i = 0; i < bbn->in_count; ++i)
+ if (bbn->in_bb [0]->next_bb == bbn)
+ prev_bb = bbn->in_bb [0];
+
mono_unlink_bblock (cfg, bb, bbn);
for (i = 0; i < bbn->out_count; ++i)
mono_link_bblock (cfg, bb, bbn->out_bb [i]);
bb->last_ins = bbn->last_ins;
}
- for (prev_bb = cfg->bb_entry; prev_bb && prev_bb->next_bb != bbn; prev_bb = prev_bb->next_bb)
- ;
+ if (!prev_bb) {
+ for (prev_bb = cfg->bb_entry; prev_bb && prev_bb->next_bb != bbn; prev_bb = prev_bb->next_bb)
+ ;
+ }
if (prev_bb) {
prev_bb->next_bb = bbn->next_bb;
} else {
/* branches to the following block can be removed */
if (bb->last_ins && bb->last_ins->opcode == OP_BR && !bbn->out_of_line) {
- bb->last_ins->opcode = OP_NOP;
+ NULLIFY_INS (bb->last_ins);
changed = TRUE;
if (cfg->verbose_level > 2)
g_print ("br removal triggered %d -> %d\n", bb->block_num, bbn->block_num);