1 From 737d79516ecaa1ccb1ad43e25006e2129c44ff8d Mon Sep 17 00:00:00 2001
2 From: Richard Lowe <richlowe@richlowe.net>
3 Date: Sun, 30 Sep 2012 16:44:14 -0400
4 Subject: [PATCH 06/34] allow the global disabling of function cloning
6 Optimizations which clone functions to create call-specific implementations
7 which may be better optimized also dissociate these functions from their
8 symbol names in ways harmful to tracing and debugging (since there are now
9 several implementations of a single source symbol, quite possibly none of them
10 having the actual source symbol name).
12 This allows any function cloning to be disabled, and makes any such
13 optimization ineffective, and our source safe for debuggers everywhere.
15 gcc/attribs.c | 9 +++++++++
16 gcc/common.opt | 5 +++++
17 gcc/doc/invoke.texi | 10 ++++++++++
18 3 files changed, 24 insertions(+)
20 diff --git a/gcc/attribs.c b/gcc/attribs.c
21 index 7d0f4b5b7b4..2d8f34d371a 100644
24 @@ -543,6 +543,15 @@ decl_attributes (tree *node, tree attributes, int flags,
25 attributes = tree_cons (get_identifier ("no_icf"), NULL, attributes);
28 + /* If the user passed -fno-clone-functions, all functions should be treated
30 + if (TREE_CODE (*node) == FUNCTION_DECL
31 + && !flag_clone_functions)
33 + if (lookup_attribute ("noclone", attributes) == NULL)
34 + attributes = tree_cons (get_identifier ("noclone"), NULL, attributes);
37 targetm.insert_attributes (*node, &attributes);
39 /* Note that attributes on the same declaration are not necessarily
40 diff --git a/gcc/common.opt b/gcc/common.opt
41 index 561e7af9783..a2e214337f0 100644
44 @@ -1145,6 +1145,11 @@ fcode-hoisting
45 Common Report Var(flag_code_hoisting) Optimization
49 +Common Report Var(flag_clone_functions) Init(1)
50 +Allow the compiler to clone functions to facilitate certain optimizations.
53 fcombine-stack-adjustments
54 Common Report Var(flag_combine_stack_adjustments) Optimization
55 Looks for opportunities to reduce stack adjustments and stack references.
56 diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
57 index 7d863e6a083..e8ec1ae4ea4 100644
58 --- a/gcc/doc/invoke.texi
59 +++ b/gcc/doc/invoke.texi
60 @@ -461,6 +461,7 @@ Objective-C and Objective-C++ Dialects}.
61 -fassociative-math -fauto-profile -fauto-profile[=@var{path}] @gol
62 -fauto-inc-dec -fbranch-probabilities @gol
65 -fcombine-stack-adjustments -fconserve-stack @gol
66 -fcompare-elim -fcprop-registers -fcrossjumping @gol
67 -fcse-follow-jumps -fcse-skip-blocks -fcx-fortran-rules @gol
68 @@ -10134,6 +10135,15 @@ and then tries to find ways to combine them.
70 Enabled by default at @option{-O1} and higher.
72 +@item -fno-clone-functions
73 +@opindex fno-clone-functions
74 +Forbid the implicit cloning of functions implicit in certain
75 +optimizations. This also effectively will disable any optimization
76 +which wishes to clone functions, equivalent to each function having
77 +the ``noclone'' attribute. This allows the prevention of the
78 +dissociation of a piece of text from an intelligible and expected
79 +symbol name, which may hamper debugging and tracing.
83 Use caller save registers for allocation if those registers are not used by