440 Commits

Author SHA1 Message Date
Mehdi Amini
716042a63f
Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC) (#83702)
The base class llvm::ThreadPoolInterface will be renamed
llvm::ThreadPool in a subsequent commit.

This is a breaking change: clients who use to create a ThreadPool must
now create a DefaultThreadPool instead.
2024-03-05 18:00:46 -08:00
Mehdi Amini
6594f428de
Split the llvm::ThreadPool into an abstract base class and an implementation (#82094)
This decouples the public API used to enqueue tasks and wait for
completion from the actual implementation, and opens up the possibility
for clients to set their own thread pool implementation for the pool.

https://discourse.llvm.org/t/construct-threadpool-from-vector-of-existing-threads/76883
2024-03-02 19:10:50 -08:00
Wentao Zhang
0bf4f82f66
[llvm-cov][CoverageView] minor fix/improvement to HTML and text coverage output (#80952)
1. add the missing condition for MC/DC in hasSubViews()
2. add style for selected line
3. remove name="Ln" attribute in the link within MC/DC views
4. remove color for \n
2024-02-16 23:24:31 -06:00
Fangrui Song
927919ac34 [llvm-cov] Simplify branch/MCDC subviews. NFC
Remove unneeded empty check and reundant copies. NFC
2024-01-27 16:00:37 -08:00
Hana Dusíková
865e4a1f33
[coverage] skipping code coverage for 'if constexpr' and 'if consteval' (#78033)
`if constexpr` and `if consteval` conditional statements code coverage
should behave more like a preprocesor `#if`-s than normal
ConditionalStmt. This PR should fix that.

---------

Co-authored-by: cor3ntin <corentinjabot@gmail.com>
2024-01-22 12:50:20 +01:00
Kazu Hirata
c03c4e2b14 [tools] Use SmallString::operator std::string (NFC) 2024-01-19 00:19:31 -08:00
Hana Dusíková
18e1179208 [llvm-cov] format cells in report with 0/0 branches/functions/lines differenly (gray instead red) and make the table a bit nicer (#75780) 2023-12-19 19:15:39 +09:00
Alan Phipps
8ecbb0404d Reland "[Coverage][llvm-cov] Enable MC/DC Support in LLVM Source-based Code Coverage (2/3)"
Part 2 of 3. This includes the Visualization and Evaluation components.

Differential Revision: https://reviews.llvm.org/D138847
2023-12-13 15:10:05 -06:00
Kazu Hirata
cc4ecfd68b
[ADT] Rename SmallString::{starts,ends}with to {starts,ends}_with (#74916)
This patch renames {starts,ends}with to {starts,ends}_with for
consistency with std::{string,string_view}::{starts,ends}_with in
C++20.  Since there are only a handful of occurrences, this patch
skips the deprecation phase and simply renames them.
2023-12-09 14:28:45 -08:00
Kazu Hirata
fcb160eabc [llvm] Stop including llvm/ADT/DenseMap.h (NFC)
Identified with clangd.
2023-11-11 22:46:28 -08:00
Alan Phipps
ab3cd075b3 Revert "[Coverage][llvm-cov] Enable MC/DC Support in LLVM Source-based Code Coverage (2/3)"
This reverts commit 618a22144db5e45da8c95dc22064103e1b5e5b71.

Buildbots failing on windows and one other issue.
2023-09-20 16:32:34 -05:00
Alan Phipps
618a22144d [Coverage][llvm-cov] Enable MC/DC Support in LLVM Source-based Code Coverage (2/3)
Part 2 of 3. This includes the Visualization and Evaluation components.

Differential Revision: https://reviews.llvm.org/D138847
2023-09-20 15:30:47 -05:00
MaggieYingYi
cd8fe1dbcb
[llvm-cov] - Output better error message when the error kind is coveragemap_error::malforme. (#65264)
The current llvm-cov error message for kind `coveragemap_error::malforme`, just gives the issue kind without any reason for what caused the issue. This patch is aimed at improving the llvm-cov error message to help identify what caused the issue.

Reviewed By: MaskRay
Close: https://github.com/llvm/llvm-project/pull/65264
2023-09-06 15:02:31 +01:00
Yuhao Gu
bea39c5443 [llvm-cov] Support directory layout in coverage reports
This is a GSoC 2023 project ([discourse link](https://discourse.llvm.org/t/coverage-support-a-hierarchical-directory-structure-in-generated-coverage-html-reports/68239)).

llvm-cov currently generates a single top-level index HTML file, which causes rendering scalability issues in large projects. This patch adds support for hierarchical directory structure into the HTML reports to solve scalability issues by introducing the following changes:

- Added a new command line option `--show-directory-coverage` for `llvm-cov show`. It works both for `--format=html` and `--format=text`.
- Two new classes: `CoveragePrinterHTMLDirectory` and `CoveragePrinterTextDirectory` was added to support the new option.
- A tool class `DirectoryCoverageReport` was added to support the two classes above.
- Updated the document.
- Added a new regression test for `--show-directory-coverage`.

Reviewed By: phosek, gulfem

Differential Revision: https://reviews.llvm.org/D151283
2023-08-24 13:46:12 +08:00
Tomas Camin
5042e1e56d
[llvm-cov] Allow multiple remaps in --path-equivalence
Previously the --path-equivalence parameter would allow to specify a single remap pair (coverage data path - local source file path). This patch changes this allowing to pass as many remaps as needed.

Reviewed By: keith

Differential Revision: https://reviews.llvm.org/D154223
2023-08-23 15:27:56 -07:00
Yuhao Gu
57cb2f6ffe Reland "[llvm-cov] Support multi-source object files for convert-for-testing"
`llvm-cov convert-for-testing` only functions properly when the input binary contains a single source file. When the binary has multiple source files, a `Malformed coverage data` error will occur when the generated .covmapping is read back. This is because the testing format lacks support for indicating the size of its file records, and current implementation just assumes there's only one record in it. This patch fixes this problem by introducing a new testing format version.

Changes to the code:

- Add a new format version. The version number is stored in the the last 8 bytes of the orignial magic number field to be backward-compatible.
- Output a LEB128 number before the file records section to indicate its size in the new version.
- Change the format parsing code correspondingly.
- Update the document to formalize the testing format.
- Additionally, fix the bug when converting COFF binaries.

Reviewed By: phosek, gulfem

Differential Revision: https://reviews.llvm.org/D156611
2023-08-18 16:43:45 +00:00
Flightor
efa8374f6b [llvm-cov] Use uint64_t to avoid overflow in addition
Reviewed By: alanphipps
Differential Revision: https://reviews.llvm.org/D157608
2023-08-18 16:51:29 +08:00
Gulfem Savrun Yeniceri
5222733b4c Revert "[llvm-cov] Fix a bug about using convert-for-testing on multi-source object files"
This reverts commit f8ad86c23405168a8cd189590184fdcc296627e0 because
it broke some downsteam tests reported in https://reviews.llvm.org/D156611.
2023-08-15 20:28:30 +00:00
Yuhao Gu
f8ad86c234 [llvm-cov] Fix a bug about using convert-for-testing on multi-source object files
`llvm-cov convert-for-testing` is used to build the .covmapping files used in its regression tests. However the current implementation only works when there's only one source file in the mapping information data. If there are more than 1 source files, `llvm-cov convert-for-testing` can still produce a .covmapping file, but when read it back, `llvm-cov` will report:

```
error: Failed to load coverage: 'main.covmapping': Malformed coverage data
```

This is because the output .covmapping file doesn't have any mark to indicate the boundary between file records and function records, and current implementation jsut assume there's only one file record in the .covmapping file.

Changes to the code:

- Make `llvm-cov convert-for-testing` output a LEB128 number before file records to indicate its size.
- Change the testing format parsing code correspondingly.
- Update existing .covmapping files.

Reviewed By: gulfem

Differential Revision: https://reviews.llvm.org/D156611
2023-08-15 02:51:28 +00:00
Elliot Goodrich
b0abd4893f [llvm] Add missing StringExtras.h includes
In preparation for removing the `#include "llvm/ADT/StringExtras.h"`
from the header to source file of `llvm/Support/Error.h`, first add in
all the missing includes that were previously included transitively
through this header.
2023-06-25 15:42:22 +01:00
Kazu Hirata
6c3ea866e9 [llvm] Migrate {starts,ends}with_insensitive to {starts,ends}_with_insensitive (NFC)
This patch migrates uses of StringRef::{starts,ends}with_insensitive
to StringRef::{starts,ends}_with_insensitive so that we can use names
similar to those used in std::string_view.  I'm planning to deprecate
StringRef::{starts,ends}with_insensitive once the migration is
complete across the code base.

Differential Revision: https://reviews.llvm.org/D150426
2023-05-12 15:37:37 -07:00
Daniel Thornburgh
072e07a9d5 [llvm-cov] Optionally fail on missing binary ID
This adds the --check-binary-id flag that makes sure that an object file
is available for every binary ID mentioned in the given profile. This
should help make the tool more robust in CI environments where it's
expected that coverage mappings should be available for every object
contributing to the profile.

Reviewed By: gulfem

Differential Revision: https://reviews.llvm.org/D144308
2023-03-03 10:24:21 -08:00
Daniel Thornburgh
8007bcc13f [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
2023-02-17 13:11:54 -08:00
Archibald Elliott
62c7f035b4 [NFC][TargetParser] Remove llvm/ADT/Triple.h
I also ran `git clang-format` to get the headers in the right order for
the new location, which has changed the order of other headers in two
files.
2023-02-07 12:39:46 +00:00
Steven Wu
516e301752 [NFC][Profile] Access profile through VirtualFileSystem
Make the access to profile data going through virtual file system so the
inputs can be remapped. In the context of the caching, it can make sure
we capture the inputs and provided an immutable input as profile data.

Reviewed By: akyrtzi, benlangmuir

Differential Revision: https://reviews.llvm.org/D139052
2023-02-01 09:25:02 -08:00
Daniel Thornburgh
a3b0dde4ed Reland: [llvm-cov] Look up object files using debuginfod
Reviewed By: gulfem

Differential Revision: https://reviews.llvm.org/D136702
2023-01-26 12:59:52 -08:00
Douglas Yung
bce910242e Revert "[llvm-cov] Look up object files using debuginfod"
This reverts commit efbc8bb18eda63007216ad0cb5a8de04963eddd5.

This change is causing failures when detecting curl on several build bots:
 - https://lab.llvm.org/buildbot/#/builders/247/builds/884
 - https://lab.llvm.org/buildbot/#/builders/231/builds/7688
 - https://lab.llvm.org/buildbot/#/builders/121/builds/27389
 - https://lab.llvm.org/buildbot/#/builders/230/builds/8464
 - https://lab.llvm.org/buildbot/#/builders/57/builds/24209
 - https://lab.llvm.org/buildbot/#/builders/127/builds/42722
2023-01-25 19:11:08 -08:00
Daniel Thornburgh
efbc8bb18e [llvm-cov] Look up object files using debuginfod
Reviewed By: gulfem

Differential Revision: https://reviews.llvm.org/D136702
2023-01-25 14:00:34 -08:00
Archibald Elliott
f09cf34d00 [Support] Move TargetParsers to new component
This is a fairly large changeset, but it can be broken into a few
pieces:
- `llvm/Support/*TargetParser*` are all moved from the LLVM Support
  component into a new LLVM Component called "TargetParser". This
  potentially enables using tablegen to maintain this information, as
  is shown in https://reviews.llvm.org/D137517. This cannot currently
  be done, as llvm-tblgen relies on LLVM's Support component.
- This also moves two files from Support which use and depend on
  information in the TargetParser:
  - `llvm/Support/Host.{h,cpp}` which contains functions for inspecting
    the current Host machine for info about it, primarily to support
    getting the host triple, but also for `-mcpu=native` support in e.g.
    Clang. This is fairly tightly intertwined with the information in
    `X86TargetParser.h`, so keeping them in the same component makes
    sense.
  - `llvm/ADT/Triple.h` and `llvm/Support/Triple.cpp`, which contains
    the target triple parser and representation. This is very intertwined
    with the Arm target parser, because the arm architecture version
    appears in canonical triples on arm platforms.
- I moved the relevant unittests to their own directory.

And so, we end up with a single component that has all the information
about the following, which to me seems like a unified component:
- Triples that LLVM Knows about
- Architecture names and CPUs that LLVM knows about
- CPU detection logic for LLVM

Given this, I have also moved `RISCVISAInfo.h` into this component, as
it seems to me to be part of that same set of functionality.

If you get link errors in your components after this patch, you likely
need to add TargetParser into LLVM_LINK_COMPONENTS in CMake.

Differential Revision: https://reviews.llvm.org/D137838
2022-12-20 11:05:50 +00:00
Gregory Alfonso
d22f050e15 Remove redundant .c_str() and .get() calls
Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D139485
2022-12-18 00:33:53 +00:00
Fangrui Song
67ba5c507a std::optional::value => operator*/operator->
value() has undesired exception checking semantics and calls
__throw_bad_optional_access in libc++. Moreover, the API is unavailable without
_LIBCPP_NO_EXCEPTIONS on older Mach-O platforms (see
_LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS).

This fixes check-llvm.
2022-12-17 01:42:39 +00:00
Fangrui Song
da2f5d0a41 [tools] llvm::Optional => std::optional 2022-12-14 08:01:04 +00:00
Gregory Alfonso
7f86bb0a71 [llvm] Call reserve before push_back in a loop
It is generally good practice, if you know how big the vector is going to be in the end, to reserve before continually calling "push_back" or "emplace_back"

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D139483
2022-12-08 08:42:50 +00:00
Kazu Hirata
934942c033 [llvm] Don't include Optional.h (NFC)
These source files no longer use Optional<T>, so they do not need to
include Optional.h.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-12-06 22:34:50 -08:00
Fangrui Song
a996cc217c Remove unused #include "llvm/ADT/Optional.h" 2022-12-05 06:31:11 +00:00
Kazu Hirata
b4482f7ca0 [tools] Use std::nullopt instead of None (NFC)
This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated.  The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-12-02 21:11:40 -08:00
Matt Arsenault
e748db0f7f Support: Convert Program APIs to std::optional 2022-12-01 17:00:44 -05:00
Kazu Hirata
a7afa37fb2 [llvm-cov] Use std::optional in SourceCoverageViewText.cpp (NFC)
This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-11-26 18:47:28 -08:00
Kazu Hirata
4bb5141a37 [llvm-cov] Use std::optional in SourceCoverageViewHTML.cpp (NFC)
This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-11-26 18:45:08 -08:00
Kazu Hirata
f64505c0f2 [llvm-cov] Use std::optional in CodeCoverage.cpp (NFC)
This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-11-26 18:42:47 -08:00
Alan Phipps
a921d6eb3b [llvm-cov] Allow branch coverage to be skipped when exporting for LCOV
This small patch adds a '--skip-branches' option to the llvm-cov export
options. This option allows branch coverage information to be skipped from the
exported LCOV directives if it's not needed. For now, this only works when
exporting LCOV (which is noted in the option description), but it can be
extended for JSON later if it makes sense.

Differential Revision: https://reviews.llvm.org/D135986
2022-10-14 16:24:41 -05:00
Fangrui Song
1c52b4f798 [llvm-cov] Remove deprecated -name-whitelist after D112816 2022-08-01 18:53:20 -07:00
Zequan Wu
4979b16db1 [llvm-cov] Improve error message by printing the object file name that produces error
If error occurs on constructing coverage info for one of the object files, it prints the name of the object file, so that users know which one is the cause of error.

Differential Revision: https://reviews.llvm.org/D130196
2022-07-21 11:26:51 -07:00
Zequan Wu
44d9def78b [llvm-cov] Add error message for missing profdata on report and export subcommands.
When profdata is missing on report and export commands, the error message is
indistinguishable from missing instrumented binary file. This adds the error
message for report and export commands.

Differential Revision: https://reviews.llvm.org/D129791
2022-07-15 12:03:52 -07:00
Kazu Hirata
611ffcf4e4 [llvm] Use value instead of getValue (NFC) 2022-07-13 23:11:56 -07:00
Nicolai Hähnle
64a78c8501 Remove unnecessary includes of ManagedStatic.h
Differential Revision: https://reviews.llvm.org/D129115
2022-07-07 14:29:20 +02:00
Kazu Hirata
a7938c74f1 [llvm] Don't use Optional::hasValue (NFC)
This patch replaces Optional::hasValue with the implicit cast to bool
in conditionals only.
2022-06-25 21:42:52 -07:00
Kazu Hirata
3b7c3a654c Revert "Don't use Optional::hasValue (NFC)"
This reverts commit aa8feeefd3ac6c78ee8f67bf033976fc7d68bc6d.
2022-06-25 11:56:50 -07:00
Kazu Hirata
aa8feeefd3 Don't use Optional::hasValue (NFC) 2022-06-25 11:55:57 -07:00
Kazu Hirata
7a47ee51a1 [llvm] Don't use Optional::getValue (NFC) 2022-06-20 22:45:45 -07:00