platform/upstream/llvm.git
2 years ago[Support] Remove unused LLVM_PTR_SIZE macro
Nikita Popov [Wed, 20 Apr 2022 10:25:41 +0000 (12:25 +0200)]
[Support] Remove unused LLVM_PTR_SIZE macro

This was used for LLVM_ALIGNAS() arguments in the past, but has
since been superseded by plain alignas() which also accepts a type.

2 years ago[Support] Remove LLVM_ATTRIBUTE_DEPRECATED
Nikita Popov [Wed, 20 Apr 2022 10:16:41 +0000 (12:16 +0200)]
[Support] Remove LLVM_ATTRIBUTE_DEPRECATED

The guidance since D94219 is to use [[deprecated]] directly. Now
that all historical uses of the macro have been removed, drop the
macro itself.

2 years ago[DomTreeUpdater] Remove deprecated methods
Nikita Popov [Wed, 20 Apr 2022 10:13:22 +0000 (12:13 +0200)]
[DomTreeUpdater] Remove deprecated methods

Remove the insertEdge(), insertEdgeRelaxed(), deleteEdge() and
deleteEdgeRelaxed() methods, which have been deprecated three
years ago.

2 years ago[X86][FMA4] Add i386 test coverage to fma4 intrinsic tests
Simon Pilgrim [Wed, 20 Apr 2022 10:13:44 +0000 (11:13 +0100)]
[X86][FMA4] Add i386 test coverage to fma4 intrinsic tests

2 years ago[IRBuilder] Remove deprecated CreateShuffleVector() method
Nikita Popov [Wed, 20 Apr 2022 10:08:40 +0000 (12:08 +0200)]
[IRBuilder] Remove deprecated CreateShuffleVector() method

This method has been deprecated for two years.

2 years ago[X86][SSE] Add i386 test coverage to sse42 intrinsic tests
Simon Pilgrim [Wed, 20 Apr 2022 10:05:55 +0000 (11:05 +0100)]
[X86][SSE] Add i386 test coverage to sse42 intrinsic tests

2 years ago[X86][SSE] Add i386 test coverage to sse41 intrinsic tests
Simon Pilgrim [Wed, 20 Apr 2022 10:05:34 +0000 (11:05 +0100)]
[X86][SSE] Add i386 test coverage to sse41 intrinsic tests

2 years ago[OpenCL] Add missing __opencl_c_atomic_scope_device guards
Sven van Haastregt [Wed, 20 Apr 2022 10:02:50 +0000 (11:02 +0100)]
[OpenCL] Add missing __opencl_c_atomic_scope_device guards

Update opencl-c.h after the specification clarification in
https://github.com/KhronosGroup/OpenCL-Docs/pull/775

2 years ago[IR] Deprecate Type::getPointerElementType() (NFC)
Nikita Popov [Wed, 20 Apr 2022 09:55:40 +0000 (11:55 +0200)]
[IR] Deprecate Type::getPointerElementType() (NFC)

There are no more in-tree users of this method, outside the
experimental SPIRV backend.

2 years ago[ScopBuilder] Avoid pointer element type access
Nikita Popov [Wed, 20 Apr 2022 09:50:58 +0000 (11:50 +0200)]
[ScopBuilder] Avoid pointer element type access

Rather than checking the bitcast pointer element types, compare
the element type of the access and the GEP result type.

The entire code is dubious due to the inspection of GEP structure,
but this at least preserves the spirit of the existing code.

2 years ago[mlir][bufferize] Fix missing copies when writing to a buffer in a loop
Matthias Springer [Wed, 20 Apr 2022 09:43:49 +0000 (18:43 +0900)]
[mlir][bufferize] Fix missing copies when writing to a buffer in a loop

Writes into tensors that are definied outside of a repetitive region, but with the write happening inside of the repetitive region were previously not considered conflicts. This was incorrect.

E.g.:
```
%0 = ... : tensor<?xf32>
scf.for ... {
  "reading_op"(%0) : tensor<?xf32>
  %1 = "writing_op"(%0) : tensor<?xf32> -> tensor<?xf32>
  ...
}
```

In the above example, "writing_op" should be out-of-place.

This commit fixes the bufferization for any op that declares its repetitive semantics via RegionBranchOpInterface.

2 years ago[X86][SSE] Add i386 test coverage to sse4a intrinsic tests
Simon Pilgrim [Wed, 20 Apr 2022 09:48:47 +0000 (10:48 +0100)]
[X86][SSE] Add i386 test coverage to sse4a intrinsic tests

2 years ago[X86][SSE] Add i386 test coverage to ssse3 intrinsic tests
Simon Pilgrim [Wed, 20 Apr 2022 09:41:39 +0000 (10:41 +0100)]
[X86][SSE] Add i386 test coverage to ssse3 intrinsic tests

2 years ago[X86][SSE] Add i386 test coverage to sse3 intrinsic tests
Simon Pilgrim [Wed, 20 Apr 2022 09:41:09 +0000 (10:41 +0100)]
[X86][SSE] Add i386 test coverage to sse3 intrinsic tests

2 years ago[XOP] Add i386 test coverage to xop intrinsic tests
Simon Pilgrim [Wed, 20 Apr 2022 09:39:53 +0000 (10:39 +0100)]
[XOP] Add i386 test coverage to xop intrinsic tests

2 years ago[mlir][docs] Add missing parentheses in example code on walkers.
Ingo Müller [Tue, 19 Apr 2022 13:21:16 +0000 (13:21 +0000)]
[mlir][docs] Add missing parentheses in example code on walkers.

`getFunction` was missing parentheses.

Reviewed By: ftynse, mehdi_amini

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

2 years ago[PowerPC] add XLC compat builtin __abs
Chen Zheng [Wed, 20 Apr 2022 09:14:22 +0000 (05:14 -0400)]
[PowerPC] add XLC compat builtin __abs

Reviewed By: jsji

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

2 years ago[Test] One more test with potentially malformed phis
Max Kazantsev [Wed, 20 Apr 2022 08:49:54 +0000 (15:49 +0700)]
[Test] One more test with potentially malformed phis

2 years ago[NFC] Return correct PreservedAnalysis for CoroEarly
Chuanqi Xu [Wed, 20 Apr 2022 08:29:52 +0000 (16:29 +0800)]
[NFC] Return correct PreservedAnalysis for CoroEarly

This is a fix for previous typo. It makes no sense to return
PreservedAnalyses::all() if anything is change. This change simplify
codes further.

2 years ago[RISCV][Clang][NFC] Update vid intrinsic tests.
Zakk Chen [Wed, 20 Apr 2022 03:20:09 +0000 (20:20 -0700)]
[RISCV][Clang][NFC] Update vid intrinsic tests.

Re-run the update_cc_test_checks.py to update expected result.
I'm not sure why those tests are passed before.

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

2 years ago[NFC] test commit
Sheng [Wed, 9 Feb 2022 10:22:01 +0000 (18:22 +0800)]
[NFC] test commit

Empty test commit, check commit access

2 years ago[NFC] Empty test commit, check commit access
Ting Wang [Thu, 27 Jan 2022 01:00:25 +0000 (20:00 -0500)]
[NFC] Empty test commit, check commit access

2 years ago[clang-tidy] Fix crash on calls to overloaded operators in `llvmlibc-callee-namespace`
Whisperity [Tue, 19 Apr 2022 09:26:54 +0000 (11:26 +0200)]
[clang-tidy] Fix crash on calls to overloaded operators in `llvmlibc-callee-namespace`

The routine that facilitated symbols to be explicitly allowed asked
the name of the called function, which resulted in a crash when the
check was accidentally run on non-trivial C++ code.

Differential Revision: http://reviews.llvm.org/D123992

Reviewed By: aaron.ballman

2 years ago[InstCombine] add tests for mul+lshr; NFC
chenglin.bi [Wed, 20 Apr 2022 08:13:31 +0000 (16:13 +0800)]
[InstCombine] add tests for mul+lshr; NFC

Baseline tests for D123453(issue #54824)

2 years ago[flang] Do not pass derived type by descriptor when not needed
Jean Perier [Wed, 20 Apr 2022 07:57:41 +0000 (09:57 +0200)]
[flang] Do not pass derived type by descriptor when not needed

A missing "!" in the call interface lowering caused all derived type
arguments without length parameters that require and explicit interface
to be passed via fir.box (runtime descriptor).

This was not the intent: there is no point passing a simple derived type
scalars or explicit shapes by descriptor just because they have an attribute
like TARGET. This would actually be problematic with existing code that is
not always 100% compliant: some code implicitly calls procedures with
TARGET dummy attributes (this is not something a compiler can enforce
if the call and procedure definition are not in the same file).

Add a Scope::IsDerivedTypeWithLengthParameter to avoid passing derived
types with only kind parameters by descriptor. There is no point, the
callee knows about the kind parameter values.

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

2 years ago[clang-format] SortIncludes should support "@import" lines in Objective-C
Konrad Kleine [Mon, 11 Apr 2022 13:26:48 +0000 (13:26 +0000)]
[clang-format] SortIncludes should support "@import" lines in Objective-C

Fixes [[ https://github.com/llvm/llvm-project/issues/38995 | #38995 ]]

This is an attempt to modify the regular expression to identify
`@import` and `import` alongside the regular `#include`. The challenging
part was not to support `@` in addition to `#` but how to handle
everything that comes after the `include|import` keywords. Previously
everything that wasn't `"` or `<` was consumed. But as you can see in
this example from the issue #38995, there is no `"` or `<` following the
keyword:

```
@import Foundation;
```

I experimented with a lot of fancy and useful expressions in [this
online regex tool](https://regex101.com) only to find out that some
things are simply not supported by the regex implementation in LLVM.

 * For example the beginning `[\t\ ]*` should be replacable by the
   horizontal whitespace character `\h*` but this will break the
   `SortIncludesTest.LeadingWhitespace` test.

That's why I've chosen to come back to the basic building blocks.

The essential change in this patch is the change from this regular
expression:

```
^[\t\ ]*#[\t\ ]*(import|include)[^"<]*(["<][^">]*[">])
        ~                              ~~~~~~~~~~~~~~
        ^                              ^
        |                              |
        only support # prefix not @    |
                                       only support "" and <> as
delimiters
                                       no support for C++ modules and ;
                                       ending. Also this allows for ">
                                       or <" or "" or <> which all seems
                                       either off or wrong.
```

to this:

```
^[\t\ ]*[@#][\t\ ]*(import|include)([^"]*("[^"]+")|[^<]*(<[^>]+>)|[\t\
]*([^;]+;))
        ~~~~                        ~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~
~~~~~~~~~~~~~~
        ^                                 ^           ^       ^       ^
        |                                 |           |       |       |
        Now support @ and #.            Clearly support "" and <> as
well as an
                                        include name without enclosing
characters.
                                        Allows for no mixture of "> or
<" or
                                        empty include names.

```

Here is how I've tested this patch:

```
ninja clang-Format
ninja FormatTests
./tools/clang/unittests/Format/FormatTests
--gtest_filter=SortIncludesTest*
```

And if that worked I doubled checked that nothing else broke by running
all format checks:

```
./tools/clang/unittests/Format/FormatTests
```

One side effect of this change is it should partially support
[C++20 Module](https://en.cppreference.com/w/cpp/language/modules)
`import` lines without the optional `export` in front. Adding
this can be a change on its own that shouldn't be too hard. I say
partially because the `@` or `#` are currently *NOT* optional in the
regular expression.

I see an opportunity to optimized the matching to exclude `@include` for
example. But eventually these should be caught by the compiler, so...

With my change, the matching group is not at a fixed position any
longer. I decided to
choose the last match (group) that is not empty.

Reviewed By: HazardyKnusperkeks

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

2 years ago[Test] Add one more test for patch [SLP]Improve reductions analysis and emission...
Max Kazantsev [Wed, 20 Apr 2022 06:55:48 +0000 (13:55 +0700)]
[Test] Add one more test for patch [SLP]Improve reductions analysis and emission, part 1.

The original patch leads to malformed phis on this test. Make sure
we're safeguarded from its return until it is fixed.

2 years agoMake tests slightly more flexible for platforms which emit arguments in between some...
Douglas Yung [Wed, 20 Apr 2022 06:25:22 +0000 (23:25 -0700)]
Make tests slightly more flexible for platforms which emit arguments in between some of the expected arguments.

2 years ago[AMDGPU] Fix -Wunused-variable in -DLLVM_ENABLE_ASSERTIONS=off builds
Fangrui Song [Wed, 20 Apr 2022 05:36:58 +0000 (22:36 -0700)]
[AMDGPU] Fix -Wunused-variable in -DLLVM_ENABLE_ASSERTIONS=off builds

2 years ago[PowerPC] Fix -Wunused-variable in -DLLVM_ENABLE_ASSERTIONS=off builds
Fangrui Song [Wed, 20 Apr 2022 05:35:05 +0000 (22:35 -0700)]
[PowerPC] Fix -Wunused-variable in -DLLVM_ENABLE_ASSERTIONS=off builds

2 years agoRevert D123198 "[BuildLibCalls] Introduce getOrInsertLibFunc() for use when building...
Fangrui Song [Wed, 20 Apr 2022 05:26:09 +0000 (22:26 -0700)]
Revert D123198 "[BuildLibCalls] Introduce getOrInsertLibFunc() for use when building libcalls."

test/Transforms/InstCombine/pr39177.ll failed in a -DLLVM_USE_SANITIZER=Undefined build.
```
lib/Transforms/Utils/BuildLibCalls.cpp:1217:17: runtime error: reference binding to null pointer of type 'llvm::Function'
```
`Function &F = *M->getFunction(Name);`

This reverts commit 0f8c626723d2bbd547e78dcab5ab260dfbc437e1.

2 years ago[gn build] Port 6c69427e880b
LLVM GN Syncbot [Wed, 20 Apr 2022 04:12:02 +0000 (04:12 +0000)]
[gn build] Port 6c69427e880b

2 years ago[gn build] port clang-linker-wrapper build file
Nico Weber [Wed, 20 Apr 2022 04:11:10 +0000 (00:11 -0400)]
[gn build] port clang-linker-wrapper build file

Tests now try to run it, so we need a build file for it.

2 years ago[clang-tidy] Improve macro handling in modernize-macro-to-enum
Richard [Mon, 11 Apr 2022 20:11:30 +0000 (14:11 -0600)]
[clang-tidy] Improve macro handling in modernize-macro-to-enum

When a macro is undef'ed or used in a preprocessor conditional
expression, we need to remember that macro should it later be
defined in the file to an integral value.  We need to exclude
such macro names from being turned into an enum.

Maintain a blacklist of identifiers that we've seen in an
undef or conditional preprocessor directive.  When the file is
done processing, remove all the blacklisted identifiers from
conversion to an enum.

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

Fixes #54842

2 years ago[mlir][Vector] Add check of supported reduction kind for ScanOp.
jacquesguan [Tue, 19 Apr 2022 03:40:39 +0000 (03:40 +0000)]
[mlir][Vector] Add check of supported reduction kind for ScanOp.

This patch adds check of supported reduction kind for ScanOp to avoid using and/or/xor for floating point type.

Reviewed By: ftynse

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

2 years agoTargetRegistry: Don't add "error" to error messages
Matt Arsenault [Tue, 19 Apr 2022 00:18:05 +0000 (20:18 -0400)]
TargetRegistry: Don't add "error" to error messages

Many of the users of this add their own "error:" to the start,
resulting in error: error.

2 years agoAMDGPU: Add assert for GDS globals
Matt Arsenault [Wed, 20 Apr 2022 02:26:26 +0000 (22:26 -0400)]
AMDGPU: Add assert for GDS globals

2 years ago[CMake][Fuchsia] Include find-all-symbols in the distribution
Petr Hosek [Tue, 19 Apr 2022 21:29:48 +0000 (14:29 -0700)]
[CMake][Fuchsia] Include find-all-symbols in the distribution

This is needed to use clang-include-fixer.

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

2 years agoAMDGPU: Serialize VGPRForAGPRCopy
Matt Arsenault [Sat, 16 Apr 2022 14:05:03 +0000 (10:05 -0400)]
AMDGPU: Serialize VGPRForAGPRCopy

2 years agoAMDGPU: Fix allocating GDS globals to LDS offsets
Matt Arsenault [Sat, 16 Apr 2022 14:28:51 +0000 (10:28 -0400)]
AMDGPU: Fix allocating GDS globals to LDS offsets

These don't seem to be very well used or tested, but try to make the
behavior a bit more consistent with LDS globals.

I'm not sure what the definition for amdgpu-gds-size is supposed to
mean. For now I assumed it's allocating a static size at the beginning
of the allocation, and any known globals are allocated after it.

2 years agoAMDGPU: Serialize a few more MachineFunctionInfo fields in MIR
Matt Arsenault [Sat, 16 Apr 2022 15:11:30 +0000 (11:11 -0400)]
AMDGPU: Serialize a few more MachineFunctionInfo fields in MIR

2 years agoAMDGPU: Serialize gds size in MIR
Matt Arsenault [Sat, 16 Apr 2022 14:25:36 +0000 (10:25 -0400)]
AMDGPU: Serialize gds size in MIR

2 years ago[mlir][LLVMIR] Add vector predication type cast intrinsic ops.
jacquesguan [Tue, 19 Apr 2022 11:12:07 +0000 (11:12 +0000)]
[mlir][LLVMIR] Add vector predication type cast intrinsic ops.

This patch adds vector predication type cast intrinsic ops.

Reviewed By: ftynse

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

2 years agoAMDGPU: Serialize WWM registers
Matt Arsenault [Sat, 16 Apr 2022 12:56:30 +0000 (08:56 -0400)]
AMDGPU: Serialize WWM registers

2 years agoMachineModuleInfo: Don't allow dynamically setting DbgInfoAvailable
Matt Arsenault [Sun, 17 Apr 2022 16:55:24 +0000 (12:55 -0400)]
MachineModuleInfo: Don't allow dynamically setting DbgInfoAvailable

This can be set up front, and used only as a cache. This avoids a
field that looks like it requires MIR serialization.

I believe this fixes 2 bugs for CodeView. First, this addresses a
FIXME that the flag -diable-debug-info-print only works with
DWARF. Second, it fixes emitting debug info with emissionKind NoDebug.

2 years agoValueMap: Fix typo
Matt Arsenault [Mon, 18 Apr 2022 15:54:22 +0000 (11:54 -0400)]
ValueMap: Fix typo

2 years agoX86: Do not use ValueMap for PreallocatedIds
Matt Arsenault [Mon, 18 Apr 2022 16:00:04 +0000 (12:00 -0400)]
X86: Do not use ValueMap for PreallocatedIds

ValueMap should only be necessary if the IR values can be
replaced. This is only used during codegen, when it's illegal to
change the underlying IR. This allows using the default copy
constructor for X86MachineFunctionInfo.

I'm not happy about targets keeping state here that's only used in one
specific pass, but we don't have a better place to put it right now.

2 years agoAMDGPU: Defer creation of WWM VGPR spill slots
Matt Arsenault [Sat, 16 Apr 2022 13:27:49 +0000 (09:27 -0400)]
AMDGPU: Defer creation of WWM VGPR spill slots

There's no reason to create these immediately. They can be created in
the prolog/epilog code like CSR spills. There's probably a cleaner way
to do this by utilizing the CSR spill code.

This makes the frame index used transient state for
PrologEpilogInserter, and thus makes serialization easier. Really this
doesn't need to be saved here but there isn't really a better place
for it.

2 years agoAArch64: Use Register
Matt Arsenault [Sat, 16 Apr 2022 20:19:25 +0000 (16:19 -0400)]
AArch64: Use Register

2 years agoAMDGPU: Remove some unreachable code in WWM pass
Matt Arsenault [Sat, 16 Apr 2022 13:29:54 +0000 (09:29 -0400)]
AMDGPU: Remove some unreachable code in WWM pass

Defs must be registers and there's no point to code after
llvm_unreachable.

2 years agoAMDGPU: Remove unused MachineFunctionInfo fields
Matt Arsenault [Sat, 16 Apr 2022 03:09:03 +0000 (23:09 -0400)]
AMDGPU: Remove unused MachineFunctionInfo fields

These were leftovers from a half-implement spill to LDS attempt.

2 years agoIntrinsics: Mark llvm.eh.sjlj.callsite argument as immarg
Matt Arsenault [Sun, 17 Apr 2022 20:39:02 +0000 (16:39 -0400)]
Intrinsics: Mark llvm.eh.sjlj.callsite argument as immarg

The assert in SelectionDAG implies that it is

2 years agoAArch64/GlobalISel: Add -global-isel-abort=1 to select tests
Matt Arsenault [Mon, 11 Apr 2022 20:04:44 +0000 (16:04 -0400)]
AArch64/GlobalISel: Add -global-isel-abort=1 to select tests

Otherwise the legalizer verifier error isn't triggered since the
default is fallback.

2 years agoGlobalISel: Add LegalizeMutations to help use More/FewerElements
Matt Arsenault [Tue, 12 Apr 2022 02:04:17 +0000 (22:04 -0400)]
GlobalISel: Add LegalizeMutations to help use More/FewerElements

2 years agoAArch64/GlobalISel: Reduce use of getMinClassForRegBank
Matt Arsenault [Sat, 9 Apr 2022 13:49:08 +0000 (09:49 -0400)]
AArch64/GlobalISel: Reduce use of getMinClassForRegBank

getMinClassForRegBank and getRegClassForTypeOnBank were basically
identical functions with different APIs. Consolidate on the version
that uses LLT instead of a bitwidth, since that would be more
appropriate to use in a generic API. Keep getMinClassForRegBank around
for now, since copies are a special case that can't simply read the
type from the register operands.

2 years agoGlobalISel: Add LLT helper to multiply vector sizes
Matt Arsenault [Sat, 9 Apr 2022 14:45:31 +0000 (10:45 -0400)]
GlobalISel: Add LLT helper to multiply vector sizes

2 years agoAArch64/GlobalISel: Remove some null checks for getVRegDef
Matt Arsenault [Sat, 9 Apr 2022 13:11:06 +0000 (09:11 -0400)]
AArch64/GlobalISel: Remove some null checks for getVRegDef

getVRegDef is not allowed to fail for generic virtual registers, so
there's not much point in checking it.

2 years agoAArch64/GlobalISel: Remove asserts on copy instructions
Matt Arsenault [Sat, 9 Apr 2022 13:01:32 +0000 (09:01 -0400)]
AArch64/GlobalISel: Remove asserts on copy instructions

These things are checked in the verifier already, so there's not much
point in re-asserting them here. They aren't directly verified for the
copy-like extension artifacts, but the incorrect output copies would
be caught on the other side.

2 years ago[lldb/gdb-remote] Fix -Wswitch after D116462
Fangrui Song [Wed, 20 Apr 2022 01:01:06 +0000 (18:01 -0700)]
[lldb/gdb-remote] Fix -Wswitch after D116462

2 years agoApply clang-tidy fixes for llvm-twine-local in OpenMPToLLVMIRTranslation.cpp (NFC)
Mehdi Amini [Sat, 16 Apr 2022 08:21:24 +0000 (08:21 +0000)]
Apply clang-tidy fixes for llvm-twine-local in OpenMPToLLVMIRTranslation.cpp (NFC)

2 years ago[CodeGen] Fix -Wswitch after D116462
Fangrui Song [Wed, 20 Apr 2022 00:33:15 +0000 (17:33 -0700)]
[CodeGen] Fix -Wswitch after D116462

2 years ago[CodeGen] Fix -Wswitch after D116462
Fangrui Song [Wed, 20 Apr 2022 00:28:54 +0000 (17:28 -0700)]
[CodeGen] Fix -Wswitch after D116462

2 years ago[DFSan] Print an error before calling null extern_weak functions, incase dfsan instru...
Andrew Browne [Tue, 19 Apr 2022 22:45:28 +0000 (15:45 -0700)]
[DFSan] Print an error before calling null extern_weak functions, incase dfsan instrumentation optimized out a null check.

Reviewed By: vitalybuka

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

2 years ago[msan] Destroy ConstantTokenNone before types above
Vitaly Buka [Tue, 19 Apr 2022 23:29:07 +0000 (16:29 -0700)]
[msan] Destroy ConstantTokenNone before types above

~ConstantTokenNone access them, so it should be destroyed first.

2 years ago[msan] Disable assert with msan
Vitaly Buka [Tue, 19 Apr 2022 23:26:17 +0000 (16:26 -0700)]
[msan] Disable assert with msan

The assert uses data from just destroyed BasicBlock.

2 years ago[msan] Advance before destroying entry
Vitaly Buka [Tue, 19 Apr 2022 23:22:37 +0000 (16:22 -0700)]
[msan] Advance before destroying entry

-fsanitize-memory-use-after-dtor reports this memory access.

2 years ago[SPIR-V](6/6) Add the module analysis pass and the simplest tests
Ilia Diachkov [Thu, 14 Apr 2022 00:46:45 +0000 (03:46 +0300)]
[SPIR-V](6/6) Add the module analysis pass and the simplest tests

This patch adds one SPIRV analysis pass and extends AsmPrinter. It is
essential for minimum SPIR-V output. Also it adds several simplest tests
to show that the target basically works.

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

Authors: Aleksandr Bezzubikov, Lewis Crawford, Ilia Diachkov,
Michal Paszkowski, Andrey Tretyakov, Konrad Trifunovic

Co-authored-by: Aleksandr Bezzubikov <zuban32s@gmail.com>
Co-authored-by: Ilia Diachkov <iliya.diyachkov@intel.com>
Co-authored-by: Michal Paszkowski <michal.paszkowski@outlook.com>
Co-authored-by: Andrey Tretyakov <andrey1.tretyakov@intel.com>
Co-authored-by: Konrad Trifunovic <konrad.trifunovic@intel.com>
2 years ago[SPIR-V](5/6) Add LegalizerInfo, InstructionSelector and utilities
Ilia Diachkov [Wed, 13 Apr 2022 22:11:15 +0000 (01:11 +0300)]
[SPIR-V](5/6) Add LegalizerInfo, InstructionSelector and utilities

The patch adds SPIRVLegalizerInfo, SPIRVInstructionSelector and
SPIRV-specific utilities.

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

Authors: Aleksandr Bezzubikov, Lewis Crawford, Ilia Diachkov,
Michal Paszkowski, Andrey Tretyakov, Konrad Trifunovic

Co-authored-by: Aleksandr Bezzubikov <zuban32s@gmail.com>
Co-authored-by: Ilia Diachkov <iliya.diyachkov@intel.com>
Co-authored-by: Michal Paszkowski <michal.paszkowski@outlook.com>
Co-authored-by: Andrey Tretyakov <andrey1.tretyakov@intel.com>
Co-authored-by: Konrad Trifunovic <konrad.trifunovic@intel.com>
2 years ago[SPIR-V](4/6) Add target lowering, TargetMachine and AsmPrinter
Ilia Diachkov [Wed, 13 Apr 2022 22:10:25 +0000 (01:10 +0300)]
[SPIR-V](4/6) Add target lowering, TargetMachine and AsmPrinter

The patch contains target lowering for SPIRV. Also it implements
TargetMachine and AsmPrinter.

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

Authors: Aleksandr Bezzubikov, Lewis Crawford, Ilia Diachkov,
Michal Paszkowski, Andrey Tretyakov, Konrad Trifunovic

Co-authored-by: Aleksandr Bezzubikov <zuban32s@gmail.com>
Co-authored-by: Ilia Diachkov <iliya.diyachkov@intel.com>
Co-authored-by: Michal Paszkowski <michal.paszkowski@outlook.com>
Co-authored-by: Andrey Tretyakov <andrey1.tretyakov@intel.com>
Co-authored-by: Konrad Trifunovic <konrad.trifunovic@intel.com>
2 years ago[SPIR-V](3/6) Add MC layer, object file support, and InstPrinter
Ilia Diachkov [Wed, 13 Apr 2022 22:10:08 +0000 (01:10 +0300)]
[SPIR-V](3/6) Add MC layer, object file support, and InstPrinter

The patch adds SPIRV-specific MC layer implementation, SPIRV object
file support and SPIRVInstPrinter.

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

Authors: Aleksandr Bezzubikov, Lewis Crawford, Ilia Diachkov,
Michal Paszkowski, Andrey Tretyakov, Konrad Trifunovic

Co-authored-by: Aleksandr Bezzubikov <zuban32s@gmail.com>
Co-authored-by: Ilia Diachkov <iliya.diyachkov@intel.com>
Co-authored-by: Michal Paszkowski <michal.paszkowski@outlook.com>
Co-authored-by: Andrey Tretyakov <andrey1.tretyakov@intel.com>
Co-authored-by: Konrad Trifunovic <konrad.trifunovic@intel.com>
2 years ago[SPIR-V](2/6) Add SPIRV target description files
Ilia Diachkov [Wed, 13 Apr 2022 22:07:33 +0000 (01:07 +0300)]
[SPIR-V](2/6) Add SPIRV target description files

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

Authors: Aleksandr Bezzubikov, Lewis Crawford, Ilia Diachkov,
Michal Paszkowski, Andrey Tretyakov, Konrad Trifunovic

Co-authored-by: Aleksandr Bezzubikov <zuban32s@gmail.com>
Co-authored-by: Ilia Diachkov <iliya.diyachkov@intel.com>
Co-authored-by: Michal Paszkowski <michal.paszkowski@outlook.com>
Co-authored-by: Andrey Tretyakov <andrey1.tretyakov@intel.com>
Co-authored-by: Konrad Trifunovic <konrad.trifunovic@intel.com>
2 years ago[SPIR-V](1/6) Add stub for SPIRV backend
Ilia Diachkov [Wed, 13 Apr 2022 22:06:35 +0000 (01:06 +0300)]
[SPIR-V](1/6) Add stub for SPIRV backend

This patch contains enough for lib/Target/SPIRV to compile: a basic
SPIRVTargetMachine and SPIRVTargetInfo.

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

Authors: Aleksandr Bezzubikov, Lewis Crawford, Ilia Diachkov,
Michal Paszkowski, Andrey Tretyakov, Konrad Trifunovic

Co-authored-by: Aleksandr Bezzubikov <zuban32s@gmail.com>
Co-authored-by: Ilia Diachkov <iliya.diyachkov@intel.com>
Co-authored-by: Michal Paszkowski <michal.paszkowski@outlook.com>
Co-authored-by: Andrey Tretyakov <andrey1.tretyakov@intel.com>
Co-authored-by: Konrad Trifunovic <konrad.trifunovic@intel.com>
2 years agoAMDGPU: More mad_64_32 test cases for multiple uses
Nicolai Hähnle [Tue, 19 Apr 2022 22:34:23 +0000 (17:34 -0500)]
AMDGPU: More mad_64_32 test cases for multiple uses

Also use gfx90a for the gfx9 test, whose code gen should be affected by
faster multiply-add instructions.

2 years ago[PS5] Avoid a driver crash
Paul Robinson [Tue, 19 Apr 2022 22:55:01 +0000 (15:55 -0700)]
[PS5] Avoid a driver crash

In some cases, an error constructing a compiler or assembler job could
leave the Inputs in a state that the code for constructing the linker
job was not ready for.

2 years ago[OpenMP] Add necessary registered targets for linker wrapper test
Joseph Huber [Tue, 19 Apr 2022 22:46:12 +0000 (18:46 -0400)]
[OpenMP] Add necessary registered targets for linker wrapper test

Summary:
The linker wrapper needs to use the registered backend to perform LTO.
This was causing problems on the buildbots that didn't support it.

2 years ago[OpenMP] Fix deleted move constructor failing on some compiles
Joseph Huber [Tue, 19 Apr 2022 22:40:15 +0000 (18:40 -0400)]
[OpenMP] Fix deleted move constructor failing on some compiles

Summary:
A previous commit added some new errors that were not correctly casted
to an r-value. This doesn't work on some compilers.

2 years ago[OpenMP] Add better testing for the linker wrapper
Joseph Huber [Tue, 19 Apr 2022 18:14:16 +0000 (14:14 -0400)]
[OpenMP] Add better testing for the linker wrapper

The linker wrapper is used to perform linking and wrapping of embedded
device object files. Currently its internals are not able to be tested
easily. This patch adds the `--dry-run` and `--print-wrapped-module`
options to investigate the link jobs that will be run along with the
wrapped code that will be created to register the binaries.

Reviewed By: JonChesterfield

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

2 years ago[BPF] Fix a bug in BPFMISimplifyPatchable pass
Peter Klausler [Mon, 4 Apr 2022 18:39:51 +0000 (11:39 -0700)]
[BPF] Fix a bug in BPFMISimplifyPatchable pass

LLVM BPF pass SimplifyPatchable is used to do necessary
code conversion for CO-RE operations. When studying bpf
selftest 'exhandler', I found a corner case not handled properly.
The following is the C code, modified from original 'exhandler'
code.
  int g;
  int test(struct t1 *p) {
    struct t2 *q = p->q;
    if (q)
      return 0;
    struct t3 *f = q->f;
    if (!f) g = 5;
    return 0;
  }

For code:
  struct t3 *f = q->f;
  if (!f) ...
The IR before BPFMISimplifyPatchable pass looks like:
  %5:gpr = LD_imm64 @"llvm.t2:0:8$0:1"
  %6:gpr = LDD killed %5:gpr, 0
  %7:gpr = LDD killed %6:gpr, 0
  JNE_ri killed %7:gpr, 0, %bb.3
  JMP %bb.2
Note that compiler knows q = 0 based dataflow and value analysis.
The correct generated code after the pass should be
  %5:gpr = LD_imm64 @"llvm.t2:0:8$0:1"
  %7:gpr = LDD killed %5:gpr, 0
  JNE_ri killed %7:gpr, 0, %bb.3
  JMP %bb.2

But the current implementation did further optimization for the
above code and generates
  %5:gpr = LD_imm64 @"llvm.t2:0:8$0:1"
  JNE_ri killed %5:gpr, 0, %bb.3
  JMP %bb.2
which is incorrect.

This patch added a cache to remember those load insns not associated
with CO-RE offset value and will skip these load insns during
transformation.

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

2 years ago[MLIR] [Python] Add a method to clear live operations map
John Demme [Tue, 19 Apr 2022 22:03:15 +0000 (15:03 -0700)]
[MLIR] [Python] Add a method to clear live operations map

Introduce a method on PyMlirContext (and plumb it through to Python) to
invalidate all of the operations in the live operations map and clear
it. Since Python has no notion of private data, an end-developer could
reach into some 3rd party API which uses the MLIR Python API (that is
behaving correctly with regard to holding references) and grab a
reference to an MLIR Python Operation, preventing it from being
deconstructed out of the live operations map. This allows the API
developer to clear the map when it calls C++ code which could delete
operations, protecting itself from its users.

Reviewed By: ftynse

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

2 years ago[RISCV] Fold (xor (sllw 1, x), -1) -> (rolw ~1, x).
Craig Topper [Tue, 19 Apr 2022 21:38:23 +0000 (14:38 -0700)]
[RISCV] Fold (xor (sllw 1, x), -1) -> (rolw ~1, x).

There's an existing generic combine that does this for legal types.
This patch adds a RISCV specific combine for W instructions.

Reviewed By: luismarques

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

2 years ago[Driver][test] Remove unneeded clang from -cc1 CHECK lines
Fangrui Song [Tue, 19 Apr 2022 21:58:48 +0000 (14:58 -0700)]
[Driver][test] Remove unneeded clang from -cc1 CHECK lines

The convention is to omit "clang" for -cc1 CHECK lines and test that -triple is adjacent to -cc1.

2 years ago[modules] Merge variable template specializations.
Richard Smith [Tue, 19 Apr 2022 21:40:52 +0000 (14:40 -0700)]
[modules] Merge variable template specializations.

2 years ago[BPF] Emit fatal error if out of range for FK_PCRel_2 branch target
Yonghong Song [Fri, 15 Apr 2022 21:57:48 +0000 (14:57 -0700)]
[BPF] Emit fatal error if out of range for FK_PCRel_2 branch target

Currently for the branch insn like
   "if $dst "#OpcodeStr#" $imm goto $BrDst"
The $BrDst range needs to be in the range of [INT16_MIN, INT16_MAX].

When running bpf selftest with latest llvm, I found
pyperf600.o generated insn with range outside
of [INT16_MIN, INT16_MAX], which caused verifier failure.
See below insn #12.

  0000000000000000 <on_event>:
  ; {
         0:       7b 1a 00 ff 00 00 00 00 *(u64 *)(r10 - 256) = r1
  ;       uint64_t pid_tgid = bpf_get_current_pid_tgid();
         1:       85 00 00 00 0e 00 00 00 call 14
         2:       bf 06 00 00 00 00 00 00 r6 = r0
  ;       pid_t pid = (pid_t)(pid_tgid >> 32);
         3:       bf 61 00 00 00 00 00 00 r1 = r6
         4:       77 01 00 00 20 00 00 00 r1 >>= 32
         5:       63 1a fc ff 00 00 00 00 *(u32 *)(r10 - 4) = r1
         6:       bf a2 00 00 00 00 00 00 r2 = r10
         7:       07 02 00 00 fc ff ff ff r2 += -4
  ;       PidData* pidData = bpf_map_lookup_elem(&pidmap, &pid);
         8:       18 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 r1 = 0 ll
        10:       85 00 00 00 01 00 00 00 call 1
        11:       bf 08 00 00 00 00 00 00 r8 = r0
  ;       if (!pidData)
        12:       15 08 15 e8 00 00 00 00 if r8 == 0 goto -6123 <LBB0_27588+0xffffffffffdae100>
        13:       b4 01 00 00 00 00 00 00 w1 = 0

We may need to add new insn to extend the range of $BrDst.
This patch added a fatal error if out of range so compiler can warn
the otherwise incorrect code generation.

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

2 years ago[gn build] Port bac6cd5bf856
LLVM GN Syncbot [Tue, 19 Apr 2022 21:23:58 +0000 (21:23 +0000)]
[gn build] Port bac6cd5bf856

2 years ago[misexpect] Re-implement MisExpect Diagnostics
Paul Kirth [Fri, 1 Apr 2022 22:03:48 +0000 (22:03 +0000)]
[misexpect] Re-implement MisExpect Diagnostics

Reimplements MisExpect diagnostics from D66324 to reconstruct its
original checking methodology only using MD_prof branch_weights
metadata.

New checks rely on 2 invariants:

1) For frontend instrumentation, MD_prof branch_weights will always be
   populated before llvm.expect intrinsics are lowered.

2) for IR and sample profiling, llvm.expect intrinsics will always be
   lowered before branch_weights are populated from the IR profiles.

These invariants allow the checking to assume how the existing branch
weights are populated depending on the profiling method used, and emit
the correct diagnostics. If these invariants are ever invalidated, the
MisExpect related checks would need to be updated, potentially by
re-introducing MD_misexpect metadata, and ensuring it always will be
transformed the same way as branch_weights in other optimization passes.

Frontend based profiling is now enabled without using LLVM Args, by
introducing a new CodeGen option, and checking if the -Wmisexpect flag
has been passed on the command line.

Reviewed By: tejohnson

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

2 years ago[clang][dataflow] Do not crash on missing `Value` for struct-typed variable init.
Yitzhak Mandelbaum [Thu, 14 Apr 2022 13:41:06 +0000 (13:41 +0000)]
[clang][dataflow] Do not crash on missing `Value` for struct-typed variable init.

Remove constraint that an initializing expression of struct type must have an
associated `Value`. This invariant is not and will not be guaranteed by the
framework, because of potentially uninitialized fields.

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

2 years ago[Libomptarget][remote] Fix compile-time error
Atmn Patel [Wed, 16 Feb 2022 23:20:43 +0000 (18:20 -0500)]
[Libomptarget][remote] Fix compile-time error

This fixes a compile-time error recently introduced within the remote
offloading plugin. This patch also removes some extra linker flags that are unnecessary, and adds an explicit abseil linker flag without which we occasionally get problems.

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

2 years ago[gn build] Port c57f03415f96
LLVM GN Syncbot [Tue, 19 Apr 2022 20:13:49 +0000 (20:13 +0000)]
[gn build] Port c57f03415f96

2 years ago[clang][Sema] Add flag to LookupName to force C/ObjC codepath
Alex Langford [Mon, 18 Apr 2022 18:41:20 +0000 (11:41 -0700)]
[clang][Sema] Add flag to LookupName to force C/ObjC codepath

Motivation: The intent here is for use in Swift.
When building a clang module for swift consumption, swift adds an
extension block to the module for name lookup purposes. Swift calls
this a SwiftLookupTable. One purpose that this serves is to handle
conflicting names between ObjC classes and ObjC protocols. They exist in
different namespaces in ObjC programs, but in Swift they would exist in
the same namespace. Swift handles this by appending a suffix to a
protocol name if it shares a name with a class. For example, if you have
an ObjC class named "Foo" and a protocol with the same name, the
protocol would be renamed to "FooProtocol" when imported into swift.

When constructing the previously mentioned SwiftLookupTable, we use
Sema::LookupName to look up name conflicts for the previous problem.
By this time, the Parser has long finished its job so the call to
LookupName gets nullptr for its Scope (TUScope will be nullptr
by this point). The C/ObjC path does not have this problem because it
only uses the Scope in specific scenarios. The C++ codepath uses the
Scope quite extensively and will fail early on if the Scope it gets is
null. In our very specific case of looking up ObjC classes with a
specific name, we want to force sema::LookupName to take the C/ObjC
codepath even if C++ or ObjC++ is enabled.

2 years ago[mlir] Adds getUpperBound() to LoopLikeInterface.
Krzysztof Drewniak [Tue, 8 Mar 2022 18:39:52 +0000 (18:39 +0000)]
[mlir] Adds getUpperBound() to LoopLikeInterface.

getUpperBound is analogous to getLowerBound(), except for the upper
bound, and is used in range analysis.

Reviewed By: Mogball

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

2 years ago[mlir][transform] Introduce transform.sequence op
Alex Zinenko [Tue, 19 Apr 2022 14:36:37 +0000 (16:36 +0200)]
[mlir][transform] Introduce transform.sequence op

Sequence is an important transform combination primitive that just indicates
transform ops being applied in a row. The simplest version requires fails
immediately if any transformation in the sequence fails. Introducing this
operation allows one to start placing transform IR within other IR.

Depends On D123135

Reviewed By: Mogball, rriddle

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

2 years ago[analyzer] Implemented RangeSet::Factory::castTo function to perform promotions,...
Denys Petrov [Tue, 25 May 2021 15:24:48 +0000 (18:24 +0300)]
[analyzer] Implemented RangeSet::Factory::castTo function to perform promotions, truncations and conversions.

Summary: Handle casts for ranges working similarly to APSIntType::apply function but for the whole range set. Support promotions, truncations and conversions.
Example:
promotion: char [0, 42] -> short [0, 42] -> int [0, 42] -> llong [0, 42]
truncation: llong [42950330884295033130] -> int [65792, 65834] -> short [256, 298] -> char [0, 42]
conversion: char [-42, 42] -> uint [0, 42]U[42949672544294967295] -> short[-42, 42]

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

2 years ago[MLIR] Add function to create BFloat16 array attribute
Ashay Rane [Tue, 19 Apr 2022 18:53:29 +0000 (18:53 +0000)]
[MLIR] Add function to create BFloat16 array attribute

This patch adds a new function `mlirDenseElementsAttrBFloat16Get()`,
which accepts the shaped type, the number of BFloat16 values, and a
pointer to an array of BFloat16 values, each of which is a `uint16_t`
value.

Reviewed By: stellaraccident

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

2 years ago[BuildLibCalls] Introduce getOrInsertLibFunc() for use when building libcalls.
Jonas Paulsson [Thu, 14 Apr 2022 08:50:26 +0000 (10:50 +0200)]
[BuildLibCalls] Introduce getOrInsertLibFunc() for use when building libcalls.

A new set of overloaded functions named getOrInsertLibFunc() are now supposed
to be used instead of getOrInsertFunction() when building a libcall from
within an LLVM optimizer(). The idea is that this new function also makes
sure that any mandatory argument attributes are added to the function
prototype (after calling getOrInsertFunction()).

inferLibFuncAttributes() is renamed to inferNonMandatoryLibFuncAttrs() as it
only adds attributes that are not necessary for correctness but merely
helping with later optimizations.

Generally, the front end is responsible for building a correct function
prototype with the needed argument attributes. If the middle end however is
the one creating the call, e.g. when replacing one libcall with another, it
then must take this responsibility.

This continues the work of properly handling argument extension if required
by the target ABI when building a lib call. getOrInsertLibFunc() now does
this for all libcalls currently built by any LLVM optimizer. It is expected
that when in the future a new optimization builds a new libcall with an
integer argument it is to be added to getOrInsertLibFunc() with the proper
handling. Note that not all targets have it in their ABI to sign/zero extend
integer arguments to the full register width, but this will be done
selectively as determined by getExtAttrForI32Param().

Review: Eli Friedman, Nikita Popov, Dávid Bolvanský

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

2 years ago[InstCombine] C0 shift (X add nuw C) --> (C0 shift C) shift X
Sanjay Patel [Tue, 19 Apr 2022 19:09:45 +0000 (15:09 -0400)]
[InstCombine] C0 shift (X add nuw C) --> (C0 shift C) shift X

With 'nuw' we can convert the increment of the shift amount
into a pre-shift (constant fold) of the shifted constant:
https://alive2.llvm.org/ce/z/FkTyR2

Fixes issue #41976

2 years ago[InstCombine] add tests for shift-of-add with constants; NFC
Sanjay Patel [Tue, 19 Apr 2022 18:48:51 +0000 (14:48 -0400)]
[InstCombine] add tests for shift-of-add with constants; NFC

2 years ago[ASan] Removed checks if the tested functions were emitted.
Kirill Stoimenov [Tue, 19 Apr 2022 19:00:41 +0000 (19:00 +0000)]
[ASan] Removed checks if the tested functions were emitted.

Reviewed By: eugenis

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

2 years ago[NFC][SLP] Improved description of getShallowScore() and getScoreAtLevelRec()
Vasileios Porpodas [Tue, 19 Apr 2022 17:59:55 +0000 (10:59 -0700)]
[NFC][SLP] Improved description of getShallowScore() and getScoreAtLevelRec()

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

2 years ago[CUDA][HIP] Fix delete operator for -fopenmp
Yaxun (Sam) Liu [Tue, 19 Apr 2022 02:21:47 +0000 (22:21 -0400)]
[CUDA][HIP] Fix delete operator for -fopenmp

When new operator is called in OpenMP parallel region,
delete operator is resolved and checked. Due to similar
issue fixed by https://reviews.llvm.org/D121765,
when resolving delete operator, the caller was not
determined correctly, which results in error as
shown in https://godbolt.org/z/jKhd8qKos.

This patch fixes the issue in a similar way as
https://reviews.llvm.org/D121765

Reviewed by: Artem Belevich

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

2 years ago[IRSim] Ignore debug instructions when creating canonical numbering
Andrew Litteken [Sat, 16 Apr 2022 21:11:39 +0000 (16:11 -0500)]
[IRSim] Ignore debug instructions when creating canonical numbering

When constructing canonical relationships between two regions, the first instruction of a basic block from the first region is used to find the corresponding basic block from the second region. However, debug instructions are not included in similarity matching, and therefore do not have a canonical numbering. This patch makes sure to ignore the debug instructions when finding the first instruction in a basic block.

Reviewer: paquette

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