re PR target/65523 (ICE: in gimple_op, at gimple.h:2270 with -fcheck-pointer-bounds...
authorJakub Jelinek <jakub@redhat.com>
Mon, 23 Mar 2015 20:03:50 +0000 (21:03 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 23 Mar 2015 20:03:50 +0000 (21:03 +0100)
PR target/65523
* tree-chkp.c (chkp_build_returned_bound): Ignore
ERF_RETURNS_ARG calls if they have fewer than needed arguments.

* gcc.target/i386/pr65523.c: New test.

From-SVN: r221606

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr65523.c [new file with mode: 0644]
gcc/tree-chkp.c

index 2df46f56d6c98f79bf78d3e1f76c3bc31e1261cf..97c0afd2063f0d60d934eb1c7352ffa1649f72f7 100644 (file)
@@ -1,3 +1,9 @@
+2015-03-23  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/65523
+       * tree-chkp.c (chkp_build_returned_bound): Ignore
+       ERF_RETURNS_ARG calls if they have fewer than needed arguments.
+
 2015-03-23  Oleg Endo  <olegendo@gcc.gnu.org>
 
        PR target/65505
index b612abc95fa50540c43591545fe112a45b0a8289..b9f8dc2774dd97f30f7ffda2495956dba31c7b84 100644 (file)
@@ -1,5 +1,8 @@
 2015-03-23  Jakub Jelinek  <jakub@redhat.com>
 
+       PR target/65523
+       * gcc.target/i386/pr65523.c: New test.
+
        PR ipa/65475
        * g++.dg/lto/pr65475_0.C: Use dg-lto-options instead of
        dg-options.
diff --git a/gcc/testsuite/gcc.target/i386/pr65523.c b/gcc/testsuite/gcc.target/i386/pr65523.c
new file mode 100644 (file)
index 0000000..5a25f50
--- /dev/null
@@ -0,0 +1,11 @@
+/* PR target/65523 */
+/* { dg-do compile } */
+/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
+
+void *memmove ();
+
+void *
+bar ()
+{
+  return memmove ();
+}
index d2df4bad0fb934999c4cfcc2bed1b5f271c620f2..977c460b60fe37c2ab43f9730ccd1fb6af05b416 100644 (file)
@@ -2153,6 +2153,7 @@ chkp_build_returned_bound (gcall *call)
   tree bounds;
   gimple stmt;
   tree fndecl = gimple_call_fndecl (call);
+  unsigned int retflags;
 
   /* To avoid fixing alloca expands in targets we handle
      it separately.  */
@@ -2196,12 +2197,11 @@ chkp_build_returned_bound (gcall *call)
     }
   /* Do not use retbnd when returned bounds are equal to some
      of passed bounds.  */
-  else if (gimple_call_return_flags (call) & ERF_RETURNS_ARG)
+  else if (((retflags = gimple_call_return_flags (call)) & ERF_RETURNS_ARG)
+          && (retflags & ERF_RETURN_ARG_MASK) < gimple_call_num_args (call))
     {
       gimple_stmt_iterator iter = gsi_for_stmt (call);
-      unsigned int retarg = 0, argno;
-      if (gimple_call_return_flags (call) & ERF_RETURNS_ARG)
-       retarg = gimple_call_return_flags (call) & ERF_RETURN_ARG_MASK;
+      unsigned int retarg = retflags & ERF_RETURN_ARG_MASK, argno;
       if (gimple_call_with_bounds_p (call))
        {
          for (argno = 0; argno < gimple_call_num_args (call); argno++)