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-6.git/src/gcc/common.opt =================================================================== --- gcc-6.git.orig/src/gcc/common.opt +++ gcc-6.git/src/gcc/common.opt @@ -1029,6 +1029,11 @@ fchecking Common Var(flag_checking) Init(CHECKING_P) Perform internal consistency checkings. +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-6.git/src/gcc/doc/invoke.texi =================================================================== --- gcc-6.git.orig/src/gcc/doc/invoke.texi +++ gcc-6.git/src/gcc/doc/invoke.texi @@ -340,7 +340,7 @@ Objective-C and Objective-C++ Dialects}. -fbranch-target-load-optimize -fbranch-target-load-optimize2 @gol -fbtr-bb-exclusive -fcaller-saves @gol -fcombine-stack-adjustments -fconserve-stack @gol --fcompare-elim -fcprop-registers -fcrossjumping @gol +-fcompare-elim -fclone-functions -fcprop-registers -fcrossjumping @gol -fcse-follow-jumps -fcse-skip-blocks -fcx-fortran-rules @gol -fcx-limited-range @gol -fdata-sections -fdce -fdelayed-branch @gol @@ -8188,6 +8188,15 @@ to these tools. With non fat LTO makefil The default is @option{-fno-fat-lto-objects} on targets with linker plugin support. +@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-6.git/src/gcc/tree-inline.c =================================================================== --- gcc-6.git.orig/src/gcc/tree-inline.c +++ gcc-6.git/src/gcc/tree-inline.c @@ -5541,7 +5541,8 @@ bool tree_versionable_function_p (tree fndecl) { return (!lookup_attribute ("noclone", DECL_ATTRIBUTES (fndecl)) - && copy_forbidden (DECL_STRUCT_FUNCTION (fndecl)) == NULL); + && (copy_forbidden (DECL_STRUCT_FUNCTION (fndecl)) == NULL) + && flag_clone_functions); } /* Delete all unreachable basic blocks and update callgraph.