Use SPARC_STACK_ALIGNMENT and round_up2() instead of magic numbers and calculations.
[libfirm] / ir / opt / funccall.c
index 3307833..f4cdb39 100644 (file)
@@ -71,23 +71,6 @@ static unsigned *busy_set;
  */
 #define mtp_temporary  mtp_property_inherited
 
-static bool has_compound_return_type(ir_node *node)
-{
-       ir_type *mtp   = get_Call_type(node);
-       size_t   n_res = get_method_n_ress(mtp);
-       size_t   i;
-
-       for (i = 0; i < n_res; ++i) {
-               ir_type *rtp = get_method_res_type(mtp, i);
-
-               if (is_compound_type(rtp)) {
-                       return true;
-               }
-       }
-
-       return false;
-}
-
 /**
  * Walker: Collect all calls to const and pure functions
  * to lists. Collect all Proj(Call) nodes into a Proj list.
@@ -105,16 +88,6 @@ static void collect_const_and_pure_calls(ir_node *node, void *env)
 
                /* set the link to NULL for all non-const/pure calls */
                set_irn_link(call, NULL);
-
-               /* If the backend's calling convention handles compound return types
-                * via a hidden pointer argument, it is incorrect to regard this
-                * call as a call to a const/pure function.
-                * TODO:  This might be overly conservative if the backend uses
-                *        a different calling convention, e.g., for small structs. */
-               if (has_compound_return_type(node)) {
-                       return;
-               }
-
                ptr = get_Call_ptr(call);
                if (is_Global(ptr)) {
                        ent = get_Global_entity(ptr);
@@ -270,7 +243,7 @@ static void fix_const_call_lists(ir_graph *irg, env_t *ctx)
 
        if (exc_changed) {
                /* ... including exception edges */
-               set_irg_doms_inconsistent(irg);
+               clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE);
        }
 }  /* fix_const_call_list */
 
@@ -404,7 +377,7 @@ static void fix_nothrow_call_list(ir_graph *irg, ir_node *call_list, ir_node *pr
 
        if (exc_changed) {
                /* ... including exception edges */
-               set_irg_doms_inconsistent(irg);
+               clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE);
        }
 }  /* fix_nothrow_call_list */
 
@@ -535,8 +508,23 @@ static mtp_additional_properties check_const_or_pure_function(ir_graph *irg, int
 {
        ir_node *end, *endbl;
        int j;
+       ir_entity *entity   = get_irg_entity(irg);
+       ir_type   *type     = get_entity_type(entity);
+       size_t     n_params = get_method_n_params(type);
+       size_t     i;
+       mtp_additional_properties may_be_const = mtp_property_const;
        mtp_additional_properties prop = get_irg_additional_properties(irg);
 
+       /* libfirm handles aggregate parameters by passing around pointers to
+        * stuff in memory, so if we have compound parameters we are never const */
+       for (i = 0; i < n_params; ++i) {
+               ir_type *param = get_method_param_type(type, i);
+               if (is_compound_type(param)) {
+                       prop        &= ~mtp_property_const;
+                       may_be_const = mtp_no_property;
+               }
+       }
+
        if (prop & mtp_property_const) {
                /* already marked as a const function */
                return mtp_property_const;
@@ -560,7 +548,7 @@ static mtp_additional_properties check_const_or_pure_function(ir_graph *irg, int
 
        end   = get_irg_end(irg);
        endbl = get_nodes_block(end);
-       prop  = mtp_property_const;
+       prop  = may_be_const;
 
        ir_reserve_resources(irg, IR_RESOURCE_IRN_VISITED);
        inc_irg_visited(irg);