[llvm-branch-commits] [llvm] 60bba0f - [llvm-cov] Create syntax to pass source w/o binary.
Tom Stellard via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Sun Mar 5 23:17:32 PST 2023
Author: Daniel Thornburgh
Date: 2023-03-04T00:00:29-08:00
New Revision: 60bba0f5a777623d1af4d5becc60f63ce139bae7
URL: https://github.com/llvm/llvm-project/commit/60bba0f5a777623d1af4d5becc60f63ce139bae7
DIFF: https://github.com/llvm/llvm-project/commit/60bba0f5a777623d1af4d5becc60f63ce139bae7.diff
LOG: [llvm-cov] Create syntax to pass source w/o binary.
Since binary ID lookup makes CLI object arguments optional, it should be
possible to pass a list of source files without a binary. Unfortunately,
the current syntax will always interpret the first source file as a
binary. This change adds a `-sources` option to cause all later
positional arguments to be considered sources.
Reviewed By: gulfem
Differential Revision: https://reviews.llvm.org/D144207
(cherry picked from commit 8007bcc13f8f5f5c352a24e122b7090494a62bfb)
Added:
Modified:
compiler-rt/test/profile/Linux/binary-id-lookup.c
llvm/docs/CommandGuide/llvm-cov.rst
llvm/tools/llvm-cov/CodeCoverage.cpp
Removed:
################################################################################
diff --git a/compiler-rt/test/profile/Linux/binary-id-lookup.c b/compiler-rt/test/profile/Linux/binary-id-lookup.c
index 9cc6648903e1d..662fdcfb32a39 100644
--- a/compiler-rt/test/profile/Linux/binary-id-lookup.c
+++ b/compiler-rt/test/profile/Linux/binary-id-lookup.c
@@ -9,6 +9,9 @@
// RUN: cp %t.main %t/.build-id/ab/cd1234.debug
// RUN: llvm-profdata merge -o %t.profdata %t.profdir/default_*.profraw
// RUN: llvm-cov show -instr-profile %t.profdata -debug-file-directory %t | FileCheck %s
+// RUN: llvm-cov show -instr-profile %t.profdata %t/libfoo.so -sources %t/foo.c -object %t.main | FileCheck %s --check-prefix=FOO-ONLY
+// RUN: llvm-cov show -instr-profile %t.profdata -debug-file-directory %t -sources %t/foo.c | FileCheck %s --check-prefix=FOO-ONLY
+// RUN: llvm-cov show -instr-profile %t.profdata -debug-file-directory %t %t/libfoo.so -sources %t/foo.c | FileCheck %s --check-prefix=FOO-ONLY
// RUN: echo "bad" > %t/.build-id/ab/cd1234.debug
// RUN: llvm-cov show -instr-profile %t.profdata -debug-file-directory %t %t.main | FileCheck %s
// RUN: not llvm-cov show -instr-profile %t.profdata -debug-file-directory %t/empty 2>&1 | FileCheck %s --check-prefix=NODATA
@@ -17,6 +20,7 @@
// CHECK: 2| 1|void bar(void) {}
// CHECK: 3| 1|int main() {
+// FOO-ONLY: 1| 1|void foo(void) {}
// NODATA: error: Failed to load coverage: '': No coverage data found
//--- foo.c
diff --git a/llvm/docs/CommandGuide/llvm-cov.rst b/llvm/docs/CommandGuide/llvm-cov.rst
index 495faa7201e18..ecbb0d2a2ec57 100644
--- a/llvm/docs/CommandGuide/llvm-cov.rst
+++ b/llvm/docs/CommandGuide/llvm-cov.rst
@@ -188,14 +188,14 @@ SHOW COMMAND
SYNOPSIS
^^^^^^^^
-:program:`llvm-cov show` [*options*] -instr-profile *PROFILE* *BIN* [*-object BIN,...*] [[*-object BIN*]] [*SOURCES*]
+:program:`llvm-cov show` [*options*] -instr-profile *PROFILE* [*BIN*] [*-object BIN*]... [*-sources*] [*SOURCE*]...
DESCRIPTION
^^^^^^^^^^^
The :program:`llvm-cov show` command shows line by line coverage of the
-binaries *BIN*,... using the profile data *PROFILE*. It can optionally be
-filtered to only show the coverage for the files listed in *SOURCES*.
+binaries *BIN*... using the profile data *PROFILE*. It can optionally be
+filtered to only show the coverage for the files listed in *SOURCE*....
*BIN* may be an executable, object file, dynamic library, or archive (thin or
otherwise).
@@ -370,14 +370,14 @@ REPORT COMMAND
SYNOPSIS
^^^^^^^^
-:program:`llvm-cov report` [*options*] -instr-profile *PROFILE* *BIN* [*-object BIN,...*] [[*-object BIN*]] [*SOURCES*]
+:program:`llvm-cov report` [*options*] -instr-profile *PROFILE* [*BIN*] [*-object BIN*]... [*-sources*] [*SOURCE*]...
DESCRIPTION
^^^^^^^^^^^
The :program:`llvm-cov report` command displays a summary of the coverage of
-the binaries *BIN*,... using the profile data *PROFILE*. It can optionally be
-filtered to only show the coverage for the files listed in *SOURCES*.
+the binaries *BIN*... using the profile data *PROFILE*. It can optionally be
+filtered to only show the coverage for the files listed in *SOURCE*....
*BIN* may be an executable, object file, dynamic library, or archive (thin or
otherwise).
@@ -451,13 +451,13 @@ EXPORT COMMAND
SYNOPSIS
^^^^^^^^
-:program:`llvm-cov export` [*options*] -instr-profile *PROFILE* *BIN* [*-object BIN,...*] [[*-object BIN*]] [*SOURCES*]
+:program:`llvm-cov export` [*options*] -instr-profile *PROFILE* [*BIN*] [*-object BIN*]... [*-sources*] [*SOURCE*]...
DESCRIPTION
^^^^^^^^^^^
The :program:`llvm-cov export` command exports coverage data of the binaries
-*BIN*,... using the profile data *PROFILE* in either JSON or lcov trace file
+*BIN*... using the profile data *PROFILE* in either JSON or lcov trace file
format.
When exporting JSON, the regions, functions, branches, expansions, and
@@ -465,7 +465,7 @@ summaries of the coverage data will be exported. When exporting an lcov trace
file, the line-based coverage, branch coverage, and summaries will be exported.
The exported data can optionally be filtered to only export the coverage
-for the files listed in *SOURCES*.
+for the files listed in *SOURCE*....
For information on compiling programs for coverage and generating profile data,
see :ref:`llvm-cov-show`.
diff --git a/llvm/tools/llvm-cov/CodeCoverage.cpp b/llvm/tools/llvm-cov/CodeCoverage.cpp
index 7366059cd242f..7b71d5ad45547 100644
--- a/llvm/tools/llvm-cov/CodeCoverage.cpp
+++ b/llvm/tools/llvm-cov/CodeCoverage.cpp
@@ -635,7 +635,7 @@ int CodeCoverageTool::run(Command Cmd, int argc, const char **argv) {
"dump-collected-objects", cl::Optional, cl::Hidden,
cl::desc("Show the collected coverage object files"));
- cl::list<std::string> InputSourceFiles(cl::Positional,
+ cl::list<std::string> InputSourceFiles("sources", cl::Positional,
cl::desc("<Source files>"));
cl::opt<bool> DebugDumpCollectedPaths(
More information about the llvm-branch-commits
mailing list