is_SubClass_of() check only once for transitive closure state
authorMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Sun, 7 Jan 2007 16:39:21 +0000 (16:39 +0000)
committerMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Sun, 7 Jan 2007 16:39:21 +0000 (16:39 +0000)
[r8494]

ir/tr/tr_inheritance.c

index b8656dd..9abc5f9 100644 (file)
@@ -471,17 +471,9 @@ ir_entity *get_entity_trans_overwrites_next (ir_entity *ent) {
 /* Classify pairs of types/entities in the inheritance relations.          */
 /* ----------------------------------------------------------------------- */
 
-/* Returns true if low is subclass of high. */
-int is_SubClass_of(ir_type *low, ir_type *high) {
+/** Returns true if low is subclass of high. */
+static int check_is_SubClass_of(ir_type *low, ir_type *high) {
   int i, n_subtypes;
-  assert(is_Class_type(low) && is_Class_type(high));
-
-  if (low == high) return 1;
-
-  if (get_irp_inh_transitive_closure_state() == inh_transitive_closure_valid) {
-    pset *m = get_type_map(high, d_down);
-    return pset_find_ptr(m, low) ? 1 : 0;
-  }
 
   /* depth first search from high downwards. */
   n_subtypes = get_class_n_subtypes(high);
@@ -494,6 +486,19 @@ int is_SubClass_of(ir_type *low, ir_type *high) {
   return 0;
 }
 
+/* Returns true if low is subclass of high. */
+int is_SubClass_of(ir_type *low, ir_type *high) {
+  assert(is_Class_type(low) && is_Class_type(high));
+
+  if (low == high) return 1;
+
+  if (get_irp_inh_transitive_closure_state() == inh_transitive_closure_valid) {
+    pset *m = get_type_map(high, d_down);
+    return pset_find_ptr(m, low) ? 1 : 0;
+  }
+  return check_is_SubClass_of(low, high);
+}
+
 
 /* Subclass check for pointers to classes.
  *