]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
invoke.texi (-fsemantic-interposition): Document.
authorJan Hubicka <hubicka@ucw.cz>
Thu, 26 Jun 2014 18:50:24 +0000 (20:50 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Thu, 26 Jun 2014 18:50:24 +0000 (18:50 +0000)
* doc/invoke.texi (-fsemantic-interposition): Document.
* common.opt (fsemantic-interposition): New flag.
* varasm.c (decl_replaceable_p): Use it.
* gcc.dg/tree-ssa/interposition.c: New testcase.

From-SVN: r212049

gcc/ChangeLog
gcc/common.opt
gcc/doc/invoke.texi
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/interposition.c [new file with mode: 0644]
gcc/varasm.c

index 78e00e9640e7bfea094acd88dcbc007fc3efbf6a..2fecad45baab562cc0754770b85baf05d2be84cf 100644 (file)
@@ -1,3 +1,9 @@
+2014-06-26  Jan Hubicka  <hubicka@ucw.cz>
+
+       * doc/invoke.texi (-fsemantic-interposition): Document.
+       * common.opt (fsemantic-interposition): New flag.
+       * varasm.c (decl_replaceable_p): Use it.
+
 2014-06-26  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
        PR target/61542
index de13e01755cc221f95e1605af8d4874fa593eb49..d515dca5ff5a4533f363542c4e50756c1c1333f3 100644 (file)
@@ -1855,6 +1855,10 @@ fsel-sched-reschedule-pipelined
 Common Report Var(flag_sel_sched_reschedule_pipelined) Init(0) Optimization
 Reschedule pipelined regions without pipelining
 
+fsemantic-interposition
+Common Report Var(flag_semantic_interposition) Init(1)
+Allow interposing function (or variables) by ones with different semantics (or initializer) respectively by dynamic linker
+
 ; sched_stalled_insns means that insns can be moved prematurely from the queue
 ; of stalled insns into the ready list.
 fsched-stalled-insns
index bb557a2207e18217a2d2b7c40f67e3152221d1e7..4df5f8113b5358bbfbd0008b2e9f8e8ce4bef635 100644 (file)
@@ -411,6 +411,7 @@ Objective-C and Objective-C++ Dialects}.
 -fschedule-insns -fschedule-insns2 -fsection-anchors @gol
 -fselective-scheduling -fselective-scheduling2 @gol
 -fsel-sched-pipelining -fsel-sched-pipelining-outer-loops @gol
+-fsemantic-interposition @gol
 -fshrink-wrap -fsignaling-nans -fsingle-precision-constant @gol
 -fsplit-ivs-in-unroller -fsplit-wide-types -fssa-phiopt -fstack-protector @gol
 -fstack-protector-all -fstack-protector-strong -fstrict-aliasing @gol
@@ -7738,6 +7739,22 @@ This option has no effect unless one of @option{-fselective-scheduling} or
 When pipelining loops during selective scheduling, also pipeline outer loops.
 This option has no effect unless @option{-fsel-sched-pipelining} is turned on.
 
+@item -fsemantic-interposition
+@opindex fsemantic-interposition
+Some object formats, like ELF, allow interposing of symbols by dynamic linker.
+This means that for symbols exported from the DSO compiler can not perform
+inter-procedural propagation, inlining and other optimizations in anticipation
+that the function or variable in question may change. While this feature is
+useful, for example, to rewrite memory allocation functions by a debugging
+implementation, it is expensive in the terms of code quality.
+With @option{-fno-semantic-inteposition} compiler assumest that if interposition
+happens for functions the overwritting function will have
+precisely same semantics (and side effects). Similarly if interposition happens
+for variables, the constructor of the variable will be the same. The flag
+has no effect for functions explicitly declared inline, where
+interposition changing semantic is never allowed and for symbols explicitly
+declared weak.
+
 @item -fshrink-wrap
 @opindex fshrink-wrap
 Emit function prologues only before parts of the function that need it,
index b64487b500a288ad7cdfe66b44773f5beac2a51a..3d0c9ae61430ca6a11e3d8a245eda3409e094215 100644 (file)
@@ -1,3 +1,7 @@
+2014-06-26  Jan Hubicka  <hubicka@ucw.cz>
+
+       * gcc.dg/tree-ssa/interposition.c: New testcase.
+
 2014-06-26  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/56633
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/interposition.c b/gcc/testsuite/gcc.dg/tree-ssa/interposition.c
new file mode 100644 (file)
index 0000000..8c89150
--- /dev/null
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -fno-semantic-interposition -fdump-tree-optimized -fPIC" } */
+int t(void)
+{
+  return 1;
+}
+int q(void)
+{
+  return t();
+}
+/* { dg-final { scan-tree-dump-times "return 1" 2 "optimized"} } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
index 7be56f1e1eef50dbd15a6702a808ed8b6acb9004..aea5a255060202c6d4799df273be83e553dc95fd 100644 (file)
@@ -6830,6 +6830,9 @@ decl_replaceable_p (tree decl)
   gcc_assert (DECL_P (decl));
   if (!TREE_PUBLIC (decl) || DECL_COMDAT (decl))
     return false;
+  if (!flag_semantic_interposition
+      && !DECL_WEAK (decl))
+    return false;
   return !decl_binds_to_current_def_p (decl);
 }