diff mbox

[i386,PR,target/66048] Fix mode switching ICE for functions returning bounds

Message ID 20150512100742.GA47912@msticlxl57.ims.intel.com
State New
Headers show

Commit Message

Ilya Enkovich May 12, 2015, 10:07 a.m. UTC
Hi,

This patch moves up use insns for returned bounds and also marks bnd1 register as holding return value.  This fixes problem in create_pre_exit for functions with no returned bounds initialization.  Bootstrapped and regtested for x86_64-unknown-linux-gnu.  Is it OK for trunk/gcc-5?

Thanks,
Ilya
--
gcc/

2015-05-12  Ilya Enkovich  <ilya.enkovich@intel.com>

	* function.c (diddle_return_value_1): Process bounds first.
	* config/i38/i386.c (ix86_function_value_regno_p): Add bnd1
	register.

gcc/testsuite/

2015-05-12  Ilya Enkovich  <ilya.enkovich@intel.com>

	* gcc.target/i386/mpx/pr66048.cc: New.

Comments

Uros Bizjak May 12, 2015, 10:40 a.m. UTC | #1
On Tue, May 12, 2015 at 12:07 PM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:

> This patch moves up use insns for returned bounds and also marks bnd1 register as holding return value.  This fixes problem in create_pre_exit for functions with no returned bounds initialization.  Bootstrapped and regtested for x86_64-unknown-linux-gnu.  Is it OK for trunk/gcc-5?
>
> 2015-05-12  Ilya Enkovich  <ilya.enkovich@intel.com>
>
>         * function.c (diddle_return_value_1): Process bounds first.
>         * config/i38/i386.c (ix86_function_value_regno_p): Add bnd1
>         register.
>
> gcc/testsuite/
>
> 2015-05-12  Ilya Enkovich  <ilya.enkovich@intel.com>
>
>         * gcc.target/i386/mpx/pr66048.cc: New.

x86 part is OK.

Thanks,
Uros.
Jeff Law May 12, 2015, 8:03 p.m. UTC | #2
On 05/12/2015 04:07 AM, Ilya Enkovich wrote:
> Hi,
>
> This patch moves up use insns for returned bounds and also marks bnd1 register as holding return value.  This fixes problem in create_pre_exit for functions with no returned bounds initialization.  Bootstrapped and regtested for x86_64-unknown-linux-gnu.  Is it OK for trunk/gcc-5?
>
> Thanks,
> Ilya
> --
> gcc/
>
> 2015-05-12  Ilya Enkovich  <ilya.enkovich@intel.com>
>
> 	* function.c (diddle_return_value_1): Process bounds first.
> 	* config/i38/i386.c (ix86_function_value_regno_p): Add bnd1
> 	register.
>
> gcc/testsuite/
>
> 2015-05-12  Ilya Enkovich  <ilya.enkovich@intel.com>
>
> 	* gcc.target/i386/mpx/pr66048.cc: New.
OK for the trunk.  Release managers have the final say on the branches, 
but looks pretty safe to me.

jeff
diff mbox

Patch

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 7bd9ff3..869e064 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -8187,7 +8187,8 @@  ix86_function_value_regno_p (const unsigned int regno)
     case SI_REG:
       return TARGET_64BIT && ix86_abi != MS_ABI;
 
-    case FIRST_BND_REG:
+    case BND0_REG:
+    case BND1_REG:
       return chkp_function_instrumented_p (current_function_decl);
 
       /* Complex values are returned in %st(0)/%st(1) pair.  */
diff --git a/gcc/function.c b/gcc/function.c
index 4f4c461..c81ee4c 100644
--- a/gcc/function.c
+++ b/gcc/function.c
@@ -5224,8 +5224,8 @@  diddle_return_value_1 (void (*doit) (rtx, void *), void *arg, rtx outgoing)
 void
 diddle_return_value (void (*doit) (rtx, void *), void *arg)
 {
-  diddle_return_value_1 (doit, arg, crtl->return_rtx);
   diddle_return_value_1 (doit, arg, crtl->return_bnd);
+  diddle_return_value_1 (doit, arg, crtl->return_rtx);
 }
 
 static void
diff --git a/gcc/testsuite/gcc.target/i386/mpx/pr66048.cc b/gcc/testsuite/gcc.target/i386/mpx/pr66048.cc
new file mode 100644
index 0000000..b29cd03
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/mpx/pr66048.cc
@@ -0,0 +1,16 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -fcheck-pointer-bounds -mmpx -march=corei7-avx" } */
+
+struct c1
+{
+  c1 (const c1 &other) : p (other.p) { };
+  int *p;
+};
+
+struct c2 : public c1 { };
+
+c1
+test (c2 a)
+{
+  return a;
+}