Beyhan's fixes included
[libfirm] / ir / opt / tropt.c
index 4a5f481..69688e5 100644 (file)
  *
  * Perform optimizations of the type representation.
  */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
 
+#ifdef HAVE_ALLOCA_H
 #include <alloca.h>
+#endif
+
+#ifdef HAVE_MALLOC_H
+#include <malloc.h>
+#endif
 
 #include "tropt.h"
 
@@ -50,14 +59,16 @@ static type *default_gen_pointer_type_to(type *tp) {
     if (get_type_n_pointertypes_to(tp) > 0) {
       res = get_type_pointertype_to(tp, 0);
     } else {
-      res = new_type_pointer(mangle_u(get_type_ident(tp), ptr_type_suffix), tp);
+      ir_mode *mode = is_Method_type(tp) ? mode_P_code : mode_P_data;
+
+      res = new_type_pointer(mangle_u(get_type_ident(tp), ptr_type_suffix), tp, mode);
       /* Update trout for pointertypes, so we can use it in next call. */
       add_type_pointertype_to(tp, res);
     }
   } else {
     res = find_pointer_type_to_type(tp);
     if (res == firm_unknown_type)
-      res = new_type_pointer(mangle_u(get_type_ident(tp), ptr_type_suffix), tp);
+      res = new_type_pointer(mangle_u(get_type_ident(tp), ptr_type_suffix), tp, mode_P_data);
   }
 
   return res;