platform/upstream/llvm.git
2 years ago[OMPIRBuilder] Fix store inst alignment for ordered depend directive
Peixin-Qiao [Fri, 14 Jan 2022 01:47:11 +0000 (09:47 +0800)]
[OMPIRBuilder] Fix store inst alignment for ordered depend directive

OpenMP runtime requires depend vec with i64 type and the alignment of
store instruction should be set as 8.

Reviewed By: kiranchandramohan, shraiysh

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

2 years ago[MemoryBuiltins] [NFC] Add missing section comments
Bryce Wilson [Fri, 14 Jan 2022 01:43:43 +0000 (17:43 -0800)]
[MemoryBuiltins] [NFC] Add missing section comments

2 years ago[libcxx][test] Add missing includes and suppress warnings
Casey Carter [Wed, 29 Dec 2021 22:06:25 +0000 (14:06 -0800)]
[libcxx][test] Add missing includes and suppress warnings

... from testing with MSVC's STL. Mostly truncation warnings and variables that are only used in `LIBCPP_ASSERT`.

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

2 years ago[flang] Support extension intrinsic function variations on ABS
Peter Klausler [Wed, 5 Jan 2022 17:54:16 +0000 (09:54 -0800)]
[flang] Support extension intrinsic function variations on ABS

Accept the legacy specific intrinsic names BABS, IIABS, JIABS,
KIABS, and ZABS as well.

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

2 years ago[lldb] Use __lldb_init_module instead of "if lldb.debugger" idiom
Dave Lee [Thu, 13 Jan 2022 18:25:59 +0000 (10:25 -0800)]
[lldb] Use __lldb_init_module instead of "if lldb.debugger" idiom

Update examples and docs to demonstrate using `__lldb_init_module` instead of
the idiom that checks for `lldb.debugger` at the top-level.

```
if __name__ == '__main__':
    ...
elif lldb.debugger:
    ...
```

Is replaced with:

```
if __name__ == '__main__':
    ...

def __lldb_init_module(debugger, internal_dict):
    ...
```

This change is for two reasons. First, it's generally encouraged not to only
use the convenience singletons (`lldb.{debugger,process,target,etc}`)
interactively from the `script` command. Second, there's a bug where
registering a python class as a command (using `command script add -c ...`),
result in the command not being runnable. Note that registering function-backed
commands does not have this bug.

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

2 years ago[GlobalValue] Make dso_local function work with comdat nodeduplicate
Fangrui Song [Fri, 14 Jan 2022 00:37:14 +0000 (16:37 -0800)]
[GlobalValue] Make dso_local function work with comdat nodeduplicate

This fixes -fno-semantic-interposition -fsanitize-coverage incompatibility.

-fPIC -fno-semantic-interposition may add dso_local to an external linkage
function. -fsanitize-coverage instrumentation does not clear dso_local when
adding comdat nodeduplicate. This causes a compatibility issue: the function
symbol may be referenced by a PC-relative relocation without using the local
alias. In -shared mode, ld will report a relocation error.

The fix is to either clear dso_local when adding comdat nodeduplicate, or
supporting comdat nodeduplicate. The latter is more appropriate, because a
comdat nodeduplicate is like not using comdat.

Note: The comdat condition was originally added by D77429 to not use local alias
for a hidden external linkage function in a deduplicate comdat. The condition
has been unused since the code was refactored to only use local alias for
default visibility symbols.
Note: `canBenefitFromLocalAlias` is used by clang/lib/CodeGen/CodeGenModule.cpp
and we don't want to add dso_local to default visibility external linkage comdat any
(clang/test/CodeGenCUDA/usual-deallocators.cu).

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

2 years ago[flang] Downgrade benign error message to a warning
Peter Klausler [Thu, 30 Dec 2021 22:24:33 +0000 (14:24 -0800)]
[flang] Downgrade benign error message to a warning

It's not conforming to specify the SAVE attribute more than
once for a variable, but it also doesn't hurt anything and
isn't fatal in other Fortran compilers.  Downgrade the
message to a warning for better portability.

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

2 years agoRevert "[LV] Inline CreateSplatIV call for scalar VFs (NFC)."
James Y Knight [Fri, 14 Jan 2022 00:00:02 +0000 (00:00 +0000)]
Revert "[LV] Inline CreateSplatIV call for scalar VFs (NFC)."

Causes a crash with the following (creduce'd) test-case:

clang -O3 '--target=aarch64-grtev4-linux-gnu' -xc - -c -o /dev/null <<EOF
int *e;
int f;
int g() {
  int h;
  int *j = 0;
  while (&f - j > 0) {
    int k;
    k = j;
    if (e == j && *e)
      k = 5;
    h = k;
    j++;
  }
  return h;
}
EOF

This reverts commit 7ce48be0fd83fb4fe3d0104f324bbbcfcc82983c.

2 years ago[MemoryBuiltins] Demote isCallocLikeFn and isAlignedAllocLikeFn to local helpers...
Philip Reames [Thu, 13 Jan 2022 23:37:41 +0000 (15:37 -0800)]
[MemoryBuiltins] Demote isCallocLikeFn and isAlignedAllocLikeFn to local helpers after removal of last external use [NFC]

2 years ago[Driver][Fuchsia] -r: imply -nostdlib like GCC
Fangrui Song [Thu, 13 Jan 2022 23:49:19 +0000 (15:49 -0800)]
[Driver][Fuchsia] -r: imply -nostdlib like GCC

Similar to D116843.

Reviewed By: phosek

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

2 years ago[CMake] Don't use -fno-semantic-interposition with Clang<=13
Fangrui Song [Thu, 13 Jan 2022 23:38:02 +0000 (15:38 -0800)]
[CMake] Don't use -fno-semantic-interposition with Clang<=13

Clang 13 has a -fsanitize-coverage -fno-semantic-interposition bug (D117190)
which may lead to
`relocation R_X86_64_PC32 cannot be used against symbol` linker error
in -DLLVM_USE_SANITIZE_COVERAGE=ON build when a shared object is built (e.g.
-DLLVM_BUILD_LLVM_DYLIB=on).

For simplicity, just disallow Clang 13 entirely.

Note: GCC -fPIC performance benefits from -fno-semantic-interposition
dramatically. Clang benefits little. Using this option is more for a dogfood
purpose to test correctness of this option, because in the wild some important
packages like CPython uses this option.

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

2 years ago[Attributor] Generalize heap to stack to any allocator with relevant properties
Philip Reames [Thu, 13 Jan 2022 23:22:55 +0000 (15:22 -0800)]
[Attributor] Generalize heap to stack to any allocator with relevant properties

This completes removal of the isXLike queries, and depends on a whole series of earlier patches which have already landed.

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

2 years ago[Attributor] Share code for abstract interpretation of allocation sizes with getObjec...
Philip Reames [Thu, 13 Jan 2022 23:21:14 +0000 (15:21 -0800)]
[Attributor] Share code for abstract interpretation of allocation sizes with getObjectSize [NFC-ish]

The basic idea is that we can parameterize the getObjectSize implementation with a callback which lets us replace the operand before analysis if desired. This is what Attributor is doing during it's abstract interpretation, and allows us to have one copy of the code.

Note this is not NFC for two reasons:
* The existing attributor code is wrong. (Well, this is under-specified to be honest, but at least inconsistent.) The intermediate math needs to be done in the index type of the pointer space. Imagine e.g. i64 arguments in a 32 bit address space.
* I did not preserve the behavior in getAPInt where we return 0 for a partially analyzed value. This looks simply wrong in the original code, and nothing test wise contradicts that.

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

2 years ago[lldb] Fix that the embedded Python REPL crashes if it receives SIGINT
Jonas Devlieghere [Thu, 13 Jan 2022 19:26:20 +0000 (11:26 -0800)]
[lldb] Fix that the embedded Python REPL crashes if it receives SIGINT

When LLDB receives a SIGINT while running the embedded Python REPL it
currently just crashes in ScriptInterpreterPythonImpl::Interrupt with an
error such as the one below:

  Fatal Python error: PyThreadState_Get: the function must be called
  with the GIL held, but the GIL is released (the current Python thread
  state is NULL)

The faulty code that causes this error is this part of
ScriptInterpreterPythonImpl::Interrupt:

  PyThreadState *state = PyThreadState_GET();
  if (!state)
    state = GetThreadState();
  if (state) {
    long tid = state->thread_id;
    PyThreadState_Swap(state);
    int num_threads = PyThreadState_SetAsyncExc(tid, PyExc_KeyboardInterrupt);

The obvious fix I tried is to just acquire the GIL before this code is
running which fixes the crash but the KeyboardInterrupt we want to raise
immediately is actually just queued and would only be raised once the
next line of input has been parsed (which e.g. won't interrupt Python
code that is currently waiting on a timer or IO from what I can see).
Also none of the functions we call here is marked as safe to be called
from a signal handler from what I can see, so we might still end up
crashing here with some bad timing.

Python 3.2 introduced PyErr_SetInterrupt to solve this and the function
takes care of all the details and avoids doing anything that isn't safe
to do inside a signal handler. The only thing we need to do is to
manually setup our own fake SIGINT handler that behaves the same way as
the standalone Python REPL signal handler (which raises a
KeyboardInterrupt).

From what I understand the old code used to work with Python 2 so I kept
the old code around until we officially drop support for Python 2.

There is a small gap here with Python 3.0->3.1 where we might still be
crashing, but those versions have reached their EOL more than a decade
ago so I think we don't need to bother about them.

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

2 years agoApply clang-tidy fixes for llvm-namespace-comment in ToolUtilities.h (NFC)
Mehdi Amini [Tue, 11 Jan 2022 23:37:59 +0000 (23:37 +0000)]
Apply clang-tidy fixes for llvm-namespace-comment in ToolUtilities.h (NFC)

2 years agoApply clang-tidy fixes for llvm-namespace-comment in ParallelLoopMapper.h (NFC)
Mehdi Amini [Tue, 11 Jan 2022 20:51:36 +0000 (20:51 +0000)]
Apply clang-tidy fixes for llvm-namespace-comment in ParallelLoopMapper.h (NFC)

2 years agoApply clang-tidy fixes for llvm-namespace-comment in GPUToNVVMPass.h (NFC)
Mehdi Amini [Tue, 11 Jan 2022 20:29:35 +0000 (20:29 +0000)]
Apply clang-tidy fixes for llvm-namespace-comment in GPUToNVVMPass.h (NFC)

2 years agoApply clang-tidy fixes for llvm-namespace-comment in MemoryPromotion.h (NFC)
Mehdi Amini [Tue, 11 Jan 2022 20:50:47 +0000 (20:50 +0000)]
Apply clang-tidy fixes for llvm-namespace-comment in MemoryPromotion.h (NFC)

2 years agoApply clang-tidy fixes for llvm-else-after-return in CommonFolders.h (NFC)
Mehdi Amini [Tue, 11 Jan 2022 20:49:18 +0000 (20:49 +0000)]
Apply clang-tidy fixes for llvm-else-after-return in CommonFolders.h (NFC)

2 years ago[MemoryBuiltins] [NFC] Remove unused overload of isAlignedAllocLikeFn
Bryce Wilson [Thu, 13 Jan 2022 21:02:11 +0000 (13:02 -0800)]
[MemoryBuiltins] [NFC] Remove unused overload of isAlignedAllocLikeFn

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

2 years agoRevert "Upstream MLIR PyTACO implementation."
Mehdi Amini [Thu, 13 Jan 2022 23:14:13 +0000 (23:14 +0000)]
Revert "Upstream MLIR PyTACO implementation."

This reverts commit 778a264da9eba0c8523cdc10a10822fd3e458dd3.

This broke the bot: tests are failing at the moment.

2 years agoApply clang-tidy fixes for llvm-header-guard in MLIR (NFC)
Mehdi Amini [Thu, 13 Jan 2022 20:27:30 +0000 (20:27 +0000)]
Apply clang-tidy fixes for llvm-header-guard in MLIR (NFC)

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

2 years ago[mlir][sparse] fix two typos
Aart Bik [Thu, 13 Jan 2022 22:36:17 +0000 (14:36 -0800)]
[mlir][sparse] fix two typos

(1) copy-and-past error in encoding alias name:
    this is an annotation for a tensor (3-d) not a matrix (2-d).

(2) typo in "initialization"

Reviewed By: bixia

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

2 years ago[flang] Allow initialization in blank COMMON
Peter Klausler [Thu, 30 Dec 2021 16:14:59 +0000 (08:14 -0800)]
[flang] Allow initialization in blank COMMON

This is nonconformant usage, but widely accepted as an extension.
Downgrade the error message to a warning.

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

2 years agoReapply 253ce92844f "[JITLink][AArch64] Add support for splitting.." with fixes.
Lang Hames [Thu, 13 Jan 2022 01:06:53 +0000 (12:06 +1100)]
Reapply 253ce92844f "[JITLink][AArch64] Add support for splitting.." with fixes.

This reapplies 253ce92844f72e3a6d0e423473f2765c2c5afd6a, which was reverted in
66b2ed477f902329c916bd4389b2034dae09c02b due to bot failures.

I have added the `-phony-externals` option added, which should fix the
unresolved symbol errors.

2 years agoUpstream MLIR PyTACO implementation.
Bixia Zheng [Wed, 12 Jan 2022 17:33:19 +0000 (09:33 -0800)]
Upstream MLIR PyTACO implementation.

Add TACO tests to test/Integration/Dialect/SparseTensor/taco. Add the MLIR
PyTACO implementation as tools under the directory.

Reviewed By: aartbik

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

2 years ago[Inline] Attempt to delete any discardable if unused functions
Arthur Eubanks [Fri, 7 Jan 2022 17:47:55 +0000 (09:47 -0800)]
[Inline] Attempt to delete any discardable if unused functions

Previously we limited ourselves to only internal/private functions. We
can also delete linkonce_odr functions.

Minor compile time wins:
https://llvm-compile-time-tracker.com/compare.php?from=d51e3474e060cb0e90dc2e2487f778b0d3e6a8de&to=bccffe3f8d5dd4dda884c9ac1f93e51772519cad&stat=instructions

Major memory wins on tramp3d:
https://llvm-compile-time-tracker.com/compare.php?from=d51e3474e060cb0e90dc2e2487f778b0d3e6a8de&to=bccffe3f8d5dd4dda884c9ac1f93e51772519cad&stat=max-rss

Relanding with fix for compile times D117236.

Reviewed By: nikic, mtrofin

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

2 years ago[openmp][devicertl] Handle missing clang_tool
Jon Chesterfield [Thu, 13 Jan 2022 22:43:25 +0000 (22:43 +0000)]
[openmp][devicertl] Handle missing clang_tool

Fixes github issues/52910

Reviewed By: jdoerfert

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

2 years ago[Inliner] Don't removeDeadConstantUsers() when checking if a function is dead
Arthur Eubanks [Thu, 13 Jan 2022 18:09:52 +0000 (10:09 -0800)]
[Inliner] Don't removeDeadConstantUsers() when checking if a function is dead

If a function has many uses, this can take a good chunk of compile times.

Reviewed By: nikic

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

2 years ago[flang] Extension: initialization of LOGICAL with INTEGER & vice versa
Peter Klausler [Tue, 4 Jan 2022 17:25:40 +0000 (09:25 -0800)]
[flang] Extension: initialization of LOGICAL with INTEGER & vice versa

We already accept assignments of INTEGER to LOGICAL (& vice versa)
as an extension, but not initialization.  Extend initialization
to cover those cases.

(Also fix misspelling in nearby comment as suggested by code reviewer.)

Decouple an inadvertent dependence cycle by moving two
one-line function definitions into a header file.

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

2 years ago[LoopNest] Add new utilites
Whitney Tsang [Thu, 13 Jan 2022 22:12:25 +0000 (17:12 -0500)]
[LoopNest] Add new utilites

getLoopIndex() is added to get the loop index of a given loop.
getLoopsAtDepth() is added to get the loops in the nest at a given
depth.

Reviewed By: Meinersbur

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

2 years ago[NFC][SCEV] Add test where it's the innermost umin_seq that has a duplicate operand
Roman Lebedev [Thu, 13 Jan 2022 22:11:49 +0000 (01:11 +0300)]
[NFC][SCEV] Add test where it's the innermost umin_seq that has a duplicate operand

2 years agoRevert "Revert "[LLDB][NativePDB] Add support for inlined functions""
Zequan Wu [Thu, 13 Jan 2022 21:51:56 +0000 (13:51 -0800)]
Revert "Revert "[LLDB][NativePDB] Add support for inlined functions""

This reland 945aa520ef07a3edb655f3f38e4c3023658dd623 with fixes.

This reverts commit 10bc3362a1a8a3df2660bf65db0ec1ccab646e1b.

2 years ago[LoopInterchange] Enable interchange with multiple outer loop indvars
Congzhe Cao [Thu, 13 Jan 2022 21:25:58 +0000 (16:25 -0500)]
[LoopInterchange] Enable interchange with multiple outer loop indvars

This patch enables loop interchange with multiple outer loop
induction variables, and hence removes the limitation that only
a single outer loop induction variable is supported. In fact, it
turns out that the current pass already trivially supports multiple
outer indvars, which is the result of a previous patch
`https://reviews.llvm.org/D102743`. Therefore, this patch removed that
limitation and provides test cases for multiple outer indvars.

Reviewed By: bmahjour

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

2 years ago[test] precommit coverage for D117249
Philip Reames [Thu, 13 Jan 2022 21:39:59 +0000 (13:39 -0800)]
[test] precommit coverage for D117249

2 years ago[AMDGPU] Ensure return address is save/restored around the call with IPRA enabled...
Venkata Ramanaiah Nalamothu [Thu, 13 Jan 2022 21:26:51 +0000 (02:56 +0530)]
[AMDGPU] Ensure return address is save/restored around the call with IPRA enabled/disabled

Reviewed By: arsenm

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

2 years ago[Clang][NVPTX]Add NVPTX intrinsics and builtins for CUDA PTX cvt sm80 instructions
Jack Kirk [Thu, 13 Jan 2022 20:01:20 +0000 (12:01 -0800)]
[Clang][NVPTX]Add NVPTX intrinsics and builtins for CUDA PTX cvt sm80 instructions

Adds NVPTX intrinsics and builtins for CUDA PTX cvt instructions for sm80
architectures and above. Requires ptx 7.0.

PTX ISA description of cvt instructions :
https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-cvt

Signed-off-by: JackAKirk <jack.kirk@codeplay.com>
Differential Revision: https://reviews.llvm.org/D116673

2 years ago[clangd] Elide even more checks in SelectionTree.
Sam McCall [Wed, 12 Jan 2022 13:50:55 +0000 (14:50 +0100)]
[clangd] Elide even more checks in SelectionTree.

During pop() we convert nodes into spans of expanded syntax::Tokens.
If we precompute a range of plausible (expanded) tokens, then we can do an
extremely cheap approximate hit-test against it, because syntax::Tokens are
ordered by pointer.

This would seem not to buy anything (we don't enter nodes unless they overlap
the selection), but in fact the spans we have are for *newly* claimed ranges
(i.e. those unclaimed by any child node).

So if you have:
   { { [[2+2]]; } }
then all of the CompoundStmts pass the hit test and are pushed, but we skip
full hit-testing of the brackets during pop() as they lie outside the range.

This is ~10x average speedup for selectiontree on a bad case I've seen
(large gtest file).

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

2 years ago[clangd] Suppress warning about system_header pragma when editing headers
Sam McCall [Mon, 10 Jan 2022 11:46:58 +0000 (12:46 +0100)]
[clangd] Suppress warning about system_header pragma when editing headers

Not sure it's OK to suppress this in clang itself - if we're building a PCH
or module, maybe it matters?

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

2 years ago[flang] Implement semantics for DEC STRUCTURE/RECORD
Peter Klausler [Sat, 18 Dec 2021 00:48:16 +0000 (16:48 -0800)]
[flang] Implement semantics for DEC STRUCTURE/RECORD

Implements part of the legacy "DEC structures" feature from
VMS Fortran.  STRUCTUREs are processed as if they were derived
types with SEQUENCE.  DATA-like object entity initialization
is supported as well (e.g., INTEGER FOO/666/) since it was used
for default component initialization in structures.  Anonymous
components (named %FILL) are also supported.

These features, and UNION/MAP, were already being parsed.
An omission in the collection of structure field names in the
case of nested structures with entity declarations was fixed
in the parser.

Structures are supported in modules, but this is mostly for
testing purposes.  The names of fields in structures accessed
via USE association cannot appear with dot notation in client
code (at least not yet).  DEC structures antedate Fortran 90,
so their actual use in applications should not involve modules.

This patch does not implement UNION/MAP, since that feature
would impose difficulties later in lowering them to MLIR types.
In the meantime, if they appear, semantics will issue a
"not yet implemented" error message.

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

2 years ago[clangd] Implement textDocument/typeDefinition
Sam McCall [Fri, 31 Dec 2021 14:40:56 +0000 (15:40 +0100)]
[clangd] Implement textDocument/typeDefinition

This reuses the type=>decl mapping from go-to-definition on auto.
(Which could stand some improvement, but that can happen later).

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

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

2 years ago[SCEV] Don't consider umin_seq scev expr to be more complex that ptrtoint scev expr
Roman Lebedev [Thu, 13 Jan 2022 20:55:00 +0000 (23:55 +0300)]
[SCEV] Don't consider umin_seq scev expr to be more complex that ptrtoint scev expr

Let's consider sequential min/max expression family
to be more complex than their non-sequential counterparts,
preserving internal ordering within them.

2 years ago[NFC][SCEV] Add test for umin_seq complexity ordering
Roman Lebedev [Thu, 13 Jan 2022 20:48:14 +0000 (23:48 +0300)]
[NFC][SCEV] Add test for umin_seq complexity ordering

2 years ago[MemoryBuiltins] (Slightly) clean up abuse of MallocLike bitmask [NFC]
Philip Reames [Thu, 13 Jan 2022 20:39:09 +0000 (12:39 -0800)]
[MemoryBuiltins] (Slightly) clean up abuse of MallocLike bitmask [NFC]

2 years ago[SimplifyCFG] Be more aggressive when sinking into block followed by unreachable
Roman Lebedev [Thu, 13 Jan 2022 20:26:43 +0000 (23:26 +0300)]
[SimplifyCFG] Be more aggressive when sinking into block followed by unreachable

I strongly believe we need some variant of this.

The main problem is e.g. that the glibc's assert has 4 parameters,
but the profitability check is only okay with one extra phi node,
so D116692 doesn't even trigger on most of the expected cases.

While that restriction probably makes sense in normal code, if we
are about to run off of a cliff (into an `unreachable`), this
successor block is unlikely so the cost to setup these PHI nodes
should not be on the hotpath, and shouldn't matter performance-wise.

Likewise, we don't sink if there are unconditional predecessors
UNLESS we'd sink at least one non-speculatable instruction,
which is a performance workaround, but if we are about to run into
`unreachable`, it shouldn't matter.

Note that we only allow the case where there are at
most unconditiona branches on the way to the unreachable block.

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

2 years ago[libc++][NFC] Fix placement of some XFAILs
Louis Dionne [Thu, 13 Jan 2022 20:28:26 +0000 (15:28 -0500)]
[libc++][NFC] Fix placement of some XFAILs

2 years ago[X86] Fix mistake in comment on LowerFROUND. NFC
Craig Topper [Thu, 13 Jan 2022 20:20:52 +0000 (12:20 -0800)]
[X86] Fix mistake in comment on LowerFROUND. NFC

The code uses floor not trunc.

2 years ago[libc][trivial] Make LlvmLibcExhaustiveTest::check method purely virtual.
Tue Ly [Thu, 13 Jan 2022 19:34:17 +0000 (14:34 -0500)]
[libc][trivial] Make LlvmLibcExhaustiveTest::check method purely virtual.

2 years ago[libc++][NFC] Add missing 'return 0' in main() functions
Louis Dionne [Thu, 13 Jan 2022 19:32:41 +0000 (14:32 -0500)]
[libc++][NFC] Add missing 'return 0' in main() functions

2 years ago[Driver][Gnu] -r: imply -nostdlib like GCC
Fangrui Song [Thu, 13 Jan 2022 19:25:23 +0000 (11:25 -0800)]
[Driver][Gnu] -r: imply -nostdlib like GCC

See `gcc -dumpspecs` that -r essentially implies -nostdlib and suppresses
default -l* and crt*.o. The behavior makes sense because otherwise there will be
assuredly conflicting definitions when the relocatable output is linked into the
final executable/shared object.

Reviewed By: thesamesam, phosek

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

2 years ago[NVPTX] Add version test for sm_75, sm_80, sm_86.
Christian Sigg [Thu, 13 Jan 2022 09:27:55 +0000 (10:27 +0100)]
[NVPTX] Add version test for sm_75, sm_80, sm_86.

Combine the sm-version tests into a single file.

Reviewed By: bkramer, tra

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

2 years ago[lit] Make sure our test temp directory is actually used by tests
Julian Lettner [Thu, 13 Jan 2022 03:06:20 +0000 (19:06 -0800)]
[lit] Make sure our test temp directory is actually used by tests

All credit to Martin Storsjö (mstorsjo) who describes the issue here:
https://github.com/llvm/llvm-project/issues/53167

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

2 years ago[NVPTX] Add fmin/fmax.NaN lowering for sm_80+.
Christian Sigg [Thu, 13 Jan 2022 10:13:38 +0000 (11:13 +0100)]
[NVPTX] Add fmin/fmax.NaN lowering for sm_80+.

Reviewed By: bkramer, tra

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

2 years ago[lldb] Add long help to `crashlog`
Dave Lee [Wed, 12 Jan 2022 23:20:08 +0000 (15:20 -0800)]
[lldb] Add long help to `crashlog`

Convert the `crashlog` command to be implemented as a class. The `Symbolicate`
function is switched to a class, to implement `get_long_help`. The text for the
long help comes from the help output generated by `OptionParser`. That is, the
output of `help crashlog` is the same as `crashlog --help`.

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

2 years ago[libc++] Refactor the tests for ranges::{advance,next,prev}
Louis Dionne [Thu, 13 Jan 2022 17:16:30 +0000 (12:16 -0500)]
[libc++] Refactor the tests for ranges::{advance,next,prev}

This makes all the tests consistent and improves code coverage. This also
uncovers a bug with negative indices in advance() (which also impacts
prev()) -- I'll fix that in a subsequent patch.

I chose to only count operations in the tests for ranges::advance because
doing so in prev() and next() too was reaching diminishing returns, and
didn't meaningfully improve our test coverage.

2 years ago[mlir] Fix attaching side effects on `FlatSymbolRefAttr`
Markus Böck [Thu, 13 Jan 2022 18:56:51 +0000 (19:56 +0100)]
[mlir] Fix attaching side effects on `FlatSymbolRefAttr`

The names of the generated attribute getters for ops changed some time ago. The method created from the attribute name returns the return type and an additional method of the same name with Attr as suffix is generated which returns the actual attribute as its storage type.

The code generating effects however was using the methods without the Attr suffix, which is a problem in the case of FlatSymbolRefAttr as it has a return type of llvm::StringRef. This would lead to compilation errors as the constructor of SideEffects::EffectInstance expects a SymbolRefAttr in this case.

This patch simply fixes the generated effects code to use the Attr suffixed getter to get the actual storage type of the attribute.

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

2 years agoADT: Make SmallVector::set_size() private
Duncan P. N. Exon Smith [Tue, 7 Dec 2021 20:48:03 +0000 (12:48 -0800)]
ADT: Make SmallVector::set_size() private

Stop allowing use of `SmallVectorBase::set_size()` outside of the
SmallVector implementation, which sets the size without calling
constructors or destructors.

Most callers should probably just use `resize()`. Or, if the new size is
guaranteed to be `<= size()`, then the new-ish `truncate()` works too
(and optimizes better).

Some callers want to avoid initializing memory before overwriting, but
need a pointer to the memory and so cannot use `push_back()`,
`emplace_back()`, or `append()`. Before this commit, this depended on
`reserve()` and `set_size()`:

```
V.reserve(V.size() + NumNew);      // Reserve expected size.
NumNew = initialize(V.end(), ...); // Get number added.
V.set_size(V.size() + NumNew);     // Set size to match.
```

Such code should be updated to use `resize_for_overwrite()` and
`truncate()`:

```
auto Size = V.size();                        // Save initial size.
V.resize_for_overwrite(Size + NumNew);       // Resize to expected size.
NumNew = initialize(V.begin() + Size, ...)); // Get number added.
V.truncate(Size + NumNew);                   // Truncate to match.
```

The new pattern is safe even for non-trivial types, since
`resize_for_overwrite()` calls constructors and `truncate()` calls
destructors. For trivial types, it should optimize the same way as the
old pattern.

Downstream code adapt to the disappearance of `set_size()` using this
new pattern should carefully audit uses of `V` between the resize and
the truncate:

- Change `V.size()` => `Size`.
- Change `V.capacity()` => `V.size()` (mostly).
- Change `V.end()` => `V.begin() + Size`.
- If `V` is an out-parameter, early returns need a `V.truncate()` or
  `V.clear()`. A scope exit is recommended.

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

2 years ago[libc] Add multithreading support for exhaustive testing and MPFRUtils.
Tue Ly [Tue, 11 Jan 2022 15:59:25 +0000 (10:59 -0500)]
[libc] Add multithreading support for exhaustive testing and MPFRUtils.

Add threading support for exhaustive testing and MPFRUtils.

Reviewed By: sivachandra

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

2 years agoClarify that fold() can't "erase" an operation in the MLIR Canonicalization doc ...
Mehdi Amini [Thu, 13 Jan 2022 18:43:18 +0000 (18:43 +0000)]
Clarify that fold() can't "erase" an operation in the MLIR Canonicalization doc (NFC)

2 years ago[flang] Any type can appear in a structure constructor for an unlimited polymorphic...
Peter Klausler [Wed, 5 Jan 2022 00:17:15 +0000 (16:17 -0800)]
[flang] Any type can appear in a structure constructor for an unlimited polymorphic allocatable component

A bogus error message is appearing for structure constructors containing
values that correspond to unlimited polymorphic allocatable components.
A value of any type can actually be used.

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

2 years agoMC: Use SmallVector::clear() instead of set_size(0)
Duncan P. N. Exon Smith [Thu, 13 Jan 2022 18:24:39 +0000 (10:24 -0800)]
MC: Use SmallVector::clear() instead of set_size(0)

2 years agoRevert "[compiler-rt][darwin] check for strcmp to test interceptors instead of pthrea...
Emily Shi [Thu, 13 Jan 2022 18:29:52 +0000 (10:29 -0800)]
Revert "[compiler-rt][darwin] check for strcmp to test interceptors instead of pthread_create"

This reverts commit 1e36bd8516f23e2eaf9c3c6c2005a8cf66070896.

2 years ago[libc] Add rounding mode support for MPFR testing macros.
Tue Ly [Fri, 7 Jan 2022 00:11:16 +0000 (19:11 -0500)]
[libc] Add rounding mode support for MPFR testing macros.

Add an extra argument for rounding mode to EXPECT_MPFR_MATCH and ASSERT_MPFR_MATCH macros.

Reviewed By: sivachandra, michaelrj

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

2 years ago[RISCV] Add tests for fixed vector mul reduction intrinsics. NFC
Craig Topper [Thu, 13 Jan 2022 18:21:55 +0000 (10:21 -0800)]
[RISCV] Add tests for fixed vector mul reduction intrinsics. NFC

CodeGen for this can be improved.

2 years ago[mlir][tosa] Update default tosa-to-linalg passes
Rob Suderman [Thu, 13 Jan 2022 17:54:42 +0000 (09:54 -0800)]
[mlir][tosa] Update default tosa-to-linalg passes

Adding the optional decompositions have been verified to improve memory
usage on common models. Added the decomposition to the default tosa to linalg
passes.

Reviewed By: NatashaKnk

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

2 years agomlir: Avoid SmallVector::set_size in SerializeToHsacoPass::loadLibraries
Duncan P. N. Exon Smith [Wed, 12 Jan 2022 02:11:15 +0000 (18:11 -0800)]
mlir: Avoid SmallVector::set_size in SerializeToHsacoPass::loadLibraries

Spotted this in a final grep of projects I don't usually build before
pushing https://reviews.llvm.org/D115380, which makes
`SmallVector::set_size()` private.

Update to `truncate()`, a new-ish variant of `resize()` that asserts the
new size is not bigger and that avoids pulling in the allocation and
initialization code for growing. Doesn't really look like the perf
impact of that would matter here, but since `dirLength` is known to be a
smaller size then we might as well.

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

2 years ago[NFC][DFSan] Update DataFlowSanitizer user docs for -dfsan-conditional-callbacks...
Andrew Browne [Thu, 13 Jan 2022 02:02:04 +0000 (18:02 -0800)]
[NFC][DFSan] Update DataFlowSanitizer user docs for -dfsan-conditional-callbacks, added in https://reviews.llvm.org/D116207

Reviewed By: morehouse

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

2 years ago[libc++] Move assignable_sentinel to a common header where it can be reused
Louis Dionne [Thu, 13 Jan 2022 17:58:53 +0000 (12:58 -0500)]
[libc++] Move assignable_sentinel to a common header where it can be reused

2 years agoEnable ReassociatingReshapeOpConversion with "non-identity" layouts.
Benoit Jacob [Thu, 13 Jan 2022 17:39:06 +0000 (17:39 +0000)]
Enable ReassociatingReshapeOpConversion with "non-identity" layouts.

Enable ReassociatingReshapeOpConversion with "non-identity" layouts.

This removes an early-return in this function, which seems unnecessary and is
preventing some memref.collapse_shape from converting to LLVM (see included lit test).

It seems unnecessary because the return message says "only empty layout map is supported"
but there actually is code in this function to deal with non-empty layout maps. Maybe
it refers to an earlier state of implementation and is just out of date?

Though, there is another concern about this early return: the condition that it actually
checks, `{src,dst}MemrefType.getLayout().isIdentity()`, is not quite the same as what the
return message says, "only empty layout map is supported". Stepping through this
`getLayout().isIdentity()` code in GDB, I found that it evaluates to `.getAffineMap().isIdentity()`
which does (AffineMap.cpp:271):

```
  if (getNumDims() != getNumResults())
    return false;
```

This seems that it would always return false for memrefs of rank greater than 1 ?

Reviewed By: nicolasvasilache

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

2 years agoFix MSVC "not all control paths return a value" warnings. NFC.
Simon Pilgrim [Thu, 13 Jan 2022 17:43:58 +0000 (17:43 +0000)]
Fix MSVC "not all control paths return a value" warnings. NFC.

2 years ago[X86] Add xop/avx2 shifts to X86TargetLowering::isBinOp
Simon Pilgrim [Thu, 13 Jan 2022 17:29:41 +0000 (17:29 +0000)]
[X86] Add xop/avx2 shifts to X86TargetLowering::isBinOp

Allows shuffle combining through per-element shift nodes

This exposed a number of issues with shuffle combining with target intrinsics that are lowered to nodes later during legalization - in particular shuffle combining and SimplifyDemandedVectorElts were being called after canonicalizeShuffleWithBinOps, meaning that shuffles didn't have a chance to be combined away before the shuffle(binop(x,y)) -> binop(shuffle(x),shuffle(y)) fold.

2 years ago[gn build] Port 67151d029bdb
LLVM GN Syncbot [Thu, 13 Jan 2022 17:34:38 +0000 (17:34 +0000)]
[gn build] Port 67151d029bdb

2 years ago[AMDGPU] Fix error handling in asm constraint syntax
Stanislav Mekhanoshin [Thu, 13 Jan 2022 07:45:27 +0000 (23:45 -0800)]
[AMDGPU] Fix error handling in asm constraint syntax

I believe this is unexploitable because in either case the result
will be 'couldn't allocate register for constraint' error message,
but error code checking is clearly wrong.

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

2 years ago[libc++] [ranges] Implement P2415R2 owning_view.
Arthur O'Dwyer [Sun, 9 Jan 2022 14:00:35 +0000 (09:00 -0500)]
[libc++] [ranges] Implement P2415R2 owning_view.

"What is a view?"
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2415r2.html
https://github.com/cplusplus/draft/pull/5010/files

This was a late-breaking (Oct 2021) change to C++20.
The only thing missing from this patch is that we're supposed
to bump the feature-test macro from
    #define __cpp_lib_ranges 202106L
to
    #define __cpp_lib_ranges 202110L
but we can't do that because we don't implement all of 202106 Ranges yet.

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

2 years agoReplace PlatformKind with PlatformType.
Juergen Ributzka [Wed, 12 Jan 2022 22:01:59 +0000 (14:01 -0800)]
Replace PlatformKind with PlatformType.

The PlatformKind/PlatformType enums contain the same information, which requires
them to be kept in-sync. This commit changes over to PlatformType as the sole
source of truth, which allows the removal of the redundant PlatformKind.

The majority of the changes were in LLD and TextAPI.

Reviewed By: cishida

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

2 years ago[libc++][NFC] Remove duplication of distance_apriori_sentinel
Louis Dionne [Thu, 13 Jan 2022 17:22:48 +0000 (12:22 -0500)]
[libc++][NFC] Remove duplication of distance_apriori_sentinel

2 years ago[MachineValueType] Don't allow MVT::getVectorNumElements() to be called for scalable...
Craig Topper [Thu, 13 Jan 2022 17:13:24 +0000 (09:13 -0800)]
[MachineValueType] Don't allow MVT::getVectorNumElements() to be called for scalable vectors.

Migrate the one caller that failed lit tests to use
MVT::getVectorMinNumElements directly.

2 years ago[X86] canonicalizeShuffleWithBinOps - add X86ISD::PSHUFHW/PSHUFLW handling
Simon Pilgrim [Thu, 13 Jan 2022 17:03:11 +0000 (17:03 +0000)]
[X86] canonicalizeShuffleWithBinOps - add X86ISD::PSHUFHW/PSHUFLW handling

2 years agoAMDGPU: Select workitem ID intrinsics to 0 with req_work_group_size
Matt Arsenault [Mon, 10 Jan 2022 00:33:57 +0000 (19:33 -0500)]
AMDGPU: Select workitem ID intrinsics to 0 with req_work_group_size

Shockingly we weren't doing this already. We should probably have this
be done earlier in the IR too, but it's still helpful to have the
lowering guarantee it so that we can modify the ABI implicit inputs
based on it.

2 years agoAMDGPU: Optimize outgoing workitem ID based on reqd_work_group_size
Matt Arsenault [Sun, 9 Jan 2022 22:28:41 +0000 (17:28 -0500)]
AMDGPU: Optimize outgoing workitem ID based on reqd_work_group_size

If we know we we aren't using a component from the kernel, we can save
a few bit packing instructions.

We're still enabling the VGPR input to the kernel though.

2 years ago[flang] Relax the Bash version check
Andrzej Warzynski [Thu, 13 Jan 2022 16:57:59 +0000 (16:57 +0000)]
[flang] Relax the Bash version check

As per https://github.com/flang-compiler/f18-llvm-project/issues/1344,
the `flang` bash script works fine with 4.4.19 and requiring
4.4.23 is too restrictive. Rather than keep updating the patch level,
this patch removes this particular check (so that it will only check the
major and minor versions instead).

As this is both rather straightforward and urgent, I'm merging this
without a review.

2 years ago[Libomptarget] Fix multiply defined symbol during linking
Joseph Huber [Thu, 13 Jan 2022 16:39:12 +0000 (11:39 -0500)]
[Libomptarget] Fix multiply defined symbol during linking

This patch adds the `weak` identifier to the openmp device environment
variable. The changes introduced in https://reviews.llvm.org/D117211
result in multiply defined symbols. Because the symbol is potentially
included multiple times for each offloading file we will get symbol
colisions, and because it needs to have external visiblity it should be
weak.

Reviewed By: JonChesterfield

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

2 years agoSupport the *_WIDTH macros in limits.h and stdint.h
Aaron Ballman [Thu, 13 Jan 2022 16:45:27 +0000 (11:45 -0500)]
Support the *_WIDTH macros in limits.h and stdint.h

This completes the implementation of
WG14 N2412 (http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2412.pdf),
which standardizes C on a twos complement representation for integer
types. The only work that remained there was to define the correct
macros in the standard headers, which this patch does.

2 years ago[LV] Extend check lines for pr34681.ll to cover foldable select.
Florian Hahn [Thu, 13 Jan 2022 15:11:14 +0000 (15:11 +0000)]
[LV] Extend check lines for pr34681.ll to cover foldable select.

2 years ago[clang] Fix function pointer address space
Elizabeth Andrews [Thu, 14 Oct 2021 00:12:31 +0000 (17:12 -0700)]
[clang] Fix function pointer address space

Functions pointers should be created with program address space. This
patch introduces program address space in TargetInfo. Targets with
non-default (default is 0) address space for functions should explicitly
set this value. This patch fixes a crash on lvalue reference to function
pointer (in device code) when using oneAPI DPC++ compiler.

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

2 years ago[CMake] Output the error message when get_errc_messages fails
John Brawn [Thu, 13 Jan 2022 15:54:20 +0000 (15:54 +0000)]
[CMake] Output the error message when get_errc_messages fails

This makes it easier figure out the cause when it fails, and is what
check_z3_version does (the other place we use try_run).

2 years agoRevert "[CodeGen][AArch64] Ensure isSExtCheaperThanZExt returns true for negative...
David Sherwood [Thu, 13 Jan 2022 15:59:03 +0000 (15:59 +0000)]
Revert "[CodeGen][AArch64] Ensure isSExtCheaperThanZExt returns true for negative constants"

This reverts commit 31009f0b5afb504fc1f30769c038e1b7be6ea45b.

It seems to be causing SVE VLA buildbot failures and has introduced a
genuine regression. Reverting for now.

2 years ago[PowerPC] add RUN lines for both endians to test; NFC
Sanjay Patel [Thu, 13 Jan 2022 15:45:31 +0000 (10:45 -0500)]
[PowerPC] add RUN lines for both endians to test; NFC

The load narrowing transform works for both targets,
so we might as well test both with simple examples
like this.

2 years agoRevert "[clang][lex] Keep references to `DirectoryLookup` objects up-to-date"
Jan Svoboda [Thu, 13 Jan 2022 15:29:10 +0000 (16:29 +0100)]
Revert "[clang][lex] Keep references to `DirectoryLookup` objects up-to-date"

This reverts commit 8503c688. This patch causes some issues with `#include_next`: https://github.com/llvm/llvm-project/issues/53161

2 years ago[X86] Add tests showing failure to merge shuffles through avx2 shift binops
Simon Pilgrim [Thu, 13 Jan 2022 15:25:13 +0000 (15:25 +0000)]
[X86] Add tests showing failure to merge shuffles through avx2 shift binops

2 years ago[X86] Add tests showing failure to merge shuffles through xop shift binops
Simon Pilgrim [Thu, 13 Jan 2022 15:06:13 +0000 (15:06 +0000)]
[X86] Add tests showing failure to merge shuffles through xop shift binops

2 years ago[libc++] Add tests verifying alphabetical order for several things.
Arthur O'Dwyer [Fri, 7 Jan 2022 14:45:05 +0000 (09:45 -0500)]
[libc++] Add tests verifying alphabetical order for several things.

These things are header #includes, CMakeLists.txt, and module.modulemap.

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

2 years agoAdd another assert to cpu-dispatch emission to help track down a tough
Erich Keane [Thu, 13 Jan 2022 14:52:58 +0000 (06:52 -0800)]
Add another assert to cpu-dispatch emission to help track down a tough
to repro error.

As mentioned yesterday, I've got a problem that I can only reproduce on
Godbolt (none of the build configs on my local machine!), so this is at
least somewhat usable until I figure out a cause.

2 years ago[DAG] Add ISD::ROTL/ROTR to TargetLoweringBase::isBinOp
Simon Pilgrim [Thu, 13 Jan 2022 14:32:03 +0000 (14:32 +0000)]
[DAG] Add ISD::ROTL/ROTR to TargetLoweringBase::isBinOp

Allows shuffle combining through rotation nodes

2 years ago[X86] Add tests showing failure to merge shuffles through rotation binops
Simon Pilgrim [Thu, 13 Jan 2022 14:09:05 +0000 (14:09 +0000)]
[X86] Add tests showing failure to merge shuffles through rotation binops

2 years ago[mlir] Introduce C API for PDL dialect types
Denys Shabalin [Thu, 13 Jan 2022 10:33:42 +0000 (11:33 +0100)]
[mlir] Introduce C API for PDL dialect types

This change introduces C API helper functions to work with PDL types.
Modification closely follow the format of the https://reviews.llvm.org/D116546.

Reviewed By: ftynse

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

2 years ago[mlir] Fix reference to out of date CMake function
Denys Shabalin [Thu, 13 Jan 2022 14:11:33 +0000 (15:11 +0100)]
[mlir] Fix reference to out of date CMake function

Reviewed By: ftynse

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

2 years ago[lldb][AArch64] Remove armv8.3-a flag from tagged memory read test
David Spickett [Thu, 13 Jan 2022 14:21:33 +0000 (14:21 +0000)]
[lldb][AArch64] Remove armv8.3-a flag from tagged memory read test

This was left over from when I had used some pointer authentication
instructions to sign the pointer. Then I realised that simply setting
the top byte is enough to prove the ABI plugin is being called.

Top byte ignore is a feature of the armv8-a architecure and doesn't
need any extra compiler flags.

2 years ago[DebugInfo][InstrRef] Short-circuit unnecessary preferred location map construction
Eugene Zhulenev [Thu, 13 Jan 2022 10:19:44 +0000 (02:19 -0800)]
[DebugInfo][InstrRef] Short-circuit unnecessary preferred location map construction

Reviewed By: cota

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

2 years ago[clangd] Ignore cvr-qualifiers in selection.
Sam McCall [Thu, 13 Jan 2022 07:03:39 +0000 (08:03 +0100)]
[clangd] Ignore cvr-qualifiers in selection.

The AST doesn't track their locations, and the default behavior of attributing
them to the lexically-enclosing node is sloppy and often inaccurate.

Also add a couple of passing test cases for declarators that weren't obvious.

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