summaryrefslogtreecommitdiff
path: root/debian/patches/illumos-fclone-functions.diff
blob: 0c047ea1c7413e971520c9308ed7feee15998af9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
From 30f4861499309bd81f1d59b41b1091fef0152680 Mon Sep 17 00:00:00 2001
From: Richard Lowe <richlowe@richlowe.net>
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-9.git/src/gcc/common.opt
===================================================================
--- gcc-9.git.orig/src/gcc/common.opt
+++ gcc-9.git/src/gcc/common.opt
@@ -1122,6 +1122,11 @@ fcode-hoisting
 Common Report Var(flag_code_hoisting) Optimization
 Enable code hoisting.
 
+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-9.git/src/gcc/doc/invoke.texi
===================================================================
--- gcc-9.git.orig/src/gcc/doc/invoke.texi
+++ gcc-9.git/src/gcc/doc/invoke.texi
@@ -404,7 +404,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
@@ -10421,6 +10421,15 @@ effect as usage of the command wrappers
 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-9.git/src/gcc/tree-inline.c
===================================================================
--- gcc-9.git.orig/src/gcc/tree-inline.c
+++ gcc-9.git/src/gcc/tree-inline.c
@@ -5806,7 +5806,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);
 }
 
 /* Update clone info after duplication.  */