projects
/
libfirm
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added add_saturated
[libfirm]
/
ir
/
opt
/
cfopt.c
diff --git
a/ir/opt/cfopt.c
b/ir/opt/cfopt.c
index
6043c37
..
8c78879
100644
(file)
--- a/
ir/opt/cfopt.c
+++ b/
ir/opt/cfopt.c
@@
-13,6
+13,13
@@
# include "config.h"
#endif
# include "config.h"
#endif
+#ifdef HAVE_MALLOC_H
+# include <malloc.h>
+#endif
+#ifdef HAVE_ALLOCA_H
+# include <alloca.h>
+#endif
+
#include <assert.h>
#include "xmalloc.h"
#include <assert.h>
#include "xmalloc.h"
@@
-600,7
+607,7
@@
static void optimize_blocks(ir_node *b, void *env) {
* we will lose blocks and thereby generate memory leaks.
*/
void optimize_cf(ir_graph *irg) {
* we will lose blocks and thereby generate memory leaks.
*/
void optimize_cf(ir_graph *irg) {
- int i, n;
+ int i,
j,
n;
ir_node **in;
ir_node *end = get_irg_end(irg);
ir_graph *rem = current_ir_graph;
ir_node **in;
ir_node *end = get_irg_end(irg);
ir_graph *rem = current_ir_graph;
@@
-613,8
+620,9
@@
void optimize_cf(ir_graph *irg) {
/* Handle graph state */
assert(get_irg_phase_state(irg) != phase_building);
/* Handle graph state */
assert(get_irg_phase_state(irg) != phase_building);
- if (get_irg_outs_state(current_ir_graph) == outs_consistent)
- set_irg_outs_inconsistent(current_ir_graph);
+ set_irg_outs_inconsistent(current_ir_graph);
+ set_irg_extblk_inconsistent(current_ir_graph);
+ set_irg_loopinfo_inconsistent(current_ir_graph);
set_irg_doms_inconsistent(current_ir_graph);
if (dom_state == dom_consistent && get_opt_optimize() && get_opt_unreachable_code()) {
set_irg_doms_inconsistent(current_ir_graph);
if (dom_state == dom_consistent && get_opt_optimize() && get_opt_unreachable_code()) {
@@
-649,12
+657,13
@@
void optimize_cf(ir_graph *irg) {
/* Walk all keep alives, optimize them if block, add to new in-array
for end if useful. */
/* Walk all keep alives, optimize them if block, add to new in-array
for end if useful. */
- in = NEW_ARR_F (ir_node *, 1);
- in[0] = get_nodes_block(end);
+ n = get_End_n_keepalives(end);
+ if (n > 0)
+ NEW_ARR_A (ir_node *, in, n);
inc_irg_visited(current_ir_graph);
/* fix the keep alive */
inc_irg_visited(current_ir_graph);
/* fix the keep alive */
- for (i =
0, n = get_End_n_keepalives(end)
; i < n; i++) {
+ for (i =
j = 0
; i < n; i++) {
ir_node *ka = get_End_keepalive(end, i);
if (irn_not_visited(ka)) {
ir_node *ka = get_End_keepalive(end, i);
if (irn_not_visited(ka)) {
@@
-665,20
+674,20
@@
void optimize_cf(ir_graph *irg) {
get_irg_block_visited(current_ir_graph)-1);
irg_block_walk(ka, optimize_blocks, NULL, NULL);
mark_irn_visited(ka);
get_irg_block_visited(current_ir_graph)-1);
irg_block_walk(ka, optimize_blocks, NULL, NULL);
mark_irn_visited(ka);
-
ARR_APP1 (ir_node *, in, ka)
;
+
in[j++] = ka
;
} else if (op == op_Phi) {
mark_irn_visited(ka);
if (! is_Block_dead(get_nodes_block(ka)))
} else if (op == op_Phi) {
mark_irn_visited(ka);
if (! is_Block_dead(get_nodes_block(ka)))
-
ARR_APP1 (ir_node *, in, ka)
;
+
in[j++] = ka
;
} else if (is_op_keep(op)) {
mark_irn_visited(ka);
if (! is_Block_dead(get_nodes_block(ka)))
} else if (is_op_keep(op)) {
mark_irn_visited(ka);
if (! is_Block_dead(get_nodes_block(ka)))
-
ARR_APP1 (ir_node *, in, ka)
;
+
in[j++] = ka
;
}
}
}
}
}
}
- DEL_ARR_F(end->in);
-
end->in = in
;
+ if (j != n)
+
set_End_keepalives(end, j, in)
;
/* the verifier doesn't work yet with floating nodes */
if (get_irg_pinned(irg) == op_pin_state_pinned) {
/* the verifier doesn't work yet with floating nodes */
if (get_irg_pinned(irg) == op_pin_state_pinned) {