[r27015]
[libfirm] / ir / lower / lower_calls.c
index 6f71e0f..7f15ee5 100644 (file)
@@ -48,7 +48,7 @@ static pmap *type_map;
  * Default implementation for finding a pointer type for a given element type.
  * Simple create a new one.
  */
-static ir_type *def_find_pointer_type(ir_type *e_type, int alignment)
+static ir_type *def_find_pointer_type(ir_type *e_type, ir_mode *mode, int alignment)
 {
        ir_type *res;
        pmap_entry *e;
@@ -56,10 +56,11 @@ static ir_type *def_find_pointer_type(ir_type *e_type, int alignment)
        /* Mode and alignment are always identical in all calls to def_find_pointer_type(), so
           we simply can use a map from the element type to the pointer type. */
        e = pmap_find(type_map, e_type);
-       if (e)
+       if (e && get_type_mode(e->value) == mode)
                res = e->value;
        else {
                res = new_type_pointer(e_type);
+               set_type_mode(res, mode);
                set_type_alignment_bytes(res, alignment);
                pmap_insert(type_map, e_type, res);
        }
@@ -129,7 +130,7 @@ static ir_type *create_modified_mtd_type(const lower_params_t *lp, ir_type *mtp)
                                else {
                                        /* this compound will be allocated on callers stack and its
                                           address will be transmitted as a hidden parameter. */
-                                       ptr_tp = lp->find_pointer_type(res_tp, lp->def_ptr_alignment);
+                                       ptr_tp = lp->find_pointer_type(res_tp, get_modeP_data(), lp->def_ptr_alignment);
                                        params[nn_params]    = ptr_tp;
                                        param_map[nn_params] = -1 - i;
                                        ++nn_params;
@@ -164,7 +165,7 @@ static ir_type *create_modified_mtd_type(const lower_params_t *lp, ir_type *mtp)
                        res_tp = get_method_res_type(mtp, i);
 
                        if (is_compound_type(res_tp)) {
-                               params[nn_params] = lp->find_pointer_type(res_tp, lp->def_ptr_alignment);
+                               params[nn_params] = lp->find_pointer_type(res_tp, get_modeP_data(), lp->def_ptr_alignment);
                                param_map[nn_params] = -1 - i;
                                ++nn_params;
                        } else {