Commit Graph

430697 Commits

Author SHA1 Message Date
Shubham Narlawar f55dbfbd9d [AArch64] Move SeparateConstOffsetFromGEPPass before LSR and enable EnableGEPOpt by default.
GEP's across basic blocks were not getting splitted due to EnableGEPOpt
which was turned off by default. Hence, EarlyCSE missed the opportunity
to eliminate common part of GEP's. This can be achieved by simply
turning GEP pass on.
 - This patch moves SeparateConstOffsetFromGEPPass() just before LSR.
 - It enables EnableGEPOpt by default.

Resolves - https://github.com/llvm/llvm-project/issues/50528

Added an unit test.

Differential Revision: https://reviews.llvm.org/D128582
2022-07-22 15:20:53 +01:00
Jacques Pienaar 1b7feac2a6 [mlir][tosa] Split canonicalization and folders out of TosaOps.
Scope ops file to ops. Used canonicalization as grouping for canonicalization
patterns and folders (also considered OpTransforms but that felt too generic
and the former two are used together).

Reviewed By: silvas, rsuderman

Differential Revision: https://reviews.llvm.org/D130297
2022-07-22 07:20:25 -07:00
Sam Estep 32dcb759c3 [clang][dataflow] Move NoopAnalysis from unittests to include
This patch moves `Analysis/FlowSensitive/NoopAnalysis.h` from `clang/unittests/` to `clang/include/clang/`, so that we can use it for doing context-sensitive analysis.

Reviewed By: ymandel, gribozavr2, sgatev

Differential Revision: https://reviews.llvm.org/D130304
2022-07-22 14:11:32 +00:00
Nikita Popov c2be703c6c [AsmPrinter] Move lowerConstant() error code out of switch (NFC)
Move this out of the switch, so that different branches can
indicate an error by breaking out of the switch. This becomes
important if there are more than the two current error cases.
2022-07-22 16:08:28 +02:00
Tue Ly d883a4ad02 [libc] Implement sinf function that is correctly rounded to all rounding modes.
Implement sinf function that is correctly rounded to all rounding modes.

- We use a simple range reduction for `pi/16 < |x|` :
    Let `k = round(x / pi)` and `y = (x/pi) - k`.
    So `k` is an integer and `-0.5 <= y <= 0.5`.
Then
```
sin(x) = sin(y*pi + k*pi)
          = (-1)^(k & 1) * sin(y*pi)
          ~ (-1)^(k & 1) * y * P(y^2)
```
    where `y*P(y^2)` is a degree-15 minimax polynomial generated by Sollya with:
```
> P = fpminimax(sin(x*pi)/x, [|0, 2, 4, 6, 8, 10, 12, 14|], [|D...|], [0, 0.5]);
```

- Performance benchmark using perf tool from CORE-MATH project
(https://gitlab.inria.fr/core-math/core-math/-/tree/master) on Ryzen 1700:
Before this patch (not correctly rounded):
```
$ CORE_MATH_PERF_MODE="rdtsc" ./perf.sh sinf
CORE-MATH reciprocal throughput   : 17.892
System LIBC reciprocal throughput : 25.559
LIBC reciprocal throughput        : 29.381
```
After this patch (correctly rounded):
```
$ CORE_MATH_PERF_MODE="rdtsc" ./perf.sh sinf
CORE-MATH reciprocal throughput   : 17.896
System LIBC reciprocal throughput : 25.740

LIBC reciprocal throughput        : 27.872
LIBC reciprocal throughput        : 20.012     (with `-msse4.2` flag)
LIBC reciprocal throughput        : 14.244     (with `-mfma` flag)
```

Reviewed By: zimmermann6

Differential Revision: https://reviews.llvm.org/D123154
2022-07-22 10:07:31 -04:00
zhijian 4f2cfbe531 [llvm-ar] Add object mode option -X for AIX
Summary:

1. Added a new option object mode -X for llvm-ar. In AIX OS , there is a object mode option -X for ar command.
please see the "-X mode" part of https://www.ibm.com/docs/ko/aix/7.1?topic=ar-command

Specifies the type of object file ar should examine. The mode must be one of the following:
32
Processes only 32-bit object files
64
Processes only 64-bit object files
32_64
Processes both 32-bit and 64-bit object files
any
Processes all of the supported object files.

The default is to process 32-bit object files (ignore 64-bit objects). The mode can also be set with the OBJECT_MODE environment variable. For example, OBJECT_MODE=64 causes ar to process any 64-bit objects and ignore 32-bit objects. The -X flag overrides the OBJECT_MODE variable.

2. Before adding the new option -X, the default behaviors of llvm-ar like -Xany, but after the adding the new option -X, the default behaviors of llvm-ar change to -X32 ,in order to let some test cases which has 32bit and 64bit object file in the same llvm-ar command, we need to add the "export OBJECT_MODE=any" into test case to change the default behaviors of llvm-ar's object mode.

Reviewers: James Henderson, Owen Reynolds, Fangrui Song
Differential Revision: https://reviews.llvm.org/D127864
2022-07-22 09:55:21 -04:00
Joseph Huber a3804a3145 [Libomptarget] Make the plugins link as LLVM libraries
Previously we made `libomptarget` link as an LLVM library so we have
access to the LLVM core libraries. After the initial patch stuck we can
now apply the same changes to the plugins. This will allow us to use
LLVM in all of `libomptarget` when we have uses for them. In the future
this should allow us to remove the dependencies on `libelf`, `libffi`,
and `dl`.

Reviewed By: JonChesterfield

Differential Revision: https://reviews.llvm.org/D130262
2022-07-22 09:34:12 -04:00
Egor Zhdan 1d0cc51051 [Clang][Driver] Fix include paths for `--sysroot /` on OpenBSD/FreeBSD
This is the same change as https://reviews.llvm.org/D126289, but applied for OpenBSD & FreeBSD.

Differential Revision: https://reviews.llvm.org/D129654
2022-07-22 14:30:32 +01:00
Tue Ly ed261e7106 [libc] Add float type and flag for nearest_integer to enable SSE4.2.
Add float type and flag for nearest integer to automatically test with
and without SSE4.2 flag.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D129916
2022-07-22 09:29:41 -04:00
Kiran Chandramohan 06dbcf7b2b [MLIR][OpenMP] Add a constraint to the Threadprivate Op
Add a constraint to ensure that the operand and result of the
threadprivate operation are the same.

Reviewed By: peixin

Differential Revision: https://reviews.llvm.org/D128609
2022-07-22 13:12:24 +00:00
Kiran Chandramohan 4ee9f3d59e [MLIR,OpenMP] : Add Conversion pattern for Critical Op
The Conversion pattern enables conversion of Critical Op with block
arguments.

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

Reviewed By: shraiysh

Differential Revision: https://reviews.llvm.org/D130343
2022-07-22 12:57:48 +00:00
Nikita Popov 5ab077f911 [LangRef] Update opaque pointers status (NFC)
Opaque pointers support is complete and default. Specify ptr as
the normal pointer type and i8* as something supported under
non-default options.

A larger update of examples in LangRef is still needed.
2022-07-22 14:47:31 +02:00
Kadir Cetinkaya 4839929bed
[clangd] Make forwarding parameter detection logic resilient
This could crash when our heuristic picks the wrong function. Make sure
there is enough parameters in the candidate to prevent those crashes.

Also special case copy/move constructors to make the heuristic work in
presence of those.

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

Differential Revision: https://reviews.llvm.org/D130260
2022-07-22 14:37:13 +02:00
Louis Dionne deb3b5552f [libc++] Take advantage of -fexperimental-library in libc++
When -fexperimental-library is passed, libc++ will now pick up the
appropriate __has_feature flag defined by Clang to enable the
experimental library features.

As a fly-by, also update the documentation for the various TSes.

Differential Revision: https://reviews.llvm.org/D130176
2022-07-22 08:33:39 -04:00
Louis Dionne 07e984bc52 [libc++] Support int8_t and uint8_t in integer distributions as an extension
In D125283, we ensured that integer distributions would not compile when
used with arbitrary unsupported types. This effectively enforced what
the Standard mentions here: http://eel.is/c++draft/rand#req.genl-1.5.

However, this also had the effect of breaking some users that were
using integer distributions with unsupported types like int8_t. Since we
already support using __int128_t in those distributions, it is reasonable
to also support smaller types like int8_t and its unsigned variant. This
commit implements that, adds tests and documents the extension. Note that
we voluntarily don't add support for instantiating these distributions
with bool and char, since those are not integer types. However, it is
trivial to replace uses of these random distributions on char using int8_t.

It is also interesting to note that in the process of adding tests
for smaller types, I discovered that our distributions sometimes don't
provide as faithful a distribution when instantiated with smaller types,
so I had to relax a couple of tests. In particular, we do a really bad
job at implementing the negative binomial, geometric and poisson distributions
for small types. I think this all boils down to the algorithm we use in
std::poisson_distribution, however I am running out of time to investigate
that and changing the algorithm would be an ABI break (which might be
reasonable).

As part of this patch, I also added a mitigation for a very likely
integer overflow bug we were hitting in our tests in negative_binomial_distribution.
I also filed http://llvm.org/PR56656 to track fixing the problematic
distributions with int8_t and uint8_t.

Supersedes D125283.

Differential Revision: https://reviews.llvm.org/D126823
2022-07-22 08:33:01 -04:00
Joseph Huber 908054df4f [Libomptarget] Only export needed definitions in the BC library
This patch adds the use of the `-internalize-public-api-file` option in
the internalization pass to internalize any definition that isn't
explicitly needed for the interface. This will allow us to perform more
optimizations on the file that normally would not have been possible
with functions internal to the library not being internal.

Depends on D130293

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D130298
2022-07-22 08:24:35 -04:00
Joseph Huber 3d0ab8638b [Internalize] Support glob patterns for API lists
The internalize pass supports an option to provide a list of symbols
that should not be internalized. THis is useful retaining certain
defintions that should be kept alive. However, this interface is
somewhat difficult to use as it requires knowing every single symbol's
name and specifying it. Many APIs provide common prefixes for the
symbols exported by the library, so it would make sense to be able to
match these using a simple glob pattern. This patch changes the handling
from a simple string comparison to a glob pattern match.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D130319
2022-07-22 08:24:32 -04:00
Joseph Huber e82e07d74a [Libomptarget] Build the DeviceRTL BC using clang directly
Currently the bitcode library is build using the clang front-end
manually. This was originally done because we did not support device
only compilation. Now we support device only compilation, at least for a
single offloading toolchain, so we can instead use clang directly rather
than using the front-end. This saves us needing to define things like
`aux_triple`.

Reviewed By: tianshilei1992

Differential Revision: https://reviews.llvm.org/D130293
2022-07-22 08:24:29 -04:00
Nikita Popov 5102084787 [Docs] Add release notes for opaque pointers (NFC) 2022-07-22 14:14:03 +02:00
Ron Lieberman 45a379ce2f Revert "[Libomptarget] Stop testing CPU offloading with LTO"
This reverts commit 3e8d46921f.
2022-07-22 12:10:06 +00:00
Matthias Springer 0eb0dfb20b [mlir][linalg] Add tile-and-fuse with transform dialect example
Differential Revision: https://reviews.llvm.org/D130346
2022-07-22 13:55:18 +02:00
Matthias Springer 32c6e0815a [mlir][linalg] Add attribute matcher to structured.match transform op
This is useful for building small test cases and will be utilized in a subsequent commit that adds a fusion example.

Differential Revision: https://reviews.llvm.org/D130344
2022-07-22 13:55:12 +02:00
Matthias Springer bc882ed21f [mlir][linalg][transform] Add fuse_into_containing op
This op fuses a given payload op into a given container op. Inside the container, all uses of the producer are replaced (fused) with the newly inserted op. If the producer is tileable and accessed via a tensor.extract_slice, the new op computes only the requested slice ("tile and fuse"). Otherwise, the entire tensor value is computed inside the container ("clone and fuse").

Differential Revision: https://reviews.llvm.org/D130244
2022-07-22 13:55:04 +02:00
Zhouyi Zhou 934d603826
[clang-tidy][NFC] Add preposition "of" to code annotation of ElseAfterReturnCheck
Reviewed By: njames93

Differential Revision: https://reviews.llvm.org/D129953
2022-07-22 12:40:08 +01:00
Jay Foad 798fa7e9d6 [AMDGPU] Add a test where regClassPriorityTrumpsGlobalness uses more vgprs 2022-07-22 12:08:47 +01:00
Ivan Butygin 917e4519bc [mlir][arith] cmpi: move constant to the right side
Convert arith.cmpi to the canonical form with constants on the right side
to simplify further optimizations and open more opportunities for CSE.


Differential Revision: https://reviews.llvm.org/D129929
2022-07-22 12:39:17 +02:00
Petar Avramovic 8de1f04c77 [AMDGPU] gfx11 Fix VOP3 dot instructions
Fix src modifiers for operands with bf16 type.
op_sel[0:1] are ignored.

Differential Revision: https://reviews.llvm.org/D129084
2022-07-22 11:43:35 +02:00
Ivan Butygin f46744bd2a [mlir][linalg] Fix FoldTensorCastConsumerOp invalid folding
CastOp can be in conditionally reachable region, in which case this folding will be invalid.
Only conservatively fold ops in same block for now.

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

Differential Revision: https://reviews.llvm.org/D130314
2022-07-22 11:39:12 +02:00
David Spickett 1ac12a5177 [lldb][ARM] Invert emulation test assert message
Previously you got:
AssertionError: False is not True : Emulation test succeeded.

Which is a bit of a head scratcher. The message is used when
the test fails, not when it succeeds.
2022-07-22 09:35:30 +00:00
Nathan James 251b5b8641
[ASTMatchers] Fix standalone build
Disable the tests and remove private include introduced in d89f9e963e.
2022-07-22 10:32:49 +01:00
Hui Xie c559964d85 [libc++][ranges] implement `std::ranges::includes`
implement `std::ranges::includes` and delegate to `std::includes`

Differential Revision: https://reviews.llvm.org/D130116
2022-07-22 10:27:48 +01:00
Hui Xie 0f6364b8a1 [libc++][ranges] implement `std::ranges::equal_range`
implement `std::ranges::equal_range` which delegates to
`std::equal_range`

Differential Revision: https://reviews.llvm.org/D129796
2022-07-22 10:24:08 +01:00
Andy Yankovsky 5c39c31a99 [lldb] Handle jumping to the end in DW_OP_skip/DW_OP_bra
DW_OP_skip/DW_OP_bra can move offset to the end of the data, which means that this was the last instruction to execute and the interpreter should terminate.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D130285
2022-07-22 09:22:40 +00:00
Benjamin Kramer 35b80c448b Don't write to source directory in test 2022-07-22 11:14:26 +02:00
Chuanqi Xu 6d9b84797c [C++20] [Modules] Handle reachability for partial specialization
Previously we don't catch the reachability for partial specialization.
Handle them in this patch.
2022-07-22 17:03:38 +08:00
Sebastian Neubauer f359eac5df [CMake][Clang] Copy folder without permissions
Copying the folder keeps the original permissions by default. This
creates problems when the source folder is read-only, e.g. in a
packaging environment.
Then, the copied folder in the build directory is read-only as well.
Later on, with configure_file, ClangConfig.cmake is copied into that
directory (in the build tree), failing when the directory is read-only.

Fix that problem by copying the folder without keeping the original
permissions.

Differential Revision: https://reviews.llvm.org/D130254
2022-07-22 10:38:54 +02:00
Sam McCall d9d554a3f4 [pseudo] Add ambiguity & unparseability metrics to -print-statistics
These can be used to quantify parsing improvements from a change.

Differential Revision: https://reviews.llvm.org/D130199
2022-07-22 10:35:06 +02:00
Benjamin Kramer fc99f18a20 [Symbolizer] Fix use-after-free
MarkupFilter keeps a reference to the last filtered StringRef. Just keep
it alive a bit longer. Found by asan.
2022-07-22 10:29:04 +02:00
Fangrui Song 242316bc27 [ELF] Simplify createObjectFile/createLazyFile. NFC
And avoid redundant identify_magic test.
2022-07-22 01:26:12 -07:00
Kazu Hirata 70257fab68 Use any_of (NFC) 2022-07-22 01:05:17 -07:00
Cullen Rhodes bf268a05cd [AArch64] Emit vector FP cmp when LE is used with fast-math
Reviewed By: paulwalker-arm

Differential Revision: https://reviews.llvm.org/D130093
2022-07-22 07:53:55 +00:00
Cullen Rhodes a8de8cab70 [AArch64] Add fcmp fast math tests
Reviewed By: paulwalker-arm

Differential Revision: https://reviews.llvm.org/D130094
2022-07-22 07:53:55 +00:00
Nikita Popov 533706c969 [InstCombine] Slightly extend alloc optimization test (NFC)
Also test realloc, and dead writes to the allocation.
2022-07-22 09:43:08 +02:00
Iain Sandoe afda39a566 re-land [C++20][Modules] Build module static initializers per P1874R1.
The re-land fixes module map module dependencies seen on Greendragon, but
not in the clang test suite.

---

Currently we only implement this for the Itanium ABI since the correct
mangling for the initializers in other ABIs is not yet known.

Intended result:

For a module interface [which includes partition interface and implementation
units] (instead of the generic CXX initializer) we emit a module init that:

 - wraps the contained initializations in a control variable to ensure that
   the inits only happen once, even if a module is imported many times by
   imports of the main unit.

 - calls module initializers for imported modules first.  Note that the
   order of module import is not significant, and therefore neither is the
   order of imported module initializers.

 - We then call initializers for the Global Module Fragment (if present)
 - We then call initializers for the current module.
 - We then call initializers for the Private Module Fragment (if present)

For a module implementation unit, or a non-module TU that imports at least one
module we emit a regular CXX init that:

 - Calls the initializers for any imported modules first.
 - Then proceeds as normal with remaining inits.

For all module unit kinds we include a global constructor entry, this allows
for the (in most cases unusual) possibility that a module object could be
included in a final binary without a specific call to its initializer.

Implementation:

 - We provide the module pointer in the AST Context so that CodeGen can act
   on it and its sub-modules.

 - We need to account for module build lines like this:
  ` clang -cc1 -std=c++20 Foo.pcm -emit-obj -o Foo.o` or
  ` clang -cc1 -std=c++20 -xc++-module Foo.cpp -emit-obj -o Foo.o`

 - in order to do this, we add to ParseAST to set the module pointer in
   the ASTContext, once we establish that this is a module build and we
   know the module pointer. To be able to do this, we make the query for
   current module public in Sema.

 - In CodeGen, we determine if the current build requires a CXX20-style module
   init and, if so, we defer any module initializers during the "Eagerly
   Emitted" phase.

 - We then walk the module initializers at the end of the TU but before
   emitting deferred inits (which adds any hidden and static ones, fixing
   https://github.com/llvm/llvm-project/issues/51873 ).

 - We then proceed to emit the deferred inits and continue to emit the CXX
   init function.

Differential Revision: https://reviews.llvm.org/D126189
2022-07-22 08:38:07 +01:00
Haojian Wu 2a88fb2ecb [pseudo] Eliminate the dangling-else syntax ambiguity.
- the grammar ambiguity is eliminated by a guard;
- modify the guard function signatures, now all parameters are folded in
  to a single object, avoid a long parameter list (as we will add more
  parameters in the near future);

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D130160
2022-07-22 09:13:09 +02:00
LLVM GN Syncbot 9daf945367 [gn build] Port 8184b252cd 2022-07-22 07:02:59 +00:00
Michael Buch 8184b252cd [LLDB][ClangExpression] Allow expression evaluation from within C++ Lambdas
This patch adds support for evaluating expressions which reference
a captured `this` from within the context of a C++ lambda expression.
Currently LLDB doesn't provide Clang with enough information to
determine that we're inside a lambda expression and are allowed to
access variables on a captured `this`; instead Clang simply fails
to parse the expression.

There are two problems to solve here:
1. Make sure `clang::Sema` doesn't reject the expression due to an
illegal member access.
2. Materialize all the captured variables/member variables required
to evaluate the expression.

To address (1), we currently import the outer structure's AST context
onto `$__lldb_class`, making the `contextClass` and the `NamingClass`
match, a requirement by `clang::Sema::BuildPossibleImplicitMemberExpr`.

To address (2), we inject all captured variables as locals into the
expression source code.

**Testing**

* Added API test
2022-07-22 08:02:09 +01:00
Michael Buch 317c8bf84d [LLDB][Expression] Allow instantiation of IR Entity from ValueObject
This is required in preparation for the follow-up patch which adds
support for evaluating expressions from within C++ lambdas. In such
cases we need to materialize variables which are not part of the
current frame but instead are ivars on a 'this' pointer of the current
frame.
2022-07-22 08:02:08 +01:00
Michael Buch fcf4e252f4 [LLDB][NFC] Create variable for hardcoded alignment/size constants in materializer 2022-07-22 08:02:07 +01:00
Haojian Wu 18cee95919 [pseudo] Tweak the cli option messages, NFC. 2022-07-22 08:53:24 +02:00