aboutsummaryrefslogtreecommitdiff
path: root/clang/docs
diff options
context:
space:
mode:
authorCalixte Denizet <cdenizet@mozilla.com>2018-11-12 09:12:27 +0000
committerCalixte Denizet <cdenizet@mozilla.com>2018-11-12 09:12:27 +0000
commitcedcc73d932f7092842e0c80e1321f6ae6b0ee63 (patch)
treea16927cc001d539e96535df3ccf0d81ce1854b60 /clang/docs
parentc6fabeac11b909f2c9f05a78c820e691a5bd693c (diff)
[Clang] Add options -fprofile-filter-files and -fprofile-exclude-files to filter the files to instrument with gcov
Summary: These options are taking regex separated by colons to filter files. - if both are empty then all files are instrumented - if -fprofile-filter-files is empty then all the filenames matching any of the regex from exclude are not instrumented - if -fprofile-exclude-files is empty then all the filenames matching any of the regex from filter are instrumented - if both aren't empty then all the filenames which match any of the regex in filter and which don't match all the regex in filter are instrumented - this patch is a follow-up of https://reviews.llvm.org/D52033 Reviewers: marco-c, vsk Reviewed By: marco-c, vsk Subscribers: cfe-commits, sylvestre.ledru Differential Revision: https://reviews.llvm.org/D52034 llvm-svn: 346642
Diffstat (limited to 'clang/docs')
-rw-r--r--clang/docs/ReleaseNotes.rst6
-rw-r--r--clang/docs/UsersManual.rst49
2 files changed, 55 insertions, 0 deletions
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 09f656815d43..72b043f28d03 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -64,6 +64,12 @@ Non-comprehensive list of changes in this release
New Compiler Flags
------------------
+- ``-fprofile-filter-files=[regexes]`` and ``-fprofile-exclude-files=[regexes]``.
+
+ Clang has now options to filter or exclude some files when
+ instrumenting for gcov-based profiling.
+ See the :doc:`UsersManual` for details.
+
- ...
Deprecated Compiler Flags
diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index a7f2f8145e87..5c28517bebb0 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1871,6 +1871,55 @@ using the ``llvm-cxxmap`` and ``llvm-profdata merge`` tools.
following the Itanium C++ ABI mangling scheme. This covers all C++ targets
supported by Clang other than Windows.
+GCOV-based Profiling
+--------------------
+
+GCOV is a test coverage program, it helps to know how often a line of code
+is executed. When instrumenting the code with ``--coverage`` option, some
+counters are added for each edge linking basic blocks.
+
+At compile time, gcno files are generated containing information about
+blocks and edges between them. At runtime the counters are incremented and at
+exit the counters are dumped in gcda files.
+
+The tool ``llvm-cov gcov`` will parse gcno, gcda and source files to generate
+a report ``.c.gcov``.
+
+.. option:: -fprofile-filter-files=[regexes]
+
+ Define a list of regexes separated by a semi-colon.
+ If a file name matches any of the regexes then the file is instrumented.
+
+ .. code-block:: console
+
+ $ clang --coverage -fprofile-filter-files=".*\.c$" foo.c
+
+ For example, this will only instrument files finishing with ``.c``, skipping ``.h`` files.
+
+.. option:: -fprofile-exclude-files=[regexes]
+
+ Define a list of regexes separated by a semi-colon.
+ If a file name doesn't match all the regexes then the file is instrumented.
+
+ .. code-block:: console
+
+ $ clang --coverage -fprofile-exclude-files="^/usr/include/.*$" foo.c
+
+ For example, this will instrument all the files except the ones in ``/usr/include``.
+
+If both options are used then a file is instrumented if its name matches any
+of the regexes from ``-fprofile-filter-list`` and doesn't match all the regexes
+from ``-fprofile-exclude-list``.
+
+.. code-block:: console
+
+ $ clang --coverage -fprofile-exclude-files="^/usr/include/.*$" \
+ -fprofile-filter-files="^/usr/.*$"
+
+In that case ``/usr/foo/oof.h`` is instrumented since it matches the filter regex and
+doesn't match the exclude regex, but ``/usr/include/foo.h`` doesn't since it matches
+the exclude regex.
+
Controlling Debug Information
-----------------------------