From 30f4861499309bd81f1d59b41b1091fef0152680 Mon Sep 17 00:00:00 2001 From: Richard Lowe Date: Sun, 30 Sep 2012 16:44:14 -0400 Subject: [PATCH] allow the global disabling of function cloning Optimizations which clone functions to create call-specific implementations which may be better optimized also dissociate these functions from their symbol names in ways harmful to tracing and debugging (since there are now several implementations of a single source symbol, quite possibly none of them having the actual source symbol name). This allows any function cloning to be disabled, and makes any such optimization ineffective, and our source safe for debuggers everywhere. See http://wiki.illumos.org/display/illumos/GCC+Modifications --- gcc/common.opt | 5 +++++ gcc/doc/invoke.texi | 11 ++++++++++- gcc/tree-inline.c | 3 ++- 3 files changed, 17 insertions(+), 2 deletions(-) Index: gcc-47/src/gcc/common.opt =================================================================== --- gcc-47.orig/src/gcc/common.opt 2013-05-20 00:23:15.808770926 +0400 +++ gcc-47/src/gcc/common.opt 2013-05-20 00:23:56.300085656 +0400 @@ -895,6 +895,11 @@ Common Report Var(flag_check_data_deps) Compare the results of several data dependence analyzers. +fclone-functions +Common Report Var(flag_clone_functions) Init(1) +Allow the compiler to clone functions to facilitate certain optimizations. +Enabled by default. + fcombine-stack-adjustments Common Report Var(flag_combine_stack_adjustments) Optimization Looks for opportunities to reduce stack adjustments and stack references. Index: gcc-47/src/gcc/doc/invoke.texi =================================================================== --- gcc-47.orig/src/gcc/doc/invoke.texi 2013-05-20 00:23:16.044530059 +0400 +++ gcc-47/src/gcc/doc/invoke.texi 2013-05-20 00:23:56.299879610 +0400 @@ -352,7 +352,7 @@ -falign-labels[=@var{n}] -falign-loops[=@var{n}] -fassociative-math @gol -fauto-inc-dec -fbranch-probabilities -fbranch-target-load-optimize @gol -fbranch-target-load-optimize2 -fbtr-bb-exclusive -fcaller-saves @gol --fcheck-data-deps -fcombine-stack-adjustments -fconserve-stack @gol +-fcheck-data-deps -fclone-functions -fcombine-stack-adjustments -fconserve-stack @gol -fcompare-elim -fcprop-registers -fcrossjumping @gol -fcse-follow-jumps -fcse-skip-blocks -fcx-fortran-rules @gol -fcx-limited-range @gol @@ -8030,6 +8030,15 @@ change in future releases when linker plugin enabled environments become more common. +@item -fno-clone-functions +@opindex fno-clone-functions +Forbid the implicit cloning of functions implicit in certain +optimizations. This also effectively will disable any optimization +which wishes to clone functions, equivalent to each function having +the ``noclone'' attribute. This allows the prevention of the +dissociation of a piece of text from an intelligible and expected +symbol name, which may hamper debugging and tracing. + @item -fcompare-elim @opindex fcompare-elim After register allocation and post-register allocation instruction splitting, Index: gcc-47/src/gcc/tree-inline.c =================================================================== --- gcc-47.orig/src/gcc/tree-inline.c 2013-04-02 16:25:00.000000000 +0400 +++ gcc-47/src/gcc/tree-inline.c 2013-05-20 00:23:20.356097199 +0400 @@ -4953,7 +4953,8 @@ tree_versionable_function_p (tree fndecl) { return (!lookup_attribute ("noclone", DECL_ATTRIBUTES (fndecl)) - && copy_forbidden (DECL_STRUCT_FUNCTION (fndecl), fndecl) == NULL); + && (copy_forbidden (DECL_STRUCT_FUNCTION (fndecl), fndecl) == NULL) + && flag_clone_functions); } /* Delete all unreachable basic blocks and update callgraph.