aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2007-08-07 23:44:59 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2007-08-07 23:44:59 +0000
commit8d5a7d1f8e00bf65bce222eb81a3f9efef74a36c (patch)
tree5dedb48ab335a56b7d0176746501250ce787dd2b /gcc
parentd4fd3465b63ef4d5e4c7d0d894dc6d69e7f54103 (diff)
downloadgcc-8d5a7d1f8e00bf65bce222eb81a3f9efef74a36c.zip
gcc-8d5a7d1f8e00bf65bce222eb81a3f9efef74a36c.tar.gz
gcc-8d5a7d1f8e00bf65bce222eb81a3f9efef74a36c.tar.bz2
common.opt (finstrument-functions-exclude-function-list): New option.
./: * common.opt (finstrument-functions-exclude-function-list): New option. (finstrument-functions-exclude-file-list): New option. * opts.c (char_p): Define and DEF_VEC. (flag_instrument_functions_exclude_functions): New static variable. (flag_instrument_functions_exclude_files): New static variable. (add_instrument_functions_exclude_list): New static function. (flag_instrument_functions_exclude_p): New function. (common_handle_option): Handle new options. * flags.h (flag_instrument_functions_exclude_p): Declare. * gimplify.c (gimplify_function_tree): Call flag_instrument_functions_exclude_p. * doc/invoke.texi (Option Summary): Mention new options. (Code Gen Options): Document new options. testsuite/: * gcc.dg/instrument-1.c: New test. * gcc.dg/instrument-2.c: New test. * gcc.dg/instrument-3.c: New test. From-SVN: r127284
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog19
-rw-r--r--gcc/common.opt8
-rw-r--r--gcc/doc/invoke.texi33
-rw-r--r--gcc/flags.h4
-rw-r--r--gcc/gimplify.c3
-rw-r--r--gcc/opts.c100
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.dg/instrument-1.c7
-rw-r--r--gcc/testsuite/gcc.dg/instrument-2.c7
-rw-r--r--gcc/testsuite/gcc.dg/instrument-3.c7
10 files changed, 193 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 374c150..08d491f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,22 @@
+2007-08-07 Yaz Saito <saito@google.com>
+ Ian Lance Taylor <iant@google.com>
+
+ * common.opt (finstrument-functions-exclude-function-list): New
+ option.
+ (finstrument-functions-exclude-file-list): New option.
+ * opts.c (char_p): Define and DEF_VEC.
+ (flag_instrument_functions_exclude_functions): New static
+ variable.
+ (flag_instrument_functions_exclude_files): New static variable.
+ (add_instrument_functions_exclude_list): New static function.
+ (flag_instrument_functions_exclude_p): New function.
+ (common_handle_option): Handle new options.
+ * flags.h (flag_instrument_functions_exclude_p): Declare.
+ * gimplify.c (gimplify_function_tree): Call
+ flag_instrument_functions_exclude_p.
+ * doc/invoke.texi (Option Summary): Mention new options.
+ (Code Gen Options): Document new options.
+
2007-08-07 Ian Lance Taylor <iant@google.com>
PR rtl-optimization/32776
diff --git a/gcc/common.opt b/gcc/common.opt
index 4e59e17..6d277ea 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -575,6 +575,14 @@ finstrument-functions
Common Report Var(flag_instrument_function_entry_exit)
Instrument function entry and exit with profiling calls
+finstrument-functions-exclude-function-list=
+Common RejectNegative Joined
+-finstrument-functions-exclude-function-list=name,... Do not instrument listed functions
+
+finstrument-functions-exclude-file-list=
+Common RejectNegative Joined
+-finstrument-functions-exclude-file-list=filename,... Do not instrument functions listed in files
+
fipa-cp
Common Report Var(flag_ipa_cp) Optimization
Perform Interprocedural constant propagation
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 233dad3..57b7e73 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -810,6 +810,8 @@ See S/390 and zSeries Options.
-fnon-call-exceptions -funwind-tables @gol
-fasynchronous-unwind-tables @gol
-finhibit-size-directive -finstrument-functions @gol
+-finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{} @gol
+-finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{} @gol
-fno-common -fno-ident @gol
-fpcc-struct-return -fpic -fPIC -fpie -fPIE @gol
-fno-jump-tables @gol
@@ -14681,6 +14683,37 @@ interrupt routines, and any functions from which the profiling functions
cannot safely be called (perhaps signal handlers, if the profiling
routines generate output or allocate memory).
+@item -finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{}
+@opindex finstrument-functions-exclude-file-list
+
+Set the list of functions that are excluded from instrumentation (see
+the description of @code{-finstrument-functions}). If the file that
+contains a function definition matches with one of @var{file}, then
+that function is not instrumented. The match is done on substrings:
+if the @var{file} parameter is a substring of the file name, it is
+considered to be a match.
+
+For example,
+@code{-finstrument-functions-exclude-file-list=/bits/stl,include/sys}
+will exclude any inline function defined in files whose pathnames
+contain @code{/bits/stl} or @code{include/sys}.
+
+If, for some reason, you want to include letter @code{','} in one of
+@var{sym}, write @code{'\,'}. For example,
+@code{-finstrument-functions-exclude-file-list='\,\,tmp'}
+(note the single quote surrounding the option).
+
+@item -finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{}
+@opindex finstrument-functions-exclude-function-list
+
+This is similar to @code{-finstrument-functions-exclude-file-list},
+but this option sets the list of function names to be excluded from
+instrumentation. The function name to be matched is its user-visible
+name, such as @code{vector<int> blah(const vector<int> &)}, not the
+internal mangled name (e.g., @code{_Z4blahRSt6vectorIiSaIiEE}). The
+match is done on substrings: if the @var{sym} parameter is a substring
+of the function name, it is considered to be a match.
+
@item -fstack-check
@opindex fstack-check
Generate code to verify that you do not go beyond the boundary of the
diff --git a/gcc/flags.h b/gcc/flags.h
index 215dc27..d52d030 100644
--- a/gcc/flags.h
+++ b/gcc/flags.h
@@ -281,6 +281,10 @@ extern bool flag_speculative_prefetching_set;
#define abi_version_at_least(N) \
(flag_abi_version == 0 || flag_abi_version >= (N))
+/* Return whether the function should be excluded from
+ instrumentation. */
+extern bool flag_instrument_functions_exclude_p (tree fndecl);
+
/* True if the given mode has a NaN representation and the treatment of
NaN operands is important. Certain optimizations, such as folding
x * 0 into 0, are not correct for NaN operands, and are normally
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 5b317c7..8b77c80 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -6494,7 +6494,8 @@ gimplify_function_tree (tree fndecl)
catch the exit hook. */
/* ??? Add some way to ignore exceptions for this TFE. */
if (flag_instrument_function_entry_exit
- && ! DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (fndecl))
+ && !DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (fndecl)
+ && !flag_instrument_functions_exclude_p (fndecl))
{
tree tf, x, bind;
diff --git a/gcc/opts.c b/gcc/opts.c
index d6f0ec1..21491fa 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -353,6 +353,15 @@ static bool flag_unroll_loops_set, flag_tracer_set;
static bool flag_value_profile_transformations_set;
static bool flag_peel_loops_set, flag_branch_probabilities_set;
+/* Functions excluded from profiling. */
+
+typedef char *char_p; /* For DEF_VEC_P. */
+DEF_VEC_P(char_p);
+DEF_VEC_ALLOC_P(char_p,heap);
+
+static VEC(char_p,heap) *flag_instrument_functions_exclude_functions;
+static VEC(char_p,heap) *flag_instrument_functions_exclude_files;
+
/* Input file names. */
const char **in_fnames;
unsigned num_in_fnames;
@@ -602,6 +611,87 @@ add_input_filename (const char *filename)
in_fnames[num_in_fnames - 1] = filename;
}
+/* Add functions or file names to a vector of names to exclude from
+ instrumentation. */
+
+static void
+add_instrument_functions_exclude_list (VEC(char_p,heap) **pvec,
+ const char* arg)
+{
+ char *tmp;
+ char *r;
+ char *w;
+ char *token_start;
+
+ /* We never free this string. */
+ tmp = xstrdup (arg);
+
+ r = tmp;
+ w = tmp;
+ token_start = tmp;
+
+ while (*r != '\0')
+ {
+ if (*r == ',')
+ {
+ *w++ = '\0';
+ ++r;
+ VEC_safe_push (char_p, heap, *pvec, token_start);
+ token_start = w;
+ }
+ if (*r == '\\' && r[1] == ',')
+ {
+ *w++ = ',';
+ r += 2;
+ }
+ else
+ *w++ = *r++;
+ }
+ if (*token_start != '\0')
+ VEC_safe_push (char_p, heap, *pvec, token_start);
+}
+
+/* Return whether we should exclude FNDECL from instrumentation. */
+
+bool
+flag_instrument_functions_exclude_p (tree fndecl)
+{
+ if (VEC_length (char_p, flag_instrument_functions_exclude_functions) > 0)
+ {
+ const char *name;
+ int i;
+ char *s;
+
+ name = lang_hooks.decl_printable_name (fndecl, 0);
+ for (i = 0;
+ VEC_iterate (char_p, flag_instrument_functions_exclude_functions,
+ i, s);
+ ++i)
+ {
+ if (strstr (name, s) != NULL)
+ return true;
+ }
+ }
+
+ if (VEC_length (char_p, flag_instrument_functions_exclude_files) > 0)
+ {
+ const char *name;
+ int i;
+ char *s;
+
+ name = DECL_SOURCE_FILE (fndecl);
+ for (i = 0;
+ VEC_iterate (char_p, flag_instrument_functions_exclude_files, i, s);
+ ++i)
+ {
+ if (strstr (name, s) != NULL)
+ return true;
+ }
+ }
+
+ return false;
+}
+
/* Decode and handle the vector of command line options. LANG_MASK
contains has a single bit set representing the current
language. */
@@ -1474,6 +1564,16 @@ common_handle_option (size_t scode, const char *arg, int value,
set_param_value ("max-inline-insns-auto", value / 2);
break;
+ case OPT_finstrument_functions_exclude_function_list_:
+ add_instrument_functions_exclude_list
+ (&flag_instrument_functions_exclude_functions, arg);
+ break;
+
+ case OPT_finstrument_functions_exclude_file_list_:
+ add_instrument_functions_exclude_list
+ (&flag_instrument_functions_exclude_files, arg);
+ break;
+
case OPT_fmessage_length_:
pp_set_line_maximum_length (global_dc->printer, value);
break;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 2ed2a7a..a6f9d6e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2007-08-07 Ian Lance Taylor <iant@google.com>
+
+ * gcc.dg/instrument-1.c: New test.
+ * gcc.dg/instrument-2.c: New test.
+ * gcc.dg/instrument-3.c: New test.
+
2007-08-07 Steve Ellcey <sje@cup.hp.com>
* gfortran.dg/c_kind_params.f90: Check for stdint.h.
diff --git a/gcc/testsuite/gcc.dg/instrument-1.c b/gcc/testsuite/gcc.dg/instrument-1.c
new file mode 100644
index 0000000..1e2d8ac
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/instrument-1.c
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+/* { dg-options "-finstrument-functions" } */
+
+void fn () { }
+
+/* { dg-final { scan-assembler "__cyg_profile_func_enter" } } */
+/* { dg-final { scan-assembler "__cyg_profile_func_exit" } } */
diff --git a/gcc/testsuite/gcc.dg/instrument-2.c b/gcc/testsuite/gcc.dg/instrument-2.c
new file mode 100644
index 0000000..297a02d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/instrument-2.c
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+/* { dg-options "-finstrument-functions -finstrument-functions-exclude-function-list=fn" } */
+
+void fn () { }
+
+/* { dg-final { scan-assembler-not "__cyg_profile_func_enter" } } */
+/* { dg-final { scan-assembler-not "__cyg_profile_func_exit" } } */
diff --git a/gcc/testsuite/gcc.dg/instrument-3.c b/gcc/testsuite/gcc.dg/instrument-3.c
new file mode 100644
index 0000000..c1a9c2a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/instrument-3.c
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+/* { dg-options "-finstrument-functions -finstrument-functions-exclude-file-list=instrument-3" } */
+
+void fn () { }
+
+/* { dg-final { scan-assembler-not "__cyg_profile_func_enter" } } */
+/* { dg-final { scan-assembler-not "__cyg_profile_func_exit" } } */