1993 Commits

Author SHA1 Message Date
Kazu Hirata
0f52c1f86c [llvm] Deprecate {Bits,Float,Double}To{Bits,Float,Double} (NFC)
Differential Revision: https://reviews.llvm.org/D143990
2023-02-14 09:52:36 -08:00
Anton Sidorenko
388d679c1d Recommit [YAML IO] Check that mapping doesn't contain duplicating keys
The revert reason is fixed in D143727 (test changes).

According to YAML specification keys must be unique for a mapping node:
"The content of a mapping node is an unordered set of key/value node pairs, with
the restriction that each of the keys is unique".

Differential Revision: https://reviews.llvm.org/D140474
2023-02-13 17:45:07 +03:00
Kazu Hirata
b49b429fde [llvm] Deprecate PowerOf2Floor and ByteSwap_{16,32,64}
llvm/include/llvm/ADT/bit.h now has equivalent functions
forward-ported from C++20.

Differential Revision: https://reviews.llvm.org/D143858
2023-02-12 21:42:07 -08:00
Kazu Hirata
ec116ea684 [llvm] Deprecate llvm::count{Leading,Trailing}{Zeros,Ones} and llvm::countPopulation
llvm/include/llvm/ADT/bit.h now has equivalent functions
forward-ported from C++20.

Differential Revision: https://reviews.llvm.org/D143837
2023-02-12 12:11:51 -08:00
Archibald Elliott
d768bf994f [NFC][TargetParser] Replace uses of llvm/Support/Host.h
The forwarding header is left in place because of its use in
`polly/lib/External/isl/interface/extract_interface.cc`, but I have
added a GCC warning about the fact it is deprecated, because it is used
in `isl` from where it is included by Polly.
2023-02-10 09:59:46 +00:00
rkayaith
32b3f13337 [YAML] Trim trailing whitespace from plain scalars
In some cases plain scalars are currently parsed with a trailing
newline. In particular this shows up often when parsing JSON files, e.g.
note the `\n` after `456` below:
```
$ cat test.yaml
{
  "foo": 123,
  "bar": 456
}
$ yaml-bench test.yaml -canonical
%YAML 1.2
---
!!map {
  ? !!str "foo"
  : !!str "123",
  ? !!str "bar"
  : !!str "456\n",
}
...
```
The trailing whitespace ends up causing the conversion of the scalar to
int/bool/etc. to fail, causing the issue seen here:
https://github.com/llvm/llvm-project/issues/15877

From reading the YAML spec (https://yaml.org/spec/1.2.2/#733-plain-style)
it seems like plain scalars should never end with whitespace, so this
change trims all trailing whitespace characters from the
value (specifically `b-line-feed`, `b-carriage-return`, `s-space`, and
`s-tab`).

Reviewed By: scott.linder

Differential Revision: https://reviews.llvm.org/D137118
2023-02-09 21:56:57 -05:00
Anton Sidorenko
ed66b81f7a Revert "[YAML IO] Check that mapping doesn't contain duplicating keys"
LLDB failures: https://lab.llvm.org/buildbot/#/builders/17/builds/33865

This reverts commit 4c228ee6d40a7cff256f1a680561b6c0155ad704.
2023-02-09 15:09:07 +03:00
Anton Sidorenko
4c228ee6d4 [YAML IO] Check that mapping doesn't contain duplicating keys
According to YAML specification keys must be unique for a mapping node:
"The content of a mapping node is an unordered set of key/value node pairs, with
the restriction that each of the keys is unique".

Differential Revision: https://reviews.llvm.org/D140474
2023-02-09 14:45:51 +03:00
Benjamin Kramer
72eac42f21 [xxHash] Don't trigger UB on empty StringRef
This is quite silly, but casting to uintptr_t seems like the easiest
option to quiet ubsan.

llvm/lib/Support/xxhash.cpp:107:12: runtime error: applying non-zero offset 8 to null pointer
    #0 0x7fe3660404c0 in llvm::xxHash64(llvm::StringRef) llvm/lib/Support/xxhash.cpp:107:12
2023-02-08 12:53:54 +01: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
Simon Pilgrim
6c8fe96582 [Support] Move ItaniumManglingCanonicalizer and SymbolRemappingReader from Support to ProfileData
As mentioned on https://discourse.llvm.org/t/issues-in-llvm-tblgen-high-parallelized-build/68037, ItaniumManglingCanonicalizer is often slow to build, resulting in a bottleneck for distributed builds while waiting for LLVMSupport to complete.

SymbolRemappingReader is the only current user of ItaniumManglingCanonicalizer, and this is only used by ProfileData and llvm-cxxmap - so I propose we move both files into the ProfileData library.

Differential Revision: https://reviews.llvm.org/D143318
2023-02-06 20:55:48 +00:00
Alexey Lapshin
1e72920c88 [dsymutil] dsymutil produces broken lines info (probably) with LTO on mac
This patch fixes #60307 issue. The 8bb4451 introduces the possibility
to unite overlapped or adjacent address ranges to keep address ranges
in an unambiguous state. The AddressRangesMap is used to normalize
address ranges. The AddressRangesMap keeps address ranges and the value
of the relocated address. For intersected range, it creates a united
range that keeps the last inserted mapping value. The same for adjusted ranges.
While it is OK to use the last inserted mapping value for intersected ranges
(as there is no way how to resolve ambiguity) It is not OK to use the
last inserted value for adjacent address ranges. Currently, two following
address ranges are united into a single one:

{0,24,17e685c} {24,d8,55afe20} -> {0,d8,55afe20}

To avoid the problem, the AddressRangesMap should not unite adjacent address ranges
with different relocated addresses. Instead, it should leave adjacent address ranges
as separate ranges. So, the ranges should look like this:

{0,24,17e685c} {24,d8,55afe20}

Differential Revision: https://reviews.llvm.org/D142936
2023-02-03 11:09:50 +01:00
Kazu Hirata
32ac9db7a5 [Support] Remove findFirstSet and findLastSet
This patch removes findFirstSet and findLastSet as there are no uses
left in LLVM.

I am not aware of any uses of findFirstSet and findLastSet in the
open-source world outside LLVM, so I am skipping the deprecation step.

Differential Revision: https://reviews.llvm.org/D142603
2023-01-26 12:29:48 -08:00
serge-sans-paille
8f79b0fe00
[llvm] Do not zero out write_unsigned_impl internal buffer
Current implementation uselessly calls memset on its internal buffer
while it does not read the non overwritten part.

Differential Revision: https://reviews.llvm.org/D142464
2023-01-26 07:59:33 +01:00
Paul Robinson
7fc871591f [unittests] Use GTEST_SKIP() instead of return when appropriate
Basically NFC: A TEST/TEST_F/etc that bails out early (usually because
setup failed or some other runtime condition wasn't met) generally
should use GTEST_SKIP() to report its status correctly, unless it
takes steps to report another status (e.g., FAIL()).

I did see a handful of tests show up as SKIPPED after this change,
which is not unexpected. The status seemed appropriate in all the new
cases.
2023-01-25 13:59:01 -08:00
Fred Riss
cf12709222 Revert "[Clang] Give Clang the ability to use a shared stat cache"
This reverts commit c5abe893120b115907376359a5809229a9f9608a.
This reverts commit a033dbbe5c43247b60869b008e67ed86ed230eaa.

This broke the build with -DLLVM_LINK_LLVM_DYLIB=ON. Reverting while I
investigate.
2023-01-19 14:07:34 -08:00
Fred Riss
a033dbbe5c [Clang] Give Clang the ability to use a shared stat cache
Every Clang instance uses an internal FileSystemStatCache to avoid
stating the same content multiple times. However, different instances
of Clang will contend for filesystem access for their initial stats
during HeaderSearch or module validation.

On some workloads, the time spent in the kernel in these concurrent
stat calls has been measured to be over 20% of the overall compilation
time. This is extremly wassteful when most of the stat calls target
mostly immutable content like a SDK.

This commit introduces a new tool `clang-stat-cache` able to generate
an OnDiskHashmap containing the stat data for a given filesystem
hierarchy.

The driver part of this has been modeled after -ivfsoverlay given
the similarities with what it influences. It introduces a new
-ivfsstatcache driver option to instruct Clang to use a stat cache
generated by `clang-stat-cache`. These stat caches are inserted at
the bottom of the VFS stack (right above the real filesystem).

Differential Revision: https://reviews.llvm.org/D136651
2023-01-18 14:31:27 -08:00
Nikita Popov
bb5e26dad9 [Support] Fix alternation support in backreferences (PR60073)
backref() always performs a full match on the remaining string,
and as such also needs to be matched against the whole remaining
strip. For alternations, the match was performed against just the
sub-strip for one alternative, which would of course fail to match
the whole string.

This can be done by skipping the part of the strip between OOR1
and O_CH, so that only the first alternative in the strip is
matched, and the remaining ones are skipped. Indeed, the necessary
OOR1 skipping code was already implemented in the easy-path of
backref(), so this is clearly how it was supposed to work.

However, there were two bugs: First, under this scheme we should
be passing the stop point of the original strip, not just the
alternative sub-strip. Second, while skipping for OOR1 was
implemented, handling for O_CH was missing. This would occur when
the last alternative matches, as O_CH is preceded by an implicit
OOR1 only.

Fixes https://github.com/llvm/llvm-project/issues/60073.
2023-01-17 09:58:10 +01:00
Joe Loser
a288d7f937 [llvm][ADT] Replace uses of makeMutableArrayRef with deduction guides
Similar to how `makeArrayRef` is deprecated in favor of deduction guides, do the
same for `makeMutableArrayRef`.

Once all of the places in-tree are using the deduction guides for
`MutableArrayRef`, we can mark `makeMutableArrayRef` as deprecated.

Differential Revision: https://reviews.llvm.org/D141814
2023-01-16 14:49:37 -07:00
Kazu Hirata
da6642a1c8 [llvm] Include <optional> instead of "llvm/ADT/Optional.h" (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
2023-01-14 15:09:00 -08:00
Jordan Rupprecht
3432f4bf86 [test] Split out Annotations from TestingSupport
The Annotations helper class does not have a gtest or gmock dependency, but because it's bundled with the rest of TestingSupport, it gets one. By splitting it out, a target can use it without being forced to use LLVM's copy of gtest.

Reviewed By: GMNGeoffrey, sammccall, gribozavr2

Differential Revision: https://reviews.llvm.org/D141175
2023-01-12 13:40:47 -08:00
Jens Massberg
d1e0fd2b13 Avoid u8"" literals in tests, their type changes in C++20
Just specify the encoded bytes instead.
Additionally delete insertion operator of raw_ostream for char8_t as it
doesn't work as users might expect (Numbers and pointers are added to
the stream instead of UTF-8 characters). Added a comment and instructions
on how to use UTF-8 strings with raw_ostream.

Differential Revision: https://reviews.llvm.org/D141392
2023-01-12 10:21:33 +01:00
Guillaume Chatelet
8fd5558b29 [NFC] Use TypeSize::geFixedValue() instead of TypeSize::getFixedSize()
This change is one of a series to implement the discussion from
https://reviews.llvm.org/D141134.
2023-01-11 16:49:38 +00:00
Guillaume Chatelet
48f5d77eee [NFC] Use TypeSize::getKnownMinValue() instead of TypeSize::getKnownMinSize()
This change is one of a series to implement the discussion from
https://reviews.llvm.org/D141134.
2023-01-11 16:36:39 +00:00
Owen Anderson
e4e0f93307 Remove the ThreadLocal template from LLVM.
This has been obsoleted by C++ thread_local for a long time.
As far as I know, Xcode was the last supported toolchain to add
support for C++ thread_local in 2016.

As a precaution, use LLVM_THREAD_LOCAL which provides even greater
backwards compatibility, allowing this to function even pre-C++11
versions of GCC.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D141349
2023-01-10 21:07:52 -07:00
Jens Massberg
f082e54cef Avoid u8"" literals in tests, their type changes in C++20
Just specify the encoded bytes instead, which causes less confusion anyway.

Differential Revision: https://reviews.llvm.org/D141368
2023-01-10 15:14:09 +01:00
Sam McCall
2bac59bab4 [Support] avoid u8"" literals in tests, their type changes in C++20
Just specify the encoded bytes instead, which causes less confusion anyway.

Differential Revision: https://reviews.llvm.org/D141312
2023-01-10 14:00:22 +01:00
Owen Anderson
ef9aa34f02 Revert "Remove the ThreadLocal template from LLVM."
This reverts commit 54d78b639b9c18b42abd4fac5c6e76105f06b3ef.
2023-01-09 21:21:38 -07:00
Owen Anderson
54d78b639b Remove the ThreadLocal template from LLVM.
This has been obsoleted by C++ thread_local for a long time.
As far as I know, Xcode was the last supported toolchain to add
support for C++ thread_local in 2016.

As a precaution, use LLVM_THREAD_LOCAL which provides even greater
backwards compatibility, allowing this to function even pre-C++11
versions of GCC.

Reviewed By: majnemer

Differential Revision: https://reviews.llvm.org/D141347
2023-01-09 21:12:27 -07:00
Guillaume Chatelet
59b029238a [reland][NFC] Vastly simplifies TypeSize
Simplifies the implementation of `TypeSize` while retaining its interface.
There is no need for abstract concepts like `LinearPolyBase`, `UnivariateLinearPolyBase` or `LinearPolySize`.

Differential Revision: https://reviews.llvm.org/D140263
2023-01-09 08:43:37 +00:00
Alexandre Ganea
e66500c774 [Support] On Windows 11 and Windows Server 2022, fix an affinity mask issue on large core count machines
Before Windows 11 and Windows Server 2022, only one 'processor group' is assigned by default to a starting process, then the program is responsible for dispatching its own threads on more 'processor groups'. That is what 8404aeb56a73ab24f9b295111de3b37a37f0b841 was doing, allowing LLVM tools to automatically use all hardware threads in the machine.

After Windows 11 and Windows Server 2022, the OS takes care of that. This has an adverse effect reported in #56618 which is that using `GetProcessAffinityMask()` API in some edge cases seems buggy now. That API is used to detect if an affinity mask was set, and adjust accordingly the available threads for a ThreadPool.

With this patch, on one hand, we let the OS dispatch threads on all 'processor groups', but only for Windows 11 & Windows Server 2022 and after. We retain the old behavior for older OS versions. On the other hand, a workaround was added to mitigate the `GetProcessAffinityMask()` issue described above (see Threading.inc, L226).

Differential Revision: https://reviews.llvm.org/D138747
2023-01-06 17:03:43 -05:00
Guillaume Chatelet
16c1c9fdcc Revert D140263 "[NFC] Vastly simplifies TypeSize"
This broke some build bots : https://lab.llvm.org/buildbot/#/builders/16/builds/41419/steps/5/logs/stdio

This reverts commit 4670d5ece57d9b030597da679072f78bb3f4d419.
2023-01-06 15:33:00 +00:00
Guillaume Chatelet
4670d5ece5 [NFC] Vastly simplifies TypeSize
Simplifies the implementation of `TypeSize` while retaining its interface.
There is no need for abstract concepts like `LinearPolyBase`, `UnivariateLinearPolyBase` or `LinearPolySize`.

Differential Revision: https://reviews.llvm.org/D140263
2023-01-06 13:19:32 +00:00
Zibi Sarbinowski
3acb2553b9 Disable a part of the unit test CommandLineTest/BadResponseFile for z/OS.
[Support] Do not run test on z/OS

A part of the unit test CommandLineTest/BadResponseFile, added in
the commit fd3d7a9f8cbb need to be disable for z/OS as it was already done for AIX platform.

Reviewed By: fanbo-meng

Differential Revision: https://reviews.llvm.org/D141084
2023-01-05 15:57:54 -06:00
serge-sans-paille
38818b60c5
Move from llvm::makeArrayRef to ArrayRef deduction guides - llvm/ part
Use deduction guides instead of helper functions.

The only non-automatic changes have been:

1. ArrayRef(some_uint8_pointer, 0) needs to be changed into ArrayRef(some_uint8_pointer, (size_t)0) to avoid an ambiguous call with ArrayRef((uint8_t*), (uint8_t*))
2. CVSymbol sym(makeArrayRef(symStorage)); needed to be rewritten as CVSymbol sym{ArrayRef(symStorage)}; otherwise the compiler is confused and thinks we have a (bad) function prototype. There was a few similar situation across the codebase.
3. ADL doesn't seem to work the same for deduction-guides and functions, so at some point the llvm namespace must be explicitly stated.
4. The "reference mode" of makeArrayRef(ArrayRef<T> &) that acts as no-op is not supported (a constructor cannot achieve that).

Per reviewers' comment, some useless makeArrayRef have been removed in the process.

This is a follow-up to https://reviews.llvm.org/D140896 that introduced
the deduction guides.

Differential Revision: https://reviews.llvm.org/D140955
2023-01-05 14:11:08 +01:00
Craig Topper
3f749a5d9d [Support][SelectionDAG][GlobalISel] Hoist PostShift adjustment for IsAdd into UnsignedDivideUsingMagic.
Instead of doing the adjustment in 3 different places in the code
base, do it inside UnsignedDivideUsingMagic::get.

Differential Revision: https://reviews.llvm.org/D141014
2023-01-04 15:18:12 -08:00
Craig Topper
8bca60fb0a [SelectionDAG][GlobalISel] Don't use UnsignedDivisionByConstantInfo for divisor of 1.
The magic algorithm sets IsAdd indication for division by 1 that
the caller had to ignore.

I considered folding the ignore into UnsignedDivisionByConstantInfo,
but we only allow 1 for vectors of mixed visiors. And really what we
want to end up with is undef. Currently, we get to undef via
DemandedElts optimizations using the select instruction. We could
directly emit undef.

Differential Revision: https://reviews.llvm.org/D140940
2023-01-04 10:01:15 -08:00
Craig Topper
84daed7fd4 [SelectionDAG][GlobalISel] Move even divisor optimization for division by constant into UnsignedDivideUsingMagic implementation. NFC
I've added a bool to UnsignedDivideUsingMagic so we can continue
testing it in the unit test with and without this optimization in
the unit test.

This is a step towards supporting "uncooperative" odd divisors.
See https://ridiculousfish.com/blog/posts/labor-of-division-episode-iii.html

Reviewed By: lebedev.ri

Differential Revision: https://reviews.llvm.org/D140924
2023-01-03 16:34:13 -08:00
Chris Bieneman
a95717ef71 [YAML] Support serializing MutableArrayRef
While the YAML format itself doesn't support fixed-sized arrays, some
of the data structures we encode in and out of YAML (specifically in
ObjectYAML) are actually fixed-sized arrays which we end up expressing
as resizable arrays.

Enabling the YAML tooling to support reading and writing from
fixed-sized arrays using MutableArrayRef can simplify some of the error
reporting and use logic for cases where the sizes of arrays are defined
by the target format.

Note: my SFINAE-foo isn't the best, so if there is a cleaner way to
implement the traits please advise.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D140427
2023-01-03 12:29:11 -06:00
Craig Topper
8abd70081f [TargetLowering] Teach BuildUDIV to take advantage of leading zeros in the dividend.
If the dividend has leading zeros, we can use them to reduce the
size of the multiplier and avoid the fixup cases.

This patch is for scalars only, but we might be able to do this
for vectors in a follow up.

Differential Revision: https://reviews.llvm.org/D140750
2022-12-29 13:58:46 -08:00
Roman Lebedev
012afbbab4
[NFC][SupportTests] Adjust UnsignedDivideUsingMagic() for readability 2022-12-25 16:47:55 +03:00
Roman Lebedev
066b492b74
[NFC] Add exhaustive test coverage for {Un}signedDivisionByConstantInfo
Use this wrapper if you want to try brute-forcing wider bit widths:
https://godbolt.org/z/3xGzTM881

I've brute-forced i16 for both signed and unsigned, and we're all good.
As mentioned in https://reviews.llvm.org/D140636
2022-12-25 04:10:32 +03:00
Matt Arsenault
eb93b8774e Support: Add polling option to sys::Wait
Currently the process is terminated after the timeout. Add an option
to let the process resume after the timeout instead.

https://reviews.llvm.org/D138952
2022-12-22 12:38:59 -05:00
Kazu Hirata
77c90c8ce0 [llvm] Use std::optional instead of 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-20 15:42:32 -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
Benjamin Kramer
2916b99182 [ADT] Alias llvm::Optional to std::optional
This avoids the continuous API churn when upgrading things to use
std::optional and makes trivial string replace upgrades possible.

I tested this with GCC 7.5, the oldest supported GCC I had around.

Differential Revision: https://reviews.llvm.org/D140332
2022-12-20 01:01:46 +01:00
Paul Robinson
34f220ae32 Fix gcc 7.5 build break after TypeSize ctors became constexpr
As seen here: https://lab.llvm.org/staging/#/builders/235/builds/1135
2022-12-19 13:17:38 -08:00
Matt Arsenault
ca0f4e193b Support: Make TypeSize constructors constexpr
This is to enable LLT to be constexpr
2022-12-19 09:48:10 -05:00
Fangrui Song
2fa744e631 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 commit fixes LLVMAnalysis and its dependencies.
2022-12-16 22:44:08 +00:00
Haowei Wu
a903ecb4a2 [vfs] Allow root paths relative to the vfsoverlay YAML file
This change adds 'root-relative' option in vfsoverlay YAML file format
so the root patchs can be relative to the YAML file directory instead of
the current working directory.

Differential Revision: https://reviews.llvm.org/D137473
2022-12-16 11:45:36 -08:00