Commit Graph

432853 Commits

Author SHA1 Message Date
Arthur Eubanks 195087d815 [llvm-reduce] Try harder to not create invalid aliases
This was done by adding --abort-on-invalid-reduction to remove-function-bodies-used-in-globals.ll and fixing the fallout.

Aliases must have a GlobalValue or ConstantExpr aliasee and the aliasee must be a definition if it's a GlobalValue.
Don't RAUW functions with null if there's an alias pointing to it, and similarly don't delete the body of a function.
Don't delete the entire body of a function when reducing blocks, preserve at least one block.

Also make debugging these sorts of things easier by dumping the module when --abort-on-invalid-reduction triggers.

Reviewed By: regehr

Differential Revision: https://reviews.llvm.org/D131505
2022-08-12 10:39:05 -07:00
Arthur Eubanks bd1f80f54e [llvm-reduce] Add delta pass to run IR passes
The exact IR passes run is customizable via `-ir-passes`.

Reviewed By: regehr

Differential Revision: https://reviews.llvm.org/D123749
2022-08-12 10:38:19 -07:00
Siva Chandra Reddy e4efe2cfc6 [libc] Pack memory functions in the integration test libc.a files.
Reviewed By: michaelrj

Differential Revision: https://reviews.llvm.org/D131752
2022-08-12 17:27:26 +00:00
Jonas Devlieghere abe9599f04
[lldb] Skip target variable tests on Darwin because of chained fixups
When targeting macOS Ventura, ld64 will use authenticated fixups for
x86_64 as well as arm64 (where that has always been the case). This
results in test failures when using an Xcode 14 toolchain on an Intel
mac running macOS Ventura:

  Failed Tests (3):
    lldb-api :: commands/target/basic/TestTargetCommand.py
    lldb-api :: lang/c/global_variables/TestGlobalVariables.py
    lldb-api :: lang/cpp/char8_t/TestCxxChar8_t.py

Rather than trying to come up with a sophisticated decorator based off
the deployment target, I marked them all as skipped with a comment
explaining why.

Differential revision: https://reviews.llvm.org/D131741
2022-08-12 10:23:15 -07:00
Arthur Eubanks a3ac1cfaed [SampleProfile] Fix non-determinism in promoteMergeNotInlinedContextSamples()
We're seeing non-determinism with loading sample profiles. It seems to
be related to the order in which we merge FunctionSamples in
promoteMergeNotInlinedContextSamples(). Use a MapVector to iterate over
NonInlinedCallSites in the order entries were inserted.

Reviewed By: wenlei, davidxl

Differential Revision: https://reviews.llvm.org/D131592
2022-08-12 10:13:25 -07:00
James Y Knight 20451cb06b Update license on Unicode.org's ConvertUTF code.
The code was relicensed by its owner (Unicode.org) a long time back,
but we still had the old (problematic) license in our fork.

Note that the source files have not been distributed from unicode.org
since 2009 (due to being buggy and unmaintained upstream), but they
were given this license before that.

Fixes https://github.com/llvm/llvm-project/issues/32309

Differential Revision: https://reviews.llvm.org/D66390
2022-08-12 16:51:08 +00:00
Sam Estep b3f1a6bf10 [clang][dataflow] Encode options using llvm::Optional
This patch restructures `DataflowAnalysisOptions` and `TransferOptions` to use `llvm::Optional`, in preparation for adding more sub-options to the `ContextSensitiveOptions` struct introduced here.

Reviewed By: sgatev, xazax.hun

Differential Revision: https://reviews.llvm.org/D131779
2022-08-12 16:29:41 +00:00
Jeff Niu bc8d966433 [mlir][math] Fix lowering of AbsIOp
The LLVM intrinsic has a bool flag `is_int_min_poison` that needs to be
set.

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D131785
2022-08-12 12:10:15 -04:00
YingChi Long e5825190b8
[clang] fix frontend crash when evaluating type trait
Before this patch type traits are checked in Parser, so use type traits
directly did not cause assertion faults. However if type traits are initialized
from a template, we didn't perform arity checks before evaluating. This
patch moves arity checks from Parser to Sema, and performing arity
checks in Sema actions, so type traits get checked corretly.

Crash input:

```
template<class... Ts> bool b = __is_constructible(Ts...);
bool x = b<>;
```

After this patch:

```
clang/test/SemaCXX/type-trait-eval-crash-issue-57008.cpp:5:32: error: type trait requires 1 or more arguments; have 0 arguments
template<class... Ts> bool b = __is_constructible(Ts...);
                               ^~~~~~~~~~~~~~~~~~
clang/test/SemaCXX/type-trait-eval-crash-issue-57008.cpp:6:10: note: in instantiation of variable template specialization 'b<>' requested here
bool x = b<>;
         ^
1 error generated.
```

See https://godbolt.org/z/q39W78hsK.

Fixes https://github.com/llvm/llvm-project/issues/57008

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D131423
2022-08-13 00:02:19 +08:00
Alex Zinenko 4b45999bdd [mlir] fix crossed transform dialect patches
One patch added a use of the IR syntax that was changed by another.
2022-08-12 15:48:15 +00:00
Kevin Athey ec277b67eb [MSAN] Separate id ptr from constant string for variable names used in track origins.
The goal is to reduce the size of the MSAN with track origins binary, by making
the variable name locations constant which will allow the linker to compress
them.

Follows: https://reviews.llvm.org/D131415

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D131631
2022-08-12 08:47:36 -07:00
Vir Narula bc56f6377c
[CostModel] Add bfloat and fp128 reduction tests
Reviewed By: fhahn

Differential Revision: https://reviews.llvm.org/D131269
2022-08-12 16:44:04 +01:00
Alex Zinenko a60ed95419 [mlir][transform] failure propagation mode in sequence
Introduce two different failure propagation mode in the Transform
dialect's Sequence operation. These modes specify whether silenceable
errors produced by nested ops are immediately propagated, thus stopping
the sequence, or suppressed. The latter is useful in end-to-end
transform application scenarios where the user cannot correct the
transformation, but it is robust enough to silenceable failures. It
can be combined with the "alternatives" operation. There is
intentionally no default value to avoid favoring one mode over the
other.

Downstreams can update their tests using:

  S='s/sequence \(%.*\) {/sequence \1 failures(propagate) {/'
  T='s/sequence {/sequence failures(propagate) {/'
  git grep -l transform.sequence | xargs sed -i -e "$S"
  git grep -l transform.sequence | xargs sed -i -e "$T"

Reviewed By: nicolasvasilache

Differential Revision: https://reviews.llvm.org/D131774
2022-08-12 15:31:22 +00:00
Leonard Grey 6c62795058 [lld-macho] Ensure cached objects are affected by `-object_path_lto`
This refactors LTO compile to look more like COFF, where cache hits and misses are all funneled through the same code path.

Previously, cache hits were *not* being saved to -object_path_lto, which led to them sometimes falling out of the cache before dsymutil could process them. As a side effect of the refactor, cached objects are now saved with -save-temps as well, which seems desirable.

(Deleted lld/test/MachO/lto-cache-dsymutil.ll and rolled it into lld/test/MachO/lto-object-path.ll, since the cache-only, non object path approach is unreliable anyway).

Differential Revision: https://reviews.llvm.org/D131624
2022-08-12 10:56:58 -04:00
Ilya Biryukov fba88adc89 [Sema] Always perform ADL when searching for transormed operators in C++20
This fixes compilation errors in the following code with
latest libc++ and libstdc++:
```cpp

int main() {
  std::tuple<std::string> s;
  std::tuple<std::string_view> sv;
  s < sv;
}
```

See https://gcc.godbolt.org/z/vGvEhxWvh for the error.

This used to happen because repeated template instantiations during
C++20 constraint satisfaction will cause a call to `RebuildCXXRewrittenBinaryOperator`
with `PerformADL` set to false, see 59351fe340/clang/lib/Sema/TreeTransform.h (L2737)

Committing urgently to unbreak breakages we see in our configurations.
The change seems relatively safe and the right thing to do.

However, I will follow-up with tests and investigation on whether we
need to do this extra semantic checking in the first place next week.
2022-08-12 16:07:02 +02:00
James Y Knight 59351fe340 SPIRV: Fix compilation in NDEBUG. 2022-08-12 14:00:39 +00:00
Tue Ly af59bac4ca [libc] Add missing header and Windows entrypoints for tanf. 2022-08-12 09:34:33 -04:00
Dawid Jurczak 8a17e74ca9 [NFC] Introduce llvm::to_vector_of to allow creation of SmallVector<T> from range of items convertible to type T
It's https://reviews.llvm.org/D129565 follow-up.

Differential Revision: https://reviews.llvm.org/D129781
2022-08-12 15:22:12 +02:00
Tue Ly 82d6e77048 [libc] Implement tanf function correctly rounded for all rounding modes.
Implement tanf function correctly rounded for all rounding modes.

We use the range reduction that is shared with `sinf`, `cosf`, and `sincosf`:
```
  k = round(x * 32/pi) and y = x * (32/pi) - k.
```
Then we use the tangent of sum formula:
```
  tan(x) = tan((k + y)* pi/32) = tan((k mod 32) * pi / 32 + y * pi/32)
         = (tan((k mod 32) * pi/32) + tan(y * pi/32)) / (1 - tan((k mod 32) * pi/32) * tan(y * pi/32))
```
We need to make a further reduction when `k mod 32 >= 16` due to the pole at `pi/2` of `tan(x)` function:
```
  if (k mod 32 >= 16): k = k - 31, y = y - 1.0
```
And to compute the final result, we store `tan(k * pi/32)` for `k = -15..15` in a table of 32 double values,
and evaluate `tan(y * pi/32)` with a degree-11 minimax odd polynomial generated by Sollya with:
```
>  P = fpminimax(tan(y * pi/32)/y, [|0, 2, 4, 6, 8, 10|], [|D...|], [0, 1.5]);
```

Performance benchmark using `perf` tool from the CORE-MATH project on Ryzen 1700:
```
$ CORE_MATH_PERF_MODE="rdtsc" ./perf.sh tanf
CORE-MATH reciprocal throughput   : 18.586
System LIBC reciprocal throughput : 50.068

LIBC reciprocal throughput        : 33.823
LIBC reciprocal throughput        : 25.161     (with `-msse4.2` flag)
LIBC reciprocal throughput        : 19.157     (with `-mfma` flag)

$ CORE_MATH_PERF_MODE="rdtsc" ./perf.sh tanf --latency
GNU libc version: 2.31
GNU libc release: stable
CORE-MATH latency   : 55.630
System LIBC latency : 106.264

LIBC latency        : 96.060
LIBC latency        : 90.727    (with `-msse4.2` flag)
LIBC latency        : 82.361    (with `-mfma` flag)
```

Reviewed By: orex

Differential Revision: https://reviews.llvm.org/D131715
2022-08-12 09:21:05 -04:00
Joe Loser e8578968f6
[ADT] Replace STLForwardCompat.h's C++17 equivalents
STLForwardCompat.h defines several utilities and type traits to mimic that of
the ones in the C++17 standard library. Now that LLVM is built with the C++17
standards mode, remove use of these equivalents in favor of the ones from the
standard library.

Differential Revision: https://reviews.llvm.org/D131717
2022-08-12 06:55:59 -06:00
Matthias Springer 0581ab65ea [mlir][linalg][transform] Support matching of attributes (and their values)
Do not just check if an attribute exists on the payload op. Also check its value.

Differential Revision: https://reviews.llvm.org/D131760
2022-08-12 14:55:00 +02:00
Benjamin Kramer 170ec0e418
[bazel] Port 3e119c0efd 2022-08-12 14:52:49 +02:00
Haojian Wu 06b97b4985 [clangd] Fix an inlay-hint crash on a broken designator.
Differential Revision: https://reviews.llvm.org/D131696
2022-08-12 14:37:46 +02:00
Maciej Gabka 48e1250a91 [clang][SVE] Undefine preprocessor macro defined in
arm_sve.h defines and uses __ai macro which needs to be undefined (as it is
already in arm_neon.h).

Reviewed By: paulwalker-arm

Differential Revision: https://reviews.llvm.org/D131580
2022-08-12 12:25:49 +00:00
Nico Weber 8b3c274efb [gn build] port 3e119c0efd (split-file move to utils/) 2022-08-12 08:20:08 -04:00
Nico Weber 39a093471a [lld/mac] Add missing `_eq` suffix on two (internal) option names
No behavior change.
2022-08-12 08:18:52 -04:00
Jinyun Joey Ye 921b13f263 Missing climits header file in MemRefUtils.h
MemRefUtils.h uses UINT_MAX, which is not included in current header files list. This patch include climits to avoid compilation error in this header file.

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D131529
2022-08-12 14:17:36 +02:00
Markus Böck 3e119c0efd [llvm][CMake] Move `split-file` from tools to utils
It fittingly already makes use of add_llvm_utility during target creation and is usually only used in conjunction with other (test) related utilities such as FileCheck and not, which are already in utils.

Differential Revision: https://reviews.llvm.org/D131713
2022-08-12 14:16:48 +02:00
Nico Weber 3d53ecfc19 [gn build] port 74384c7fce 2022-08-12 08:10:16 -04:00
Haojian Wu 1828c75d5f [pseudo] Apply the function-declarator to member functions.
A followup patch of d489b3807f, but for
member functions, this will eliminate a false parse of member
declaration.

Differential Revision: https://reviews.llvm.org/D131720
2022-08-12 13:49:01 +02:00
Haojian Wu a1a1a78ac8 [pseudo] Eliminate an ambiguity for the empty member declaration.
We happened to introduce a `member-declaration := ;` rule
when inlining the `member-declaration := decl-specifier-seq_opt
member-declarator-list_opt ;`.
And with the `member-declaration := empty-declaration` rule, we had two parses of `;`.

This patch is to restrict the grammar to eliminate the
`member-declaration := ;` rule.

Differential Revision: https://reviews.llvm.org/D131724
2022-08-12 13:46:26 +02:00
Nimish Mishra 435feefbdd [flang][OpenMP] Lowering support for default clause
This patch adds lowering support for default clause.

1. During symbol resolution in semantics, should the enclosing context
   have a default data sharing clause defined and a `parser::Name` is not
   attached to an explicit data sharing clause, the
   `semantics::Symbol::Flag::OmpPrivate` flag (in case of
   default(private)) and `semantics::Symbol::Flag::OmpFirstprivate` flag
   (in case of default(firstprivate)) is added to the symbol.

2. During lowering, all symbols having either
   `semantics::Symbol::Flag::OmpPrivate` or
   `semantics::Symbol::Flag::OmpFirstprivate` flag are collected and
   privatised appropriately.

Co-authored-by: Peixin Qiao <qiaopeixin@huawei.com>

Reviewed by: peixin

Differential Revision: https://reviews.llvm.org/D123930
2022-08-12 16:46:26 +05:30
Nimish Mishra 30b779d515 Revert "[flang][OpenMP] Lowering support for default clause"
This reverts commit 6a305c9b49.
2022-08-12 16:45:38 +05:30
Nimish Mishra 6a305c9b49 [flang][OpenMP] Lowering support for default clause
This patch adds lowering support for default clause.

1. During symbol resolution in semantics, should the enclosing context have
a default data sharing clause defined and a `parser::Name` is not attached
to an explicit data sharing clause, the
`semantics::Symbol::Flag::OmpPrivate` flag (in case of default(private))
and `semantics::Symbol::Flag::OmpFirstprivate` flag (in case of
default(firstprivate)) is added to the symbol.

2. During lowering, all symbols having either
`semantics::Symbol::Flag::OmpPrivate` or
`semantics::Symbol::Flag::OmpFirstprivate` flag are collected and
privatised appropriately.

Co-authored-by: Peixin Qiao <qiaopeixin@huawei.com>

Reviewed by: peixin

Differential Revision: https://reviews.llvm.org/D123930
2022-08-12 22:08:14 +05:30
Adrian Vogelsgesang d7e0cec60e [libc++][test] Mark `test_comparisons.h` helpers as nodiscard
I accidentally wrote `testComparisons(...)` instead of
`assert(testComparisons(...))`. This compiled without issues, but
did not provide the intended test coverage. By adding a `nodiscard`,
we can make sure that the compiler catches such mistakes for us.

Differential Revision: https://reviews.llvm.org/D131364
2022-08-12 03:30:33 -07:00
Utkarsh Saxena 72ac7cac3f Handle explicitly defaulted consteval special members.
Followup patch for D128083

Previously, using a non-consteval constructor from an consteval constructor would code generates the consteval constructor.
Example
```
template <typename T>
struct S {
  T i;
  consteval S() = default;
};
struct Foo {
    Foo() {}
};
void func() {
  S<Foo> three; // incorrectly accepted by clang.
}
```

This happened because clang erroneously disregards `consteval` specifier for a `consteval explicitly defaulted special member functions in a class template` if it has dependent data members without a `consteval default constructor`.

According to
```
C++14 [dcl.constexpr]p6 (CWG DR647/CWG DR1358):
If the instantiated template specialization of a constexpr function
template or member function of a class template would fail to satisfy
the requirements for a constexpr function or constexpr constructor, that
specialization is still a constexpr function or constexpr constructor,
even though a call to such a function cannot appear in a constant
expression.
```

Therefore the `consteval defaulted constructor of a class template` should be considered `consteval` even if the data members' default constructors are not consteval.
Keeping this constructor `consteval` allows complaining while processing the call to data member constructors.
(Same applies for other special member functions).

This works fine even when we have more than one default constructors since we process the constructors after the templates are instantiated.

This does not address initialization issues raised in
[2602](https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#2602) and compiler divergence seen in https://godbolt.org/z/va9EMvvMe

Fixes: https://github.com/llvm/llvm-project/issues/51593

Differential Revision: https://reviews.llvm.org/D131479
2022-08-12 12:13:06 +02:00
Simon Pilgrim 4de35f4bbf [DAG] Add TODO to remove creation of INSERT_SUBVECTOR nodes from SimplifyMultipleUseDemandedBits
SimplifyMultipleUseDemandedBits shouldn't be creating general nodes like this - although we allow bitcasts, even general constant folding is avoided.

Removing it causes a number of regressions that need addressing first, but I've added a TODO for now.
2022-08-12 10:45:30 +01:00
Filipp Zhinkin 1626ee6a95 [DAGCombine] Hoist shifts out of a logic operations tree.
Hoist and combine shift operations from logic operations tree:
logic (logic (SH x0, s), y), (logic (SH x1, s), z)  --> logic (SH (logic x0, x1), s), (logic y, z)

The transformation improves code generated for some cases related to the issue https://github.com/llvm/llvm-project/issues/49541.

Correctness:
https://alive2.llvm.org/ce/z/pVqVgY
https://alive2.llvm.org/ce/z/YVvT-q
https://alive2.llvm.org/ce/z/W5zTBq
https://alive2.llvm.org/ce/z/YfJsvJ
https://alive2.llvm.org/ce/z/3YSyDM
https://alive2.llvm.org/ce/z/Bs2kzk
https://alive2.llvm.org/ce/z/EoQpzU
https://alive2.llvm.org/ce/z/Jnc_5H
https://alive2.llvm.org/ce/z/_LP6k_
https://alive2.llvm.org/ce/z/KvZNC9

Reviewed By: spatel

Differential Revision: https://reviews.llvm.org/D131189
2022-08-12 12:42:16 +03:00
Nicolas Vasilache a6bf6f25f0 [mlir][Linalg] Let FuseIntoContainingOp return success when nothing is fused.
This composes better when the op is applied in situations where it does not match.

Differential Revision: https://reviews.llvm.org/D131734
2022-08-12 02:18:31 -07:00
Michał Górny 9ba71d03b0 [lldb] [gdb-remote] Remove unimplemented ProcessIDIsValid() (NFC)
This method is not implemented and not referenced anywhere in the code.

Sponsored by: The FreeBSD Foundation
2022-08-12 11:17:15 +02:00
Matthias Springer bf1b9528ff [mlir][bufferize] Fix missing copy when bufferizing loops
Using a loop init_arg inside of the loop is not supported. This change adds a pre-processing pass that resolves such IR with copies.

Differential Revision: https://reviews.llvm.org/D131689
2022-08-12 10:44:55 +02:00
Marius Brehler f3547fd541 [mlir][emitc][nfc] Clean up tests
With https://reviews.llvm.org/D131666 the types were removed from the
EmitC opaque attributes. This cleans up the tests accordingly.
2022-08-12 08:25:31 +00:00
Alex Zinenko e8e718fa4b Revert "[mlir] Switch segment size attributes to DenseI32ArrayAttr"
This reverts commit 30171e76f0.

Breaks Python tests in MLIR, missing C API and Python changes.
2022-08-12 10:22:47 +02:00
Martin Storsjö e6db064394 [doc] Remove release notes from the main branch for changes that were backported to 15.x 2022-08-12 11:21:51 +03:00
Balázs Kéri 6e75ec5e38 [clang-tidy] Support C++14 in bugprone-signal-handler.
Check `bugprone-signal-handler` is improved to check for
C++-specific constructs in signal handlers. This check is
valid until C++17.

Reviewed By: whisperity

Differential Revision: https://reviews.llvm.org/D118996
2022-08-12 09:45:53 +02:00
Daniil Fukalov 5eeef48ed1 [NFC] Split test to reduce time to run.
The `RUN:` line with `--debug` used just two function. Moved this test out to
different file.

Reviewed By: vangthao

Differential Revision: https://reviews.llvm.org/D130920
2022-08-12 10:40:31 +03:00
Max Kazantsev a3d1fb3b59 [SCEV] Prove condition invariance via context
Contextual knowledge may be used to prove invariance of some conditions.
For example, in this case:
```
  ; %len >= 0
  guard(%iv = {start,+,1}<nuw> <s %len)
  guard(%iv = {start,+,1}<nuw> <u %len)
```
the 2nd check always fails if `start` is negative and always passes otherwise.

It looks like there are more opportunities of this kind that are still to be
implemented in the future.

Differential Revision: https://reviews.llvm.org/D129753
Reviewed By: apilipenko
2022-08-12 14:23:35 +07:00
Marius Brehler 90736babca [mlir][EmitC] Remove the type from the OpaqueAttr
This removes the type from EmitC's opaque attribute. The value provided
as a StringRefParameter can always be emitted as is. In consquence the
constant and variable ops explicitly need to opaque attributes which are
no longer typed attributes.

Co-authored-by: Simon Camphausen <simon.camphausen@iml.fraunhofer.de>

Reviewed By: Mogball, jpienaar

Differential Revision: https://reviews.llvm.org/D131666
2022-08-12 07:12:24 +00:00
Ting Wang 13c1e7a8aa [PowerPC] Fix test case changed by "Add XXEVAL TD pattern" [NFC] 2022-08-12 02:56:54 -04:00
wanglian 061f7ec9fa [LegalizeTypes][NFC] Use getConstantOperandVal instead of cast constant getvalue
Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D131642
2022-08-12 14:35:10 +08:00