Hi,

This patch is to resolve missing IPA_REF_CHKP issues.  When node has 
instrumented version it usually has no body (either originally or was 
tranfromed into instrumentation thunk).  But in some cases we don't instrument 
function and instrumentation clone becomes a thunk instead.  In this case we 
still have IPA_REF_CHKP reference from the original node to its clone.  But 
several passes (e.g. inline, expand) remove all node's references causing 
IPA_REF_CHKP check in verify_node fail.  Initially I was going to always 
rebuild IPA_REF_CHKP for functions having instrumentation clones.  But later 
realized this reference is used to keep instrumentation clones reachable which 
is not required when instrumentation clone has no body (and therefore will not 
be emitted anyway).  Thus I just relaxed the check in verify_node.  
Bootstrapped and tested on x86_64-unknown-linux-gnu.  Will apply to trunk and 
later to gcc_5 if no objections appear.

Thanks,
Ilya
--
gcc/

2015-04-16  Ilya Enkovich  <ilya.enkov...@intel.com>

        * cgraph.c (cgraph_node::verify_node): Require
        IPA_CHKP_REF for instrumentation thunks only.

gcc/testsuite/

2015-04-16  Ilya Enkovich  <ilya.enkov...@intel.com>

        * gcc.target/i386/mpx/chkp-reference-1.c: New.


diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index 85531c8..cbf9cfc 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -3012,7 +3012,7 @@ cgraph_node::verify_node (void)
            ref_found = true;
          }
 
-      if (!ref_found)
+      if (!ref_found && thunk.thunk_p && thunk.add_pointer_bounds_args)
        {
          error ("Analyzed node has no reference to instrumented version");
          error_found = true;
diff --git a/gcc/testsuite/gcc.target/i386/mpx/chkp-reference-1.c 
b/gcc/testsuite/gcc.target/i386/mpx/chkp-reference-1.c
new file mode 100644
index 0000000..38b0ee2
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/mpx/chkp-reference-1.c
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fcheck-pointer-bounds -mmpx" } */
+
+#include <setjmp.h>
+
+static int
+test1 ()
+{
+  jmp_buf buf;
+  int state;
+
+  state = __builtin_setjmp (buf);
+
+  return state;
+}
+
+void test2 (int(*)());
+
+void
+test3 (void)
+{
+    test2 (test1);
+}

Reply via email to