2010-09-05 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 5 Sep 2010 10:47:05 +0000 (10:47 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 5 Sep 2010 10:47:05 +0000 (10:47 +0000)
PR tree-optimization/45535
* tree-ssa-alias.c (indirect_ref_may_alias_decl_p): Properly
handle TMR_INDEX2.  Make sure TMR_INDEX is not NULL before
dereferencing it.
(indirect_refs_may_alias_p): Likewise.

* gcc.c-torture/compile/pr45535.c: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@163877 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr45535.c [new file with mode: 0644]
gcc/tree-ssa-alias.c

index ab41e8b..daef269 100644 (file)
@@ -1,3 +1,11 @@
+2010-09-05  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/45535
+       * tree-ssa-alias.c (indirect_ref_may_alias_decl_p): Properly
+       handle TMR_INDEX2.  Make sure TMR_INDEX is not NULL before
+       dereferencing it.
+       (indirect_refs_may_alias_p): Likewise.
+
 2010-09-05  Naveen H.S  <naveen.S@kpitcummins.com>
 
        * config/sh/sh.c (sh_option_override): Make static.
index bb5661b..ff909fa 100644 (file)
@@ -1,3 +1,8 @@
+2010-09-05  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/45535
+       * gcc.c-torture/compile/pr45535.c: New testcase.
+
 2010-09-04  Andreas Schwab  <schwab@linux-m68k.org>
 
        * g++.dg/debug/dwarf2/global-used-types-1.C: Replace ".*" by
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr45535.c b/gcc/testsuite/gcc.c-torture/compile/pr45535.c
new file mode 100644 (file)
index 0000000..03d15a1
--- /dev/null
@@ -0,0 +1,38 @@
+typedef struct {
+    unsigned long pmd0;
+    unsigned long pmd1;
+} pmd_t;
+typedef unsigned int pgd_t;
+struct mm_struct {
+    pgd_t * pgd;
+};
+extern inline int pmd_bad(pmd_t pmd)
+{
+}
+extern inline void pmd_clear(pmd_t * pmdp)
+{
+  ((*pmdp).pmd0) = 0x20 | 0x00;
+  ((*pmdp).pmd1) = 0x20 | 0x00;
+}
+static inline void free_one_pmd(pmd_t * dir)
+{
+  if (pmd_bad(*dir)) {
+      pmd_clear(dir);
+  }
+}
+static inline void free_one_pgd(pgd_t * dir)
+{
+  int j;
+  pmd_t * pmd;
+  pmd = ((pmd_t *) ((unsigned long) (void *)(__pgd_val(dir) & (~((1UL << 12)-1)))) + (((0) >> 21) & (512 - 1)));
+  for (j = 0; j < 512 ; j++) {
+      free_one_pmd(pmd+j);
+  }
+}
+void clear_page_tables(struct mm_struct *mm, unsigned long first, int nr)
+{
+  pgd_t * page_dir = mm->pgd;
+  do {
+      free_one_pgd(page_dir);
+  } while (--nr);
+}
index a9f1c19..e00c50a 100644 (file)
@@ -693,7 +693,8 @@ indirect_ref_may_alias_decl_p (tree ref1 ATTRIBUTE_UNUSED, tree base1,
      (the pointer base cannot validly point to an offset less than zero
      of the variable).
      They also cannot alias if the pointer may not point to the decl.  */
-  if ((TREE_CODE (base1) != TARGET_MEM_REF || !TMR_INDEX (base1))
+  if ((TREE_CODE (base1) != TARGET_MEM_REF
+       || (!TMR_INDEX (base1) && !TMR_INDEX2 (base1)))
       && !ranges_overlap_p (MAX (0, offset1p), -1, offset2p, max_size2))
     return false;
   if (!ptr_deref_may_alias_decl_p (ptr1, base2))
@@ -725,7 +726,8 @@ indirect_ref_may_alias_decl_p (tree ref1 ATTRIBUTE_UNUSED, tree base1,
      is relative to the start of the type which we ensure by
      comparing rvalue and access type and disregarding the constant
      pointer offset.  */
-  if ((TREE_CODE (base1) != TARGET_MEM_REF || !TMR_INDEX (base1))
+  if ((TREE_CODE (base1) != TARGET_MEM_REF
+       || (!TMR_INDEX (base1) && !TMR_INDEX2 (base1)))
       && (TREE_CODE (base1) != MEM_REF
          || same_type_for_tbaa (TREE_TYPE (base1), TREE_TYPE (ptrtype1)) == 1)
       && same_type_for_tbaa (TREE_TYPE (ptrtype1), TREE_TYPE (base2)) == 1)
@@ -807,16 +809,23 @@ indirect_refs_may_alias_p (tree ref1 ATTRIBUTE_UNUSED, tree base1,
   if ((!cfun || gimple_in_ssa_p (cfun))
       && operand_equal_p (ptr1, ptr2, 0)
       && (((TREE_CODE (base1) != TARGET_MEM_REF
-           || !TMR_INDEX (base1))
+           || (!TMR_INDEX (base1) && !TMR_INDEX2 (base1)))
           && (TREE_CODE (base2) != TARGET_MEM_REF
-              || !TMR_INDEX (base2)))
+              || (!TMR_INDEX (base2) && !TMR_INDEX2 (base2))))
          || (TREE_CODE (base1) == TARGET_MEM_REF
              && TREE_CODE (base2) == TARGET_MEM_REF
              && (TMR_STEP (base1) == TMR_STEP (base2)
                  || (TMR_STEP (base1) && TMR_STEP (base2)
                      && operand_equal_p (TMR_STEP (base1),
                                          TMR_STEP (base2), 0)))
-             && operand_equal_p (TMR_INDEX (base1), TMR_INDEX (base2), 0))))
+             && (TMR_INDEX (base1) == TMR_INDEX (base2)
+                 || (TMR_INDEX (base1) && TMR_INDEX (base2)
+                     && operand_equal_p (TMR_INDEX (base1),
+                                         TMR_INDEX (base2), 0)))
+             && (TMR_INDEX2 (base1) == TMR_INDEX2 (base2)
+                 || (TMR_INDEX2 (base1) && TMR_INDEX2 (base2)
+                     && operand_equal_p (TMR_INDEX2 (base1),
+                                         TMR_INDEX2 (base2), 0))))))
     {
       /* The offset embedded in MEM_REFs can be negative.  Bias them
         so that the resulting offset adjustment is positive.  */