lto-partition.c (privatize_symbol_name): Correctly privatize instrumentation clones.
authorIlya Enkovich <ilya.enkovich@intel.com>
Tue, 9 Dec 2014 08:00:52 +0000 (08:00 +0000)
committerIlya Enkovich <ienkovich@gcc.gnu.org>
Tue, 9 Dec 2014 08:00:52 +0000 (08:00 +0000)
gcc/

* lto/lto-partition.c (privatize_symbol_name): Correctly
privatize instrumentation clones.

gcc/testsuite/

* gcc.dg/lto/lto.exp: Load mpx-dg.exp.
* gcc.dg/lto/chkp-privatize_0.c: New.
* gcc.dg/lto/chkp-privatize_1.c: New.

From-SVN: r218508

gcc/ChangeLog
gcc/lto/lto-partition.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/lto/chkp-privatize_0.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/lto/chkp-privatize_1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/lto/lto.exp

index eba4f993e5f9033294ec2d177a4ba94cd17ff802..5ca94246784ac7455e37317ec60ee9432826da41 100644 (file)
@@ -1,3 +1,8 @@
+2014-12-09  Ilya Enkovich  <ilya.enkovich@intel.com>
+
+       * lto/lto-partition.c (privatize_symbol_name): Correctly
+       privatize instrumentation clones.
+
 2014-12-09  Ilya Enkovich  <ilya.enkovich@intel.com>
 
        * lto-cgraph.c (input_cgraph_1): Don't break existing
index 65f0582cf6b2df04bf0de204ff1b7cdc5700d0ab..809a4937b663d205f05c8c31cb87c0ca8659028b 100644 (file)
@@ -787,8 +787,16 @@ static bool
 privatize_symbol_name (symtab_node *node)
 {
   tree decl = node->decl;
-  const char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
-  cgraph_node *cnode;
+  cgraph_node *cnode = dyn_cast <cgraph_node *> (node);
+  const char *name;
+
+  /* If we want to privatize instrumentation clone
+     then we need to change original function name
+     which is used via transparent alias chain.  */
+  if (cnode && cnode->instrumentation_clone)
+    decl = cnode->orig_decl;
+
+  name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
 
   /* Our renaming machinery do not handle more than one change of assembler name.
      We should not need more than one anyway.  */
@@ -821,15 +829,20 @@ privatize_symbol_name (symtab_node *node)
                             (DECL_ASSEMBLER_NAME (decl)));
   /* We could change name which is a target of transparent alias
      chain of instrumented function name.  Fix alias chain if so  .*/
-  if ((cnode = dyn_cast <cgraph_node *> (node))
-      && !cnode->instrumentation_clone
-      && cnode->instrumented_version
-      && cnode->instrumented_version->orig_decl == decl)
+  if (cnode)
     {
-      tree iname = DECL_ASSEMBLER_NAME (cnode->instrumented_version->decl);
-
-      gcc_assert (IDENTIFIER_TRANSPARENT_ALIAS (iname));
-      TREE_CHAIN (iname) = DECL_ASSEMBLER_NAME (decl);
+      tree iname = NULL_TREE;
+      if (cnode->instrumentation_clone)
+       iname = DECL_ASSEMBLER_NAME (cnode->decl);
+      else if (cnode->instrumented_version
+              && cnode->instrumented_version->orig_decl == decl)
+       iname = DECL_ASSEMBLER_NAME (cnode->instrumented_version->decl);
+
+      if (iname)
+       {
+         gcc_assert (IDENTIFIER_TRANSPARENT_ALIAS (iname));
+         TREE_CHAIN (iname) = DECL_ASSEMBLER_NAME (decl);
+       }
     }
   if (symtab->dump_file)
     fprintf (symtab->dump_file,
index 1b1e7d5e95901a5db1d40f1a538aca1e2c46628f..31f740dba876673eb00a3471c03294071188a890 100644 (file)
@@ -1,3 +1,9 @@
+2014-12-09  Ilya Enkovich  <ilya.enkovich@intel.com>
+
+       * gcc.dg/lto/lto.exp: Load mpx-dg.exp.
+       * gcc.dg/lto/chkp-privatize_0.c: New.
+       * gcc.dg/lto/chkp-privatize_1.c: New.
+
 2014-12-09  Ilya Enkovich  <ilya.enkovich@intel.com>
 
        PR bootstrap/63995
diff --git a/gcc/testsuite/gcc.dg/lto/chkp-privatize_0.c b/gcc/testsuite/gcc.dg/lto/chkp-privatize_0.c
new file mode 100644 (file)
index 0000000..4c899e8
--- /dev/null
@@ -0,0 +1,18 @@
+/* { dg-lto-do link } */
+/* { dg-require-effective-target mpx { target { i?86-*-* x86_64-*-* } } } */
+/* { dg-lto-options { { -fPIC -flto -flto-partition=max -fcheck-pointer-bounds -mmpx } } } */
+
+static int
+__attribute__ ((noinline))
+func1 (int i)
+{
+  return i + 2;
+}
+
+extern int func2 (int i);
+
+int
+main (int argc, char **argv)
+{
+  return func1 (argc) + func2 (argc) + 1;
+}
diff --git a/gcc/testsuite/gcc.dg/lto/chkp-privatize_1.c b/gcc/testsuite/gcc.dg/lto/chkp-privatize_1.c
new file mode 100644 (file)
index 0000000..db39e7f
--- /dev/null
@@ -0,0 +1,8 @@
+int func1 = 10;
+
+int
+func2 (int i)
+{
+  func1++;
+  return i + func1;
+}
index 25862978bda3675fcc6b08f29c26438b134ffa85..797c02f9e6c60c22f8d68e5974291dfff6d68678 100644 (file)
@@ -30,6 +30,7 @@ if $tracelevel then {
 # Load procedures from common libraries. 
 load_lib standard.exp
 load_lib gcc.exp
+load_lib mpx-dg.exp
 
 # Load the language-independent compabibility support procedures.
 load_lib lto.exp