platform/upstream/llvm.git
2 years ago[mlir] Also update inferReturnTensorTypes (NFC)
Jacques Pienaar [Thu, 22 Jul 2021 20:57:36 +0000 (13:57 -0700)]
[mlir] Also update inferReturnTensorTypes (NFC)

Missed this one in the first go.

2 years ago[lldb] Fix build failure introduced by 3d4cadfb26437bd686ca8177f5454a366fed59eb
Med Ismail Bennani [Thu, 22 Jul 2021 20:54:27 +0000 (20:54 +0000)]
[lldb] Fix build failure introduced by 3d4cadfb26437bd686ca8177f5454a366fed59eb

This patch updates the `ScriptedProcess::GetGenericInteger` return type
to `llvm::Optional<unsigned long long>` to match implementation.

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2 years ago[lldb/Interpreter] Conform ScriptedProcessPythonInterface to SWIG python types
Med Ismail Bennani [Thu, 22 Jul 2021 20:47:25 +0000 (20:47 +0000)]
[lldb/Interpreter] Conform ScriptedProcessPythonInterface to SWIG python types

This patch should address the compiler warnings due to mismatch type
comparaison.

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2 years ago[LLD] [COFF] Make -export-all-symbols work as intended for EXEs
Martin Storsjö [Sun, 18 Jul 2021 19:52:32 +0000 (22:52 +0300)]
[LLD] [COFF] Make -export-all-symbols work as intended for EXEs

If some symbols are marked with dllexport, we still want to export
all symbols if -export-all-symbols is specified. Previously, this
only worked as it should for DLL output, not for EXE.

This should fix downstream bug
https://github.com/msys2/MINGW-packages/issues/9163.

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

2 years ago[MLGO] Correct protobuf path
Mircea Trofin [Thu, 22 Jul 2021 20:24:28 +0000 (13:24 -0700)]
[MLGO] Correct protobuf path

2 years ago[clang-tidy] performance-unnecessary-copy-initialization: Create option to exclude...
Felix Berger [Fri, 16 Jul 2021 18:38:47 +0000 (14:38 -0400)]
[clang-tidy] performance-unnecessary-copy-initialization: Create option to exclude container types from triggering the check.

Add string list option of type names analagous to `AllowedTypes` which lets
users specify a list of ExcludedContainerTypes.

Types matching this list will not trigger the check when an expensive variable
is copy initialized from a const accessor method they provide, i.e.:

```
ExcludedContainerTypes = 'ExcludedType'

void foo() {
  ExcludedType<ExpensiveToCopy> Container;
  const ExpensiveToCopy NecessaryCopy = Container.get();
}
```

Even though an expensive to copy variable is copy initialized the check does not
trigger because the container type is excluded.

This is useful for container types that don't own their data, such as view types
where modification of the returned references in other places cannot be reliably
tracked, or const incorrect types.

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

Reviewed-by: ymandel
2 years ago[WebAssembly] Implementation of global.get/set for reftypes in LLVM IR
Paulo Matos [Thu, 22 Jul 2021 19:11:39 +0000 (21:11 +0200)]
[WebAssembly] Implementation of global.get/set for reftypes in LLVM IR

Reland of 31859f896.

This change implements new DAG notes GLOBAL_GET/GLOBAL_SET, and
lowering methods for load and stores of reference types from IR
globals. Once the lowering creates the new nodes, tablegen pattern
matches those and converts them to Wasm global.get/set.

Reviewed By: tlively

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

2 years ago[NFC][MLGO] Fix vector sizing
Mircea Trofin [Thu, 22 Jul 2021 19:47:49 +0000 (12:47 -0700)]
[NFC][MLGO] Fix vector sizing

The bots only build release mode, and the use of `reserve` instead of
`resize`, while not causing invalid memory accesses, is incorrect.

2 years ago[AIX] Define __LONGDOUBLE64 macro
Jake Egan [Thu, 22 Jul 2021 19:44:26 +0000 (15:44 -0400)]
[AIX] Define __LONGDOUBLE64 macro

This patch defines the macro __LONGDOUBLE64 for AIX when long double is 8 bytes.

Reviewed By: cebowleratibm

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

2 years ago[NFCI][TLI] prepare[US]REMEqFold(): don't add nonsensical 'exact' flag to rotates...
Roman Lebedev [Thu, 22 Jul 2021 19:59:22 +0000 (22:59 +0300)]
[NFCI][TLI] prepare[US]REMEqFold(): don't add nonsensical 'exact' flag to rotates created

As pointed out by Craig Topper.

2 years ago[ms] [llvm-ml] Fix macro case-insensitivity
Eric Astor [Thu, 22 Jul 2021 19:50:37 +0000 (15:50 -0400)]
[ms] [llvm-ml] Fix macro case-insensitivity

We previously had issues identifying macros not registered with a lowercase name.

Reviewed By: mstorsjo, thakis

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

2 years ago[AIX] Generate large code model relocations when mcmodel=medium on AIX
Anjan Kumar Guttahalli Krishna [Thu, 22 Jul 2021 04:20:11 +0000 (00:20 -0400)]
[AIX] Generate large code model relocations when mcmodel=medium on AIX

This patch makes the changes in the driver that converts the medium code
model to large.

Reviewed By: hubert.reinterpretcast

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

2 years agoFix TSAN signal interceptor out-of-bound access
Shu-Chun Weng [Wed, 21 Jul 2021 17:59:09 +0000 (10:59 -0700)]
Fix TSAN signal interceptor out-of-bound access

signal(2) and sigaction(2) have defined behaviors for invalid signal number
(EINVAL) and some programs rely on it.

The added test case also reveals that MSAN is too strict in this regard.

Test case passed on x86_64 Linux and AArch64 Linux.

Reviewed By: vitalybuka

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

2 years ago[LICM][SCCP] Regenerate test checks (NFC)
Nikita Popov [Thu, 22 Jul 2021 19:06:39 +0000 (21:06 +0200)]
[LICM][SCCP] Regenerate test checks (NFC)

2 years ago[AIX] Clang's library integration support for 128-bit long double is incomplete on...
Anjan Kumar Guttahalli Krishna [Thu, 22 Jul 2021 19:32:06 +0000 (15:32 -0400)]
[AIX] Clang's library integration support for 128-bit long double is incomplete on AIX.

Emit the unsupported option error until the Clang's library integration support for 128-bit long double is available for AIX.

Reviewed By: Whitney, cebowleratibm

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

2 years ago[mlir] Update to use ValueShapeRange (NFC)
Jacques Pienaar [Thu, 22 Jul 2021 19:24:48 +0000 (12:24 -0700)]
[mlir] Update to use ValueShapeRange (NFC)

Update to use alias in preparation for changing it to not just be a pure alias.

2 years ago[libomptarget][amdgpu][nfc] Normalise license headers
Jon Chesterfield [Thu, 22 Jul 2021 19:22:49 +0000 (20:22 +0100)]
[libomptarget][amdgpu][nfc] Normalise license headers

Reviewed By: gregrodgers, jdoerfert

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

2 years ago[SimplifyCFG] FoldTwoEntryPHINode(): bailout on inverted logical and/or (PR51149)
Roman Lebedev [Thu, 22 Jul 2021 19:11:46 +0000 (22:11 +0300)]
[SimplifyCFG] FoldTwoEntryPHINode(): bailout on inverted logical and/or (PR51149)

The logical (select) form of and/or will now be a source of problems.
We don't really account for it's inverted form, yet it exists,
and presumably we should treat it just like non-inverted form:
https://alive2.llvm.org/ce/z/BU9AXk

https://bugs.llvm.org/show_bug.cgi?id=51149 reports a reportedly-serious
perf regression that will hopefully be mitigated by this.

2 years ago[NFC][SimplifyCFG] Add some more tests w/ two-entry PHI nodes and
Roman Lebedev [Thu, 22 Jul 2021 19:07:23 +0000 (22:07 +0300)]
[NFC][SimplifyCFG] Add some more tests w/ two-entry PHI nodes and

2 years ago[clang-tidy] performance-unnecessary-copy-initialization: Disable check when variable...
Felix Berger [Wed, 14 Jul 2021 20:11:55 +0000 (16:11 -0400)]
[clang-tidy] performance-unnecessary-copy-initialization: Disable check when variable and initializer have different replaced template param types.

This can happen when a template with two parameter types is instantiated with a
single type. The fix would only be valid for this instantiation but fail for
others that rely on an implicit type conversion.

The test cases illustrate when the check should trigger and when not.

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

2 years ago[nfc] Fix typo in comment, s/node/note
Jon Chesterfield [Thu, 22 Jul 2021 19:16:53 +0000 (20:16 +0100)]
[nfc] Fix typo in comment, s/node/note

2 years ago[CostModel][X86] Adjust shift SSE4 legalized costs based on llvm-mca reports.
Simon Pilgrim [Thu, 22 Jul 2021 19:07:18 +0000 (20:07 +0100)]
[CostModel][X86] Adjust shift SSE4 legalized costs based on llvm-mca reports.

Update shl/lshr/ashr costs based on the worst case costs from the script in D103695 - many of the 128-bit shifts (usually where integer multiplies aren't used) have similar behaviour to AVX1 so we can merge them.

2 years ago[CostModel][X86] Fix funnel shift check prefixes
Simon Pilgrim [Thu, 22 Jul 2021 19:00:05 +0000 (20:00 +0100)]
[CostModel][X86] Fix funnel shift check prefixes

We'd lost AVX1 test coverage due to bulldozer (XOP) trying to use the same check prefixes - we really need to fix the update script to avoid this!

2 years ago[libomptarget][amdgpu][nfc] Replace use of gelf.h with libelf.h
Jon Chesterfield [Thu, 22 Jul 2021 19:04:13 +0000 (20:04 +0100)]
[libomptarget][amdgpu][nfc] Replace use of gelf.h with libelf.h

AMDGPU can assume Elf64 so doesn't need to abstract over Elf32

Drop a few other unused headers at the same time. Now only llvm elf
and libelf are used by the plugin.

Reviewed By: jdoerfert

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

2 years agoCorrectly diagnose taking the address of a register variable in C
Aaron Ballman [Thu, 22 Jul 2021 18:49:21 +0000 (14:49 -0400)]
Correctly diagnose taking the address of a register variable in C

We caught the cases where the user would explicitly use the & operator,
but we were missing implicit conversions such as array decay.

Fixes PR26336. Thanks to Samuel Neves for inspiration for the patch.

2 years ago[gn build] Port 3959c95deb11
LLVM GN Syncbot [Thu, 22 Jul 2021 18:41:45 +0000 (18:41 +0000)]
[gn build] Port 3959c95deb11

2 years ago[X86] Fix SLM FP<->INT throughputs.
Simon Pilgrim [Thu, 22 Jul 2021 18:26:07 +0000 (19:26 +0100)]
[X86] Fix SLM FP<->INT throughputs.

Noticed while trying to clean up the shift costs model for SSE4 targets using the script in D10369 - SLM double-pumps all the 128-bit vector conversion ops and only use FP0 pipe - numbers taken from Intel AOM + Agner.

2 years ago[ARC] Add disassembly for the conditioned RSUB immediate instruction
Thomas Johnson [Thu, 22 Jul 2021 18:15:24 +0000 (11:15 -0700)]
[ARC] Add disassembly for the conditioned RSUB immediate instruction

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

2 years ago[Matrix] Fix -Wunused-variable in -DLLVM_ENABLE_ASSERTIONS=off build after D106457...
Fangrui Song [Thu, 22 Jul 2021 18:33:01 +0000 (11:33 -0700)]
[Matrix] Fix -Wunused-variable in -DLLVM_ENABLE_ASSERTIONS=off build after D106457. NFC

2 years ago[libc++] Add helper type non-propagating-cache
Louis Dionne [Mon, 19 Jul 2021 16:12:49 +0000 (12:12 -0400)]
[libc++] Add helper type non-propagating-cache

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

2 years ago[libc++][docs] Take lock for range.single.view.
zoecarver [Thu, 22 Jul 2021 18:15:24 +0000 (11:15 -0700)]
[libc++][docs] Take lock for range.single.view.

Mark this item as in progress and assigned to me.

2 years ago[clang][test] Add -fuse-ld= to test case added in 2542c1a5a130 to resolve test failur...
Alex Lorenz [Thu, 22 Jul 2021 18:12:38 +0000 (11:12 -0700)]
[clang][test] Add -fuse-ld= to test case added in 2542c1a5a130 to resolve test failure with CLANG_DEFAULT_LINKER=lld

2 years ago[Matrix] Fix miscompile for NT matmul if the transpose has other use
Adam Nemet [Wed, 21 Jul 2021 16:46:47 +0000 (09:46 -0700)]
[Matrix] Fix miscompile for NT matmul if the transpose has other use

We should only add the fake lowering entry for the matrix remark if the
transpose is not lowered on its own.  `MapVector::insert` is used to insert
the entry during proper lowering which does not overwrite the fake entry in
the map.

We actually had test coverage for this but the reference output code was
wrong; it was storing undef rather than the transposed column.

Also add an assert that would have caught this.

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

2 years ago[mlir] Improve description of interface options
Marius Brehler [Thu, 22 Jul 2021 12:06:52 +0000 (12:06 +0000)]
[mlir] Improve description of interface options

Reviewed By: rriddle

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

2 years ago[InstCombine][test] add coverage for possible fabs folds; NFC
Krishna Kariya [Thu, 22 Jul 2021 17:18:57 +0000 (13:18 -0400)]
[InstCombine][test] add coverage for possible fabs folds; NFC

This goes with D101727 (adds FMF to the select).

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

2 years ago[clang][driver][darwin] Add driver support for Mac Catalyst
Alex Lorenz [Tue, 13 Jul 2021 19:33:04 +0000 (12:33 -0700)]
[clang][driver][darwin] Add driver support for Mac Catalyst

This commit adds driver support for the Mac Catalyst target,
as supported by the Apple clang compile

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

2 years ago[AArch64] Adjust the cost of integer sum reductions
David Green [Thu, 22 Jul 2021 17:19:54 +0000 (18:19 +0100)]
[AArch64] Adjust the cost of integer sum reductions

This changes the cost to (LT.first-1) * cost(add) + 2, where the cost of
an add is assumed to be 1. This brings it inline with the other
reductions.

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

2 years ago[CostModel][X86] Adjust shift SSE legalized costs based on llvm-mca reports.
Simon Pilgrim [Thu, 22 Jul 2021 16:40:44 +0000 (17:40 +0100)]
[CostModel][X86] Adjust shift SSE legalized costs based on llvm-mca reports.

Update shl/lshr/ashr costs based on the worst case costs from the script in D103695.

2 years ago[OpenMPOpt] Add support for BooleanStateWithSetVector
Shilei Tian [Thu, 22 Jul 2021 16:37:43 +0000 (12:37 -0400)]
[OpenMPOpt] Add support for BooleanStateWithSetVector

D101977 added `BooleanStateWithPtrSetVector` to store pointers to a set meanwhile
tracking boolean state. One of the limitation is that it can only store pointer.
We might want it to store other types of values, such as integer for parallel
level. This patch generalizes the idea and create `BooleanStateWithSetVector`.
`BooleanStateWithPtrSetVector` therefore becomes a type alias of `BooleanStateWithSetVector`.

Reviewed By: jdoerfert

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

2 years ago[test] Add llvm-stress to LLVM_TEST_DEPENDS and lit substitutions
Fangrui Song [Thu, 22 Jul 2021 16:37:01 +0000 (09:37 -0700)]
[test] Add llvm-stress to LLVM_TEST_DEPENDS and lit substitutions

D106430 added a test which needs LLVM_TEST_DEPENDS and lit substitution.

2 years ago[MLIR][memref] Fix findDealloc() to handle > 1 dealloc for the given alloc.
Rahul Joshi [Thu, 22 Jul 2021 00:13:40 +0000 (17:13 -0700)]
[MLIR][memref] Fix findDealloc() to handle > 1 dealloc for the given alloc.

- Change findDealloc() to return Optional<Operation *> and return None if > 1
  dealloc is associated with the given alloc.
- Add findDeallocs() to return all deallocs associated with the given alloc.
- Fix current uses of findDealloc() to bail out if > 1 dealloc is found.

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

2 years ago[libomptarget][amdgpu] Implement dlopen of libhsa
Jon Chesterfield [Thu, 22 Jul 2021 15:54:10 +0000 (16:54 +0100)]
[libomptarget][amdgpu] Implement dlopen of libhsa

AMDGPU plugin equivalent of D95155, build without HSA installed locally

Compiles a new file, plugins/amdgpu/dynamic_hsa/hsa.cpp, to an object file that
exposes the same symbols that the plugin presently uses from hsa. The object
file contains dlopen of hsa and cached dlsym calls. Also provides header files
corresponding to the subset that is used.

This is behind a feature flag, LIBOMPTARGET_FORCE_DLOPEN_LIBHSA, default off.
That allows developers to build against the dlopen/dlsym implementation, e.g.
while testing this mode.

Enabling by default will cause this plugin to build on a wider variety of
machines than it does at present so may break some CI builds. That risk can
be minimised by reviewing the header dependencies of the library and ensuring
it doesn't use any libraries that are not already used by libomptarget.

Separating the implementation from enabling by default in case the latter needs
to be rolled back after wider CI results.

Reviewed By: jdoerfert

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

2 years ago[PowerPC] Add PowerPC "__stbcx" builtin and intrinsic for XL compatibility
Victor Huang [Thu, 22 Jul 2021 15:05:30 +0000 (10:05 -0500)]
[PowerPC] Add PowerPC "__stbcx" builtin and intrinsic for XL compatibility

This patch is in a series of patches to provide builtins for compatibility
with the XL compiler. This patch adds the builtin and intrinsic for "__stbcx".

Reviewed By: nemanjai, #powerpc

Differential revision: https://reviews.llvm.org/D106484

2 years ago[OpenCL][NFC] Refactors lang version check in test.
Anastasia Stulova [Thu, 22 Jul 2021 15:43:18 +0000 (16:43 +0100)]
[OpenCL][NFC] Refactors lang version check in test.

Fixed test to use predefined version marco instead
of passing extra macro in the command line.

Patch by Topotuna (Justas Janickas)!

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

2 years ago[OPENMP]Fix PR49787: Codegen for calling __tgt_target_teams_nowait_mapper has too...
Alexey Bataev [Thu, 22 Jul 2021 15:11:49 +0000 (08:11 -0700)]
[OPENMP]Fix PR49787: Codegen for calling __tgt_target_teams_nowait_mapper has too few arguments.

Added missed arguments in
__tgt_target_teams_nowait_mapper/__tgt_target_nowait_mapper runtime
functions calls.

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

2 years ago[lld/mac] Move handling of special undefineds later
Nico Weber [Thu, 22 Jul 2021 14:31:39 +0000 (10:31 -0400)]
[lld/mac] Move handling of special undefineds later

treatUndefinedSymbol() was previously called before gatherInputSections()
and markLive() for these special symbols, but after them for normal
undefineds.

For PR50760, treatUndefinedSymbol() will have to potentially create
sections, so it's good to move treatUndefinedSymbol() for special
undefineds later, so that it can assume that gatherInputSections()
and markLive() has already been called always.

No intended behavior change, but part of PR50760 (and covered in
tests in the patch for the full feature).

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

2 years agoRevert "[OPENMP]Fix PR49787: Codegen for calling __tgt_target_teams_nowait_mapper...
Alexey Bataev [Thu, 22 Jul 2021 15:06:03 +0000 (08:06 -0700)]
Revert "[OPENMP]Fix PR49787: Codegen for calling __tgt_target_teams_nowait_mapper has too few arguments."

This reverts commit b455f7f22564a096c043b02fa159ab16669c121c to fix
buildbots.

2 years ago[lldb] Remove a wrong assert in TestStructTypes that checks that empty structs in...
Raphael Isemann [Thu, 22 Jul 2021 14:56:32 +0000 (16:56 +0200)]
[lldb] Remove a wrong assert in TestStructTypes that checks that empty structs in C always have size 0

D105471 fixes the way we assign sizes to empty structs in C mode. Instead of
just giving them a size 0, we instead use the size we get from DWARF if possible.

After landing D105471 the TestStructTypes test started failing on Windows. The
tests checked that the size of an empty C struct is 0 while the size LLDB now
reports is 4 bytes. It turns out that 4 bytes are the actual size Clang is using
for C structs with the MicrosoftRecordLayoutBuilder. The commit that introduced
that behaviour is 00a061dccc6671c96412d7b28ab2012963208579.

This patch removes that specific check from TestStructTypes. Note that D105471
added a series of tests that already cover this case (and the added checks
automatically adjust to whatever size the target compiler chooses for empty
structs).

2 years ago[OPENMP]Fix PR49787: Codegen for calling __tgt_target_teams_nowait_mapper has too...
Alexey Bataev [Wed, 21 Jul 2021 20:35:09 +0000 (13:35 -0700)]
[OPENMP]Fix PR49787: Codegen for calling __tgt_target_teams_nowait_mapper has too few arguments.

Added missed arguments in
__tgt_target_teams_nowait_mapper/__tgt_target_nowait_mapper runtime
functions calls.

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

2 years ago[HIP] Fix no matching constructor for init of shared_ptr and malloc
Aaron En Ye Shi [Wed, 21 Jul 2021 17:21:04 +0000 (17:21 +0000)]
[HIP] Fix no matching constructor for init of shared_ptr and malloc

Allow standard header versions of malloc and free to be defined
before introducing the device versions.

Fixes: SWDEV-295901

Reviewed By: yaxunl

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

2 years ago[libomptarget][nfc] Improve static assert message in dlwrap
Jon Chesterfield [Thu, 22 Jul 2021 14:24:19 +0000 (15:24 +0100)]
[libomptarget][nfc] Improve static assert message in dlwrap

Revision of D102858. Raise dlwrap arity argument to template argument
so the correct value is given in the error message. E.g. '2 == 1' instead of
'2 == trait<>::nargs'.

Arity higher than it should be:
Before diff
```
$/plugins/cuda/dynamic_cuda/cuda.cpp:23:1: error:
      static_assert failed due to requirement '2 == trait<cudaError_enum (*)(unsigned int)>::nargs'
      "Arity Error"
DLWRAP_INTERNAL(cuInit, 2);
^~~~~~~~~~~~~~~~~~~~~~~~~~
...
$/include/dlwrap.h:166:3: note: expanded from macro
      'DLWRAP_COMMON'
  static_assert(ARITY == trait<decltype(&SYMBOL)>::nargs, "Arity Error");      \
```

After diff
In file included from $/plugins/cuda/dynamic_cuda/cuda.cpp:16:
```
$/include/dlwrap.h:131:3: error: static_assert failed due to
      requirement '2UL == 1UL' "Arity Error"
  static_assert(Requested == Required, "Arity Error");
  ^             ~~~~~~~~~~~~~~~~~~~~~
$/plugins/cuda/dynamic_cuda/cuda.cpp:23:1: note: in
      instantiation of function template specialization 'dlwrap::verboseAssert<2UL, 1UL>' requested
      here
DLWRAP_INTERNAL(cuInit, 2);
```

Arity lower than it should be:
Before diff
```
$/plugins/cuda/dynamic_cuda/cuda.cpp:131:10: error: no
      matching function for call to 'dlwrap_cuInit'
  return dlwrap_cuInit(X);
         ^~~~~~~~~~~~~
$/plugins/cuda/dynamic_cuda/cuda.cpp:23:1: note: candidate
      function not viable: requires 0 arguments, but 1 was provided
DLWRAP_INTERNAL(cuInit, 0);
```

After diff
In file included from $/plugins/cuda/dynamic_cuda/cuda.cpp:16:
```
$/include/dlwrap.h:131:3: error: static_assert failed due to
      requirement '0UL == 1UL' "Arity Error"
  static_assert(Requested == Required, "Arity Error");
  ^             ~~~~~~~~~~~~~~~~~~~~~
$/plugins/cuda/dynamic_cuda/cuda.cpp:23:1: note: in
      instantiation of function template specialization 'dlwrap::verboseAssert<0UL, 1UL>' requested
      here
DLWRAP_INTERNAL(cuInit, 0);
```

Reviewed By: jdoerfert

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

2 years ago[AArch64][SME] Improve diagnostic for vector select register
Cullen Rhodes [Thu, 22 Jul 2021 13:46:19 +0000 (13:46 +0000)]
[AArch64][SME] Improve diagnostic for vector select register

Reviewed By: sdesmalen

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

2 years agoRevert "[clang][fpenv][patch] Change clang option -ffp-model=precise to select ffp...
Melanie Blower [Thu, 22 Jul 2021 13:40:54 +0000 (09:40 -0400)]
Revert "[clang][fpenv][patch] Change clang option -ffp-model=precise to select ffp-contract=on"

This reverts commit b9b696bba6702a31ac0995a494cd31c730ade5ec.
Buildbot failures see https://lab.llvm.org/buildbot#builders/118/builds/4138
and https://lab.llvm.org/buildbot#builders/110/builds/5112

2 years ago[lldb] Fix TestCompletion by using SIGPIPE instead of SIGINT as test signal
Raphael Isemann [Thu, 22 Jul 2021 13:31:12 +0000 (15:31 +0200)]
[lldb] Fix TestCompletion by using SIGPIPE instead of SIGINT as test signal

The test I added in commit 078003482e90ff5c7ba047a3d3152f0b0c392b31 was using
SIGINT for testing the tab completion. The idea is to have a signal that only
has one possible completion and I ended up picking SIGIN -> SIGINT for the test.
However on non-Linux systems there is SIGINFO which is a valid completion for
`SIGIN' and so the test fails there.

This replaces SIGIN -> SIGINT with SIGPIP -> SIGPIPE completion which according
to LLDB's signal list in Host.cpp is the only valid completion.

2 years ago[Transforms] Remove getOrCreateInitFunction (NFC)
Kazu Hirata [Thu, 22 Jul 2021 13:30:39 +0000 (06:30 -0700)]
[Transforms] Remove getOrCreateInitFunction (NFC)

The last use was removed on Jan 16, 2019 in commit
81101de5853b4ed64640220a086a67b16f36f153.

2 years ago[OpenMP] Fix warnings for uninitialized block counts
Joseph Huber [Thu, 22 Jul 2021 12:27:36 +0000 (08:27 -0400)]
[OpenMP] Fix warnings for uninitialized block counts

Summary:
Fixes some warning given for uninitialized block counts if the exection mode is
not recognized. This shouldn't happen in practice because the execution mode is
checked when it's read from the device.

2 years ago[gn build] (manually) port 78bda894129 from 2012 because 924d62ca4a85 added it to...
Nico Weber [Thu, 22 Jul 2021 13:11:07 +0000 (09:11 -0400)]
[gn build] (manually) port 78bda894129 from 2012 because 924d62ca4a85 added it to check-llvm

2 years agoImplement _ExtInt conversion rules
Aaron Ballman [Thu, 22 Jul 2021 13:10:36 +0000 (09:10 -0400)]
Implement _ExtInt conversion rules

Clang implemented the _ExtInt datatype as a bit-precise integer type,
which was then proposed to WG14. WG14 has accepted the proposal
(http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2709.pdf), but Clang
requires some additional work as a result.

In the original Clang implementation, we elected to disallow implicit
conversions involving these types until after WG14 finalized the rules.
This patch implements the rules decided by WG14: no integer promotion
for bit-precise types, conversions prefer the larger of the two types
and in the event of a tie (say _ExtInt(32) and a 32-bit int), the
standard type wins.

There are more changes still needed to conform to N2709, but those will
be handled in follow-up patches.

2 years ago[lldb][NFC] Allow range-based for loops over DWARFDIE's children
Raphael Isemann [Thu, 22 Jul 2021 12:18:57 +0000 (14:18 +0200)]
[lldb][NFC] Allow range-based for loops over DWARFDIE's children

This patch adds the ability to get a DWARFDIE's children as an LLVM range.

This way we can use for range loops to iterate over them and we can use LLVM's
algorithms like `llvm::all_of` to query all children.

The implementation has to do some small shenanigans as the iterator needs to
store a DWARFDIE, but a DWARFDIE container is also a DWARFDIE so it can't return
the iterator by value. I just made the `children` getter a templated function to
avoid the cyclic dependency.

Reviewed By: #lldb, werat, JDevlieghere

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

2 years ago[lldb/Plugins] Add ScriptedProcess Process Plugin
Med Ismail Bennani [Tue, 20 Jul 2021 13:00:54 +0000 (13:00 +0000)]
[lldb/Plugins] Add ScriptedProcess Process Plugin

This patch introduces Scripted Processes to lldb.

The goal, here, is to be able to attach in the debugger to fake processes
that are backed by script files (in Python, Lua, Swift, etc ...) and
inspect them statically.

Scripted Processes can be used in cooperative multithreading environments
like the XNU Kernel or other real-time operating systems, but it can
also help us improve the debugger testing infrastructure by writting
synthetic tests that simulates hard-to-reproduce process/thread states.

Although ScriptedProcess is not feature-complete at the moment, it has
basic execution capabilities and will improve in the following patches.

rdar://65508855

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2 years ago[clang][fpenv][patch] Change clang option -ffp-model=precise to select ffp-contract=on
Melanie Blower [Thu, 22 Jul 2021 11:58:50 +0000 (07:58 -0400)]
[clang][fpenv][patch] Change clang option -ffp-model=precise to select ffp-contract=on

Change the ffp-model=precise to enables -ffp-contract=on (previously
-ffp-model=precise enabled -ffp-contract=fast). This is a follow-up
to Andy Kaylor's comments in the llvm-dev discussion "Floating Point
semantic modes". From the same email thread, I put Andy's distillation
of floating point options and floating point modes into UsersManual.rst
Also fixes bugs.llvm.org/show_bug.cgi?id=50222

Reviewed By: rjmccall, andrew.kaylor

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

2 years ago[lldb] Fix that `process signal` completion always returns all signals
Raphael Isemann [Thu, 22 Jul 2021 11:37:34 +0000 (13:37 +0200)]
[lldb] Fix that `process signal` completion always returns all signals

`CompletionRequest::AddCompletion` adds the given string as completion of the
current command token. `CompletionRequest::TryCompleteCurrentArg` only adds it
if the current token is a prefix of the given string. We're using
`AddCompletion` for the `process signal` handler which means that `process
signal SIGIN` doesn't get uniquely completed to `process signal SIGINT` as we
unconditionally add all other signals (such as `SIGABRT`) as possible
completions.

By using `TryCompleteCurrentArg` we actually do the proper filtering which will
only add `SIGINT` (as that's the only signal with the prefix 'SIGIN' in the
example above).

Reviewed By: mib

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

2 years ago[LoopVectorize] Fix crash for predicated instruction with scalable VF
Caroline Concatto [Wed, 5 May 2021 14:20:16 +0000 (15:20 +0100)]
[LoopVectorize] Fix crash for predicated instruction with scalable VF

This patch avoids computing discounts for predicated instructions  when the
VF is scalable.
There is no support for vectorization of loops with division because the
vectorizer cannot guarantee that zero divisions will not happen.

This loop now does not use VF scalable

```
for (long long i = 0; i < n; i++)
    if (cond[i])
      a[i] /= b[i];
```

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

2 years agoAdd support for zero-sized Scalars as a LowLevelType
Paulo Matos [Fri, 16 Jul 2021 08:34:44 +0000 (10:34 +0200)]
Add support for zero-sized Scalars as a LowLevelType

Opaque values (of zero size) can be stored in memory with the
implemention of reference types in the WebAssembly backend. Since
MachineMemOperand uses LLTs we need to be able to support
zero-sized scalars types in LLTs.

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

2 years ago[lldb][NFCI] Remove redundant accessibility heuristic in the DWARF parser
Raphael Isemann [Thu, 22 Jul 2021 11:31:23 +0000 (13:31 +0200)]
[lldb][NFCI] Remove redundant accessibility heuristic in the DWARF parser

LLDB's DWARF parser has some heuristics for guessing and fixing up the
accessibility of C++ class/struct members after they were already created in the
internal Clang AST. The heuristic is that if a struct/class has a base class,
then it's actually a class and it's members are private unless otherwise
specified.

From what I can see this heuristic isn't sound and also unnecessary. The idea
that inheritance implies that the `class` keyword was used and the default
visibility is `private` is incorrect. Also both GCC and Clang use
`DW_TAG_structure_type` and `DW_TAG_class_type` for `struct` and `class` types
respectively, so the default visibility we infer from that information is always
correct and there is no need to fix it up.

And finally, the access specifiers we set in the Clang AST are anyway unused
within LLDB. The expression parser explicitly ignores them to give users access
to private members and there is not SBAPI functionality that exposes this
information.

This patch removes all the heuristic code for the reasons above and instead
just relies on the access values we infer from the tag kind and explicit
annotations in DWARF.

This patch is NFCI.

Reviewed By: werat

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

2 years ago[lldb] Generalize empty record size computation to avoid giving empty C++ structs...
Raphael Isemann [Thu, 22 Jul 2021 11:25:16 +0000 (13:25 +0200)]
[lldb] Generalize empty record size computation to avoid giving empty C++ structs a size of 0

C doesn't allow empty structs but Clang/GCC support them and give them a size of 0.

LLDB implements this by checking the tag kind and if it's `DW_TAG_structure_type` then
we give it a size of 0 via an empty external RecordLayout. This is done because our
internal TypeSystem is always in C++ mode (which means we would give them a size
of 1).

The current check for when we have this special case is currently too lax as types with
`DW_TAG_structure_type` can also occur in C++ with types defined using the `struct`
keyword. This means that in a C++ program with `struct Empty{};`, LLDB would return
`0` for `sizeof(Empty)` even though the correct size is 1.

This patch removes this special case and replaces it with a generic approach that just
assigns empty structs the byte_size as specified in DWARF. The GCC/Clang special
case is handles as they both emit an explicit `DW_AT_byte_size` of 0. And if another
compiler decides to use a different byte size for this case then this should also be
handled by the same code as long as that information is provided via `DW_AT_byte_size`.

Reviewed By: werat, shafik

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

2 years agoRevert "[hwasan] Use stack safety analysis."
Florian Mayer [Thu, 22 Jul 2021 11:15:54 +0000 (12:15 +0100)]
Revert "[hwasan] Use stack safety analysis."

This reverts commit bde9415fef25e9ff6e10595a2f4f5004dd62f10a.

2 years ago[LoopIdiom] Transform memmove-like loop into memmove (PR46179)
Dawid Jurczak [Thu, 22 Jul 2021 09:42:59 +0000 (11:42 +0200)]
[LoopIdiom] Transform memmove-like loop into memmove (PR46179)

The purpose of patch is to learn Loop idiom recognition pass how to recognize simple memmove patterns
in similar way like GCC: https://godbolt.org/z/fh95e83od
LoopIdiomRecognize already has machinery for memset and memcpy recognition, patch tries to extend exisiting capabilities with minimal effort.

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

2 years ago[hwasan] Use stack safety analysis.
Florian Mayer [Tue, 20 Jul 2021 09:38:52 +0000 (10:38 +0100)]
[hwasan] Use stack safety analysis.

This avoids unnecessary instrumentation.

Reviewed By: eugenis, vitalybuka

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

2 years ago[clang][AST] Add support for DecompositionDecl to ASTImporter.
Balázs Kéri [Thu, 22 Jul 2021 09:43:13 +0000 (11:43 +0200)]
[clang][AST] Add support for DecompositionDecl to ASTImporter.

BindingDecl was added recently but the related DecompositionDecl is needed
to make C++17 structured bindings importable.
Import of BindingDecl was changed to avoid infinite import loop.

Reviewed By: martong

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

2 years ago[clang][lex] NFC: Add explicit cast to silence -Wsign-compare
Jan Svoboda [Thu, 22 Jul 2021 10:21:12 +0000 (12:21 +0200)]
[clang][lex] NFC: Add explicit cast to silence -Wsign-compare

2 years ago[InstCombine] Fold (gep (oneuse(gep Ptr, Idx0)), Idx1) -> (gep Ptr, (add Idx0, Idx1...
Simon Pilgrim [Thu, 22 Jul 2021 09:58:31 +0000 (10:58 +0100)]
[InstCombine] Fold (gep (oneuse(gep Ptr, Idx0)), Idx1) -> (gep Ptr, (add Idx0, Idx1)) (PR51069)

As noticed on D106352, after we've folded "(select C, (gep Ptr, Idx), Ptr) -> (gep Ptr, (select C, Idx, 0))" if the inner Ptr was also a (now one use) gep we could then merge the geps, using the sum of the indices instead.

I've limited this to basic 2-op geps - a more general case further down InstCombinerImpl.visitGetElementPtrInst doesn't have the one-use limitation but only creates the add if it can be created via SimplifyAddInst.

https://alive2.llvm.org/ce/z/f8pLfD (Thanks Roman!)

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

2 years ago[libomptarget][amdgpu][nfc] Drop dead signal pool setup
Jon Chesterfield [Thu, 22 Jul 2021 09:29:30 +0000 (10:29 +0100)]
[libomptarget][amdgpu][nfc] Drop dead signal pool setup

This class is instantiated once in rtl.cpp before hsa_init is
called. The hsa_signal_create call therefore fails leaving the pool empty.

This signal pool is a legacy from ATMI where it was constructed after hsa_init.
Moving the state into the rtl.cpp global class disabled the initial populating
of the pool without noticeably changing performance. Just rechecked with a fix
that allocates the signals after hsa_init and that also doesn't noticeably
change performance.

This patch therefore drops the initialisation. Only change from main is to
drop a DEBUG_PRINT statement that would say the pool initial size is zero.

Reviewed By: jdoerfert

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

2 years ago[clang] Use i64 for the !srcloc metadata on asm IR nodes.
Simon Tatham [Thu, 22 Jul 2021 09:08:06 +0000 (10:08 +0100)]
[clang] Use i64 for the !srcloc metadata on asm IR nodes.

This is part of a patch series working towards the ability to make
SourceLocation into a 64-bit type to handle larger translation units.

!srcloc is generated in clang codegen, and pulled back out by llvm
functions like AsmPrinter::emitInlineAsm that need to report errors in
the inline asm. From there it goes to LLVMContext::emitError, is
stored in DiagnosticInfoInlineAsm, and ends up back in clang, at
BackendConsumer::InlineAsmDiagHandler(), which reconstitutes a true
clang::SourceLocation from the integer cookie.

Throughout this code path, it's now 64-bit rather than 32, which means
that if SourceLocation is expanded to a 64-bit type, this error report
won't lose half of the data.

The compiler will tolerate both of i32 and i64 !srcloc metadata in
input IR without faulting. Test added in llvm/MC. (The semantic
accuracy of the metadata is another matter, but I don't know of any
situation where that matters: if you're reading an IR file written by
a previous run of clang, you don't have the SourceManager that can
relate those source locations back to the original source files.)

Original version of the patch by Mikhail Maltsev.

Reviewed By: dexonsmith

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

2 years ago[AArch64] Add and update reduction and shuffle costs. NFC
David Green [Thu, 22 Jul 2021 09:22:42 +0000 (10:22 +0100)]
[AArch64] Add and update reduction and shuffle costs. NFC

2 years agosanitizers: increase .clang-format columns to 100
Dmitry Vyukov [Wed, 21 Jul 2021 13:39:01 +0000 (15:39 +0200)]
sanitizers: increase .clang-format columns to 100

The current (default) line length is 80 columns.
That's based on old hardware and historical conventions.
There are no existent reasons to keep line length that small,
especially provided that our coding style uses quite lengthy
identifiers. The Linux kernel recently switched to 100,
let's start with 100 as well.

This change intentionally does not re-format code.
Re-formatting is intended to happen incrementally,
or on dir-by-dir basis separately.

Reviewed By: vitalybuka, melver, MaskRay

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

2 years ago[RISCV] Fix a crash when lowering split float arguments
Fraser Cormack [Thu, 20 May 2021 16:28:45 +0000 (17:28 +0100)]
[RISCV] Fix a crash when lowering split float arguments

Lowering certain float vectors without legal vector types could cause a
crash due to a bad interaction between passing floats via GPRs and
argument splitting. Split vector floats appear just like scalar floats.
Under certain situations we choose to pass these float arguments via
GPRs and use an XLenVT location and set the 'BCvt' info to track how
they must be converted back to floating-point values. However, later
logic for handling split arguments may take over, in which case we lose
the previous information and set the 'Indirect' info, thus incorrectly
lowering to integer types.

I don't believe that we would have come across the notion of split
floating-point arguments before. This patch addresses the issue by
updating the lowering so that split arguments are only passed indirectly
when they are scalar integer types.

This has some change to how we lower some larger illegal float vectors,
as can be seen in 'fastcc-float.ll' where the vector is now passed
partly in registers and partly on the stack.

Reviewed By: luismarques

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

2 years ago[RISCV] Lower more BUILD_VECTOR sequences to RVV's VID
Fraser Cormack [Fri, 16 Jul 2021 14:12:46 +0000 (15:12 +0100)]
[RISCV] Lower more BUILD_VECTOR sequences to RVV's VID

This relands a6ca88e908b5befcd9b0f8c8cb40f53095cc17bc which was originally
reverted due to overflow bugs in e3fa2b1eab60342dc882b7b888658b03c472fa2b.

This patch teaches the compiler to identify a wider variety of
`BUILD_VECTOR`s which form integer arithmetic sequences, and to lower
them to `vid.v` with modifications for non-unit steps and non-zero
addends.

The sequences handled by this optimization must either be monotonically
increasing or decreasing. Consecutive elements holding the same value
indicate a fractional step which, while simple mathematically,
becomes more complex to handle both in the realm of lossy integer
division and in the presence of `undef`s.

For example, a common "interleaving" shuffle index will be lowered by
LLVM to both `<0,u,1,u,2,...>` and `<u,0,u,1,u,...>` `BUILD_VECTOR`
nodes. Either of these would ideally be lowered to `vid.v` shifted right
by 1. Detection of this sequence in presence of general `undef` values
is more complicated, however: `<0,u,u,1,>` could match either
`<0,0,0,1,>` or `<0,0,1,1,>` depending on later values in the sequence.
Both are possible, so backtracking or multiple passes is inevitable.

Sticking to monotonic sequences keeps the logic simpler as it can be
done in one pass. Fractional steps will likely be a separate
optimization in a future patch.

Reviewed By: craig.topper

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

2 years ago[clang-tidy] Fix crash and handle AttributedType in 'bugprone-easily-swappable-parame...
Whisperity [Tue, 20 Jul 2021 14:05:54 +0000 (16:05 +0200)]
[clang-tidy] Fix crash and handle AttributedType in 'bugprone-easily-swappable-parameters'

@vabridgers identified a way to crash the check by running on code that
involve `AttributedType`s. This patch fixes the check to first and
foremost not crash, but also improves the logic handling qualifiers.

If the types contain any additional (not just CVR) qualifiers that are
not the same, they will not be deemed mixable. The logic for CVR-Mixing
and the `QualifiersMix` check option remain unchanged.

Reviewed By: aaron.ballman, vabridgers

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

2 years agoRead and write a LC_NOTE "addrable bits" for addressing mask
Jason Molenda [Thu, 22 Jul 2021 08:02:54 +0000 (01:02 -0700)]
Read and write a LC_NOTE "addrable bits" for addressing mask

This patch adds code to process save-core for Mach-O files which
embeds an "addrable bits" LC_NOTE when the process is using a
code address mask (e.g. AArch64 v8.3 with ptrauth aka arm64e).
Add code to ObjectFileMachO to read that LC_NOTE from corefiles,
and ProcessMachCore to set the process masks based on it when reading
a corefile back in.

Also have "process status --verbose" print the current address masks
that lldb is using internally to strip ptrauth bits off of addresses.

Differential Revision: https://reviews.llvm.org/D106348
rdar://68630113

2 years ago[llvm][tools] Hide remaining unrelated llvm- tool options
Timm Bäder [Wed, 21 Jul 2021 10:03:05 +0000 (12:03 +0200)]
[llvm][tools] Hide remaining unrelated llvm- tool options

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

2 years ago[clangd] Ensure Ref::Container refers to an indexed symbol
Nathan Ridge [Tue, 29 Jun 2021 05:54:12 +0000 (01:54 -0400)]
[clangd] Ensure Ref::Container refers to an indexed symbol

Fixes https://github.com/clangd/clangd/issues/806

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

2 years ago[llvm-mc-assemble-fuzzer] Initialize MCTargetOptions.
Hsiangkai Wang [Wed, 21 Jul 2021 02:27:35 +0000 (10:27 +0800)]
[llvm-mc-assemble-fuzzer] Initialize MCTargetOptions.

When run the command in the llvm-mc-assemble-fuzzer document,

```
llvm-mc-fuzzer --triple=aarch64-linux-gnu --fuzzer-args -max_len=4
```

it triggers the following assertion:

```
llvm-mc-assemble-fuzzer:
llvm-project/llvm/lib/MC/MCTargetOptionsCommandFlags.cpp:38:
bool llvm::mc::getRelaxAll(): Assertion `RelaxAllView &&
"RegisterMCTargetOptionsFlags not created."' failed.
```

It is caused by no global RegisterMCTargetOptionsFlags object to initialize
the MC target options.

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

2 years ago[AArch64][SVE] Handle svbool_t VLST <-> VLAT/GNUT conversion
Jun Ma [Mon, 19 Jul 2021 13:10:17 +0000 (21:10 +0800)]
[AArch64][SVE] Handle svbool_t VLST <-> VLAT/GNUT conversion

According to https://godbolt.org/z/q5rME1naY and acle, we found that
there are different SVE conversion behaviours between clang and gcc. It turns
out that llvm does not handle SVE predicates width properly.

This patch 1) checks SVE predicates width rightly with svbool_t type.
2) removes warning on svbool_t VLST <-> VLAT/GNUT conversion.
3) disables VLST <-> VLAT/GNUT conversion between SVE vectors and predicates
due to different width.

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

2 years ago[Attributor][FIX] Improve call graph updating
Johannes Doerfert [Fri, 16 Jul 2021 19:14:37 +0000 (14:14 -0500)]
[Attributor][FIX] Improve call graph updating

If we remove a non-intrinsic instruction we need to tell the (old) call
graph about it. This caused problems with some features down the line as
they allowed to removed calls more aggressively.

2 years ago[Attributor][FIX] Do not introduce multiple instances of SSA values
Johannes Doerfert [Wed, 21 Jul 2021 20:11:44 +0000 (15:11 -0500)]
[Attributor][FIX] Do not introduce multiple instances of SSA values

If we have a recursive function we could create multiple instantiations
of an SSA value, one per recursive invocation of the function. This is a
problem as we use SSA value equality in various places. The basic idea
follows from this test:

```
static int r(int c, int *a) {
  int X;
  return c ? r(false, &X) : a == &X;
}

int test(int c) {
  return r(c, undef);
}
```

If we look through the argument `a` we will end up with `X`. Using SSA
value equality we will fold `a == &X` to true and return true even
though it should have been false because `a` and `&X` are from different
instantiations of the function.

Various tests for this  have been placed in value-simplify-instances.ll
and this commit fixes them all by avoiding to produce simplified values
that could be non-unique at runtime. Thus, the result of a simplify
value call will always be unique at runtime or the original value, both
do not allow to accidentally compare two instances of a value with each
other and conclude they are equal statically (pointer equivalence) while
they are unequal at runtime.

2 years ago[Attributor] Improve the Attributor::getAssumedConstant interface
Johannes Doerfert [Thu, 22 Jul 2021 02:58:00 +0000 (21:58 -0500)]
[Attributor] Improve the Attributor::getAssumedConstant interface

Similar to Attributor::getAssumedSimplified we need to allow IRPs
directly to get the right simplification callback (and context).

2 years ago[RegisterCoalescer] Make resolveConflicts aware of earlyclobber
ShihPo Hung [Thu, 22 Jul 2021 03:51:18 +0000 (11:51 +0800)]
[RegisterCoalescer] Make resolveConflicts aware of earlyclobber

Prior to this patch, it skipped the instruction defining VNI when checking if the tainted lanes are used.
In the given example, VRGATHER is an illegal instruction because its DstReg overlaps with SrcReg.

Therefore we need to check the defining instruction as well when there is an earlyclobber constraint.

Reviewed By: qcolombet

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

2 years ago[Attributor][NFC] Precommit tests exposing a conceptual simplification problem
Johannes Doerfert [Wed, 21 Jul 2021 04:00:32 +0000 (23:00 -0500)]
[Attributor][NFC] Precommit tests exposing a conceptual simplification problem

Value simplification works under the implicit assumption that two SSA
values (`llvm::Value`) that are pointer equal are also equal at runtime.
This is mostly true except for values that are instantiated multiple
times. These test cases expose the problems we currently have when it
comes to recursion and multiple instances of values.

2 years ago[OpenMP][FIX] Use name + type checks not only name checks for calls
Johannes Doerfert [Tue, 20 Jul 2021 03:31:51 +0000 (22:31 -0500)]
[OpenMP][FIX] Use name + type checks not only name checks for calls

A call that is analyzed in an optimization needs to be verified against
the name and type of the runtime function to avoid that we look at
arguments that do not exist (anymore). This can happen if the signature
was rewritten. Since we will not set RFI.Declaration if the type doesn't
match we can use it (if it's not null) to determine if the signature is
as expected.

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

2 years ago[Attributor][NFC] Clang format
Johannes Doerfert [Thu, 22 Jul 2021 03:01:02 +0000 (22:01 -0500)]
[Attributor][NFC] Clang format

2 years ago[mlir] Fix various issues in TimerImpl.
rdzhabarov [Thu, 22 Jul 2021 00:06:43 +0000 (00:06 +0000)]
[mlir] Fix various issues in TimerImpl.

More specifically:
1) Use variable after move.
2) steady_clock needs to be used for measuring time intervals, but not the system_clock.

Reviewed By: mehdi_amini

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

2 years ago[MLIR] Fix affine.for empty loop body folder
Uday Bondhugula [Thu, 22 Jul 2021 01:39:53 +0000 (07:09 +0530)]
[MLIR] Fix affine.for empty loop body folder

Fix affine.for empty loop body folder in the presence of yield values.
The existing pattern ignored iter_args/yield values and thus crashed
when yield values had uses.

Reviewed By: mehdi_amini

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

2 years ago[RISCV] Optimize multiplication in the zba extension with SH*ADD
Ben Shi [Thu, 22 Jul 2021 02:26:52 +0000 (10:26 +0800)]
[RISCV] Optimize multiplication in the zba extension with SH*ADD

This patch make the following optimization.

(mul x, 3 * power_of_2) -> (SLLI (SH1ADD x, x), bits)
(mul x, 5 * power_of_2) -> (SLLI (SH2ADD x, x), bits)
(mul x, 9 * power_of_2) -> (SLLI (SH3ADD x, x), bits)

Reviewed By: craig.topper

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

2 years ago[AMDGPU] Add VReg_192/VReg_224 support for MIMG instructions
Carl Ritson [Thu, 22 Jul 2021 01:22:02 +0000 (10:22 +0900)]
[AMDGPU] Add VReg_192/VReg_224 support for MIMG instructions

Allow MIMG instructions to be selected with 6/7 VGPRs for vaddr.
Previously these were rounded up to VReg_256 this saves VGPRs.

Reviewed By: foad

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

2 years ago[mlir] Extend scf pipeling to support loop carried dependencies
thomasraoux [Mon, 19 Jul 2021 23:05:23 +0000 (16:05 -0700)]
[mlir] Extend scf pipeling to support loop carried dependencies

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

2 years ago[Clang][RISCV] Implement vsoxseg and vsuxseg.
Hsiangkai Wang [Tue, 8 Jun 2021 06:29:40 +0000 (14:29 +0800)]
[Clang][RISCV] Implement vsoxseg and vsuxseg.

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

2 years ago[Clang][RISCV] Implement vssseg.
Hsiangkai Wang [Tue, 8 Jun 2021 05:29:51 +0000 (13:29 +0800)]
[Clang][RISCV] Implement vssseg.

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

2 years ago[Clang][RISCV] Implement vsseg.
Hsiangkai Wang [Tue, 8 Jun 2021 05:09:07 +0000 (13:09 +0800)]
[Clang][RISCV] Implement vsseg.

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

2 years ago[Clang][RISCV] Add vloxseg and vluxseg test cases.
Hsiangkai Wang [Mon, 7 Jun 2021 13:53:49 +0000 (21:53 +0800)]
[Clang][RISCV] Add vloxseg and vluxseg test cases.