platform/upstream/llvm.git
21 months ago[Libomptarget] Clean up CUDA plugin CMake files
Joseph Huber [Wed, 25 Jan 2023 19:39:02 +0000 (13:39 -0600)]
[Libomptarget] Clean up CUDA plugin CMake files

Clean up this file after changing it in D142568.

Depends on D142568

Reviewed By: tianshilei1992

Differential Revision: https://reviews.llvm.org/D142573

21 months ago[Libomptarget] Remove find_package(CUDA) as it has been deprecated
Joseph Huber [Wed, 25 Jan 2023 19:19:37 +0000 (13:19 -0600)]
[Libomptarget] Remove find_package(CUDA) as it has been deprecated

Since D137724 and the LLVM 17 release we have updated to CMake version
3.20. This means that `find_package(CUDA)` is officially deprecated and
can be replaced with `find_package(CUDAToolkit)` instead. This patch
does this and also cleans up a bit of the CMake.

Reviewed By: tianshilei1992

Differential Revision: https://reviews.llvm.org/D142568

21 months ago[nvptx-arch] Remove `find_package(CUDA)` as it has been deprecated.
Joseph Huber [Wed, 25 Jan 2023 19:24:34 +0000 (13:24 -0600)]
[nvptx-arch] Remove `find_package(CUDA)` as it has been deprecated.

Since D137724 and the LLVM 17 release we have updated to CMake version
3.20. This means we can use `find_package(CUDAToolkit)` instead as the
legacy module is deprecated.

Reviewed By: tianshilei1992

Differential Revision: https://reviews.llvm.org/D142570

21 months ago[GVN] Improve PRE on load instructions
Guozhi Wei [Wed, 25 Jan 2023 19:45:01 +0000 (19:45 +0000)]
[GVN] Improve PRE on load instructions

This patch implements the enhancement proposed by
https://github.com/llvm/llvm-project/issues/59312.

Suppose we have following code

   v0 = load %addr
   br %LoadBB

 LoadBB:
   v1 = load %addr
   ...

 PredBB:
   ...
   br %cond, label %LoadBB, label %SuccBB

 SuccBB:
   v2 = load %addr
   ...

Instruction v1 in LoadBB is partially redundant, edge (PredBB, LoadBB) is a
critical edge. SuccBB is another successor of PredBB, it contains another load
v2 which is identical to v1. Current GVN splits the critical edge
(PredBB, LoadBB) and inserts a new load in it. A better method is move the load
of v2 into PredBB, then v1 can be changed to a PHI instruction.

If there are two or more similar predecessors, like the test case in the bug
entry, current GVN simply gives up because otherwise it needs to split multiple
critical edges. But we can move all loads in successor blocks into predecessors.

Differential Revision: https://reviews.llvm.org/D141712

21 months ago[BOLT] Use LTO fuzzy name matching in function-order
Amir Ayupov [Wed, 25 Jan 2023 19:37:55 +0000 (11:37 -0800)]
[BOLT] Use LTO fuzzy name matching in function-order

Allow partial name matching wrt LTO suffixes in `function-order`
user-supplied function list, the same as permitted by profile matching.

Reviewed By: #bolt, rafauler

Differential Revision: https://reviews.llvm.org/D142269

21 months ago[BOLT] Emit a warning about invalid entries in function-order list
Amir Ayupov [Wed, 25 Jan 2023 19:37:42 +0000 (11:37 -0800)]
[BOLT] Emit a warning about invalid entries in function-order list

Move individual warnings under verbosity >= 1, print out a warning with
aggregate number.

Reviewed By: #bolt, rafauler

Differential Revision: https://reviews.llvm.org/D142397

21 months ago[mlir][sparse] (re)introducing getRankedTensorType/getMemrefType
wren romano [Tue, 24 Jan 2023 21:23:52 +0000 (13:23 -0800)]
[mlir][sparse] (re)introducing getRankedTensorType/getMemrefType

The bulk of D142074 seems to have gotten overwritten due to some sort of merge conflict (afaict there's no record of it having been reverted intentionally).  So this commit redoes those changes.  In addition to the original changes, this commit also:
* moves the definition of `getRankedTensorType` (from `Transforms/CodegenUtils.h` to `IR/SparseTensor.h`), so that it can be used by `IR/SparseTensorDialect.cpp`.
* adds `getMemRefType` as another abbreviation.

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D142503

21 months ago[mlir][scf] Fix typo in comment in BufferizableOpInterfaceImpl.cpp (NFC).
Ingo Müller [Wed, 25 Jan 2023 16:22:11 +0000 (16:22 +0000)]
[mlir][scf] Fix typo in comment in BufferizableOpInterfaceImpl.cpp (NFC).

Reviewed By: ingomueller-net

Differential Revision: https://reviews.llvm.org/D142554

21 months ago[lldb][test] Replace use of p with expression (NFC)
Dave Lee [Wed, 11 Jan 2023 19:37:07 +0000 (11:37 -0800)]
[lldb][test] Replace use of p with expression (NFC)

In API tests, replace use of the `p` alias with the `expression` command.

To avoid conflating tests of the alias with tests of the expression command,
this patch canonicalizes to the use `expression`.

Differential Revision: https://reviews.llvm.org/D141539

21 months ago[clang][CodeGen][NFC] Fix `llvm-else-after-return`
Michael Liao [Wed, 25 Jan 2023 15:19:44 +0000 (15:19 +0000)]
[clang][CodeGen][NFC] Fix `llvm-else-after-return`

21 months ago[mlir][tosa] Update tosa.avg_pool2d for bit-exact TOSA behavior
Rob Suderman [Wed, 25 Jan 2023 17:58:03 +0000 (17:58 +0000)]
[mlir][tosa] Update tosa.avg_pool2d for bit-exact TOSA behavior

The normalization component of average pool has a very specific
rounding behavior for compouting the division for floating
point values. Updated so that the bit-exact version is implemented.

Also includes a fix for computing the stride part of the average pool
operation.

Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D141339

21 months ago[Clang] Add sanity check in Sema::getDestructorName to prevent nullptr dereference
Shafik Yaghmour [Wed, 25 Jan 2023 18:47:21 +0000 (10:47 -0800)]
[Clang] Add sanity check in Sema::getDestructorName to prevent nullptr dereference

Currently in Sema::getDestructorName we call SS.getScopeRep()->getPrefix() but
SS.getScopeRep() can return nullptr because LookupInNestedNameSpec(...) called a
little before can invalidate SS.

This fixes: https://github.com/llvm/llvm-project/issues/59446

Differential Revision: https://reviews.llvm.org/D140598

21 months agoAMDGPU: Convert some tests to opaque pointers
Matt Arsenault [Wed, 25 Jan 2023 14:04:26 +0000 (10:04 -0400)]
AMDGPU: Convert some tests to opaque pointers

21 months agoLangRef: Fix extra spaces in udec_wrap description
Matt Arsenault [Wed, 25 Jan 2023 13:45:48 +0000 (09:45 -0400)]
LangRef: Fix extra spaces in udec_wrap description

21 months ago[llvm-c] Remove LLVMContextSetOpaquePointers
Arthur Eubanks [Tue, 6 Dec 2022 17:20:08 +0000 (09:20 -0800)]
[llvm-c] Remove LLVMContextSetOpaquePointers

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D139441

21 months agoRevert "Recommit "[SCCP] Use range info to prove AddInst has NUW flag.""
Florian Hahn [Wed, 25 Jan 2023 18:22:24 +0000 (18:22 +0000)]
Revert "Recommit "[SCCP] Use range info to prove AddInst has NUW flag.""

This reverts commit 366e1faa2fffd5b2284e25b09b6a26bcd2aca2b7.

It looks like this exposes another set of crashes on the buildbots.
Revert while I investigate.

21 months agoRecommit "[SCCP] Use range info to prove AddInst has NUW flag."
Florian Hahn [Wed, 25 Jan 2023 18:07:24 +0000 (18:07 +0000)]
Recommit "[SCCP] Use range info to prove AddInst has NUW flag."

The recommitted version fixes a crash when one of the operands is a
constant other than a ConstantInt. Test for that case have been added
in 5b16cd97b8e1c273.

It splits off the new logic into a separate function because setting the
flags is quite different compared to the other cases handled in replaceSignedInst
which all require replacing an existing instruction. Instructions are
now refined before any replacements are done, which has the advantage
that we should have lattice values for all operands (fixing the crashes
and simplifies the logic) and also allows optimizing more cases where one
of the operands also gets replaced (see improvements in
@sge_with_sext_to_zext_conversion).

It also guards makeGuaranteedNoWrapRegion by `if (!Inst.hasNoUnsignedWrap())`
as discussed in the review.

Fixes #60280.
Fixes #60278.

Original message:
    This patch updates SCCP to use the value ranges of AddInst operands to
    try to prove the AddInst does not overflow in the unsigned sense and
    adds the NUW flag. The reasoning is done with
    makeGuaranteedNoWrapRegion (thanks @nikic for point it out!).

    Follow-ups will include adding NSW and extension to more
    OverflowingBinaryOperators.

    Reviewed By: nikic

    Differential Revision: https://reviews.llvm.org/D142387

21 months ago[ScheduleDAG] Fix removing edges with weak deps
Austin Kerbow [Mon, 23 Jan 2023 05:26:08 +0000 (21:26 -0800)]
[ScheduleDAG] Fix removing edges with weak deps

In SUnit::removePred edges are removed from the Preds and Succs lists before
updating the bookkeeping. This could result in incorrect values for
NumPreds/SuccsLeft and cause WeakPreds/SuccsLeft to underflow, since the
incorrect SDep will be used to update these values.

Reviewed By: rampitec

Differential Revision: https://reviews.llvm.org/D142325

21 months agoAvoid removing useful loop metadata when stripping debug info
She Dongrui [Wed, 25 Jan 2023 17:52:48 +0000 (09:52 -0800)]
Avoid removing useful loop metadata when stripping debug info

The stripDebugLocFromLoopID() may mistakenly remove useful metadata nodes
when they are operands of a child node, which also has DILocation operands.

It can be reproduced by the output of clang for code similar to the following:

for(int i = 0; i < n; i++)
  x[i] = 10;
-strip-debug removes the child node of llvm.loop.vectorize.followup_all,
which contains llvm.loop.isvectorized and llvm.loop.unroll.count.

This patch fixes by checking all children nodes and only remove a metadata
node if all its children are DILocation.

Differential Revision: https://reviews.llvm.org/D141909

21 months ago[ASan][libcxx] Annotating std::vector with all allocators
Advenam Tacet [Wed, 25 Jan 2023 18:01:24 +0000 (19:01 +0100)]
[ASan][libcxx] Annotating std::vector with all allocators

This revision is a part of a series of patches extending
AddressSanitizer C++ container overflow detection
capabilities by adding annotations, similar to those existing
in std::vector, to std::string and std::deque collections.
These changes allow ASan to detect cases when the instrumented
program accesses memory which is internally allocated by
the collection but is still not in-use (accesses before or
after the stored elements for std::deque, or between the size and
capacity bounds for std::string).

The motivation for the research and those changes was a bug,
found by Trail of Bits, in a real code where an out-of-bounds read
could happen as two strings were compared via a std::equals function
that took iter1_begin, iter1_end, iter2_begin iterators
(with a custom comparison function).
When object iter1 was longer than iter2, read out-of-bounds on iter2
could happen. Container sanitization would detect it.

In revision D132522, support for non-aligned memory buffers (sharing
first/last granule with other objects) was added, therefore the
check for standard allocator is not necessary anymore.
This patch removes the check in std::vector annotation member
function (__annotate_contiguous_container) to support
different allocators.

If you have any questions, please email:
 - advenam.tacet@trailofbits.com
 - disconnect3d@trailofbits.com

Reviewed By: #libc, #sanitizers, philnik, vitalybuka

Spies: EricWF, philnik, #sanitizers, libcxx-commits

Differential Revision: https://reviews.llvm.org/D136765

21 months ago[libc] Implement strcasestr
Alex Brachet [Wed, 25 Jan 2023 17:58:13 +0000 (17:58 +0000)]
[libc] Implement strcasestr

Differential Revision: https://reviews.llvm.org/D142518

21 months ago[RS4GC] Remove the hardcoded GC strategy names (v2)
Campbell Suter [Wed, 25 Jan 2023 14:12:19 +0000 (17:12 +0300)]
[RS4GC] Remove the hardcoded GC strategy names (v2)

Previously, RewriteStatepointsForGC had a hardcoded list of GC
strategies for which it would run, and using it with a custom strategy
required patching LLVM.

The logic for selecting the variables that are considered managed was
also hardcoded to use pointers in address space 1, rather than
delegating to GCStrategy::isGCManagedPointer.

This patch fixes both of these flaws: this pass now applies to all
functions whose GCStrategy returns true for useStatepoints, and checking
if a pointer is managed or not is also now done by the strategy.

One potentially questionable design decision in this change: the pass will
be enabled for all GC strategies that use statepoints. It seems unlikely
this would be a problem - consumers that don't use this pass probably
aren't adding it to the pass manager anyway - but if you had two different
GC strategies and only one wants this pass enabled then that'd need a new
flag in GCStrategy, which I can add if anyone thinks it's necessary.

This is an updated version of D140458, rebased to account for LLVM's
changes since D140504 (required by this patch) landed.

Reviewed By: dantrushin

Differential Revision: https://reviews.llvm.org/D141110

21 months agoFix assertion in GCStrategy.
Denis Antrushin [Wed, 25 Jan 2023 17:17:06 +0000 (20:17 +0300)]
Fix assertion in GCStrategy.

It meant to check that `UseRS4GC` requires `UseStatepoints`.
Instead it always required `UseStatepoints` when `useRS4GC()`
was called.

21 months ago[llvm-ml] Disallow '{' and '}' at the start of a statement
Sergei Barannikov [Mon, 23 Jan 2023 13:52:20 +0000 (16:52 +0300)]
[llvm-ml] Disallow '{' and '}' at the start of a statement

'{', '}' and (conditionally) '*' were allowed at the start of a
statement. This behavior was copied from AsmParser, where they were
added to support Hexagon bundles (braces) and BFP memory instructions
(the star).
MASM dialect is x86-specific and does not allow these symbols to be
used at the beginning of an instruction.

Worth noting that '{' is a valid first character in AT&T syntax
(e.g. "{vex} vpmadd52huq ..."); MASM variant is to omit the braces.

Reviewed By: epastor

Differential Revision: https://reviews.llvm.org/D142321

21 months ago[flang] Fix element indexing in derived type default initialization
Valentin Clement [Wed, 25 Jan 2023 17:38:34 +0000 (18:38 +0100)]
[flang] Fix element indexing in derived type default initialization

Derived type default initialization was not taking the step into
consideration.

```
module dt_init
  type p1
    integer :: a
  end type
  type, extends(p1) :: p2
    integer :: b = 10
  end type
contains
  subroutine init_dt(z)
    class(p1), intent(out) :: z(:)
    select type(z)
    type is (p2)
      print*,z
    end select
  end subroutine
end module
program test
  use dt_init
  type(p2) :: t(6) = [ p2(1,2),p2(3,4),p2(5,6),p2(7,8),p2(9,10),p2(11,12) ]
  print*,t
  call init_dt(t(::2))
  print*,t
end program
```

Without the fix, the three first elements are initialized

```
 1 2 3 4 5 6 7 8 9 10 11 12
 1 10 5 10 9 10
 1 10 3 10 5 10 7 8 9 10 11 12
```

Where it should be element number 1,3,5

```
 1 2 3 4 5 6 7 8 9 10 11 12
 1 10 5 10 9 10
 1 10 3 4 5 10 7 8 9 10 11 12
```

Reviewed By: klausler

Differential Revision: https://reviews.llvm.org/D142527

21 months ago[BOLT] Use MCInstrDesc::operands() instead of OpInfo
Jay Foad [Wed, 25 Jan 2023 11:29:12 +0000 (11:29 +0000)]
[BOLT] Use MCInstrDesc::operands() instead of OpInfo

operands() is the preferred accessor since D142213. OpInfo will be
removed in D142219.

Differential Revision: https://reviews.llvm.org/D142530

21 months ago[Polly] Remove failing Polly-ACC test.
Michael Kruse [Wed, 25 Jan 2023 17:07:47 +0000 (11:07 -0600)]
[Polly] Remove failing Polly-ACC test.

The test has been failing since after last update of ISL (a749e09e).

21 months ago[LSAN] Attempt to fix the ppc64 build by excluding unsupported test
Kirill Stoimenov [Wed, 25 Jan 2023 17:04:07 +0000 (17:04 +0000)]
[LSAN] Attempt to fix the ppc64 build by excluding unsupported test

Reviewed By: kstoimenov

Differential Revision: https://reviews.llvm.org/D142561

21 months ago[AMDGPU] Make flat_offset a 32-bit operand instead of 16-bits
Mateja Marjanovic [Wed, 25 Jan 2023 15:48:56 +0000 (16:48 +0100)]
[AMDGPU] Make flat_offset a 32-bit operand instead of 16-bits

Differential Revision: https://reviews.llvm.org/D142549

21 months ago[libc] Fix warning in ExecuteFunctionUnix.cpp
Alex Brachet [Wed, 25 Jan 2023 16:49:10 +0000 (16:49 +0000)]
[libc] Fix warning in ExecuteFunctionUnix.cpp

WIFEXITED and friends expect an `int *` but these methods
were marked `const` so they instead got a `const int *`.
This macros aren't actually modifying their argument, but
we were never using these functions on an immutable
`ProcessStatus` type anyway.

21 months ago[Polly] Update ISL to isl-0.25-193-g8621c60c.
Michael Kruse [Wed, 25 Jan 2023 15:56:22 +0000 (09:56 -0600)]
[Polly] Update ISL to isl-0.25-193-g8621c60c.

The bugfix https://reviews.llvm.org/D142308 might already have been
fixed upstream.

21 months ago[libc] Templatize strstr
Alex Brachet [Wed, 25 Jan 2023 16:42:34 +0000 (16:42 +0000)]
[libc] Templatize strstr

Differential Revision: https://reviews.llvm.org/D142517

21 months ago[VPlan] Use VPDominatorTree in VPlanVerifier .
Florian Hahn [Wed, 25 Jan 2023 16:32:40 +0000 (16:32 +0000)]
[VPlan] Use VPDominatorTree in VPlanVerifier .

Use VPDominatorTree to generalize def-use verification.

Depends on D140513.

Reviewed By: Ayal

Differential Revision: https://reviews.llvm.org/D140514

21 months ago[clang][Interp][NFC] Refector OffsetHelper
Timm Bäder [Sat, 31 Dec 2022 15:44:41 +0000 (16:44 +0100)]
[clang][Interp][NFC] Refector OffsetHelper

There was a FIXME comment for this. Stop getting the values in
OffsetHelper and let the caller do that instead, so we can control
whether the value(s) are removed from the stack at all.

Also use ArithOp instead of the unclear boolean for Add.

21 months agoFix warnings
Kazu Hirata [Wed, 25 Jan 2023 16:21:29 +0000 (08:21 -0800)]
Fix warnings

This patch fixes:

  clang-tools-extra/clangd/Hover.cpp:1036:28: warning: unused variable
  ‘MTE’ [-Wunused-variable]

  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp:22295:19: error:
  unused variable 'AN' [-Werror,-Wunused-variable]

21 months ago[clang][Interp][NFC] Cast in InterpFrame::localBlock
Timm Bäder [Sat, 31 Dec 2022 11:53:02 +0000 (12:53 +0100)]
[clang][Interp][NFC] Cast in InterpFrame::localBlock

We know we save a Block* here, so do the cast there instead of
everywhere we're calling this function.

21 months ago[clang][Interp][NFCI] Remove an unnecessary DupPtr op
Timm Bäder [Sat, 31 Dec 2022 08:53:56 +0000 (09:53 +0100)]
[clang][Interp][NFCI] Remove an unnecessary DupPtr op

When initializing a primitive array, we don't need to dup the base
pointer for every element.

21 months ago[mlir] fix crash when call a function decl
Xiang Li [Wed, 25 Jan 2023 15:26:01 +0000 (10:26 -0500)]
[mlir] fix crash when call a function decl

Check region before use it.
Fixes #60215  https://github.com/llvm/llvm-project/issues/60215

Differential Revision: https://reviews.llvm.org/D142544

21 months ago[clang][Interp] Add back Run() call
Timm Bäder [Wed, 28 Dec 2022 08:34:47 +0000 (09:34 +0100)]
[clang][Interp] Add back Run() call

We need to run the functions we compiled immediately after to check if
they can ever be a constant expression.

Differential Revision: https://reviews.llvm.org/D140724

21 months ago[clang][Interp][NFC] Use InitThisField in initializers
Timm Bäder [Wed, 28 Dec 2022 08:44:21 +0000 (09:44 +0100)]
[clang][Interp][NFC] Use InitThisField in initializers

This creates fewer instructions, makes the bytecode easier to read and
InitThisField also cares about checkingPotentialConstantExpression()
cases.

21 months ago[clang][Interp][NFC] Add a helper function for local variables
Timm Bäder [Mon, 26 Dec 2022 10:49:58 +0000 (11:49 +0100)]
[clang][Interp][NFC] Add a helper function for local variables

... in EvalEmitter.

21 months ago[clang][Interp][NFC] Replace remaining dyn_cast_or_null uses
Timm Bäder [Fri, 23 Dec 2022 06:56:58 +0000 (07:56 +0100)]
[clang][Interp][NFC] Replace remaining dyn_cast_or_null uses

21 months ago[AArch64] Remove HasCrypto tablegen predicate. NFC
David Green [Wed, 25 Jan 2023 15:36:01 +0000 (15:36 +0000)]
[AArch64] Remove HasCrypto tablegen predicate. NFC

This is unused, with all relevant patterns and instructions using the
HasAES / HasSHA2 / HasSHA3 / HasSM4 predicates.

21 months ago[Clang] Make the linker wrapper test require Linux
Joseph Huber [Wed, 25 Jan 2023 15:30:51 +0000 (09:30 -0600)]
[Clang] Make the linker wrapper test require Linux

Summary:
We only support this offloading on Linux currently, and this handling of
static libraries is mostly based on Linux systems. So we should only
test those systems for now until we expland to other operating systems
in the future.

21 months ago[clang][Interp] Compound assign operators for FP values
Timm Bäder [Tue, 20 Dec 2022 09:19:56 +0000 (10:19 +0100)]
[clang][Interp] Compound assign operators for FP values

Differential Revision: https://reviews.llvm.org/D140377

21 months ago[clang][Interp][NFC] Get rid of InterpSize
Timm Bäder [Sat, 10 Dec 2022 07:15:09 +0000 (08:15 +0100)]
[clang][Interp][NFC] Get rid of InterpSize

21 months ago[clang][Interp][NFC] Remove an unused function
Timm Bäder [Wed, 7 Dec 2022 15:18:29 +0000 (16:18 +0100)]
[clang][Interp][NFC] Remove an unused function

21 months ago[AMDGCN] Fix device lib test to work with lib64
Siu Chi Chan [Tue, 24 Jan 2023 16:31:04 +0000 (11:31 -0500)]
[AMDGCN] Fix device lib test to work with lib64

This change fixes an issue introduced by
https://reviews.llvm.org/D140315.  A new unit test was added to validate
the search for the device libraries being placed in Clang's resource
directory; however, the test didn't take into account that certain
platforms use lib64 for 64-bit library directory.

Differential Revision: https://reviews.llvm.org/D142506

Change-Id: I9c31a4f08fbc383350d82d6aba01987a3ef63e51

21 months ago[mlir][LLVM] Add result attribute import support
Christian Ulmann [Wed, 25 Jan 2023 14:52:59 +0000 (15:52 +0100)]
[mlir][LLVM] Add result attribute import support

This commit introduces support for importing result attributes.

Depends on D142372

Reviewed By: gysit

Differential Revision: https://reviews.llvm.org/D142476

21 months ago[gn build] Port cb7f58221101
LLVM GN Syncbot [Wed, 25 Jan 2023 14:40:30 +0000 (14:40 +0000)]
[gn build] Port cb7f58221101

21 months agodoc: Fix typo in clang-tidy no-automatic-move doc
MarcoFalke [Wed, 25 Jan 2023 14:39:35 +0000 (15:39 +0100)]
doc: Fix typo in clang-tidy no-automatic-move doc

The latter version is called NotCool in the source code and on godbolt.

21 months agoReplace use of sprintf with snprint in SparseTensorRuntime.cpp (NFC)
Mehdi Amini [Wed, 25 Jan 2023 04:44:22 +0000 (20:44 -0800)]
Replace use of sprintf with snprint in SparseTensorRuntime.cpp (NFC)

This fixes a warning on MacOS:

warning: 'sprintf' is deprecated: This function is provided for compatibility
reasons only.  Due to security concerns inherent in the design of sprintf(3),
it is highly recommended that you use snprintf(3) instead.

21 months agoExclude running MLIR tests for Toy example Ch6 and Ch7 when JIT is unavailable
Mehdi Amini [Wed, 25 Jan 2023 04:43:38 +0000 (20:43 -0800)]
Exclude running MLIR tests for Toy example Ch6 and Ch7 when JIT is unavailable

21 months ago[ADT] FloatingPointMode.h - add missing closing namespace comment. NFC.
Simon Pilgrim [Wed, 25 Jan 2023 12:55:55 +0000 (12:55 +0000)]
[ADT] FloatingPointMode.h - add missing closing namespace comment. NFC.

Fixes clang-tidy warning

21 months ago[clang][Interp] Add empty messages to static_asserts
Timm Bäder [Wed, 25 Jan 2023 14:19:17 +0000 (15:19 +0100)]
[clang][Interp] Add empty messages to static_asserts

To satisfy builders:
https://lab.llvm.org/buildbot/#/builders/216/builds/16264

21 months ago[mlir][doc] Fix syntax for affine.dam_wait
Xiang Li [Tue, 17 Jan 2023 03:29:12 +0000 (22:29 -0500)]
[mlir][doc] Fix syntax for affine.dam_wait

Change dma_Start to dma_wait for affine.dma_wait.
Also change dma_Start to dma_start for affine.dma_start.

Differential Revision: https://reviews.llvm.org/D141887

21 months agoRe-apply "[clang][Interp] Support floating-point values"
Timm Bäder [Wed, 25 Jan 2023 13:51:16 +0000 (14:51 +0100)]
Re-apply "[clang][Interp] Support floating-point values"

Don't move the Repr struct into Integral this time.

Differential Revision: https://reviews.llvm.org/D134859

21 months ago[mlir][LLVM] Add param attr verifiers
Christian Ulmann [Wed, 25 Jan 2023 13:59:24 +0000 (14:59 +0100)]
[mlir][LLVM] Add param attr verifiers

This commit introduces unified parameter attribute verifiers to the LLVM
dialect and removes according checks in the export. As LLVM does not
verify the validity of certain attributes on return values, this commit
unifies the handling of argument and result attributes wherever possible.

Depends on D142212

Reviewed By: gysit

Differential Revision: https://reviews.llvm.org/D142372

21 months agoFix one of the regressions found in revert of concept sugaring
Erich Keane [Tue, 24 Jan 2023 20:49:24 +0000 (12:49 -0800)]
Fix one of the regressions found in revert of concept sugaring

It seems that the sugaring patches had some pretty significant
interdependencies, and at least one issue exists that requires part of
the concept-sugaring patch.  I don't believe this to have anything to do
with the increased compile-times that were seen, so hopefully this will
fix our problems without further regressions.

See https://reviews.llvm.org/rG12cb1cb3720de8d164196010123ce1a8901d8122
for discussion.

Differential Revision: https://reviews.llvm.org/D142500

21 months ago[bazel] fix for 494734b06d62b54fdcbd982f96274dede572ba07
Krasimir Georgiev [Wed, 25 Jan 2023 14:00:10 +0000 (14:00 +0000)]
[bazel] fix for 494734b06d62b54fdcbd982f96274dede572ba07

21 months ago[Flang][Debug] Use pathnames from location of functions
Kiran Chandramohan [Wed, 25 Jan 2023 13:37:54 +0000 (13:37 +0000)]
[Flang][Debug] Use pathnames from location of functions

This ensures that functions in included files have the correct path
in their file metadata.

Note: This patch also sets all locations to have the full path names.

Reviewed By: vzakhari, PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D142263

21 months agoRevert "[clang][Interp] Support floating-point values"
Timm Bäder [Wed, 25 Jan 2023 13:48:16 +0000 (14:48 +0100)]
Revert "[clang][Interp] Support floating-point values"

This reverts commit 62f43c3eae2460d4ca3da7897fd2d7c56920638c.

This breaks a couple of builders, e.g.

https://lab.llvm.org/buildbot/#/builders/139/builds/34925

21 months ago[TableGen] Speed up computeUberSets. NFC.
Jay Foad [Tue, 24 Jan 2023 11:56:09 +0000 (11:56 +0000)]
[TableGen] Speed up computeUberSets. NFC.

Differential Revision: https://reviews.llvm.org/D142472

21 months ago[MC] Remove MCInstrDesc::opInfo_begin/end, unused since D142213
Jay Foad [Wed, 25 Jan 2023 11:40:19 +0000 (11:40 +0000)]
[MC] Remove MCInstrDesc::opInfo_begin/end, unused since D142213

21 months ago[clang][Interp] Support floating-point values
Timm Bäder [Sun, 30 Oct 2022 06:28:56 +0000 (07:28 +0100)]
[clang][Interp] Support floating-point values

Add a new Floating type and a few new opcodes to support floating point
values.

Differential Revision: https://reviews.llvm.org/D134859

21 months ago[Polly] Convert some tests to opaque pointers (NFC)
Nikita Popov [Wed, 25 Jan 2023 13:22:31 +0000 (14:22 +0100)]
[Polly] Convert some tests to opaque pointers (NFC)

Convert ScopInfo tests.

21 months ago[gn build] Port a7a4463acbe1
LLVM GN Syncbot [Wed, 25 Jan 2023 13:27:16 +0000 (13:27 +0000)]
[gn build] Port a7a4463acbe1

21 months ago[LoopVectorize] Enable integer Mul and Add as select reduction patterns
Matt Devereau [Mon, 16 Jan 2023 09:20:17 +0000 (09:20 +0000)]
[LoopVectorize] Enable integer Mul and Add as select reduction patterns

This patch vectorizes Phi node loop reductions for select's whos condition
comes from a floating-point comparison, with its operands being integers
for Add, Sub, and Mul reductions.

Example:

int foo(float *x, int n) {
    int sum = 0;
    for (int i=0; i<n; ++i) {
        float elem = x[i];
        if (elem > 0) {
            sum += 2;
        }
    }
    return sum;
}

Differential Revision: https://reviews.llvm.org/D141842

21 months ago[clang][Interp] Array initialization via string literal
Timm Bäder [Sat, 5 Nov 2022 13:04:56 +0000 (14:04 +0100)]
[clang][Interp] Array initialization via string literal

Differential Revision: https://reviews.llvm.org/D137488

21 months ago[MLIR] Remove LLVM typed pointer support
Nikita Popov [Wed, 25 Jan 2023 13:15:01 +0000 (14:15 +0100)]
[MLIR] Remove LLVM typed pointer support

This breaks lowering to typed pointers, and forces import to always
use opaque pointers.

This has no effect on MLIR-level typed pointer support in the
LLVMIR dialect.

21 months ago[mlir][arith] Don't crash when folding a & ~a -> 0 on vectors
Benjamin Kramer [Wed, 25 Jan 2023 13:07:48 +0000 (14:07 +0100)]
[mlir][arith] Don't crash when folding a & ~a -> 0 on vectors

m_Constant happily accepts vector splats, so just use the generic way of
getting a zero attribute.

21 months ago[clang][Interp] Start implementing builtin functions
Timm Bäder [Sat, 5 Nov 2022 12:08:40 +0000 (13:08 +0100)]
[clang][Interp] Start implementing builtin functions

Differential Revision: https://reviews.llvm.org/D137487

21 months ago[mlir] Improve line breaks of code snippets in comments (NFC).
Ingo Müller [Wed, 25 Jan 2023 10:04:32 +0000 (10:04 +0000)]
[mlir] Improve line breaks of code snippets in comments (NFC).

Reviewed By: ingomueller-net

Differential Revision: https://reviews.llvm.org/D142528

21 months ago[clang][Interp] Specify c++ standard used in switch test
Timm Bäder [Wed, 25 Jan 2023 12:32:21 +0000 (13:32 +0100)]
[clang][Interp] Specify c++ standard used in switch test

As a follow up for 024e4f16ca795b98a5dea371cab623f851858925.

This should fix builders defaulting to pre-c++17.
E.g. https://lab.llvm.org/buildbot/#/builders/139/builds/34918

21 months ago[SVE][InstrFormats] Explcitly set hasSideEffects for all SVE instructions.
Paul Walker [Thu, 19 Jan 2023 13:45:36 +0000 (13:45 +0000)]
[SVE][InstrFormats] Explcitly set hasSideEffects for all SVE instructions.

The instruction property hasSideEffects relies on the presence of
tablegen isel patterns when constructing its value, unless
specifically overriden. Since adding SVE scheduling information
we've noticed this property flip-flop as isel patterns have been
updated. To make things consistent (and correct) this patch
explicitly sets the property for all SVE instructions.

This has resulted in the following notable changes:
* Normal load and store instructions no longer report having side
  effects.
* All prefetch instructions correctly report having side effects.
* FFR related instructions continue to report having side effects.
  This is likely overkill but I've chosen to remain cautious here.
* Most all integer instructions no longer report having side effects.
* Most all floating point instructions no longer report having side
  effects, but do now report their potential for raising FP
  exceptions. I do not know how to test the latter so I've again
  took a caution route of taging all floating point instructions
  except for DUPs.
* The conflict detection intrinsics now report they don't touch
  memory.

NOTE: SVE isel makes significant use of psuedo instructions but
this patch makes no effort to update them.

NOTE: We'll need a similar patch for SME but without a scheduling
model it'll be harder to verify the results.

Differential Revision: https://reviews.llvm.org/D142122

21 months ago[AArch64] Codegen for FEAT_LRCPC3
Tomas Matheson [Wed, 25 Jan 2023 12:03:47 +0000 (12:03 +0000)]
[AArch64] Codegen for FEAT_LRCPC3

Implements support for the following 128-bit atomic operations with +rcpc3:
 - 128-bit store-release -> STILP
 - 128-bit load-acquire -> LDIAPP

D126250 and D137590 added support for emitting LDAPR (Load-Acquire RCPc) rather
than LDAP (Load-Acquire) when +rcpc is available. This patch allows emitting
the 128-bit RCPc instructions added in FEAT_LRCPC3 (LDIAPP/STILP). The
implementation is different from LDAPR, because there are no non-RCPc
equivalents for these new instructions.

Support for the offset variants will be added in D141431.

Reviewed By: lenary

Differential Revision: https://reviews.llvm.org/D141429

21 months ago[SCCP] Add extra tests for Add flag inference.
Florian Hahn [Wed, 25 Jan 2023 12:22:56 +0000 (12:22 +0000)]
[SCCP] Add extra tests for Add flag inference.

Add extra tests from #60280 and #60278 as well as test showing missed
optimization opportunity.

21 months ago[clang][Interp] Implement switch statements
Timm Bäder [Fri, 4 Nov 2022 12:27:22 +0000 (13:27 +0100)]
[clang][Interp] Implement switch statements

Differential Revision: https://reviews.llvm.org/D137415

21 months ago[MLIR] Convert remaining tests to opaque pointers (NFC)
Nikita Popov [Wed, 25 Jan 2023 11:51:38 +0000 (12:51 +0100)]
[MLIR] Convert remaining tests to opaque pointers (NFC)

These were the final tests using -opaque-pointers=0 in mlir/.

21 months ago[AArch64] Codegen for FEAT_LSE128
Tomas Matheson [Wed, 25 Jan 2023 11:59:10 +0000 (11:59 +0000)]
[AArch64] Codegen for FEAT_LSE128

Codegen support for 128-bit atomicrmw (and|or|xchg).
      - store atomic -> swpp
      - atomicrmw xchg -> swpp
      - atomicrmw and -> ldclrp
      - atomicrmw or -> ldsetp

Reviewed By: lenary

Differential Revision: https://reviews.llvm.org/D141406

21 months ago[clang][Interp] Reject invalid declarations and expressions
Timm Bäder [Fri, 4 Nov 2022 04:58:59 +0000 (05:58 +0100)]
[clang][Interp] Reject invalid declarations and expressions

Reject them early, since we will run into problems and/or assertions
later on anyway.

Differential Revision: https://reviews.llvm.org/D137386

21 months ago[Support] Avoid using main thread for llvm::parallelFor().
Alexey Lapshin [Tue, 24 Jan 2023 13:05:43 +0000 (14:05 +0100)]
[Support] Avoid using main thread for llvm::parallelFor().

The llvm::parallelFor() uses threads created by ThreadPoolExecutor as well as main thread.
The index for the main thread matches with the index for the first thread created by ThreadPoolExecutor.
It results in that getThreadIndex returns the same value for different threads.
To avoid thread index clashing - do not use main thread for llvm::parallelFor():

parallel::TaskGroup TG;
for (; Begin + TaskSize < End; Begin += TaskSize) {
  TG.spawn([=, &Fn] {
    for (size_t I = Begin, E = Begin + TaskSize; I != E; ++I)
      Fn(I);
  });
}
for (; Begin != End; ++Begin)    <<<< executed by main thread.
  Fn(Begin);                     <<<<
return;                          <<<<

Differential Revision: https://reviews.llvm.org/D142317

21 months ago[LTO] Remove OpaquePointers option from config (NFC)
Nikita Popov [Wed, 25 Jan 2023 11:37:56 +0000 (12:37 +0100)]
[LTO] Remove OpaquePointers option from config (NFC)

Always use opaque pointers.

21 months ago[AArch64][SME2] Add intrinsics to move multi-vectors to/from ZA.
Kerry McLaughlin [Wed, 25 Jan 2023 10:56:18 +0000 (10:56 +0000)]
[AArch64][SME2] Add intrinsics to move multi-vectors to/from ZA.

Adds intrinsics for the following:
 - mova: array to vector / vector to array
 - mova: tile to vector / vector to tile

Tablegen patterns have been added to match the ZA write intrinsics. As the
read intrinsics return a multi-vector, a function called SelectMultiVectorMove
has been added to AArch64ISelDAGToDAG to select the correct instruction. The
SelectSMETile function has also been added to check that the tile number
passed to read intrinsics is valid for the base register.

This patch also cleans up the sme_vector_to_tile_patterns multiclass to remove
the pattern for an offset of 0, which is handled by tileslice.

NOTE: These intrinsics are still in development and are subject to future changes.

Reviewed By: david-arm

Differential Revision: https://reviews.llvm.org/D142031

21 months ago[clang][Interp] Fix ImplicitValueInitExprs for pointer types
Timm Bäder [Wed, 2 Nov 2022 09:28:21 +0000 (10:28 +0100)]
[clang][Interp] Fix ImplicitValueInitExprs for pointer types

This previously ran into an "unknown type" assertion when trying to emit
a 'Zero' op for a pointer type. Emit a NullPtr op instead.

Differential Revision: https://reviews.llvm.org/D137235

21 months ago[LLD] Remove no-opaque-pointers plugin option
Nikita Popov [Wed, 25 Jan 2023 11:29:59 +0000 (12:29 +0100)]
[LLD] Remove no-opaque-pointers plugin option

We always use opaque pointers. The opaque-pointers option is
retained as a no-op, same as no-lto-legacy-pass-manager.

21 months ago[gold] Remove no-opaque-pointers option
Nikita Popov [Wed, 25 Jan 2023 11:26:57 +0000 (12:26 +0100)]
[gold] Remove no-opaque-pointers option

The opaque-pointers option is retained as a no-op, same as with
new-pass-manager.

21 months ago[LTO] Remove -lto-opaque-pointers flag
Nikita Popov [Wed, 25 Jan 2023 11:04:51 +0000 (12:04 +0100)]
[LTO] Remove -lto-opaque-pointers flag

Always use the config default of OpaquePointers == true.

21 months ago[clang][Interp] Support inc/dec operators for pointers
Timm Bäder [Wed, 2 Nov 2022 08:09:23 +0000 (09:09 +0100)]
[clang][Interp] Support inc/dec operators for pointers

Differential Revision: https://reviews.llvm.org/D137232

21 months ago[X86] Ensure the _mm_test_all_ones macro does not reuse argument (PR60006)
Simon Pilgrim [Wed, 25 Jan 2023 10:55:56 +0000 (10:55 +0000)]
[X86] Ensure the _mm_test_all_ones macro does not reuse argument (PR60006)

The macro _mm_test_all_ones(V) was defined as _mm_testc_si128((V), _mm_cmpeq_epi32((V), (V))) - which could cause side effects depending on the source of the V value.

The _mm_cmpeq_epi32((V), (V)) trick was just to materialize an all-ones value, which can be more safely generated with _mm_set1_epi32(-1) .

Fixes #60006

Differential Revision: https://reviews.llvm.org/D142477

21 months ago[AArch64][SME2] Add Multi-vector add/sub and accumulate into ZA intrinsic
Caroline Concatto [Wed, 25 Jan 2023 09:29:48 +0000 (09:29 +0000)]
[AArch64][SME2] Add Multi-vector add/sub and accumulate into ZA intrinsic

Add the following intrinsic:
    ADD
    SUB
    FADD
    FSUB
NOTE: These intrinsics are still in development and are subject to future changes.

Reviewed By: kmclaughlin

Differential Revision: https://reviews.llvm.org/D142210

21 months ago[NFC][WebAssembly] More fpclamptosat tests
Samuel Parker [Wed, 25 Jan 2023 10:19:51 +0000 (10:19 +0000)]
[NFC][WebAssembly] More fpclamptosat tests

21 months ago[clang][Interp] Fix dereferencing arrays with no offset applied
Timm Bäder [Mon, 31 Oct 2022 14:48:15 +0000 (15:48 +0100)]
[clang][Interp] Fix dereferencing arrays with no offset applied

A pointer to an array and a pointer to the first element of the array
are not the same in the interpreter, so handle this specially in
deref().

Differential Revision: https://reviews.llvm.org/D137082

21 months ago[InstCombine] Add additional tests for dead phi cycles (NFC)
Nikita Popov [Wed, 25 Jan 2023 09:46:43 +0000 (10:46 +0100)]
[InstCombine] Add additional tests for dead phi cycles (NFC)

21 months ago[flang][hlfir] Add hlfir.copy_in and hlfir.copy_out codegen to FIR.
Jean Perier [Wed, 25 Jan 2023 08:54:50 +0000 (09:54 +0100)]
[flang][hlfir] Add hlfir.copy_in and hlfir.copy_out codegen to FIR.

Use runtime Assign to deal with the copy (and the temporary creation, so
that this code can deal with polymorphic temps without any change).

Using Assign for the copy is desired here since the copy happens when
the data is not contiguous, and it happens inside an if/then which
makes it hard to optimize.
See https://github.com/llvm/llvm-project/commit/2b60ed405b8110b20ab2e383839759ea34003127
for more details (note that, contrary to this last commit, the code at
hand is only dealing with copy-in/copy-out, it is not intended to deal
with preparing VALUE arguments).

Differential Revision: https://reviews.llvm.org/D142475

21 months ago[AArch64][SME2] Add the IR intrinsics for SME2 fclamp, sclamp and uclamp instructions
David Sherwood [Mon, 23 Jan 2023 13:38:53 +0000 (13:38 +0000)]
[AArch64][SME2] Add the IR intrinsics for SME2 fclamp, sclamp and uclamp instructions

Adds intrinsics for the following SME2 instructions:

* fclamp (2 and 4 vectors)
* sclamp (2 and 4 vectors)
* uclamp (2 and 4 vectors)

I've added these new instructions to the existing sve2p1-* tests
because although they are included as part of SME2 they are still
SVE-like, in that they only operate on SVE vectors.

NOTE: These intrinsics are still in development and are subject to future changes.

Differential Revision: https://reviews.llvm.org/D142355

21 months ago[clang][Interp] Re-apply "Implement missing compound assign operators"
Timm Bäder [Mon, 31 Oct 2022 11:44:38 +0000 (12:44 +0100)]
[clang][Interp] Re-apply "Implement missing compound assign operators"

Implement mul, div, rem, etc. compound assign operators.

Differential Revision: https://reviews.llvm.org/D137071

21 months ago[clang][Interp] Fix compound assign operator types
Timm Bäder [Sun, 22 Jan 2023 20:09:35 +0000 (21:09 +0100)]
[clang][Interp] Fix compound assign operator types

Just like we do (or will do) for floating types, we need to take into
acocunt that the LHSComputationType, ResultType and type of the
expression (what we ultimately store) might be different.

Do this by emitting cast ops before and after doing the computation.

This fixes the test failures introduced by
490e8214fca48824beda8b508d6d6bbbf3d8d9a7 on big endian machines.

Differential Revision: https://reviews.llvm.org/D142328

21 months agoUpdateTestChecks: cleanup NamelessValues constructor
Nicolai Hähnle [Tue, 17 Jan 2023 15:18:32 +0000 (16:18 +0100)]
UpdateTestChecks: cleanup NamelessValues constructor

Remove global_ir_{prefix,prefix_regexp} (one of which is misnamed),
since they are really quite redundant with ir_{prefix,regexp} and
default the is_before_functions argument, which basically just adds
noise to the table of NamelessValues.

Differential Revision: https://reviews.llvm.org/D142451

21 months agoupdate_test_checks.py: pick up --tool from UTC_ARGS
Nicolai Hähnle [Mon, 23 Jan 2023 09:38:53 +0000 (10:38 +0100)]
update_test_checks.py: pick up --tool from UTC_ARGS

It's not clear to me how to write a test for this. The tests run in an
environment where the tools may not be in PATH, and so the existing
custom-tool.test needs to use --tool-binary when invoking
update_test_checks.py. But it can't do so without also using --tool.

This change does fix a problem though with using
update_any_test_checks.py in an environment where the tools *are*
available in PATH.

Differential Revision: https://reviews.llvm.org/D142450