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.enkov...@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.enkov...@intel.com>

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


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;
+}

Reply via email to