This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix a -fcheck-pointer-bounds -mmpx ICE (PR target/65523)


Hi!

On the following testcase we ICE, because we don't verify we have the
ERF_RETURNS_ARG argument, on non-verified builtins that is possible.
Other uses of ERF_RETURNS_ARG seem to verify it.
Also, there was an unneeded extra gimple_call_return_flags call,
the condition has already checked that ERF_RETURNS_ARG flag is set.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

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.

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

--- gcc/tree-chkp.c.jj	2015-03-09 08:05:05.000000000 +0100
+++ gcc/tree-chkp.c	2015-03-23 14:37:52.469289930 +0100
@@ -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++)
--- gcc/testsuite/gcc.target/i386/pr65523.c.jj	2015-03-23 14:44:36.977729292 +0100
+++ gcc/testsuite/gcc.target/i386/pr65523.c	2015-03-23 14:45:17.518071777 +0100
@@ -0,0 +1,11 @@
+/* PR target/65523 */
+/* { dg-do compile } */
+/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
+
+void *memmove ();
+
+void *
+bar ()
+{
+  return memmove ();
+}

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]