platform/upstream/llvm.git
2 years ago[InstCombine] Precommit tests for umul_with_overflow. nfc
Chenbing Zheng [Fri, 2 Sep 2022 03:13:54 +0000 (11:13 +0800)]
[InstCombine] Precommit tests for umul_with_overflow. nfc

2 years ago[msan] Fix debug info with getNextNode
Vitaly Buka [Thu, 1 Sep 2022 04:49:15 +0000 (21:49 -0700)]
[msan] Fix debug info with getNextNode

When we want to add instrumentation after
an instruction, instrumentation still should
keep debug info of the instruction.

Reviewed By: kda, kstoimenov

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

2 years ago[InstCombine] complete fold extractvalue (any_mul_with_overflow X, -1)
Chenbing Zheng [Fri, 2 Sep 2022 02:58:42 +0000 (10:58 +0800)]
[InstCombine] complete fold extractvalue (any_mul_with_overflow X, -1)

When we do extractvalue (any_mul_with_overflow X, -1) --> (-X and icmp),
which left partly failed to match vector constant with poison element.
This patch try to fix it.

Alive2: https://alive2.llvm.org/ce/z/2rGp_3

Reviewed By: spatel

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

2 years ago[msan] Use no-origin functions when possible
Vitaly Buka [Fri, 2 Sep 2022 02:02:25 +0000 (19:02 -0700)]
[msan] Use no-origin functions when possible

Saves 1.8% of .text size on CTMark

Reviewed By: kda

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

2 years ago[LLDB][RISCV] Add more instruction decode and execute for EmulateInstructionRISCV
Emmmer [Sat, 27 Aug 2022 14:40:02 +0000 (22:40 +0800)]
[LLDB][RISCV] Add more instruction decode and execute for EmulateInstructionRISCV

Add:
- most of instructions from RVI base instructions set.
- some instruction decode tests from objdump.

Further work:
- implement riscv imac extension.

Reviewed By: DavidSpickett

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

2 years ago[NFC] fix typo
Chenbing Zheng [Fri, 2 Sep 2022 02:04:52 +0000 (10:04 +0800)]
[NFC] fix typo

2 years ago[test][msan] Add implicit-check-not rename some prefixes
Vitaly Buka [Fri, 2 Sep 2022 02:00:28 +0000 (19:00 -0700)]
[test][msan] Add implicit-check-not rename some prefixes

2 years ago[flang] Add lcobound and ucobound to the list of intrinsics
Katherine Rasmussen [Sat, 14 May 2022 04:41:21 +0000 (21:41 -0700)]
[flang] Add lcobound and ucobound to the list of intrinsics

Add the coarray intrinsic functions, lcobound and ucobound, to the
list of intrinsics. For both of these functions, add a check to
ensure that if the optional dim argument is present and statically
checkable, its value is in the inclusive range of 1 and the corank
of the coarray argument. In the semantics tests for lcobound and
ucobound, remove the XFAIL directive, add the ERROR directives and
add additional standard-conforming and non-standard conforming
calls.

Reviewed By: klausler, craig.rasmussen

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

2 years agoFix inconsistent target arch when attaching to arm64 binaries on
Adrian Prantl [Wed, 31 Aug 2022 23:14:09 +0000 (16:14 -0700)]
Fix inconsistent target arch when attaching to arm64 binaries on
arm64e platforms.

On arm64e-capable Apple platforms, the system libraries are always
arm64e, but applications often are arm64. When a target is created
from file, LLDB recognizes it as an arm64 target, but debugserver will
still (technically correct) report the process as being arm64e. For
consistency, set the target to arm64 here.

rdar://92248684

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

2 years ago[mlir][sparse] added codegen for dimop, pointers, indices, values
Aart Bik [Thu, 1 Sep 2022 19:34:58 +0000 (12:34 -0700)]
[mlir][sparse] added codegen for dimop, pointers, indices, values

Demonstrates how sparse tensor type -> tuple -> getter
will eventually yield actual code on the memrefs directly

Reviewed By: Peiming

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

2 years ago[CUDA] Allow using -o with -fsyntax-only
Artem Belevich [Thu, 1 Sep 2022 18:24:35 +0000 (11:24 -0700)]
[CUDA] Allow using -o with -fsyntax-only

-fsyntax-only breaks down CUDA compilation pipeline and make it look like
multiple independent subcompilations and that trips the multiple arguments check
when -o is specified.

We do want to allow -fsyntax-only to be used with otherwise unmodified clang
options as it's commonly used by various tooling.

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

2 years ago[mlir][sparse] Add SparseTensorStorageExpansion Pass to expand compounded sparse...
Peiming Liu [Thu, 1 Sep 2022 17:06:31 +0000 (17:06 +0000)]
[mlir][sparse] Add SparseTensorStorageExpansion Pass to expand compounded sparse tensor tuples

This patch adds SparseTensorStorageExpansion pass, it flattens the tuple used to store a sparse
tensor handle.

Right now, it only set up the skeleton for the pass, more lowering rules for sparse tensor storage
operation need to be added.

Reviewed By: aartbik

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

2 years ago[flang] Make use of do variable more consistent.
Slava Zakharin [Thu, 1 Sep 2022 19:33:39 +0000 (12:33 -0700)]
[flang] Make use of do variable more consistent.

Instead of using the IV block argument of the do-loop we will use
the do-variable value loaded from its location. This usage is consistent
with other uses of the do-variable inside the loop.

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

2 years ago[clang] Give better message for unsupported no_sanitize on globals
Alex Brachet [Thu, 1 Sep 2022 22:35:42 +0000 (22:35 +0000)]
[clang] Give better message for unsupported no_sanitize on globals

Previously if you specified no_sanitize("known_sanitizer") on a global you
would yield a misleading error "'no_sanitize' attribute only applies to
functions and methods", but no_sanitize("unknown") would simply be a warning,
"unknown sanitizer 'unknown' ignored". This changes the former to a warning
"'no_sanitize' attribute argument not supported for globals: known_sanitizer".

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

2 years ago[InstCombine] Treat passing undef to noundef params as UB
Arthur Eubanks [Wed, 31 Aug 2022 18:17:10 +0000 (11:17 -0700)]
[InstCombine] Treat passing undef to noundef params as UB

Reviewed By: nikic

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

2 years ago[mlir][tosa] Add remaining tosa comparison folders
Rob Suderman [Thu, 1 Sep 2022 21:10:19 +0000 (14:10 -0700)]
[mlir][tosa] Add remaining tosa comparison folders

Added numerical splat folders for comparison operations and
equal of two identical int values.

Reviewed By: NatashaKnk

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

2 years ago[libc][NFC] Use cpp::optional for checking exceptional values of math functions.
Tue Ly [Thu, 1 Sep 2022 18:30:51 +0000 (14:30 -0400)]
[libc][NFC] Use cpp::optional for checking exceptional values of math functions.

Update the utility functions for checking exceptional values of math
functions to use cpp::optional return values.

Reviewed By: sivachandra

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

2 years ago[PGO] Support PGO annotation of CallBrInst
Rong Xu [Thu, 1 Sep 2022 21:13:50 +0000 (14:13 -0700)]
[PGO] Support PGO annotation of CallBrInst

We currently instrument CallBrInst but do not annotate it with
the branch weight. This patch enables PGO annotation of CallBrInst.

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

2 years ago[llvm-objdump][COFF] Correctly decode `UOP_Epilog` opcodes
Arpad Borsos [Thu, 1 Sep 2022 21:05:13 +0000 (14:05 -0700)]
[llvm-objdump][COFF] Correctly decode `UOP_Epilog` opcodes

At least `ntdll` is using the undocumented version 2 unwind info, and opcode 6, which is already defined as `UOP_Epilog`.
Using `llvm-objdump --unwind` with `ntdll` would previously result in unreachable assertions because this code was missing from `getNumUsedSlots` and `getUnwindCodeTypeName`.
The slots of these codes comes from https://github.com/dotnet/runtime/blob/57bfe474518ab5b7cfe6bf7424a79ce3af9d6657/src/coreclr/inc/win64unwind.h#L51-L52 which I would assume is a good authoritative source.

Reviewed By: MaskRay

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

2 years ago[MSAN] removing redundant tests and parameters (NFC)
Kevin Athey [Wed, 19 Jan 2022 00:04:05 +0000 (16:04 -0800)]
[MSAN] removing redundant tests and parameters (NFC)

Reviewed By: vitalybuka

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

2 years ago[msan] Combine shadow check of the same instruction
Vitaly Buka [Wed, 31 Aug 2022 23:58:32 +0000 (16:58 -0700)]
[msan] Combine shadow check of the same instruction

Reduces .text size by 1% on our large binary.

On CTMark (-O2 -fsanitize=memory -fsanitize-memory-use-after-dtor -fsanitize-memory-param-retval)
Size -0.4%
Time -0.8%

Reviewed By: kda

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

2 years ago[clangd] Fix tests for implicit C function declaration
Aleksandr Platonov [Thu, 1 Sep 2022 18:51:25 +0000 (21:51 +0300)]
[clangd] Fix tests for implicit C function declaration

clangd code fixes at D122983 were not right.
We need to check that clangd provides IncludeFixer fixits for implicit function declaration even if this is not an error (e.g. implicit function declaration in C89).

Reviewed By: sammccall

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

2 years ago[JITLink] Sink ELFX86RelocationKind into implementation file (ELF_x86_64.cpp).
Lang Hames [Thu, 1 Sep 2022 19:26:47 +0000 (12:26 -0700)]
[JITLink] Sink ELFX86RelocationKind into implementation file (ELF_x86_64.cpp).

The ELF/x86-64 backend uses the generic x86_64 edges now, so the
ELFX86RelocationKind is just an implementation detail.

2 years ago[SCCP][PhaseOrdering] add tests for sdiv/srem range transforms; NFC
Sanjay Patel [Thu, 1 Sep 2022 19:58:20 +0000 (15:58 -0400)]
[SCCP][PhaseOrdering] add tests for sdiv/srem range transforms; NFC

issue #57472

2 years ago[LLDB][NativePDB] Fix a minor bug.
Zequan Wu [Wed, 31 Aug 2022 21:45:27 +0000 (14:45 -0700)]
[LLDB][NativePDB] Fix a minor bug.

llvm::codeview::visitMemberRecordStream in CompleteTagDecl will call
GetOrCreateType create type if not seen before, which inserts new entries
into m_decl_to_status. This may invalidates status which is a reference to
std::pair::second from DenseMapIterator.

2 years ago[nfc][msan] Group checks per instruction
Vitaly Buka [Wed, 31 Aug 2022 22:55:18 +0000 (15:55 -0700)]
[nfc][msan] Group checks per instruction

It's a preparation of to combine shadow checks of the same instruction

Reviewed By: kda, kstoimenov

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

2 years agoRevert "[flang] Avoid copyin/copyout if the actual argument is contiguous at runtime"
Valentin Clement [Thu, 1 Sep 2022 20:04:29 +0000 (22:04 +0200)]
Revert "[flang] Avoid copyin/copyout if the actual argument is contiguous at runtime"

This reverts commit 6ab6f23b14d51d65bfe86df64d0e976ebb573429.

2 years ago[ADT] bit.h - replace <stdint.h> with <cstdint>
Simon Pilgrim [Thu, 1 Sep 2022 19:44:56 +0000 (20:44 +0100)]
[ADT] bit.h - replace <stdint.h> with <cstdint>

This is a C++ header after all.

2 years ago[mlir:PDLL] Actually run the integration tests
River Riddle [Thu, 1 Sep 2022 02:21:50 +0000 (19:21 -0700)]
[mlir:PDLL] Actually run the integration tests

This revealed that the test was a bit out of date and failing, this
commit also tweaks the .mlir to actually test pdll properly.

2 years ago[X86] Fix reciprocal instruction throughput/uops counts
Simon Pilgrim [Thu, 1 Sep 2022 19:25:52 +0000 (20:25 +0100)]
[X86] Fix reciprocal instruction throughput/uops counts

Matches numbers from AMD SoG + Agner - should always be on FPU Pipes 0+1, no additional uops for folded instructions and znver1 double pumps 256-bit vectors

Noticed while adding CostKinds support to the x86 cost models

2 years ago[clang][dataflow] Refactor `TypeErasedDataflowAnalysisTest` - replace usage of the...
Wei Yi Tee [Thu, 1 Sep 2022 17:34:22 +0000 (17:34 +0000)]
[clang][dataflow] Refactor `TypeErasedDataflowAnalysisTest` - replace usage of the deprecated overload of `checkDataflow`.

Reviewed By: gribozavr2, sgatev

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

2 years ago[flang] Avoid copyin/copyout if the actual argument is contiguous at runtime
Valentin Clement [Thu, 1 Sep 2022 19:15:48 +0000 (21:15 +0200)]
[flang] Avoid copyin/copyout if the actual argument is contiguous at runtime

This patch adds contiguity check with the runtime to avoid copyin/copyout
in case the actual argument is actually contiguous.

Reviewed By: jeanPerier

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

2 years ago[libc++] Avoids self references in transitive include test.
Mark de Wever [Sat, 27 Aug 2022 10:58:14 +0000 (12:58 +0200)]
[libc++] Avoids self references in transitive include test.

The output of --trace-includes starts with the header whose includes are
being processed. Since the sanitize script processed all lines this
include was added to the list of transitive includes. This looks odd
since it implies all headers have a cyclic dependency on themselves.
This change removes this self-include.

Instead of just dropping the first line extract that header and use it
to guard against cyclic dependencies in the header itself.

The regex used has a small improvement; don't capture groups that aren't
extracted.

Depends on D132284

Reviewed By: ldionne, #libc

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

2 years ago[libc] add division, modulo, and power to UInt
Michael Jones [Thu, 18 Aug 2022 18:46:58 +0000 (11:46 -0700)]
[libc] add division, modulo, and power to UInt

This adds division and power implementations to UInt. Modulo and
division are handled by the same function. These are necessary for some
higher order mathematics, often involving large floating point numbers.

Reviewed By: sivachandra, lntue

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

2 years ago[libc] move builtin_wrappers out of fputil
Michael Jones [Wed, 31 Aug 2022 18:14:27 +0000 (11:14 -0700)]
[libc] move builtin_wrappers out of fputil

builtin_wrappers contains the wrappers for the clz builtins, which do
not depend on anything in fputil. This patch moves the file out of
FPUtil. The location is updated as appropriate.

Reviewed By: lntue

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

2 years ago[MachineFunctionPass] Support -filter-passes for -print-changed
Fangrui Song [Thu, 1 Sep 2022 18:06:06 +0000 (11:06 -0700)]
[MachineFunctionPass] Support -filter-passes for -print-changed

[MachineFunctionPass] Support -filter-passes for -print-changed

-filter-passes specifies a `PassID` (a lower-case dashed-separated pass name,
also used by -print-after, -stop-after, etc) instead of a CamelCasePass.

`-filter-passes=CamelCaseNewPMPass` seems like a workaround for new PM passes before
we can use lower-case dashed-separated pass names (as used by `-passes=`).

Example:
```
# getPassName() is "IRTranslator". PassID is "irtranslator"
llc -mtriple=aarch64 -print-changed -filter-passes=irtranslator < print-changed-machine.ll
```

Close https://github.com/llvm/llvm-project/issues/57453

Reviewed By: aeubanks

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

2 years ago[gn build] Port f6b66cbc7df1
LLVM GN Syncbot [Thu, 1 Sep 2022 18:01:38 +0000 (18:01 +0000)]
[gn build] Port f6b66cbc7df1

2 years ago[libc][bazel] split fputil into individual targets
Michael Jones [Thu, 1 Sep 2022 00:03:48 +0000 (17:03 -0700)]
[libc][bazel] split fputil into individual targets

This matches the change made to cmake, mostly. I've left the process of
splitting the inclusions for all the math functions for a later time.

Reviewed By: lntue, sivachandra

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

2 years ago[test][msan] Basic debug info test
Vitaly Buka [Thu, 1 Sep 2022 04:46:17 +0000 (21:46 -0700)]
[test][msan] Basic debug info test

2 years ago[libomptarget] Enable the device allocator for AMDGPU
Joseph Huber [Thu, 1 Sep 2022 17:26:26 +0000 (12:26 -0500)]
[libomptarget] Enable the device allocator for AMDGPU

This patch adds support for the device memory type, this is currently equivalent
to the default type so it should be treated as the same.

Reviewed By: JonChesterfield

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

2 years ago[llvm][Testing/ADT] Implement `IsStringMapEntry` testing matcher for verifying the...
Wei Yi Tee [Thu, 1 Sep 2022 16:15:55 +0000 (16:15 +0000)]
[llvm][Testing/ADT] Implement `IsStringMapEntry` testing matcher for verifying the entries in a `StringMap`.

Reviewed By: gribozavr2, ymandel, sgatev

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

2 years ago[mlir] fix ubsan when loading array<i0>
Jeff Niu [Thu, 1 Sep 2022 16:49:53 +0000 (09:49 -0700)]
[mlir] fix ubsan when loading array<i0>

2 years ago[mlir][sparse] refined doc of sparse tensor ops
Aart Bik [Thu, 1 Sep 2022 03:31:24 +0000 (20:31 -0700)]
[mlir][sparse] refined doc of sparse tensor ops

Reviewed By: bixia

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

2 years ago[mlir][sparse] improved tensor type lowering
Aart Bik [Thu, 1 Sep 2022 01:22:04 +0000 (18:22 -0700)]
[mlir][sparse] improved tensor type lowering

Also includes a first codegen example (although full support need tuple access)

Reviewed By: Peiming

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

2 years ago[MSan] Fix determinism issue when using msan-track-origins.
Jordan Rupprecht [Thu, 1 Sep 2022 16:15:57 +0000 (09:15 -0700)]
[MSan] Fix determinism issue when using msan-track-origins.

When instrumenting `alloca`s, we use a `SmallSet` (i.e. `SmallPtrSet`). When there are fewer elements than the `SmallSet` size, it behaves like a vector, offering stable iteration order. Once we have too many `alloca`s to instrument, the iteration order becomes unstable. This manifests as non-deterministic builds because of the global constant we create while instrumenting the alloca.

The test added is a simple IR file, but was discovered while building `libcxx/src/filesystem/operations.cpp` from libc++. A reduced C++ example from that:

```
// clang++ -fsanitize=memory -fsanitize-memory-track-origins \
//   -fno-discard-value-names -S -emit-llvm \
//   -c op.cpp -o op.ll
struct Foo {
  ~Foo();
};
bool func1(Foo);
void func2(Foo);
void func3(int) {
  int f_st, t_st;
  Foo f, t;
  func1(f) || func1(f) || func1(t) || func1(f) && func1(t);
  func2(f);
}
```

Reviewed By: kda

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

2 years ago[test][InstCombine] Update precommitted test
Arthur Eubanks [Thu, 1 Sep 2022 16:06:30 +0000 (09:06 -0700)]
[test][InstCombine] Update precommitted test

2 years agoExpand Div/Rem: consider the case where the dividend is zero
Nuno Lopes [Thu, 1 Sep 2022 16:04:26 +0000 (17:04 +0100)]
Expand Div/Rem: consider the case where the dividend is zero
So we can't use ctlz in poison-producing mode

2 years agoRevert "[Pipelines] Introduce DAE after ArgumentPromotion"
Arthur Eubanks [Thu, 1 Sep 2022 15:42:36 +0000 (08:42 -0700)]
Revert "[Pipelines] Introduce DAE after ArgumentPromotion"

This reverts commit b10a341aa5b0b93b9175a8f11efc9a0955ab361e.

This commit exposes the pre-existing https://github.com/llvm/llvm-project/issues/56503 in some edge cases. Will fix that and then reland this.

2 years agoRemoving an accidentally duplicated heading; NFC
Aaron Ballman [Thu, 1 Sep 2022 15:44:11 +0000 (11:44 -0400)]
Removing an accidentally duplicated heading; NFC

2 years ago[AArch64][SVE] Add floating-point repeated complex pattern llc tests
Matt Devereau [Thu, 1 Sep 2022 15:00:37 +0000 (15:00 +0000)]
[AArch64][SVE] Add floating-point repeated complex pattern llc tests

2 years agoApply clang-tidy fixes for performance-unnecessary-value-param in InferIntRangeInterf...
Mehdi Amini [Mon, 29 Aug 2022 10:44:12 +0000 (10:44 +0000)]
Apply clang-tidy fixes for performance-unnecessary-value-param in InferIntRangeInterfaceImpls.cpp (NFC)

2 years agoApply clang-tidy fixes for readability-identifier-naming in AffineOps.cpp (NFC)
Mehdi Amini [Mon, 29 Aug 2022 10:32:39 +0000 (10:32 +0000)]
Apply clang-tidy fixes for readability-identifier-naming in AffineOps.cpp (NFC)

2 years agotweak zstd behavior in cmake and llvm config for better testing
Cole Kissane [Thu, 1 Sep 2022 14:49:42 +0000 (07:49 -0700)]
tweak zstd behavior in cmake and llvm config for better testing

add LLVM_PREFER_STATIC_ZSTD (default TRUE) cmake config flag
(compression test seems to fail for shared zstd on windows, note that zstd multithread is by default disabled in the static build so it may be a hidden variable)
propagate variable zstd_DIR in LLVMConfig.cmake.in
fix llvm-config CMakeLists.txt behavior for absolute libs windows
get zstd lib name

Reviewed By: phosek

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

2 years ago[DwarfEhPrepare] Assign dummy debug location for inserted _Unwind_Resume calls (PR57469)
Nikita Popov [Thu, 1 Sep 2022 08:13:35 +0000 (10:13 +0200)]
[DwarfEhPrepare] Assign dummy debug location for inserted _Unwind_Resume calls (PR57469)

DwarfEhPrepare inserts calls to _Unwind_Resume into landing pads.
If _Unwind_Resume happens to be defined in the same module and
debug info is used, then this leads to a verifier error:

  inlinable function call in a function with debug info must
    have a !dbg location
  call void @_Unwind_Resume(ptr %exn.obj) #0

Fix this by assigning a dummy location to the call. (As this
happens in the backend, inlining is not actually relevant here.)

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

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

2 years ago[flang] Handle special case for SHIFTA intrinsic
Valentin Clement [Thu, 1 Sep 2022 14:27:51 +0000 (16:27 +0200)]
[flang] Handle special case for SHIFTA intrinsic

This patch update the lowering of the shifta intrinsic to match
the behvior of gfortran. When the SHIFT value is equal to the
integer bitwidth then we handle it differently.
This is due to the operation used in lowering (`mlir::arith::ShRSIOp`)
that lowers to `ashr`.

Before this patch we have the following results:

```
SHIFTA(  -1, 8) =  0
SHIFTA(  -2, 8) =  0
SHIFTA( -30, 8) =  0
SHIFTA( -31, 8) =  0
SHIFTA( -32, 8) =  0
SHIFTA( -33, 8) =  0
SHIFTA(-126, 8) =  0
SHIFTA(-127, 8) =  0
SHIFTA(-128, 8) =  0
```

While gfortran is giving this:

```
SHIFTA(  -1, 8) = -1
SHIFTA(  -2, 8) = -1
SHIFTA( -30, 8) = -1
SHIFTA( -31, 8) = -1
SHIFTA( -32, 8) = -1
SHIFTA( -33, 8) = -1
SHIFTA(-126, 8) = -1
SHIFTA(-127, 8) = -1
SHIFTA(-128, 8) = -1
```

With this patch flang and gfortran have the same behavior.

Reviewed By: jeanPerier

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

2 years ago[PHITranslateAddr] Require dominance when searching for translated address (PR57025)
Nikita Popov [Tue, 30 Aug 2022 12:26:36 +0000 (14:26 +0200)]
[PHITranslateAddr] Require dominance when searching for translated address (PR57025)

This is a fix for PR57025 and an alternative to D131776. The problem
in the phi-translation-to-wrong-context.ll test case is that phi
translation of %gep.j into if2 pick %gep.i as the result. While this
instruction has the correct pointer address, it occurs in a context
where %i != 0. As such, we get a NoAlias result for the store in
if2, even though they do alias for %i == 0 (which is legal in the
original context of the pointer).

PHITranslateValue already has a MustDominate option, which can be
used to restrict PHI translation results to values that dominate the
translated-into block. However, this is more aggressive than what we
need and would significantly regress GVN results. In particular, if
we have a pointer value that does not require any translation, then
it is fine to continue using that value in the predecessor, because
the context is still correct for the original query. We only run into
problems if PHITranslateSubExpr() picks a completely random
instruction in a context that may have preconditions that do not hold.

Fix this by always performing the dominance checks in
PHITranslateSubExpr(), without enabling the more general MustDominate
requirement.

Fixes https://github.com/llvm/llvm-project/issues/57025. This also
fixes the test case for https://github.com/llvm/llvm-project/issues/30999,
but I'm not sure whether that's just the particular test case,
or a general solution to the problem.

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

2 years ago[clang][dataflow] Use `StringMap` for storing analysis states at annotated points...
Wei Yi Tee [Thu, 1 Sep 2022 13:50:38 +0000 (13:50 +0000)]
[clang][dataflow] Use `StringMap` for storing analysis states at annotated points instead of `vector<pair<string, StateT>>`.

Reviewed By: gribozavr2, sgatev, ymandel

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

2 years ago[CombinerHelper] Avoid deprecated method (NFC)
Nikita Popov [Thu, 1 Sep 2022 14:09:05 +0000 (16:09 +0200)]
[CombinerHelper] Avoid deprecated method (NFC)

2 years ago[LICM] Regenerate test checks (NFC)
Nikita Popov [Thu, 1 Sep 2022 14:06:26 +0000 (16:06 +0200)]
[LICM] Regenerate test checks (NFC)

2 years ago[clang][dataflow] Add `SetupTest` parameter for `AnalysisInputs`.
Wei Yi Tee [Thu, 1 Sep 2022 13:23:39 +0000 (13:23 +0000)]
[clang][dataflow] Add `SetupTest` parameter for `AnalysisInputs`.

Moves the work required for retrieving annotation states into the `SetupTest` and `PostVisitCFG` callback to avoid having to run a separate pass over the CFG after analysis has completed.

Reviewed By: gribozavr2, sgatev, ymandel

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

2 years ago[LICM] Remove unnecessary condition (NFC)
Nikita Popov [Thu, 1 Sep 2022 13:41:51 +0000 (15:41 +0200)]
[LICM] Remove unnecessary condition (NFC)

2 years ago[LICM] Fix thread safety checks for promotion of byval args
Nikita Popov [Thu, 1 Sep 2022 13:29:40 +0000 (15:29 +0200)]
[LICM] Fix thread safety checks for promotion of byval args

This code was relying on a very subtle contract: The expectation
was that for non-allocas, the unwind safety check would already
perform a capture check, so we don't need to perform it later.
This held true when this unwind safety was only handled for allocas
and noalias calls, but became incorrect when byval support was
added.

To avoid this kind of issue, just remove the dependency between the
unwind and thread-safety checks entirely. At worst, this means we
perform a redundant capture check. If this should turn out to be
problematic for compile-time, we can cache that query in a more
explicit way.

2 years ago[clang][dataflow] Refactor `TestingSupport.h`
Wei Yi Tee [Thu, 1 Sep 2022 12:48:33 +0000 (12:48 +0000)]
[clang][dataflow] Refactor `TestingSupport.h`

- Add `AnalysisInputs` struct as the parameters for `checkDataflow`, and renamed `AnalysisData` struct to `AnalysisOutputs` which contains the data structures generated from a dataflow analysis run.

- Remove compulsory binding from statement to annotations. Instead, `checkDataflow` in the most general form takes a `VerifyResults` callback which takes as input an `AnalysisOutputs` struct. This struct contains the data structures generated by the analysis that can then be tested. We then introduce two overloads/wrappers of `checkDataflow` for different mechanisms of testing - one which exposes annotation line numbers and is not restricted to statements, and the other which exposes states computed after annotated statements. In the future, we should look at retrieving the analysis states for constructs other than statements.

Reviewed By: gribozavr2, sgatev

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

2 years agoReapply "[DebugInfo] Extend the InstrRef LDV to support DbgValues with many Ops"
Stephen Tozer [Tue, 30 Aug 2022 13:30:47 +0000 (14:30 +0100)]
Reapply "[DebugInfo] Extend the InstrRef LDV to support DbgValues with many Ops"

Re-landing with an erroneous assert removed.

This reverts commit 58d104b352a65bec3fb7a8fd23bf2d408b4c76f7.

2 years ago[LICM] Add another byval capture test (NFC)
Nikita Popov [Thu, 1 Sep 2022 13:16:08 +0000 (15:16 +0200)]
[LICM] Add another byval capture test (NFC)

Variant with capture after the loop, in which case promotion is
safe.

2 years ago[clang] cleanup -fstrict-flex-arrays implementation
serge-sans-paille [Tue, 30 Aug 2022 14:49:53 +0000 (16:49 +0200)]
[clang] cleanup -fstrict-flex-arrays implementation

This is a follow up to https://reviews.llvm.org/D126864, addressing some remaining
comments.

It also considers union with a single zero-length array field as FAM for each
value of -fstrict-flex-arrays.

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

2 years ago[LICM] Add test for byval scalar promotion miscompile (NFC)
Nikita Popov [Thu, 1 Sep 2022 13:02:55 +0000 (15:02 +0200)]
[LICM] Add test for byval scalar promotion miscompile (NFC)

2 years ago[SPIRV] support builtin types and ExtInsts selection
Ilia Diachkov [Wed, 31 Aug 2022 11:53:02 +0000 (14:53 +0300)]
[SPIRV] support builtin types and ExtInsts selection

The patch adds the support of OpenCL and SPIR-V built-in types. It also
implements ExtInst selection and adds spv_unreachable and spv_alloca
intrinsics which improve the generation of the corresponding SPIR-V code.
Five LIT tests are included to demonstrate the improvement.

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

Co-authored-by: Aleksandr Bezzubikov <zuban32s@gmail.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[InstCombine] fix crash on type mismatch with fcmp fold
Sanjay Patel [Thu, 1 Sep 2022 12:32:06 +0000 (08:32 -0400)]
[InstCombine] fix crash on type mismatch with fcmp fold

The existing predicate doesn't work for a single-element
vector, so make sure we are not crossing scalar/vector types.

Test (was crashing) based on the post-commit example for:
482777123427

2 years ago[InstCombine] fold power-of-2 ctlz/cttz with inverted result
Sanjay Patel [Wed, 31 Aug 2022 20:05:53 +0000 (16:05 -0400)]
[InstCombine] fold power-of-2 ctlz/cttz with inverted result

When X is a power-of-two or zero and zero input is poison:
ctlz(i32 X) ^ 31 --> cttz(X)
cttz(i32 X) ^ 31 --> ctlz(X)

https://alive2.llvm.org/ce/z/Cs7sFE

2 years ago[RISCV][NFC] Fix typo in comment in RISCVInstrInfoZicbo.td
Alex Bradbury [Thu, 1 Sep 2022 12:49:55 +0000 (13:49 +0100)]
[RISCV][NFC] Fix typo in comment in RISCVInstrInfoZicbo.td

Zicbop->Zicbom typo.

2 years ago[LICM] Add some debug output to scalar promotion (NFC)
Nikita Popov [Thu, 1 Sep 2022 08:48:49 +0000 (10:48 +0200)]
[LICM] Add some debug output to scalar promotion (NFC)

2 years ago[GVN] Pre-commit test case showing miscompile in github issue #57025
Bjorn Pettersson [Fri, 12 Aug 2022 12:56:23 +0000 (14:56 +0200)]
[GVN] Pre-commit test case showing miscompile in github issue #57025

This commit adds a reproducer for
  https://github.com/llvm/llvm-project/issues/57025
showing a miscompile in GVN.

Not sure how likely this kind of faults would be in a normal pipeline,
considering that the input IR has some dead code in it. On the other
hand, GVN itself sometimes creates dead basic blocks when splitting
critical edges. Anyway, the fault was found when doing fuzzy testing
using random pass pipelines.

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

2 years ago[SLP]Fix PR55734: SLP vectorizer's reduce_and formation introduces poison.
Alexey Bataev [Wed, 1 Jun 2022 22:37:51 +0000 (15:37 -0700)]
[SLP]Fix PR55734: SLP vectorizer's reduce_and formation introduces poison.

Need either follow the original order of the operands for bool logical
ops, or emit freeze instruction to avoid poison propagation.

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

2 years ago[GlobalISel] Add sdiv exact (X, constant) -> mul combine.
Amara Emerson [Mon, 25 Jul 2022 21:21:40 +0000 (14:21 -0700)]
[GlobalISel] Add sdiv exact (X, constant) -> mul combine.

This port of the SDAG optimization is only for exact sdiv case.

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

2 years ago[DebugInfo] Missing debug location after replacement in processSRem function
Yuanbo Li [Thu, 1 Sep 2022 10:03:48 +0000 (11:03 +0100)]
[DebugInfo] Missing debug location after replacement in processSRem function

This patch fixes an issue in which CorrelatedValuePropagation::processSRem
would create new instructions to represent the SRem instruction, but would not
correctly copy any existing debug location metadata to the new instruction.

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

2 years ago[Clang][Comments] Parse `<img src=""/>` in doc comments correctly
Egor Zhdan [Tue, 30 Aug 2022 11:55:43 +0000 (12:55 +0100)]
[Clang][Comments] Parse `<img src=""/>` in doc comments correctly

This is a valid HTML5 tag. Previously it triggered a Clang error (`HTML start tag prematurely ended, expected attribute name or '>'`) since Clang was treating `/>` as a text token. This was happening because after lexing the closing quote (`"`) the lexer state was reset to "Normal" while the tag was not actually closed yet: `>` was not yet parsed at that point.

rdar://91464292

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

2 years ago[lldb] [Core] Pass error/status from Communication::ReadThread()
Michał Górny [Tue, 23 Aug 2022 17:20:25 +0000 (19:20 +0200)]
[lldb] [Core] Pass error/status from Communication::ReadThread()

Ensure that the ConnectionStatus and Status from
Communication::ReadThread() is correctly passed to ::Read() in order
to fix further discrepancies between ::Read() calls in non-threaded
and threaded modes.

Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.llvm.org/D132577

2 years ago[VPlan] Add field to track if intrinsic should be used for call. (NFC)
Florian Hahn [Thu, 1 Sep 2022 12:14:40 +0000 (13:14 +0100)]
[VPlan] Add field to track if intrinsic should be used for call. (NFC)

This patch moves the cost-based decision whether to use an intrinsic or
library call to the point where the recipe is created. This untangles
code-gen from the cost model and also avoids doing some extra work as
the information is already computed at construction.

Reviewed By: Ayal

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

2 years ago[mlir] Address post commit comments on 8f2457ccf01f00bb83bd391ac04209e75361fb9a and...
Nicolas Vasilache [Thu, 1 Sep 2022 11:37:56 +0000 (04:37 -0700)]
[mlir] Address post commit comments on 8f2457ccf01f00bb83bd391ac04209e75361fb9a and fix the test

2 years ago[Flang][OpenMP] Add support for real typed reductions in worksharing-loop
Dylan Fleming [Thu, 1 Sep 2022 10:24:32 +0000 (10:24 +0000)]
[Flang][OpenMP] Add support for real typed reductions in worksharing-loop

Allows addition/multiplication reductions to be used with
real types by adding getReductionOperation() to OpenMP.cpp,
which can select either integer or floating-point instruction.

Reviewed By: kiranchandramohan

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

2 years agoRevert "Expand Div/Rem: consider the case where the dividend is zero"
Nuno Lopes [Thu, 1 Sep 2022 11:10:35 +0000 (12:10 +0100)]
Revert "Expand Div/Rem: consider the case where the dividend is zero"

This reverts commit 4aed09868b5a51a29aade11d9d412c3313310f29.

2 years ago[CTE][docs] Fix bad links in ReleaseNotes
Nathan James [Thu, 1 Sep 2022 11:10:53 +0000 (12:10 +0100)]
[CTE][docs] Fix bad links in ReleaseNotes

2 years ago[mlir][Linalg] Add missing support for memory space to DropUnitDims
Nicolas Vasilache [Wed, 31 Aug 2022 22:08:35 +0000 (15:08 -0700)]
[mlir][Linalg] Add missing support for memory space to DropUnitDims

Previously, the memory space would not be propagated properly, creating invalid IR.

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

2 years agoExpand Div/Rem: consider the case where the dividend is zero
Nuno Lopes [Thu, 1 Sep 2022 11:00:03 +0000 (12:00 +0100)]
Expand Div/Rem: consider the case where the dividend is zero
So we can't use ctlz in poison-producing mode

2 years ago[DeadArgElim] Use structure bindings in foreach loops. NFC
Pavel Samolysov [Wed, 31 Aug 2022 14:44:34 +0000 (17:44 +0300)]
[DeadArgElim] Use structure bindings in foreach loops. NFC

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

2 years ago[gn build] Port d931ac9e27ca
LLVM GN Syncbot [Thu, 1 Sep 2022 10:19:04 +0000 (10:19 +0000)]
[gn build] Port d931ac9e27ca

2 years ago[clang][dataflow] Generalise match switch utility to other AST types and add a `CFGMa...
Wei Yi Tee [Thu, 1 Sep 2022 08:39:59 +0000 (08:39 +0000)]
[clang][dataflow] Generalise match switch utility to other AST types and add a `CFGMatchSwitch` which currently handles `CFGStmt` and `CFGInitializer`.

`MatchSwitch` currently takes in matchers and functions for the `Stmt` class.

This patch generalises the match switch utility (renamed to `ASTMatchSwitch`) to work for different AST node types by introducing a template argument which is the base type for the AST nodes that the match switch will handle.

A `CFGMatchSwitch` is introduced as a wrapper around multiple `ASTMatchSwitch`s for different base types. It works by unwrapping `CFGElement`s into their contained AST nodes and passing the nodes to the relevant `ASTMatchSwitch`. The `CFGMatchSwitch` currently only handles `CFGStmt` and `CFGInitializer`.

Reviewed By: gribozavr2, sgatev

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

2 years ago[clang][WebAssembly] Pass `-Wa,--no-type-check` through to the MC layer
Sam Clegg [Thu, 4 Aug 2022 23:03:21 +0000 (16:03 -0700)]
[clang][WebAssembly] Pass `-Wa,--no-type-check` through to the MC layer

I took as an example the `-Wa,--noexecstack` clang flag that maps down
to `cc1 -mnoexecstack`.

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

2 years ago[LLDB] Simplify cmake for instruction emulation unit tests
David Spickett [Wed, 31 Aug 2022 14:41:57 +0000 (14:41 +0000)]
[LLDB] Simplify cmake for instruction emulation unit tests

I got suspicious because of checking "ARM" for an "ARM64" plugin.
As far as I can tell these never needed an llvm target to function.

Looking at the corresponding cmake for the libraries under test they
don't reference target libraries either.

Reviewed By: labath

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

2 years ago[OpenCL][SPIR-V] Test extern functions with a pointer arg.
Anastasia Stulova [Thu, 1 Sep 2022 09:18:03 +0000 (10:18 +0100)]
[OpenCL][SPIR-V] Test extern functions with a pointer arg.

Added a test case that enhances coverage of opaque pointers
particularly for the problematic case with extern functions
for which there is no solution found for type recovery.

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

2 years ago[NFC][clang] LLVM_FALLTHROUGH => [[fallthrough]]
Sheng [Thu, 1 Sep 2022 09:17:46 +0000 (09:17 +0000)]
[NFC][clang] LLVM_FALLTHROUGH => [[fallthrough]]

2 years ago[LLVM] Add missing stdint include to Bit.h
David Spickett [Thu, 1 Sep 2022 08:54:57 +0000 (08:54 +0000)]
[LLVM] Add missing stdint include to Bit.h

To fix failing builds on Windows on Arm:
https://lab.llvm.org/staging/#/builders/59/builds/928/steps/4/logs/stdio

<...>/ADT/bit.h(50,5): error: unknown type name 'uint32_t'
    uint32_t v = Value;
    ^

2 years agoRevert "[test][msan] Basic debug info test"
Douglas Yung [Thu, 1 Sep 2022 09:09:04 +0000 (02:09 -0700)]
Revert "[test][msan] Basic debug info test"

This reverts commit ed241e873009dd0a32c6eb0dc02885d37c05e1cd.

This test is failing on many bots:

https://lab.llvm.org/buildbot/#/builders/3/builds/12656
https://lab.llvm.org/buildbot/#/builders/6/builds/12696
https://lab.llvm.org/buildbot/#/builders/9/builds/12687
https://lab.llvm.org/buildbot/#/builders/58/builds/25332
https://lab.llvm.org/buildbot/#/builders/67/builds/8059
https://lab.llvm.org/buildbot/#/builders/117/builds/8806
https://lab.llvm.org/buildbot/#/builders/139/builds/27430
https://lab.llvm.org/buildbot/#/builders/164/builds/24139
https://lab.llvm.org/buildbot/#/builders/216/builds/9144

2 years ago[LLDB] Make build.py use uname to set platform
Muhammad Omair Javaid [Wed, 31 Aug 2022 11:33:45 +0000 (16:33 +0500)]
[LLDB] Make build.py use uname to set platform

This patch makes build helper script build.py to use platform.uname for
machine/architecture detection. Visual studio environment when set using
various batch files like vcvars*.bat set PLATFORM environment variable
however VsDevCmd.bat does not set PLATFORM variable.

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

2 years ago[LLDB] Make API tests to run using MSYS tools
Muhammad Omair Javaid [Wed, 31 Aug 2022 08:08:57 +0000 (13:08 +0500)]
[LLDB] Make API tests to run using MSYS tools

MSYS 'uname' on windows returns "MSYS_NT*" instead of windows32 and also
MSYS 'pwd' returns non-windows path string.
This patch fixes Makefile.rules to make adjustments required to run LLDB
API tests using MSYS tools.

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

2 years ago[InstCombine] Fold extractvalue of phi
Nikita Popov [Thu, 1 Sep 2022 08:48:49 +0000 (10:48 +0200)]
[InstCombine] Fold extractvalue of phi

Just as we do for most other operations, we should push
extractvalue instructions through phis, if this does not increase
unfolded instruction count.

2 years ago[InstCombine] Add tests for extractvalue of phi (NFC)
Nikita Popov [Thu, 1 Sep 2022 08:46:44 +0000 (10:46 +0200)]
[InstCombine] Add tests for extractvalue of phi (NFC)

2 years ago[NFC] Emit builtin coroutine calls uniforally
Chuanqi Xu [Thu, 1 Sep 2022 08:30:43 +0000 (16:30 +0800)]
[NFC] Emit builtin coroutine calls uniforally

All the coroutine builtins were emitted in EmitCoroutineIntrinsic except
__builtin_coro_size. This patch tries to emit all the corotine builtins
uniformally.

2 years ago[MC][WebAssembly] Allow accurate errors in doBeforeLabelEmit
Sam Clegg [Wed, 31 Aug 2022 12:50:11 +0000 (05:50 -0700)]
[MC][WebAssembly] Allow accurate errors in doBeforeLabelEmit

Although we only currently have one error produced in this function I am
working on changes right now that add some more.  This change makes the
error location more accurate.

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