]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/24665 (internal compiler error: get_indirect_ref_operands)
authorRichard Henderson <rth@redhat.com>
Sun, 20 Nov 2005 05:37:08 +0000 (21:37 -0800)
committerRichard Henderson <rth@gcc.gnu.org>
Sun, 20 Nov 2005 05:37:08 +0000 (21:37 -0800)
        PR tree-opt/24665
        * tree-gimple.c (is_gimple_id): Export.
        * tree-gimple.h (is_gimple_id): Declare.
        * tree-ssa-ccp.c (ccp_decl_initial_min_invariant): New.
        (get_default_value): Use it.
        (maybe_fold_stmt_indirect): Likewise.

From-SVN: r107244

gcc/ChangeLog
gcc/testsuite/g++.dg/opt/pr24665.C [new file with mode: 0644]
gcc/tree-gimple.c
gcc/tree-gimple.h
gcc/tree-ssa-ccp.c

index 7cc52812c117fff59beb3ec1de74d80d7aa835ad..991b8838c9c7394a46e048a653f2204affa87a41 100644 (file)
@@ -1,3 +1,12 @@
+2005-11-19  Richard Henderson  <rth@redhat.com>
+
+       PR tree-opt/24665
+       * tree-gimple.c (is_gimple_id): Export.
+       * tree-gimple.h (is_gimple_id): Declare.
+       * tree-ssa-ccp.c (ccp_decl_initial_min_invariant): New.
+       (get_default_value): Use it.
+       (maybe_fold_stmt_indirect): Likewise.
+
 2005-11-19  James A. Morrison  <phython@gcc.gnu.org>
 
         * tree-vrp.c (compare_ranges): Return false for EQ_EXPR if VR0 is less
diff --git a/gcc/testsuite/g++.dg/opt/pr24665.C b/gcc/testsuite/g++.dg/opt/pr24665.C
new file mode 100644 (file)
index 0000000..646642c
--- /dev/null
@@ -0,0 +1,29 @@
+// { dg-do compile }
+// { dg-options "-O2" }
+
+typedef unsigned long T;
+typedef volatile T* const hwreg_t;
+struct RegisterLayout
+{
+    T intmask;
+};
+struct Controller_t
+{
+    Controller_t();
+    inline void
+    disableInterrupt()
+    {
+        *mpMaskRegister = 0;
+    };
+    static hwreg_t mpMaskRegister;
+};
+
+extern char SimulatedRegisters[];
+
+hwreg_t Controller_t::mpMaskRegister
+  = &(reinterpret_cast<volatile RegisterLayout*>(SimulatedRegisters))->intmask;
+
+Controller_t::Controller_t()
+{
+    disableInterrupt();
+}
index 284f577711cfac04dea19e24b61adb50d6ee04ad..82bbf7acea418be0a5133c776be5cba4f1205717 100644 (file)
@@ -35,8 +35,6 @@ Boston, MA 02110-1301, USA.  */
 
 /* For the definitive definition of GIMPLE, see doc/tree-ssa.texi.  */
 
-static inline bool is_gimple_id (tree);
-
 /* Validation of GIMPLE expressions.  */
 
 /* Return true if T is a GIMPLE RHS for an assignment to a temporary.  */
@@ -244,7 +242,7 @@ is_gimple_variable (tree t)
 
 /*  Return true if T is a GIMPLE identifier (something with an address).  */
 
-static inline bool
+bool
 is_gimple_id (tree t)
 {
   return (is_gimple_variable (t)
index 5f7724b01b300d2cff0c95257352aa1ead6b4906..83c17fbad7a0e17c48ae9c3240536588f55c9f99 100644 (file)
@@ -53,6 +53,8 @@ extern bool is_gimple_formal_tmp_var (tree);
 extern bool is_gimple_formal_tmp_reg (tree);
 /* Returns true iff T is any sort of variable.  */
 extern bool is_gimple_variable (tree);
+/* Returns true iff T is any sort of symbol.  */
+extern bool is_gimple_id (tree);
 /* Returns true iff T is a variable or an INDIRECT_REF (of a variable).  */
 extern bool is_gimple_min_lval (tree);
 /* Returns true iff T is something whose address can be taken.  */
index e9e1c0b9e42e5ab62c11455a2990a13b7af46904..cd446ee63e0fa23d69bd761a10a7a1e048c74f8c 100644 (file)
@@ -273,6 +273,32 @@ debug_lattice_value (prop_value_t val)
 }
 
 
+/* The regular is_gimple_min_invariant does a shallow test of the object.
+   It assumes that full gimplification has happened, or will happen on the
+   object.  For a value coming from DECL_INITIAL, this is not true, so we
+   have to be more strict outselves.  */
+
+static bool
+ccp_decl_initial_min_invariant (tree t)
+{
+  if (!is_gimple_min_invariant (t))
+    return false;
+  if (TREE_CODE (t) == ADDR_EXPR)
+    {
+      /* Inline and unroll is_gimple_addressable.  */
+      while (1)
+       {
+         t = TREE_OPERAND (t, 0);
+         if (is_gimple_id (t))
+           return true;
+         if (!handled_component_p (t))
+           return false;
+       }
+    }
+  return true;
+}
+
+
 /* Compute a default value for variable VAR and store it in the
    CONST_VAL array.  The following rules are used to get default
    values:
@@ -317,7 +343,7 @@ get_default_value (tree var)
   else if (TREE_STATIC (sym)
           && TREE_READONLY (sym)
           && DECL_INITIAL (sym)
-          && is_gimple_min_invariant (DECL_INITIAL (sym)))
+          && ccp_decl_initial_min_invariant (DECL_INITIAL (sym)))
     {
       /* Globals and static variables declared 'const' take their
         initial value.  */
@@ -1712,7 +1738,7 @@ maybe_fold_stmt_indirect (tree expr, tree base, tree offset)
 
       /* Fold away CONST_DECL to its value, if the type is scalar.  */
       if (TREE_CODE (base) == CONST_DECL
-         && is_gimple_min_invariant (DECL_INITIAL (base)))
+         && ccp_decl_initial_min_invariant (DECL_INITIAL (base)))
        return DECL_INITIAL (base);
 
       /* Try folding *(&B+O) to B[X].  */