2288 Commits

Author SHA1 Message Date
Christian Sigg
710b5a1232
Fix logic to detect cl::option equality. (#65754)
This is a new attempt of https://reviews.llvm.org/D159481, this time as
GitHub PR.

`GenericOptionValue::compare()` should return `true` for a match.

- `OptionValueBase::compare()` always returns `false` and shouldn't
match anything.
- `OptionValueCopy::compare()` returns `false` if not `Valid` which
corresponds to no match.

Also adding some tests.
2023-09-10 12:25:19 +02:00
Ellis Hoag
8eb34700c2 [SpecialCaseList] Add option to use Globs instead of Regex to match patterns
Add an option in `SpecialCaseList` to use Globs instead of Regex to match patterns. `GlobPattern` was extended in https://reviews.llvm.org/D153587 to support brace expansions which allows us to use patterns like `*/src/foo.{c,cpp}`. It turns out that most patterns only take advantage of `*` so using Regex was overkill and required lots of escaping in practice. This often led to bugs due to forgetting to escape special characters.

Since this would be a breaking change, we temporarily support Regex by default and use Globs when `#!special-case-list-v2` is the first line in the file. Users should switch to the glob format described in https://llvm.org/doxygen/classllvm_1_1GlobPattern.html. For example, `(abc|def)` should become `{abc,def}`.

See discussion in https://reviews.llvm.org/D152762 and https://discourse.llvm.org/t/use-glob-instead-of-regex-for-specialcaselists/71666.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D154014
2023-09-01 09:06:11 -07:00
4vtomat
4b40ced4e5 [RISCV] Add --print-supported-extensions support
This revision supports --print-supported-extensions,
it prints out all of the extensions and corresponding version supported.

Reviewed By: craig.topper, kito-cheng

Differential Revision: https://reviews.llvm.org/D146054
2023-08-31 00:24:06 -07:00
Ellis Hoag
8daace8b2d [GlobPattern] Support brace expansions
Extend `GlobPattern` to support brace expansions, e.g., `foo.{c,cpp}` as discussed in https://reviews.llvm.org/D152762#4425203.

The high level change was to turn `Tokens` into a list that gets larger when we see a new brace expansion term. Then in `GlobPattern::match()` we must check against each token group.

This is a breaking change since `{` will no longer match a literal without escaping. However, `\{` will match the literal `{` before and after this change. Also, from a brief survey of LLVM, it seems that `GlobPattern` is mostly used for symbol and path matching, which likely won't need `{` in their patterns.

See https://github.com/devongovett/glob-match#syntax for a nice glob reference.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D153587
2023-08-30 08:30:39 -07:00
Piyou Chen
4b60e1e821 [RISCV] Add function that check extension name with version
Check whether a extension string with version is valid, and get the targetfeature from it.

New functions be used in RISCVISAInfo for https://reviews.llvm.org/D151730.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D152423
2023-08-20 21:06:57 -07:00
Dmitry Chernenkov
c27cda5350 [Bazel] Fix for Optionally print symbolizer markup backtraces. 2023-08-18 09:40:34 +00:00
Daniel Thornburgh
8d3ff601a3 Fix symbolizer markup backtrace build/test.
This corrects a Darwin build failure due to a missing stub and an
environment-specific Linux test failure due to an overly restrictive
test regex. This also backs out of the previous fix attempt; %p is
intended to be printed and parsed with the semantics of #.
2023-08-17 13:53:02 -07:00
Michael Liao
7026a0caca [llvm][Support] Fix backtrace output by removing '#'. NFC
- '#' has the string "0x" prepended for non-zero values. That results in
  inconsistent behavior between zero and non-zero values.
2023-08-17 15:58:12 -04:00
Michael Liao
a2dbb195d8 [llvm][Support] Fix backtrace match pattern to be consistent with the one generated. NFC 2023-08-17 15:25:02 -04:00
Daniel Thornburgh
22b9404f09 Optionally print symbolizer markup backtraces.
When the environment LLVM_ENABLE_SYMBOLIZER_MARKUP is set, if
llvm-symbolizer fails or is disabled, this change will print a backtrace
in llvm-symbolizer markup instead of falling back to in-process
symbolization mechanisms.

This allows llvm-symbolizer to be run on the output later to produce a
high quality backtrace, even for fully-stripped LLVM utilities.

Reviewed By: mcgrathr

Differential Revision: https://reviews.llvm.org/D139750
2023-08-17 10:54:47 -07:00
Aleksandr Bezzubikov
a7a634aa2b [LLVM][Casting.h] Fix dyn_cast for std::unique_ptr.
Unlike isa<> and cast<>, current implementation of dyn_cast<> fails
to process a std::unique_ptr to a class supporting LLVM RTTI:

// A and B support LLVM RTTI
class A {...}
class B: public A {...}

void foo() {
...
  auto V = std::make_unique<A>();
  auto VB = dyn_cast<B>(std::move(V));
  if (VB)
    ...
...
}

Reviewed By: lattner, bzcheeseman

Differential Revision: https://reviews.llvm.org/D147991
2023-08-13 18:04:19 -07:00
Corentin Jabot
68410fbed7 Fix handling of medial hyphens in Unicode Names.
In a Unicode name was stored in a way that caused
a medial hyphen to be at the end of a a chunk, it would not
be properly ignored by the loose matching algorithm.

For example if `LEFT-TO-RIGHT OVERRIDE` was stored as
`LEFT-` [...], the `-` would not be ignored.

The generators now ensures nodes are not cut accross
medial hyphen boundaries.

Fixes #64161

Differential Revision: https://reviews.llvm.org/D156518
2023-07-28 15:09:08 +02:00
Fangrui Song
4553dc46a0 [Support] Rewrite GlobPattern
The current implementation has two primary issues:

* Matching `a*a*a*b` against `aaaaaa` has exponential complexity.
* BitVector harms data cache and is inefficient for literal matching.

and a minor issue that `\` at the end may cause an out of bounds access
in `StringRef::operator[]`.

Switch to an O(|S|*|P|) greedy algorithm instead: factor the pattern
into segments split by '*'. The segment is matched sequentianlly by
finding the first occurrence past the end of the previous match. This
algorithm is used by lots of fnmatch implementations, including musl and
NetBSD's.

In addition, `optional<StringRef> Exact, Suffix, Prefix` wastes space.
Instead, match the non-metacharacter prefix against the haystack, then
match the pattern with the rest.

In practice `*suffix` style patterns are less common and our new
algorithm is fast enough, so don't bother storing the non-metacharacter
suffix.

Note: brace expansions (D153587) can leverage the `matchOne` function.

Differential Revision: https://reviews.llvm.org/D156046
2023-07-25 18:46:55 -07:00
Fangrui Song
16b2569f8e [unittest] Add [*] test to GlobPatternTest.cpp 2023-07-25 18:31:09 -07:00
Fangrui Song
eb52fee248 [unittest] Remove some tests from f5ae7e3489f317ce8c60df7258dbe31c8f988aa9 that current GlobPattern cannot handle 2023-07-25 17:26:53 -07:00
Fangrui Song
6a684dbc44 [Support] Remove llvm::is_trivially_{copy/move}_constructible
This restores D132311, which was reverted in
29c841ce93e087fa4e0c5f3abae94edd460bc24a (Sep 2022) due to certain files
not buildable with GCC 7.3.0. The previous attempt was reverted by
6cd9608fb37ca2418fb44b57ec955bb5efe10689 (Dec 2020).

This time, GCC 7.3.0 has existing build errors for a long time due to
structured bindings for many files, e.g.

```
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:9098:13: error: cannot decompose class type ‘std::pair<llvm::Value*, const llvm::SCEV*>’: both it and it
s base class ‘std::pair<llvm::Value*, const llvm::SCEV*>’ have non-static data members
   for (auto [_, Stride] : Legal->getLAI()->getSymbolicStrides()) {
             ^~~~~~~~~~~
```

... and also some `error: duplicate initialization of` instances due to llvm/Transforms/IPO/Attributor.h.

---

GCC 7.5.0 has a bug that, without this change, certain `SmallVector` with a `std::pair` element type like `SmallVector<std::pair<Instruction * const, Info>, 0> X;` lead to spurious

```
/tmp/opt/gcc-7.5.0/include/c++/7.5.0/type_traits:878:48: error: constructor required before non-static data member for ‘...’ has been parsed
```

Switching to std::is_trivially_{copy/move}_constructible fixes the error.
2023-07-25 17:21:16 -07:00
Fangrui Song
f5ae7e3489 [unittest] Improve GlobPattern tests
They cover some interesting cases when I was developing
https://reviews.llvm.org/D156046
2023-07-25 16:10:38 -07:00
Fangrui Song
1b162fabe8 [Support] Change SetVector's default template parameter to SmallVector<*, 0>
Similar to D156016 for MapVector.

This brings back commit fae7b98c221b5b28797f7b56b656b6b819d99f27 with a
fix to llvm/unittests/Support/ThreadPool.cpp's `_WIN32` code path.
2023-07-25 13:13:35 -07:00
Piyou Chen
b03a6db276 [RISCV] Replace zihintntl with zicond in ISAInfo unittest
Some ISAInfo unittest base on experimental-zihintntl, but zihintntl will become none-experimental. This patch use another experimental extension zicond to replace zihintntl.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D155673
2023-07-19 04:41:25 -07:00
Fangrui Song
48e93f57f1 [Support] Add llvm::xxh3_64bits
ld.lld SHF_MERGE|SHF_STRINGS duplicate elimination is computation heavy
and utilitizes llvm::xxHash64, a simplified version of XXH64.
Externally many sources confirm that a new variant XXH3 is much faster.

I have picked a few hash implementations and computed the
proportion of time spent on hashing in the overall link time (a debug
build of clang 16 on a machine using AMD Zen 2 architecture):

* llvm::xxHash64: 3.63%
* official XXH64 (`#define XXH_VECTOR XXH_SCALAR`): 3.53%
* official XXH3_64bits (`#define XXH_VECTOR XXH_SCALAR`): 1.21%
* official XXH3_64bits (default, essentially `XXH_SSE2`): 1.22%
* this patch llvm::xxh3_64bits: 1.19%

The remaining part of lld remains unchanged. Consequently, a lower ratio
indicates that hashing is faster. Therefore, it is evident that XXH3 from xxhash
is significantly faster than both the official version and our llvm::xxHash64.

(
string length: count
1-3: 393434
4-8: 2084056
9-16: 2846249
17-128: 5598928
129-240: 1317989
241-: 328058
)

This patch adds heavily simplified https://github.com/Cyan4973/xxHash,
taking account of many simplification ideas from Devin Hussey's xxhash-clean.

Important x86-64 optimization ideas:

* Make XXH3_len_129to240_64b and XXH3_hashLong_64b noinline
* Unroll XXH3_len_17to128_64b
* __restrict does not affect Clang code generation

Beside SHF_MERGE|SHF_STRINGS duplicate elimination, llvm/ADT/StringMap.h
StringMapImpl::LookupBucketFor and a few places in lld can potentially be
accelerated by switching to llvm::xxh3_64bits.

Link: https://github.com/llvm/llvm-project/issues/63750

Reviewed By: serge-sans-paille

Differential Revision: https://reviews.llvm.org/D154812
2023-07-18 13:36:11 -07:00
Eli Friedman
4b3dbaaa32 Fix nanosecond printing for TimePoint formatter.
There was a copy-paste of the wrong field width, so the nanoseconds
weren't correctly padded with zeros.  Found by inspection.
2023-07-14 15:51:23 -07:00
Craig Topper
0aecddcee9 [RISCV] Add Zce extension.
According to the spec, Zce is an alias for Zca, Zcb, Zcmp, and Zcmt.
If F is enabled on RV32 it also includes Zcf.

This patch adds the Zce and the implication rule which unfortunately
requires custom handling for adding Zcf.

I've also made all the Zc* extensions imply Zca.

I've also added an error for Zcf without RV32.

Reviewed By: asb

Differential Revision: https://reviews.llvm.org/D153742
2023-07-13 12:22:06 -07:00
Jan Svoboda
d77588df45 [llvm][vfs] For virtual directories, use the virtual path as the real path
A follow-up to D135841. This patch returns the virtual path for directories from `RedirectingFileSystem`. This ensures the contents of `Path` are the same as the contents of `FS->getRealPath(Path)`. This also means we can drop the workaround in Clang's module map canonicalization, where we couldn't use the real path for a directory if it resolved to a different `DirectoryEntry`. In addition to that, we can also avoid introducing new workaround for a bug triggered by the newly introduced test case.

Reviewed By: benlangmuir

Differential Revision: https://reviews.llvm.org/D135849
2023-07-10 10:41:15 -07:00
Elliot Goodrich
39d8e6e22c 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.

This is fixing all files missed in b0abd4893fa1.

Differential Revision: https://reviews.llvm.org/D154543
2023-07-08 10:19:07 +01:00
Haojian Wu
7aafea0012 [llvm][Support] Deprecate llvm::writeFileAtomically API
We're in favor of the llvm::writeToOutput API, and all
writeFileAtomically usages have been migrated to writeToOutput.

Differential Revision: https://reviews.llvm.org/D153740
2023-07-06 12:27:48 +02:00
Haojian Wu
1233e2e668 [Support] Don't set "all_exe" mode by default for file written by llvm::writeToOutput
Differential Revision: https://reviews.llvm.org/D153652
2023-06-30 09:20:36 +02:00
Haojian Wu
975f71faa7 [ELFAttributeParser] Update the ELFAttributeParserTest for 8f208ed
The 8f208ed has removed the "unrecognized vendor-name" error, updated
the unittest accordingly.
2023-06-27 14:40:02 +02:00
Alex Bradbury
6101d720cb [RISCV] Relax rules for ordering s/z/x prefixed extensions in ISA naming strings
This was discussed somewhat in D148315. As it stands, we require in
RISCVISAInfo::parseArchString (used for e.g. -march parsing in Clang)
that extensions are given in the order of z, then s, then x prefixed
extensions (after the standard single-letter extensions). However, we
recently (in D148315) moved to that order from z/x/s as the canonical
ordering was changed in the spec. In addition, recent GCC seems to
require z* extensions before s*.

My recollection of the history here is that we thought keeping -march as
close to the rules for ISA naming strings as possible would simplify
things, as there's an existing spec to point to. My feeling is that now
we've had incompatible changes, and an incompatibility with GCC there's
no real benefit to sticking to this restriction, and it risks making it
much more painful than it needs to be to copy a -march= string between
GCC and Clang.

This patch removes all ordering restrictions so you can freely mix x/s/z
extensions.

To be very explicit, this doesn't change our behaviour when emitting a
canonically ordered extension string (e.g. in build attributes). We of
course sort according to the canonical order (as we understand it) in
that case.

Differential Revision: https://reviews.llvm.org/D149246
2023-06-27 13:32:11 +01: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
Craig Topper
61e91988bc [RISCV] Add errors for mixing Zcmp with C/Zcd and D.
We already had an error for Zcmt though it appears to be untested
Add similar one for Zcmp along with tests for both.

Factor the code to share the strings as much as possible.

Reviewed By: VincentWu

Differential Revision: https://reviews.llvm.org/D153159
2023-06-21 00:10:37 -07:00
Ellis Hoag
1390675542 [SpecialCaseList] Remove TrigramIndex
`TrigramIndex` was added back in https://reviews.llvm.org/D27188 as an optimization to make `SpecialCaseList::match()` faster. I've found that `TrigramIndex` actually makes the function slower and it has no functional use, so we can remove it.

I grabbed the list of queries passed to `SpecialCaseList::match()` on a random very large file (`AArch64ISelLowering.cpp`) and measured the runtime to call `match()` on all of them with [this line](8e1f820bb4/llvm/lib/Support/SpecialCaseList.cpp (L64)) disabled and then enabled.

```
$ hyperfine --warmup 3 'GTEST_FILTER="SpecialCaseListTest.Large" USE_TRIGRAMS=1 build/unittests/Support/SupportTests' 'GTEST_FILTER="SpecialCaseListTest.Large" USE_TRIGRAMS=0 build/unittests/Support/SupportTests'
Benchmark 1: GTEST_FILTER="SpecialCaseListTest.Large" USE_TRIGRAMS=1 build/unittests/Support/SupportTests
  Time (mean ± σ):     575.9 ms ±  20.3 ms    [User: 573.1 ms, System: 2.7 ms]
  Range (min … max):   555.5 ms … 620.0 ms    10 runs

Benchmark 2: GTEST_FILTER="SpecialCaseListTest.Large" USE_TRIGRAMS=0 build/unittests/Support/SupportTests
  Time (mean ± σ):     283.4 ms ±   6.7 ms    [User: 280.3 ms, System: 3.0 ms]
  Range (min … max):   277.0 ms … 294.9 ms    10 runs

Summary
  'GTEST_FILTER="SpecialCaseListTest.Large" USE_TRIGRAMS=0 build/unittests/Support/SupportTests' ran
    2.03 ± 0.09 times faster than 'GTEST_FILTER="SpecialCaseListTest.Large" USE_TRIGRAMS=1 build/unittests/Support/SupportTests'
```

Using `perf` I found that most of the runtime in `TrigramIndex::isDefinitelyOut()` comes from a division operation that seems to come from `std::unordered_map`: 8e1f820bb4/llvm/include/llvm/Support/TrigramIndex.h (L62)

Removing `TrigramIndex` will make it easier to potentially switch to using `GlobPattern` instead of a full regex for `SpecialCaseList`. See discussion in https://reviews.llvm.org/D152762 for details.

Reviewed By: MaskRay, #sanitizers, vitalybuka

Differential Revision: https://reviews.llvm.org/D153171
2023-06-19 10:41:45 -07:00
Steven Wu
03e8637a91 [CMake] Add missing dependency in llvm Support unittests
Casting.cpp in llvm unittests includes "llvm/IR/User.h" which depends on
intrinsic_gen if using module because it needs to build IR module including
`Attributes.h`.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D153048
2023-06-16 09:47:31 -07:00
Raphael Isemann
5039d36454 [Support] Remove TaskQueue
TaskQueue was added several years ago as part of D48240.

There are currently no uses of this class anywhere in LLVM and I don't see
any patch that plans to use this class, so it doesn't seem useful to keep
compiling and testing this class at the moment.

The code itself is fine, so if we actually end up having a use for this code,
then I think it's perfectly fine to just re-commit this class then.

Differential revision: https://reviews.llvm.org/D86338
2023-06-13 10:19:42 -04:00
Ellis Hoag
c1d935ece3 [InstrProf] Fix BalancedPartitioning when threads are disabled
In https://reviews.llvm.org/D147812 we introduced the class
`BalancedPartitioning` which includes some threading code. The tests in
that diff run forever when built with `-DLLVM_ENABLE_THREADS=OFF` so
some bots were broken.

These tests were skipped in
https://reviews.llvm.org/rGa4845eaf2e9aa18dd900d7cbeff4e5ff52e4b50e
because of this.

This diff disables the threading code if `LLVM_ENABLE_THREADS` is
disabled so we can re-enable the tests.

Reviewed By: luporl

Differential Revision: https://reviews.llvm.org/D152390
2023-06-07 12:04:35 -07:00
Leandro Lupori
a4845eaf2e [InstrProf] Skip Balanced Partitioning tests on ARM
Balanced Partitioning tests, added by 1794532bb942, currently
hang on ARM, what causes check-all to never finish.

Issue #63168

Differential Revision: https://reviews.llvm.org/D147812
2023-06-07 17:39:41 +00:00
Ellis Hoag
1794532bb9 [InstrProf] Move BPFunctionNode test to ProfileDataTests
In https://reviews.llvm.org/D147812 I created
`BalancedPartitioningTest.cpp` and inadvertently drastically increased the
number of files needed to compile `SupportTests`. Instead lets move the
`BPFunctionNode` test to `unittests/ProfileData` so we can remove the
extra dependency.

Reviewed By: thakis

Differential Revision: https://reviews.llvm.org/D152325
2023-06-06 19:12:51 -07:00
Ellis Hoag
1117b9a284 [InstrProf] Use BalancedPartitioning to order temporal profiling trace data
In [0] we described an algorithm called //BalancedPartitioning// (bp) to consume function traces [1] and compute a function order that reduces the number of page faults during startup.

This patch adds the `order` command to the `llvm-profdata` tool which uses bp to output a function order that can be passed to the linker via `--symbol-ordering-file=`.

Special thanks to Sergey Pupyrev and Julian Mestre for designing this balanced partitioning algorithm.

[0] https://discourse.llvm.org/t/rfc-temporal-profiling-extension-for-irpgo/68068
[1] https://reviews.llvm.org/D147287

Reviewed By: spupyrev

Differential Revision: https://reviews.llvm.org/D147812
2023-06-06 11:59:57 -07:00
Nikita Popov
660e453012 [KnownBits] Also test 1-bit values in exhaustive tests (NFC)
Similar to what we do with ConstantRanges, also test 1-bit values
in exhaustive tests, as these often expose special conditions.
This would have exposed the assertion failure fixed in D151788
earlier.
2023-05-31 17:50:01 +02:00
Jay Foad
5aa6bbe745 [KnownBits] Check functions that return zero for poison results
Differential Revision: https://reviews.llvm.org/D151456
2023-05-25 16:02:16 +01:00
Nikita Popov
d2502eb091 [KnownBits] Add support for nuw/nsw on shifts
Implement precise nuw/nsw support in the KnownBits implementation,
replacing the rather crude handling in ValueTracking.

Differential Revision: https://reviews.llvm.org/D151208
2023-05-25 10:17:10 +02:00
Nikita Popov
d4bfc144ea [KnownBits] Check for conflict-freedom in exhaustive tests
And make sure udiv() Exact does not produce conflicts.
2023-05-24 10:34:44 +02:00
Noah Goldstein
5f50b180c5 [KnownBits] Add implementations for saturating add/sub functions
These where previously missing. Even in the case where overflow is
indeterminate we can still deduce some of the low/high bits.

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D150102
2023-05-23 13:52:40 -05:00
Noah Goldstein
4fd3401e76 [KnownBits] Improve implementation of KnownBits::abs
`abs` preserves the lowest set bit, so if we know the lowest set bit,
set it in the output.

As well, implement the case where the operand is known negative.

Reviewed By: foad, RKSimon

Differential Revision: https://reviews.llvm.org/D150100
2023-05-23 13:52:39 -05:00
Noah Goldstein
7d05ab99ed [KnownBits] Improve KnownBits::udiv
We can more precisely determine the upper bits doing `MaxNum /
MinDenum` as opposed to only using the MSB.

As well, if the `exact` flag is set, we can sometimes determine some
of the low-bits.

Differential Revision: https://reviews.llvm.org/D150094
2023-05-16 18:58:12 -05:00
Noah Goldstein
8c569c922b [KnownBits] Add implementation for KnownBits::sdiv
Can figure out some of the upper bits (similiar to `udiv`) if we know
the sign of the inputs.

As well, if we have the `exact` flag we can sometimes determine some
low-bits.

Differential Revision: https://reviews.llvm.org/D150093
2023-05-16 18:58:12 -05:00
Nikita Popov
0b81ff3ac5 [KnownBits] Handle shifts over wide types
Do not assert if the bit width is larger than 64 bits. This case
is currently hidden from the IR layer by other checks, but gets
exposed with future changes.
2023-05-16 11:26:39 +02:00
Nikita Popov
9d73a8bdc6 [KnownBits] Make shl/lshr/ashr implementations optimal
The implementations for shifts were suboptimal in the case where
the max shift amount was >= bitwidth. In that case we should still
use the usual code clamped to BitWidth-1 rather than just giving up
entirely.

Additionally, there was an implementation bug where the known zero
bits for the individual shift amounts were not set in the shl/lshr
implementations. I think after these changes, we'll be able to drop
some of the code in ValueTracking which *also* evaluates all possible
shift amounts and has been papering over this issue.

For the "all poison" case I've opted to return an unknown value for
now. It would be better to return zero, but this has fairly
substantial test fallout, so I figured it's best to not mix it into
this change. (The "correct" return value would be a conflict, but
given that a lot of our APIs assert conflict-freedom, that's probably
not the best idea to actually return.)

Differential Revision: https://reviews.llvm.org/D150587
2023-05-16 09:44:26 +02:00
Jay Foad
3a86713307 [KnownBitsTest] Remove stray semicolons 2023-05-15 16:20:06 +01:00
Nikita Popov
0f1fb626b3 [KnownBitsTest] Align with ConstantRange test infrastructure (NFC)
Align the way we perform exhaustive tests for KnownBits with what
we do for ConstantRange. Test each case separately by specifying
a function on KnownBits and one on APInts. Additionally, specify
a callback that determines which cases are supposed to be optimal,
rather than only correct. Unlike the ConstantRange case there is
a well-defined, unique notion of optimality for KnownBits.

If a failure occurs, print out the inputs, computed result and
exact result. Adjust the printing function to produce the output
in a format that is meaningful for KnownBits, i.e. print the
actual known bits, using ? to signify unknowns and ! to signify
conflicts.
2023-05-15 16:48:57 +02:00
Alexey Lapshin
6ab43f9b87 [Support] Add PerThreadBumpPtrAllocator class.
PerThreadBumpPtrAllocator allows separating allocations by thread id.
That makes allocations race free. It is possible because
ThreadPoolExecutor class creates threads, keeps them until
the destructor of ThreadPoolExecutor is called, and assigns ids
to the threads. Thus PerThreadBumpPtrAllocator should be used with only
threads created by ThreadPoolExecutor. This allocator is useful when
thread safe BumpPtrAllocator is needed.

Reviewed By: MaskRay, dexonsmith, andrewng

Differential Revision: https://reviews.llvm.org/D142318
2023-05-06 14:35:26 +02:00