ipa-chkp.c (chkp_maybe_create_clone): Reset cdtor flags for instrumentation thunk.
authorIlya Enkovich <ilya.enkovich@intel.com>
Mon, 6 Apr 2015 10:41:55 +0000 (10:41 +0000)
committerIlya Enkovich <ienkovich@gcc.gnu.org>
Mon, 6 Apr 2015 10:41:55 +0000 (10:41 +0000)
gcc/

* ipa-chkp.c (chkp_maybe_create_clone): Reset cdtor
flags for instrumentation thunk.
(chkp_produce_thunks): Likewise.

gcc/testsuite/

* gcc.dg/lto/chkp-ctor-merge_0.c: New.

From-SVN: r221877

gcc/ChangeLog
gcc/ipa-chkp.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/lto/chkp-ctor-merge_0.c [new file with mode: 0644]

index f9cb04c39b488a86f180252131686a6aeab751ef..847c53220b9d0512c86d924bceffea9d30a59fac 100644 (file)
@@ -1,3 +1,9 @@
+2015-04-06  Ilya Enkovich  <ilya.enkovich@intel.com>
+
+       * ipa-chkp.c (chkp_maybe_create_clone): Reset cdtor
+       flags for instrumentation thunk.
+       (chkp_produce_thunks): Likewise.
+
 2015-04-05  Martin Liska  <mliska@suse.cz>
 
        PR ipa/65665
index 3218d42330e14c647413916f705b9987f3d70e9f..03abab5641a1d01077beaf585c39833ba789ee21 100644 (file)
@@ -550,6 +550,9 @@ chkp_maybe_create_clone (tree fndecl)
              clone->thunk.thunk_p = true;
              clone->thunk.add_pointer_bounds_args = true;
              clone->create_edge (node, NULL, 0, CGRAPH_FREQ_BASE);
+             /* Thunk shouldn't be a cdtor.  */
+             DECL_STATIC_CONSTRUCTOR (clone->decl) = 0;
+             DECL_STATIC_DESTRUCTOR (clone->decl) = 0;
            }
          else
            {
@@ -714,6 +717,9 @@ chkp_produce_thunks (bool early)
                             0, CGRAPH_FREQ_BASE);
          node->create_reference (node->instrumented_version,
                               IPA_REF_CHKP, NULL);
+         /* Thunk shouldn't be a cdtor.  */
+         DECL_STATIC_CONSTRUCTOR (node->decl) = 0;
+         DECL_STATIC_DESTRUCTOR (node->decl) = 0;
        }
     }
 
index bb7d971c96eacaf2fb5f395d80090f4276746b4e..9849363b5c3327fad26d9d6e607f7c935b0d27c2 100644 (file)
@@ -1,3 +1,7 @@
+2015-04-06  Ilya Enkovich  <ilya.enkovich@intel.com>
+
+       * gcc.dg/lto/chkp-ctor-merge_0.c: New.
+
 2015-04-04  Vladimir Makarov  <vmakarov@redhat.com>
 
        PR target/65647
diff --git a/gcc/testsuite/gcc.dg/lto/chkp-ctor-merge_0.c b/gcc/testsuite/gcc.dg/lto/chkp-ctor-merge_0.c
new file mode 100644 (file)
index 0000000..ac4095b
--- /dev/null
@@ -0,0 +1,23 @@
+/* { dg-lto-do run } */
+/* { dg-require-effective-target mpx } */
+/* { dg-lto-options { { -O2 -flto -fcheck-pointer-bounds -mmpx -nodefaultlibs -lc } } } */
+
+int glob = 1;
+
+void __attribute__((constructor))
+ctor1 ()
+{
+  glob += 1;
+}
+
+
+void __attribute__((constructor))
+ctor2 ()
+{
+  glob -= 2;
+}
+
+int main (int argc, const char **argv)
+{
+  return glob;
+}