re PR middle-end/67222 (ICE in gimple_call_arg with bogus posix_memalign)
authorMarek Polacek <polacek@redhat.com>
Tue, 18 Aug 2015 13:41:27 +0000 (13:41 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Tue, 18 Aug 2015 13:41:27 +0000 (13:41 +0000)
PR middle-end/67222
* gimple-low.c (lower_stmt): Don't lower BUILT_IN_POSIX_MEMALIGN
if the call isn't valid.
* tree-ssa-alias.c (ref_maybe_used_by_call_p_1): Check builtins using
gimple_call_builtin_p.
(call_may_clobber_ref_p_1): Likewise.
(stmt_kills_ref_p): Likewise.

* gcc.dg/torture/pr67222.c: New test.

From-SVN: r226969

gcc/ChangeLog
gcc/gimple-low.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr67222.c [new file with mode: 0644]
gcc/tree-ssa-alias.c

index dcd5d4768f529caddc7bef8743134b36a29ab20b..90b78937a1f211ae696fcac9af7358ff7f222099 100644 (file)
@@ -1,3 +1,13 @@
+2015-08-18  Marek Polacek  <polacek@redhat.com>
+
+       PR middle-end/67222
+       * gimple-low.c (lower_stmt): Don't lower BUILT_IN_POSIX_MEMALIGN
+       if the call isn't valid.
+       * tree-ssa-alias.c (ref_maybe_used_by_call_p_1): Check builtins using
+       gimple_call_builtin_p.
+       (call_may_clobber_ref_p_1): Likewise.
+       (stmt_kills_ref_p): Likewise.
+
 2015-08-18  Robert Suchanek  <robert.suchanek@imgtec.com>
 
        * config/mips/mips-protos.h (mips_hard_regno_rename_ok): New prototype.
index d4697e21ac66d4842c00185a2e90b5b837b66d8d..4eae3a0994dd1a05f9549aa5d94194efa461dd64 100644 (file)
@@ -346,7 +346,8 @@ lower_stmt (gimple_stmt_iterator *gsi, struct lower_data *data)
                return;
              }
            else if (DECL_FUNCTION_CODE (decl) == BUILT_IN_POSIX_MEMALIGN
-                    && flag_tree_bit_ccp)
+                    && flag_tree_bit_ccp
+                    && gimple_builtin_call_types_compatible_p (stmt, decl))
              {
                lower_builtin_posix_memalign (gsi);
                return;
index aff223c8a1628b7da277f84e4cbcfd89373505db..97322ac25d5321e3442e894d8243cbadff0345d4 100644 (file)
@@ -1,3 +1,8 @@
+2015-08-18  Marek Polacek  <polacek@redhat.com>
+
+       PR middle-end/67222
+       * gcc.dg/torture/pr67222.c: New test.
+
 2015-08-18  Robert Suchanek  <robert.suchanek@imgtec.com>
 
        * gcc.target/mips/interrupt_handler-bug-1.c: New test.
diff --git a/gcc/testsuite/gcc.dg/torture/pr67222.c b/gcc/testsuite/gcc.dg/torture/pr67222.c
new file mode 100644 (file)
index 0000000..739f869
--- /dev/null
@@ -0,0 +1,19 @@
+/* PR middle-end/67222 */
+/* { dg-do compile } */
+
+void
+foo (void **p)
+{
+  posix_memalign (); /* { dg-warning "implicit declaration" } */
+  posix_memalign (p);
+  posix_memalign (0);
+  posix_memalign (p, 1);
+  posix_memalign (p, "foo");
+  posix_memalign ("gnu", "gcc");
+  posix_memalign (1, p);
+  posix_memalign (1, 2);
+  posix_memalign (1, 2, 3);
+  posix_memalign (p, p, p);
+  posix_memalign (p, "qui", 3);
+  posix_memalign (p, 1, 2);
+}
index e103220d807ddd33baea3fb337c3e0debfa61a76..044505268a51351d1969d1611ab37949d450d2d8 100644 (file)
@@ -1535,7 +1535,7 @@ ref_maybe_used_by_call_p_1 (gcall *call, ao_ref *ref)
      escape points.  See tree-ssa-structalias.c:find_func_aliases
      for the list of builtins we might need to handle here.  */
   if (callee != NULL_TREE
-      && DECL_BUILT_IN_CLASS (callee) == BUILT_IN_NORMAL)
+      && gimple_call_builtin_p (call, BUILT_IN_NORMAL))
     switch (DECL_FUNCTION_CODE (callee))
       {
        /* All the following functions read memory pointed to by
@@ -1941,7 +1941,7 @@ call_may_clobber_ref_p_1 (gcall *call, ao_ref *ref)
      escape points.  See tree-ssa-structalias.c:find_func_aliases
      for the list of builtins we might need to handle here.  */
   if (callee != NULL_TREE
-      && DECL_BUILT_IN_CLASS (callee) == BUILT_IN_NORMAL)
+      && gimple_call_builtin_p (call, BUILT_IN_NORMAL))
     switch (DECL_FUNCTION_CODE (callee))
       {
        /* All the following functions clobber memory pointed to by
@@ -2341,7 +2341,7 @@ stmt_kills_ref_p (gimple stmt, ao_ref *ref)
     {
       tree callee = gimple_call_fndecl (stmt);
       if (callee != NULL_TREE
-         && DECL_BUILT_IN_CLASS (callee) == BUILT_IN_NORMAL)
+         && gimple_call_builtin_p (stmt, BUILT_IN_NORMAL))
        switch (DECL_FUNCTION_CODE (callee))
          {
          case BUILT_IN_FREE: