Common Joined RejectNegative Var(profile_prefix_path)
Remove prefix from absolute path before mangling name for -fprofile-generate= and -fprofile-use=.
+fprofile-prefix-map=
+Common Joined RejectNegative Var(common_deferred_options) Defer
+-fprofile-prefix-map=<old>=<new> Map one directory name to another in GCOV coverage result.
+
fprofile-generate
Common
Enable common options for generating profile info for profile feedback directed optimizations.
#include "profile.h"
#include "diagnostic.h"
#include "varasm.h"
+#include "file-prefix-map.h"
#include "gcov-io.c"
gcov_write_unsigned (DECL_ARTIFICIAL (current_function_decl)
&& !DECL_FUNCTION_VERSIONED (current_function_decl)
&& !DECL_LAMBDA_FUNCTION_P (current_function_decl));
- gcov_write_filename (startloc.file);
+ gcov_write_filename (remap_profile_filename (startloc.file));
gcov_write_unsigned (startloc.line);
gcov_write_unsigned (startloc.column);
-fvtv-counts -fvtv-debug @gol
-finstrument-functions @gol
-finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{} @gol
--finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{}}
+-finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{}} @gol
+-fprofile-prefix-map=@var{old}=@var{new}
@item Preprocessor Options
@xref{Preprocessor Options,,Options Controlling the Preprocessor}.
option is equivalent to specifying all the individual
@option{-f*-prefix-map} options. This can be used to make reproducible
builds that are location independent. See also
-@option{-fmacro-prefix-map} and @option{-fdebug-prefix-map}.
+@option{-fmacro-prefix-map}, @option{-fdebug-prefix-map} and
+@option{-fprofile-prefix-map}.
@item -fplugin=@var{name}.so
@opindex fplugin
pointing to the base directory of the build can be used to strip the irrelevant
part of the path and keep all file names relative to the main build directory.
+@item -fprofile-prefix-map=@var{old}=@var{new}
+@opindex fprofile-prefix-map
+When compiling files residing in directory @file{@var{old}}, record
+profiling information (with @option{--coverage})
+describing them as if the files resided in
+directory @file{@var{new}} instead.
+See also @option{-ffile-prefix-map}.
+
@item -fprofile-update=@var{method}
@opindex fprofile-update
/* Linked lists of file_prefix_map structures. */
static file_prefix_map *macro_prefix_maps; /* -fmacro-prefix-map */
static file_prefix_map *debug_prefix_maps; /* -fdebug-prefix-map */
+static file_prefix_map *profile_prefix_maps; /* -fprofile-prefix-map */
/* Record a file prefix mapping for -fmacro-prefix-map. */
void
{
add_prefix_map (macro_prefix_maps, arg, "-ffile-prefix-map");
add_prefix_map (debug_prefix_maps, arg, "-ffile-prefix-map");
+ add_prefix_map (profile_prefix_maps, arg, "-ffile-prefix-map");
+}
+
+/* Record a file prefix mapping for -fprofile-prefix-map. */
+void
+add_profile_prefix_map (const char *arg)
+{
+ add_prefix_map (profile_prefix_maps, arg, "-fprofile-prefix-map");
}
/* Remap using -fmacro-prefix-map. Return the GC-allocated new name
{
return remap_filename (debug_prefix_maps, filename);
}
+
+/* Remap using -fprofile-prefix-map. Return the GC-allocated new name
+ corresponding to FILENAME or FILENAME if no remapping was performed. */
+const char *
+remap_profile_filename (const char *filename)
+{
+ return remap_filename (profile_prefix_maps, filename);
+}
void add_macro_prefix_map (const char *);
void add_debug_prefix_map (const char *);
void add_file_prefix_map (const char *);
+void add_profile_prefix_map (const char *);
const char *remap_macro_filename (const char *);
const char *remap_debug_filename (const char *);
+const char *remap_profile_filename (const char *);
#endif /* !GCC_FILE_PREFIX_MAP_H */
case OPT_fdebug_prefix_map_:
case OPT_ffile_prefix_map_:
case OPT_fmacro_prefix_map_:
+ case OPT_fprofile_prefix_map_:
continue;
default:
add_file_prefix_map (opt->arg);
break;
+ case OPT_fprofile_prefix_map_:
+ add_profile_prefix_map (opt->arg);
+ break;
+
case OPT_fdump_:
g->get_dumps ()->dump_switch_p (opt->arg);
break;
case OPT_fdebug_prefix_map_:
case OPT_ffile_prefix_map_:
+ case OPT_fprofile_prefix_map_:
/* Deferred. */
break;
case OPT_fdebug_prefix_map_:
case OPT_fmacro_prefix_map_:
case OPT_ffile_prefix_map_:
+ case OPT_fprofile_prefix_map_:
case OPT_fcompare_debug:
case OPT_fchecking:
case OPT_fchecking_:
#include "dumpfile.h"
#include "cfgloop.h"
#include "sreal.h"
+#include "file-prefix-map.h"
#include "profile.h"
static int prev_line;
bool name_differs, line_differs;
+ if (file_name != NULL)
+ file_name = remap_profile_filename (file_name);
+
location_triplet triplet;
triplet.filename = file_name;
triplet.lineno = line;