1 From b6cbdbd62e15411f79d7b0df3bd080deb4000ae2 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: 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 ebc0783c439..6c754caa9f9 100644
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 6dfce7eb42d..f00008e02f3 100644
44 @@ -1153,6 +1153,11 @@ fcode-hoisting
45 Common Var(flag_code_hoisting) Optimization
49 +Common Var(flag_clone_functions) Init(1)
50 +Allow the compiler to clone functions to facilitate certain optimizations.
53 fcombine-stack-adjustments
54 Common 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 7cb80dc7346..4f265aeead0 100644
58 --- a/gcc/doc/invoke.texi
59 +++ b/gcc/doc/invoke.texi
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 @@ -11129,6 +11130,15 @@
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