459929 Commits

Author SHA1 Message Date
Teresa Johnson
bfe7205975 Restore "[MemProf] Context disambiguation cloning pass [patch 3/4]"
This reverts commit 6fbf022908c104a380fd1854fb96eafc64509366, restoring
commit bf6ff4fd4b735afffc65f92a4a79f6610e7174c3 with a fix for a bot
failure due to a previously unstable iteration order.

Differential Revision: https://reviews.llvm.org/D141077
2023-05-04 06:31:44 -07:00
Martin Braenne
c849843c3e [clang][dataflow][NFC] Eliminate unnecessary helper stripReference().
`QualType::getNonReferenceType()` does the same thing.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D149744
2023-05-04 13:14:04 +00:00
Luo, Yuanke
d9b92c4d55 [Coverity] Improper use of negtive value.
The `Iteration` value may be -1 which would cause incorrect loop count
when pass the value to buildSqrtNROneConst or buildSqrtNRTwoConst.
2023-05-04 21:11:49 +08:00
Evgenii Kudriashov
a82d27a9a6 [X86] Support llvm.{min,max}imum.f{16,32,64}
Addresses https://github.com/llvm/llvm-project/issues/53353

Reviewed By: RKSimon, pengfei

Differential Revision: https://reviews.llvm.org/D145634
2023-05-04 21:04:48 +08:00
Evgenii Kudriashov
62f1d91727 [NFC][X86] Remove cfi instructions and unused attributes from half.ll test
Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D149114
2023-05-04 21:04:48 +08:00
Florian Hahn
b85a402dd8
[VPlan] Introduce new entry block to VPlan for early SCEV expansion.
This patch adds a new preheader block the VPlan to place SCEV expansions
expansions like the trip count. This preheader block is disconnected
at the moment, as the bypass blocks of the skeleton are not yet modeled
in VPlan.

The preheader block is executed before skeleton creation, so the SCEV
expansion results can be used during skeleton creation. At the moment,
the trip count expression and induction steps are expanded in the new
preheader. The remainder of SCEV expansions will be moved gradually in
the future.

D147965 will update skeleton creation to use the steps expanded in the
pre-header to fix #58811.

Reviewed By: Ayal

Differential Revision: https://reviews.llvm.org/D147964
2023-05-04 14:00:13 +01:00
Jon Chesterfield
f19f7497ca [libc][rpc] Factor try_lock, unlock into functions on Process
Reduces line noise and localises changes needed for volta

Reviewed By: jhuber6

Differential Revision: https://reviews.llvm.org/D149845
2023-05-04 13:58:25 +01:00
Théo Degioanni
525d60bf35 [mlir][mem2reg] Add support for mem2reg in MemRef.
This patch implements the mem2reg interfaces for MemRef types. This only supports scalar memrefs of a small list of types. It would be beneficial to create more interfaces for default values before expanding support to more types. Additionally, I am working on an upcoming revision to bring SROA to MLIR that should help with non-scalar memrefs.

Reviewed By: gysit, Mogball

Differential Revision: https://reviews.llvm.org/D149441
2023-05-04 12:44:15 +00:00
Marius Brehler
9b21cb27b1 [mlir][emitc][nfc] Update ApplyOp example 2023-05-04 12:40:04 +00:00
NAKAMURA Takumi
342a3ce27e Move LLT::dump()'s impl to LowLevelType.cpp
Suggested by @jobnoorman
https://reviews.llvm.org/D148767#4317848
2023-05-04 21:29:59 +09:00
LLVM GN Syncbot
62cc657339 [gn build] Port f05ce9045af4 2023-05-04 12:14:42 +00:00
Joseph Huber
2e1c0ec629 [libc] Support global constructors and destructors on NVPTX
This patch adds the necessary hacks to support global constructors and
destructors. This is an incredibly hacky process caused by the primary
fact that Nvidia does not provide any binary tools and very little
linker support. We first had to emit references to these functions and
their priority in D149451. Then we dig them out of the module once it's
loaded to manually create the list that the linker should have made for
us. This patch also contains a few Nvidia specific hacks, but it passes
the test, albeit with a stack size warning from `ptxas` for the
callback. But this should be fine given the resource usage of a common
test.

This also adds a dependency on LLVM to the NVPTX loader, which hopefully doesn't
cause problems with our CUDA buildbot.

Depends on D149451

Reviewed By: tra

Differential Revision: https://reviews.llvm.org/D149527
2023-05-04 07:13:00 -05:00
Joseph Huber
f05ce9045a [NVPTX] Add NVPTXCtorDtorLoweringPass to handle global ctors / dtors
This patch mostly adapts the existing AMDGPUCtorDtorLoweringPass for use
by the Nvidia backend. This pass transforms the ctor / dtor list into a
kernel call that can be used to invoke those functinos. Furthermore, we
emit globals such that the names and addresses of these constructor
functions can be found by the driver. Unfortunately, since NVPTX has no
way to emit variables at a named section, nor a functioning linker to
provide the begin / end symbols, we need to mangle these names and have
an external application find them.

This work is related to the work in D149398 and D149340.

Reviewed By: tra

Differential Revision: https://reviews.llvm.org/D149451
2023-05-04 07:13:00 -05:00
Nicolai Hähnle
909095a880 AMDGPU: Precommit test showing codegen weakness
The code sequence on gfx9 has a lot of useless v_bfi instructions.

Differential Revision: https://reviews.llvm.org/D149840
2023-05-04 14:11:04 +02:00
Jon Chesterfield
3cd230e0d9 [libc][rpc] Fold can send/recv into buffer_unavailable
Left out of D149788 to simplify the diff

Reviewed By: jhuber6

Differential Revision: https://reviews.llvm.org/D149807
2023-05-04 13:09:35 +01:00
Martin Braenne
c8f81ee1da [clang-tidy] bugprone-use-after-move: Ctor arguments should be sequenced if ctor call is written as list-initialization.
See

https://timsong-cpp.github.io/cppwp/n4868/dcl.init#list-4

This eliminates a false positive in bugprone-use-after-move; this newly added
test used to be falsely classified as a use-after-move:

```
    A a;
    S3 s3{a.getInt(), std::move(a)};
```

Reviewed By: PiotrZSL

Differential Revision: https://reviews.llvm.org/D148110
2023-05-04 12:05:39 +00:00
Timm Bäder
c3f1faf96f [clang][Interp][NFC] Fix allocateLocalPrimitive parameter name
This is passed on to Program::createDescriptor, where it is used as a
value for IsConst.
2023-05-04 13:45:14 +02:00
Joseph Huber
632fa3798c [libc] Enable running libc unit tests on AMDGPU
The previous patches added the necessary support for global constructors
used to register tests. This patch enables the AMDGPU target to build
and run the unit tests on the GPU. Currently this only tests the `ctype`
tests, but adding more should be straightforward from here on.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D149517
2023-05-04 06:32:52 -05:00
Laszlo Kindrat
17faae95d7 [ADT] Introduce map_to_vector helper
The following pattern is common in the llvm codebase, as well as in downstream projects:
```
llvm::to_vector(llvm::map_range(container, lambda))
```
This patch introduces a shortcut for this called `map_to_vector`.

This template depends on both `llvm/ADT/SmallVector.h` and `llvm/ADT/STLExtras.h`, and since these are both relatively large and do not depend on each other, the `map_to_vector` helper is placed in a new header under `llvm/ADT/SmallVectorExtras.h`. Only a handful of use cases have been updated to use the new helper.

Differential Revision: https://reviews.llvm.org/D145390
2023-05-04 06:25:25 -05:00
Jacob Crawley
7c57195c49 [flang][hlfir] lower hlfir.product into fir runtime call
The shared code for lowering the sum and product operations in
flang/lib/Optimizer/HLFIR/Transforms/LowerHLFIRIntrinsics.cpp have
been moved into a new class HlfirReductionIntrinsicConverion.

Depends on: D148719

Differential Revision: https://reviews.llvm.org/D149644
2023-05-04 11:23:38 +00:00
Jacob Crawley
508d49a55c [flang] lower product intrinsic to hlfir.product operation
Carries out the initial lowering of the product intrinsic into HLFIR
following a similar method to sum, the --use-hlfir-intrinsic-ops flag
in test/Lower/HLFIR/expr-box is set to false so that the tests will
pass until hlfir.product is lowered into fir.call

Depends on: D147624

Differential Revision: https://reviews.llvm.org/D148719
2023-05-04 11:23:38 +00:00
Jacob Crawley
41b5268678 [flang] add hlfir.product operation
Adds a HLFIR operation for the PRODUCT intrinsic according to
the design set out in flang/doc/HighLevelFIR.md

Since the PRODUCT intrinsic is essentially identical to SUM
in terms of its arguments and result characteristics in the
Fortran Standard, the operation definition and subsequent
tests also take the same form.

Differential Revision: https://reviews.llvm.org/D147624
2023-05-04 11:23:37 +00:00
Donát Nagy
b88023c257 [analyzer][NFC] Use std::optional instead of custom "empty" state
This commit eliminates the uninitialized error state from the class
RegionRawOffsetV2 (which is locally used by the Clang Static Analyzer
checker alpha.security.ArrayBoundV2) and replaces its use with
std::optional.

Motivated by https://reviews.llvm.org/D148355#inline-1437928

Moreover, the code of RegionRawOffsetV2::computeOffset() is rearranged
to clarify its behavior. The helper function getValue() was eliminated
by picking a better initial value for the variable Offset; two other
helper functions were replaced by the lambda function Calc() because
this way it doesn't need to take the "context" objects as parameters.

This reorganization revealed some surprising (but not outright buggy)
behavior that's marked by a FIXME and will be revisited in a separate
commit.

Differential Revision: https://reviews.llvm.org/D149259
2023-05-04 12:56:15 +02:00
Luke Lau
d9683a70fe [RISCV] Fix extract_vector_elt on i1 at idx 0 being inverted
It looks like the intention here is to truncate a XLenVT -> i1, in
which case we should be emitting snez instead of sneq if I'm understanding
correctly.

Reviewed By: jacquesguan, frasercrmck

Differential Revision: https://reviews.llvm.org/D149732
2023-05-04 11:45:35 +01:00
Timm Bäder
eadf6db585 [docs] Hide collaboration and include graphs in doxygen docs
They don't convey any useful information and make the documentation
unnecessarily hard to read.

Differential Revision: https://reviews.llvm.org/D149641
2023-05-04 12:26:51 +02:00
Tom Weaver
8bb4943387 Revert "[DebugInfo] add test case for D147506, NFC"
This reverts commit 6a808270e8a9becc07857240ebbf6731743a4485.

This test was added after https://reviews.llvm.org/D147506 was comittted which
has been reverted pending a buildbot fix for:
https://lab.llvm.org/buildbot/#/builders/247/builds/4125
2023-05-04 11:21:21 +01:00
Mats Petersson
8cbb945165 [flang]Add test for 2D loop versioning test
Another test based on review comments added late in the review.

This one confirms that the multiplication and addition of the outer
index to the inner index and thus form the 2D index.

Reviewed By: tblah

Differential Revision: https://reviews.llvm.org/D149265
2023-05-04 11:18:29 +01:00
Tom Weaver
1d8ab713ad Revert "[DebugLine] save one debug line entry for empty prologue"
This reverts commit b48a8233f5e230e46182bf5c523ceb6a04cec8f5.

This change caused https://lab.llvm.org/buildbot/#/builders/247/builds/4125
to start failing, please address the failures before resubmitting.
2023-05-04 11:08:58 +01:00
gregrodgers
f238a98e84 [OpenMP][libomptarget][AMDGPU] Enable active HSA wait state
Adds HSA timeout hint of 2 seconds to the AMDGPU nextgen-plugin to improve
performance of small kernels.
The HSA runtime may stay in HSA_WAIT_STATE_ACTIVE for up to the timeout
value before switching to HSA_WAIT_STATE_BLOCKED. This can improve
latency from which small kernels can benefit.
The value was determined via experimentation w/ different benchmarks.

The timeout value can be overriden using the environment variable
LIBOMPTARGET_AMDGPU_STREAM_BUSYWAIT with a value in microseconds.

Original author: Greg Rodgers <Gregory.Rodgers@amd.com>
Contributions from: JP Lehr <JanPatrick.Lehr@amd.com>

Differential Revision: https://reviews.llvm.org/D148808
2023-05-04 06:01:14 -04:00
Colin Ogilvie
f3dcd3ad99 [clang-format] Correctly limit formatted ranges when specifying qualifier alignment
The qualifier alignment fixer appeared to ignore any ranges specified for limiting formatting.
This change ensures that it only formats affected lines to avoid unexpected changes.

Fixes #54888.

Differential Revision: https://reviews.llvm.org/D149643
2023-05-04 02:59:05 -07:00
Jon Chesterfield
cb7e3da054 [libc][rpc] Treat pointers as arrays consistently
Noticed in passing. Either way compiles.

Reviewed By: jhuber6

Differential Revision: https://reviews.llvm.org/D149808
2023-05-04 10:52:45 +01:00
Luke Lau
9e9bf1e3ed [RISCV] Use setcc to truncate results in widenVectorOpsToi8
To avoid an unnecessary vand.vi

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D149771
2023-05-04 10:49:27 +01:00
Alexey Lapshin
06b617064a [Support][Parallel] Change check for nested TaskGroups.
This patch changes check for nested TaskGroups so that it allows
parallel execution for TaskGroups. Following pattern would not work
parallelly with current check:

std::function<void()> Fn = [&]() {
  parallel::TaskGroup tg;

  tg.spawn([&]() { });
};

ThreadPool Pool;

Pool.async(Fn);
Pool.async(Fn);

Pool.wait();

One of the TaskGroup would work sequentially as current check
verifies overall number of TaskGroup. Two not nested
TaskGroups can work parallelly but current check prevents this.

Also this patch avoids parallel mode for TaskGroup
in parallel::strategy.ThreadsRequested == 1 case.

This patch is a followup of discussion from D142318

Differential Revision: https://reviews.llvm.org/D148984
2023-05-04 11:28:39 +02:00
Simon Pilgrim
3928589314 [DAG] computeKnownBits - remove old ashr TODO comment
KnownBits::ashr now uses the minimum shift amount to try and extend the sign bit
2023-05-04 10:26:30 +01:00
Sergio Afonso
41a1415dc3 [Flang][Driver][NFC] Improve -emit-obj unit tests
Instead of looking for the existence of a `ret` instruction after disassembly
as a way to check that the right ISA is present in the produced binary, check
instead the ELF header of the file. This is a more reliable solution, since the
alternative can easily result in false positives.

Differential Revision: https://reviews.llvm.org/D149578
2023-05-04 10:13:07 +01:00
Adrian Kuegel
f248fc375f [mlir][Bazel] Update BUILD.bazel file for cc4703745ffa398b66f985b483cb8b61eb2ed425
Differential Revision: https://reviews.llvm.org/D149823
2023-05-04 10:46:21 +02:00
Florian Hahn
79692750d2
[LV] Use VPValue for SCEV expansion in fixupIVUsers.
The step is already expanded in the VPlan. Use this expansion instead.
This is a step towards modeling fixing up IV users in VPlan.

 It also fixes a crash casued by SCEV-expanding the Step expression in
fixupIVUsers, where the IR is in an incomplete state

Reviewed By: Ayal

Differential Revision: https://reviews.llvm.org/D147963
2023-05-04 09:25:59 +01:00
Timm Bäder
d3c0165244 [clang][Interp][NFC] Remove unnecessary include from State.h
Forward-declare OptionalDiagnostic instead. And turn a few comments in
to doc comments.
2023-05-04 10:21:01 +02:00
Timm Bäder
5c9a84960d [clang][Interp][NFC] Use const references to Floating
in the static functions. Since a Floating is backed by an APFloat, we
don't want to copy that around if it's not necessary.
2023-05-04 10:03:40 +02:00
Jean Perier
9f867a3c46 [flang][hlfir] Add assignment mask operations
Add hlfir.forall_mask, hlfir.where, and hlfir.elsewhere operations that
are operations that holds (optionally for hlfir.elsewhere) the
evaluation of a logical mask that controls the evaluation of nested
operations.

They allow representing Fortran forall control mask, as well as where
and eslewhere statements/constructs.

They use the OrderedAssignmentTreeOpInterface since they can all be used
inside Forall and their masks should be fully evaluated for all the
index-value set induced by parent Forall before any of the nested
operations in their body is evaluated.

I initially tried making them into a single operation with some attributes
to make a difference, but I felt this made the verifier/parser/printer and
usages messier/tricky compared to making three distinct operations that
represent the three Fortran feature in a vanilla way.

Differential Revision: https://reviews.llvm.org/D149754
2023-05-04 10:00:36 +02:00
Jean Perier
1f2c8f6a77 [flang][hlfir] Add hlfir.forall and its OrderAssignmentTreeOpInterface
This patch adds the hlfir.forall operation and the
OrderAssignmentTreeOpInterface that allows representing Fortran forall.

It uses regions to keep Fortran expression evaluation independent from
each other in the IR. Forall assignments inside hlfir.forall are
represented with hlfir.region_assign which also keeps the IR generated
for each expressions independently.

The goal of this representation is to provide a representation that is
straightforward to generate from Fortran parse tree without any analysis, while
providing enough structure information so that an optimization pass can decide
how to schedule, and save if needed, the evaluations of the Forall and Where
expression and statements. It allows the data dependency analysis to be done at
the HLFIR level.

The OrderAssignmentTreeOpInterface allows ensuring that the Forall/Where
tree structure is kept in the IR. It will allow visiting this tree in
the IR without hard coding the operation structures in the pass.

Differential Revision: https://reviews.llvm.org/D149734
2023-05-04 09:59:05 +02:00
Mikael Holmen
a5eae04386 [FuzzMutate] Remove unused variable [NFC]
gcc warned with
 ../lib/FuzzMutate/RandomIRBuilder.cpp:319:28: warning: unused variable 'PtrTy' [-Wunused-variable]
   319 |           if (PointerType *PtrTy = dyn_cast<PointerType>(I.getType()))
       |                            ^~~~~
2023-05-04 09:58:05 +02:00
Mikael Holmen
617fc0b9fe [clangd] Remove unused variable [NFC]
gcc warned with
 ../../clang-tools-extra/clangd/Protocol.cpp:481:23: warning: unused variable 'ChangeAnnotation' [-Wunused-variable]
   481 |       if (const auto& ChangeAnnotation =
       |                       ^~~~~~~~~~~~~~~~
2023-05-04 09:58:05 +02:00
Timm Bäder
0354f31b51 [clang][Interp][NFC] Don't cast primitive types to the same type
We might classify different clang types to the same interp types, so
skip the cast in that case.

No test attached since this is already exercised a few times in the
existing tests.
2023-05-04 09:53:15 +02:00
Timm Bäder
67c9fd7a18 [clang][Interp][NFC] Make Pointer::block() const 2023-05-04 09:36:40 +02:00
Timm Bäder
6ccf3307f4 [clang][Interp] Add missing static_assert messages 2023-05-04 09:10:21 +02:00
Guillaume Chatelet
c267501c15 [libc] Use proper flags for compiler version detection
The `-v` flag means verbose and not version.
With `clang` this flag prints the version and exits successfully.
Under `GCC` this is not a valid command line so the binary exits with
an error.
2023-05-04 07:09:46 +00:00
Job Noorman
9fb5af5909 [lld][RISCV][NFC] Simplify symbol value calculation in relax
The `valueDelta` map was used to calculate the symbol value deltas from
the previous iteration. Since the symbol values themselves are also
updated every iteration, the following invariant holds:

```
sa[i].offset == sa[i].d->value + valueDelta[sa[i].d]
```

Note that `sa[i].offset` contains the original value of `sa[i].d` and is
never changed.

This means that the current way of updating symbol values can be
rewritten to not need the `valueDelta` map:

```
sa[i].d->value -= delta - valueDelta.find(sa[i].d)->second;
<=> (replace invariant)
sa[i].d->value -= delta - (sa[i].offset - sa[i].d->value);
<=>
sa[i].d->value = sa[i].d->value - (delta - (sa[i].offset - sa[i].d->value));
<=>
sa[i].d->value = sa[i].d->value - delta + sa[i].offset - sa[i].d->value;
<=>
sa[i].d->value = sa[i].offset - delta;
```

This patch implements this simplification. I believe this improves the
readability of the code as it took me quite some time to understand the
use of `valueDelta`. It might also have a slight performance benefit as
it removes one iteration over all relocations every relax iteration.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D149735
2023-05-04 09:08:52 +02:00
Timm Bäder
338c2489f6 [clang][Interp] Implement inc/dec operators for floats
Differential Revision: https://reviews.llvm.org/D149634
2023-05-04 08:52:53 +02:00
Timm Bäder
fd4c302c41 [clang][Interp][NFC] Call discard() when discarding ExprWithCleanups 2023-05-04 08:45:14 +02:00