aboutsummaryrefslogtreecommitdiff
path: root/gold/options.h
diff options
context:
space:
mode:
authorSriraman Tallam <tmsriram@google.com>2009-10-13 21:17:43 +0000
committerSriraman Tallam <tmsriram@google.com>2009-10-13 21:17:43 +0000
commit032ce4e9e37bd92e928352fca78b1eee3bb41fdd (patch)
treeca3bb0efd21ae5b265a39f8b4179c4d28d3465b2 /gold/options.h
parent55b126d49cd449155a9057c7212d0b2e74bab465 (diff)
downloadgdb-032ce4e9e37bd92e928352fca78b1eee3bb41fdd.zip
gdb-032ce4e9e37bd92e928352fca78b1eee3bb41fdd.tar.gz
gdb-032ce4e9e37bd92e928352fca78b1eee3bb41fdd.tar.bz2
* gc.h (gc_process_relocs): Check if icf is enabled using new
function. * gold.cc (queue_initial_tasks): Likewise. (queue_middle_tasks): Likewise. * object.cc (do_layout): Likewise. * symtab.cc (is_section_folded): Likewise. * main.cc (main): Likewise. * reloc.cc (Read_relocs::run): Likewise. (Sized_relobj::do_scan_relocs): Likewise. * icf.cc (is_function_ctor_or_dtor): New function. (Icf::find_identical_sections): Check if function is ctor or dtor when safe icf is chosen. * options.h (General_options::icf): Change option to be an enum. (Icf_status): New enum. (icf_enabled): New method. (icf_safe_folding): New method. (set_icf_status): New method. (icf_status_): New variable. * (options.cc) (General_options::finalize): Set icf_status_. * testsuite/Makefile.am: Add commands to build icf_safe_test. Modify icf_test and icf_keep_unique_test to use the --icf enum flag. * testsuite/icf_safe_test.sh: New file. * testsuite/icf_safe_test.cc: New file.
Diffstat (limited to 'gold/options.h')
-rw-r--r--gold/options.h32
1 files changed, 29 insertions, 3 deletions
diff --git a/gold/options.h b/gold/options.h
index 848e648..f14582e 100644
--- a/gold/options.h
+++ b/gold/options.h
@@ -836,9 +836,11 @@ class General_options
DEFINE_special(static, options::ONE_DASH, '\0',
N_("Do not link against shared libraries"), NULL);
- DEFINE_bool(icf, options::TWO_DASHES, '\0', false,
- N_("Identical Code Folding (Fold identical functions)"),
- N_("Don't fold identical functions (default)"));
+ DEFINE_enum(icf, options::TWO_DASHES, '\0', "none",
+ N_("Identical Code Folding. "
+ "\'--icf=safe\' folds only ctors and dtors."),
+ ("[none,all,safe]"),
+ {"none", "all", "safe"});
DEFINE_uint(icf_iterations, options::TWO_DASHES , '\0', 0,
N_("Number of iterations of ICF (default 2)"), N_("COUNT"));
@@ -1065,6 +1067,14 @@ class General_options
is_stack_executable() const
{ return this->execstack_status_ == EXECSTACK_YES; }
+ bool
+ icf_enabled() const
+ { return this->icf_status_ != ICF_NONE; }
+
+ bool
+ icf_safe_folding() const
+ { return this->icf_status_ == ICF_SAFE; }
+
// The --demangle option takes an optional string, and there is also
// a --no-demangle option. This is the best way to decide whether
// to demangle or not.
@@ -1115,6 +1125,20 @@ class General_options
EXECSTACK_NO
};
+ enum Icf_status
+ {
+ // Do not fold any functions (Default or --icf=none).
+ ICF_NONE,
+ // All functions are candidates for folding. (--icf=all).
+ ICF_ALL,
+ // Only ctors and dtors are candidates for folding. (--icf=safe).
+ ICF_SAFE
+ };
+
+ void
+ set_icf_status(Icf_status value)
+ { this->icf_status_ = value; }
+
void
set_execstack_status(Execstack value)
{ this->execstack_status_ = value; }
@@ -1148,6 +1172,8 @@ class General_options
bool printed_version_;
// Whether to mark the stack as executable.
Execstack execstack_status_;
+ // Whether to do code folding.
+ Icf_status icf_status_;
// Whether to do a static link.
bool static_;
// Whether to do demangling.