public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix a -fcheck-pointer-bounds -mmpx ICE (PR target/65523)
@ 2015-03-23 19:55 Jakub Jelinek
  2015-03-23 20:01 ` Richard Biener
  0 siblings, 1 reply; 3+ messages in thread
From: Jakub Jelinek @ 2015-03-23 19:55 UTC (permalink / raw)
  To: Richard Biener, Ilya Enkovich; +Cc: gcc-patches

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix a -fcheck-pointer-bounds -mmpx ICE (PR target/65523)
  2015-03-23 19:55 [PATCH] Fix a -fcheck-pointer-bounds -mmpx ICE (PR target/65523) Jakub Jelinek
@ 2015-03-23 20:01 ` Richard Biener
  2015-04-23 18:12   ` H.J. Lu
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Biener @ 2015-03-23 20:01 UTC (permalink / raw)
  To: Jakub Jelinek, Ilya Enkovich; +Cc: gcc-patches

On March 23, 2015 8:54:54 PM GMT+01:00, Jakub Jelinek <jakub@redhat.com> wrote:
>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?

OK.

Thanks,
Richard.

>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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix a -fcheck-pointer-bounds -mmpx ICE (PR target/65523)
  2015-03-23 20:01 ` Richard Biener
@ 2015-04-23 18:12   ` H.J. Lu
  0 siblings, 0 replies; 3+ messages in thread
From: H.J. Lu @ 2015-04-23 18:12 UTC (permalink / raw)
  To: Richard Biener; +Cc: Jakub Jelinek, Ilya Enkovich, GCC Patches

On Mon, Mar 23, 2015 at 1:01 PM, Richard Biener <rguenther@suse.de> wrote:
> On March 23, 2015 8:54:54 PM GMT+01:00, Jakub Jelinek <jakub@redhat.com> wrote:
>>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?
>
> OK.
>
> Thanks,
> Richard.
>
>>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.
>>

MPX doesn't support x32.  I checked in this patch to skip it
for x32.

-- 
H.J.
---
Index: ChangeLog
===================================================================
--- ChangeLog (revision 222381)
+++ ChangeLog (working copy)
@@ -1,3 +1,7 @@
+2015-04-23  H.J. Lu  <hongjiu.lu@intel.com>
+
+ * gcc.target/i386/pr65523.c: Skip x32.
+
 2015-04-23  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

  * gcc.target/arm/neon/pr51534.c: Update vcg* scan-assembly patterns
Index: gcc.target/i386/pr65523.c
===================================================================
--- gcc.target/i386/pr65523.c (revision 222381)
+++ gcc.target/i386/pr65523.c (working copy)
@@ -1,5 +1,5 @@
 /* PR target/65523 */
-/* { dg-do compile } */
+/* { dg-do compile { target { ! x32 } } } */
 /* { dg-options "-fcheck-pointer-bounds -mmpx" } */

 void *memmove ();

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-04-23 18:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-23 19:55 [PATCH] Fix a -fcheck-pointer-bounds -mmpx ICE (PR target/65523) Jakub Jelinek
2015-03-23 20:01 ` Richard Biener
2015-04-23 18:12   ` H.J. Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).