irgopt.c: comparison of types does not take care of compatibilities
[libfirm] / ir / ir / irgopt.c
index ca22b3a..d76ad26 100644 (file)
@@ -87,14 +87,14 @@ local_optimize_graph (ir_graph *irg) {
 /********************************************************************/
 
 /* Remeber the new node in the old node by using a field all nodes have. */
-inline void
+INLINE void
 set_new_node (ir_node *old, ir_node *new)
 {
   old->link = new;
 }
 
 /* Get this new node, before the old node is forgotton.*/
-inline ir_node *
+INLINE ir_node *
 get_new_node (ir_node * n)
 {
   return n->link;
@@ -106,7 +106,7 @@ get_new_node (ir_node * n)
    Remembering the arity is useful, as it saves a lot of pointer
    accesses.  This function is called for all Phi and Block nodes
    in a Block. */
-inline int
+INLINE int
 compute_new_arity(ir_node *b) {
   int i, res;
   int irg_v, block_v;
@@ -150,7 +150,8 @@ copy_node (ir_node *n, void *env) {
       new_arity = get_irn_arity(n);
     }
   }
-  nn = new_ir_node(current_ir_graph,
+  nn = new_ir_node(get_irn_dbg_info(n),
+                  current_ir_graph,
                   block,
                   get_irn_op(n),
                   get_irn_mode(n),
@@ -171,7 +172,7 @@ copy_node (ir_node *n, void *env) {
    Spare the Bad predecessors of Phi and Block nodes. */
 void
 copy_preds (ir_node *n, void *env) {
-  ir_node *nn, *block, *on;
+  ir_node *nn, *block;
   int i, j;
 
   nn = get_new_node(n);
@@ -236,7 +237,8 @@ copy_graph () {
 
   oe = get_irg_end(current_ir_graph);
   /* copy the end node by hand, allocate dynamic in array! */
-  ne = new_ir_node(current_ir_graph,
+  ne = new_ir_node(get_irn_dbg_info(oe),
+                  current_ir_graph,
                   NULL,
                   op_End,
                   mode_X,
@@ -326,6 +328,11 @@ copy_graph_env () {
     copy_preds(get_irg_bad(current_ir_graph), NULL);
   }
   set_irg_bad(current_ir_graph, get_new_node(get_irg_bad(current_ir_graph)));
+  if (get_irn_link(get_irg_unknown(current_ir_graph)) == NULL) {
+    copy_node(get_irg_unknown(current_ir_graph), NULL);
+    copy_preds(get_irg_unknown(current_ir_graph), NULL);
+  }
+  set_irg_unknown(current_ir_graph, get_new_node(get_irg_unknown(current_ir_graph)));
 }
 
 /* Copies all reachable nodes to a new obstack.  Removes bad inputs
@@ -406,9 +413,9 @@ void inline_method(ir_node *call, ir_graph *called_graph) {
   ir_node **res_pred;
   ir_node **cf_pred;
   ir_node *ret, *phi;
-  ir_node *cf_op, *bl;
+  ir_node *cf_op = NULL, *bl;
   int arity, n_ret, n_exc, n_res, i, j, rem_opt;
-  type *called_frame, *caller_frame;
+  type *called_frame;
 
   if (!get_optimize() || !get_opt_inline()) return;
   /** Turn off optimizations, this can cause problems when allocating new nodes. **/
@@ -424,7 +431,7 @@ void inline_method(ir_node *call, ir_graph *called_graph) {
 
   /** Check preconditions **/
   assert(get_irn_op(call) == op_Call);
-  assert(get_Call_type(call) == get_entity_type(get_irg_ent(called_graph)));
+  /* assert(get_Call_type(call) == get_entity_type(get_irg_ent(called_graph))); */
   assert(get_type_tpop(get_Call_type(call)) == type_method);
   if (called_graph == current_ir_graph) return;
 
@@ -471,14 +478,11 @@ void inline_method(ir_node *call, ir_graph *called_graph) {
 
   /* Initialize for compaction of in arrays */
   inc_irg_block_visited(current_ir_graph);
-  /*
-      set_Block_block_visited(get_irg_start_block(called_graph),
-      get_irg_block_visited(current_ir_graph) +1 +1); /* count for self edge */
 
   /*** Replicate local entities of the called_graph ***/
   /* copy the entities. */
   called_frame = get_irg_frame_type(called_graph);
-  for (i = 0; i < get_class_n_member(called_frame); i++) {
+  for (i = 0; i < get_class_n_members(called_frame); i++) {
     entity *new_ent, *old_ent;
     old_ent = get_class_member(called_frame, i);
     new_ent = copy_entity_own(old_ent, get_cur_frame_type());
@@ -517,7 +521,7 @@ void inline_method(ir_node *call, ir_graph *called_graph) {
   end_bl = get_new_node(get_irg_end_block(called_graph));
   end = get_new_node(get_irg_end(called_graph));
   arity = get_irn_arity(end_bl);    /* arity = n_exc + n_ret  */
-  n_res = get_method_n_res(get_Call_type(call));
+  n_res = get_method_n_ress(get_Call_type(call));
 
   res_pred = (ir_node **) malloc (n_res * sizeof (ir_node *));
   cf_pred = (ir_node **) malloc (arity * sizeof (ir_node *));
@@ -813,10 +817,7 @@ place_floats_early (ir_node *n)
    Start, Call and end at pinned nodes as Store, Call.  Place_early
    places all floating nodes reachable from its argument through floating
    nodes and adds all beginnings at pinned nodes to the worklist. */
-inline void place_early () {
-  int i;
-  bool del_me;
-
+INLINE void place_early () {
   assert(worklist);
   inc_irg_visited(current_ir_graph);
 
@@ -838,7 +839,7 @@ inline void place_early () {
 static ir_node *
 consumer_dom_dca (ir_node *dca, ir_node *consumer, ir_node *producer)
 {
-  ir_node *block;
+  ir_node *block = NULL;
 
   /* Compute the latest block into which we can place a node so that it is
      before consumer. */
@@ -951,7 +952,7 @@ place_floats_late (ir_node *n)
   }
 }
 
-inline void place_late() {
+INLINE void place_late() {
   assert(worklist);
   inc_irg_visited(current_ir_graph);
 
@@ -1024,7 +1025,6 @@ static void merge_blocks(ir_node *n, void *env) {
 }
 
 static void collect_nodes(ir_node *n, void *env) {
-  int i;
   if (is_no_Block(n)) {
     ir_node *b = get_nodes_Block(n);
 
@@ -1263,8 +1263,6 @@ void optimize_cf(ir_graph *irg) {
   if (get_irg_dom_state(current_ir_graph) == dom_consistent)
     set_irg_dom_inconsistent(current_ir_graph);
 
-  //DDME(get_irg_ent(irg));
-
   /* Use block visited flag to mark non-empty blocks. */
   inc_irg_block_visited(irg);
   irg_walk(end, merge_blocks, collect_nodes, NULL);
@@ -1280,7 +1278,7 @@ void optimize_cf(ir_graph *irg) {
   inc_irg_visited(current_ir_graph);
   for(i = 0; i < get_End_n_keepalives(end); i++) {
     ir_node *ka = get_End_keepalive(end, i);
-    if (irn_not_visited(ka))
+    if (irn_not_visited(ka)) {
       if ((get_irn_op(ka) == op_Block) && Block_not_block_visited(ka)) {
        set_irg_block_visited(current_ir_graph,  /* Don't walk all the way to Start. */
                              get_irg_block_visited(current_ir_graph)-1);
@@ -1292,6 +1290,7 @@ void optimize_cf(ir_graph *irg) {
        ARR_APP1 (ir_node *, in, ka);
       }
     }
+  }
   /* DEL_ARR_F(end->in);   GL @@@ tut nicht ! */
   end->in = in;