projects
/
mono.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #4540 from kumpera/android-changes-part1
[mono.git]
/
mono
/
mini
/
branch-opts.c
diff --git
a/mono/mini/branch-opts.c
b/mono/mini/branch-opts.c
index cab90f84d3de89b717e58beaf13e98419f440afa..2f964b4162f88a70a06caaf992da8b14db18bac2 100644
(file)
--- a/
mono/mini/branch-opts.c
+++ b/
mono/mini/branch-opts.c
@@
-1,5
+1,6
@@
-/*
- * branch-opts.c: Branch optimizations support
+/**
+ * \file
+ * Branch optimizations support
*
* Authors:
* Patrik Torstensson (Patrik.Torstesson at gmail.com)
*
* Authors:
* Patrik Torstensson (Patrik.Torstesson at gmail.com)
@@
-8,10
+9,12
@@
* Copyright 2011 Xamarin Inc. http://www.xamarin.com
* Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
* Copyright 2011 Xamarin Inc. http://www.xamarin.com
* Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
- #include "mini.h"
+#include "config.h"
+#include <mono/utils/mono-compiler.h>
#ifndef DISABLE_JIT
#ifndef DISABLE_JIT
-
+
+#include "mini.h"
/*
* Returns true if @bb is a basic block which falls through the next block.
/*
* Returns true if @bb is a basic block which falls through the next block.
@@
-971,15
+974,12
@@
mono_merge_basic_blocks (MonoCompile *cfg, MonoBasicBlock *bb, MonoBasicBlock *b
MonoBasicBlock *prev_bb;
int i;
MonoBasicBlock *prev_bb;
int i;
+ /* There may be only one control flow edge between two BBs that we merge, and it should connect these BBs together. */
+ g_assert (bb->out_count == 1 && bbn->in_count == 1 && bb->out_bb [0] == bbn && bbn->in_bb [0] == bb);
+
bb->has_array_access |= bbn->has_array_access;
bb->extended |= bbn->extended;
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]);
mono_unlink_bblock (cfg, bb, bbn);
for (i = 0; i < bbn->out_count; ++i)
mono_link_bblock (cfg, bb, bbn->out_bb [i]);
@@
-1032,10
+1032,14
@@
mono_merge_basic_blocks (MonoCompile *cfg, MonoBasicBlock *bb, MonoBasicBlock *b
bb->last_ins = bbn->last_ins;
}
bb->last_ins = bbn->last_ins;
}
- if (!prev_bb) {
+
+ /* Check if the control flow predecessor is also the linear IL predecessor. */
+ if (bbn->in_bb [0]->next_bb == bbn)
+ prev_bb = bbn->in_bb [0];
+ else
+ /* If it isn't, look for one among all basic blocks. */
for (prev_bb = cfg->bb_entry; prev_bb && prev_bb->next_bb != bbn; prev_bb = prev_bb->next_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 {
if (prev_bb) {
prev_bb->next_bb = bbn->next_bb;
} else {
@@
-1478,4
+1482,8
@@
mono_optimize_branches (MonoCompile *cfg)
} while (changed && (niterations > 0));
}
} while (changed && (niterations > 0));
}
-#endif /* DISABLE_JIT */
+#else /* !DISABLE_JIT */
+
+MONO_EMPTY_SOURCE_FILE (branch_opts);
+
+#endif /* !DISABLE_JIT */