Fixed 'inline' lossage --flo
[libfirm] / ir / ir / irgopt.c
index abedb27..2112f6f 100644 (file)
@@ -434,7 +434,7 @@ dead_node_elimination(ir_graph *irg) {
   free_outs(current_ir_graph);
 
   /* @@@ so far we loose loops when copying */
-  set_irg_loop(current_ir_graph, NULL);
+  free_loop_information(current_ir_graph);
 
   if (get_opt_optimize() && get_opt_dead_node_elimination()) {
 
@@ -599,11 +599,11 @@ void inline_method(ir_node *call, ir_graph *called_graph) {
   ir_node **cf_pred;
   ir_node *ret, *phi;
   int arity, n_ret, n_exc, n_res, i, j, rem_opt, irn_arity;
-  int exc_handling; ir_node *proj;
+  int exc_handling;
   type *called_frame;
 
-  if (!get_opt_optimize() || !get_opt_inline() ||
-      (get_irg_inline_property(called_graph) == irg_inline_forbidden)) return;
+  if ( !(get_irg_inline_property(called_graph) == irg_inline_forced) && (!get_opt_optimize() || !get_opt_inline() ||
+      (get_irg_inline_property(called_graph) == irg_inline_forbidden))) return;
 
   /* --  Turn off optimizations, this can cause problems when allocating new nodes. -- */
   rem_opt = get_opt_optimize();
@@ -634,13 +634,6 @@ void inline_method(ir_node *call, ir_graph *called_graph) {
      exc_handling: 0 There is a handler.
                    1 Branches to End.
                   2 Exception handling not represented in Firm. -- */
-  exc_handling = 2;
-  for (proj = (ir_node *)get_irn_link(call); proj; proj = (ir_node *)get_irn_link(proj)) {
-    assert(get_irn_op(proj) == op_Proj);
-    if (get_Proj_proj(proj) == pn_Call_M_except) { exc_handling = 0; break;}
-    if (get_Proj_proj(proj) == pn_Call_X_except) { exc_handling = 1; }
-  }
-
   {
     ir_node *proj, *Mproj = NULL, *Xproj = NULL;
     for (proj = (ir_node *)get_irn_link(call); proj; proj = (ir_node *)get_irn_link(proj)) {
@@ -648,9 +641,9 @@ void inline_method(ir_node *call, ir_graph *called_graph) {
       if (get_Proj_proj(proj) == pn_Call_X_except) Xproj = proj;
       if (get_Proj_proj(proj) == pn_Call_M_except) Mproj = proj;
     }
-    if      (Mproj) { assert(Xproj); exc_handling = 0; }
-    else if (Xproj) {                exc_handling = 1; }
-    else            {                exc_handling = 2; }
+    if      (Mproj) { assert(Xproj); exc_handling = 0; } // Mproj
+    else if (Xproj) {                exc_handling = 1; } //!Mproj &&  Xproj
+    else            {                exc_handling = 2; } //!Mproj && !Xproj
   }
 
 
@@ -821,7 +814,7 @@ void inline_method(ir_node *call, ir_graph *called_graph) {
      Second the Call branches to End, the exception is not handled.  Just
      add all inlined exception branches to the End node.
      Third: there is no Exception edge at all. Handle as case two. */
-  if (exc_handler == 0) {
+  if (exc_handling == 0) {
     n_exc = 0;
     for (i = 0; i < arity; i++) {
       ir_node *ret;
@@ -861,7 +854,7 @@ void inline_method(ir_node *call, ir_graph *called_graph) {
     int main_end_bl_arity;
     ir_node **end_preds;
 
-    /* assert(exc_handler == 1 || no exceptions. ) */
+    /* assert(exc_handling == 1 || no exceptions. ) */
     n_exc = 0;
     for (i = 0; i < arity; i++) {
       ir_node *ret = get_irn_n(end_bl, i);
@@ -1503,7 +1496,10 @@ void place_code(ir_graph *irg) {
   if (get_irg_dom_state(irg) != dom_consistent)
     compute_doms(irg);
 
-  construct_backedges(irg);
+  if (get_irg_loopinfo_state(irg) != loopinfo_consistent) {
+    free_loop_information(irg);
+    construct_backedges(irg);
+  }
 
   /* Place all floating nodes as early as possible. This guarantees
      a legal code placement. */
@@ -1517,6 +1513,7 @@ void place_code(ir_graph *irg) {
   place_late(worklist);
 
   set_irg_outs_inconsistent(current_ir_graph);
+  set_irg_loopinfo_inconsistent(current_ir_graph);
   del_pdeq(worklist);
   current_ir_graph = rem;
 }