platform/upstream/llvm.git
2 years ago[Attributor] [NFC] Use canonical variable name
Bryce Wilson [Fri, 14 Jan 2022 07:06:00 +0000 (23:06 -0800)]
[Attributor] [NFC] Use canonical variable name

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

2 years ago[BOLT][NFC] Refactor reset-release to move assignment
Amir Ayupov [Wed, 23 Jun 2021 22:10:47 +0000 (15:10 -0700)]
[BOLT][NFC] Refactor reset-release to move assignment

Summary:
Follow the clang-tidy suggestion to replace reset-release with move assignment.

Move assignment's effect for unique_ptr:
> Effects: Transfers ownership from `u` to `*this` as if by calling `reset(u.release())`
followed by an assignment from `std::forward<D>(u.get_deleter())`.

2 years ago[BOLT][NFC] Remove uses of `std::vector<bool>`
Amir Ayupov [Thu, 13 Jan 2022 21:48:51 +0000 (13:48 -0800)]
[BOLT][NFC] Remove uses of `std::vector<bool>`

Summary:
LLVM Programmer’s Manual strongly discourages the use of `std::vector<bool>`
and suggests `llvm::BitVector` as a possible replacement.

2 years agoPartially revert cac7aabbd82: some APIs don't have in-tree users and some build break...
Mehdi Amini [Fri, 14 Jan 2022 06:14:56 +0000 (06:14 +0000)]
Partially revert cac7aabbd82: some APIs don't have in-tree users and some build breaks weren't caught

2 years ago[bazel] Separate capi_deps from deps in mlir_c_api_cc_library.
Stella Laurenzo [Thu, 13 Jan 2022 01:35:29 +0000 (01:35 +0000)]
[bazel] Separate capi_deps from deps in mlir_c_api_cc_library.

This is important because *Objects targets need to only depend on other *Objects targets, not on the unsuffixed CAPI rules. Depending on how it is linked in the current setup, it can cause duplicate symbols.

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

2 years ago[RISCV] Improve i64 splat vector lowering in RV32.
jacquesguan [Tue, 4 Jan 2022 07:41:44 +0000 (15:41 +0800)]
[RISCV] Improve i64 splat vector lowering in RV32.

We could use vmv.v.i/vmv.v.x whose eew is 32 to lower the i64 splat vector if the i64 constant scalar could be splitted into two same i32 scalar.

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

2 years ago[RISCV] Add more i64 splat vector test.
jacquesguan [Tue, 4 Jan 2022 08:28:05 +0000 (16:28 +0800)]
[RISCV] Add more i64 splat vector test.

Precommit test for D117079.

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

2 years ago[RISCV] Remove unused check prefixes. NFC
Craig Topper [Fri, 14 Jan 2022 06:02:04 +0000 (22:02 -0800)]
[RISCV] Remove unused check prefixes. NFC

2 years ago[NFC][msan] Init few vars later
Vitaly Buka [Fri, 14 Jan 2022 02:56:13 +0000 (18:56 -0800)]
[NFC][msan] Init few vars later

2 years ago[RISCV] Add basic Zfh inline assembly tests. NFC
Craig Topper [Fri, 14 Jan 2022 05:51:50 +0000 (21:51 -0800)]
[RISCV] Add basic Zfh inline assembly tests. NFC

The abi name test shows incorrect fcvt.d.h, fcvt.h.d, fcvt.f.h,
and fcvt.h.f instructions around the inline assembly.

2 years ago[RISCV] Add inline asm f32 test cases with D extension. NFC
Craig Topper [Fri, 14 Jan 2022 05:34:15 +0000 (21:34 -0800)]
[RISCV] Add inline asm f32 test cases with D extension. NFC

Using named registers as input or output constraints creates fcvt.d.s
and fcvt.s.d instructions around the inline assembly.

This makes the data unusable by the inline assembly and corrupts
the results of the inline assembly.

2 years agoFix registers for Windows on ARM64
Nenad Mikša [Fri, 14 Jan 2022 05:36:57 +0000 (21:36 -0800)]
Fix registers for Windows on ARM64

Reviewed By: #sanitizers, vitalybuka

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

2 years ago[NFC][msan] Declare some getShadow vars later
Vitaly Buka [Thu, 13 Jan 2022 23:53:57 +0000 (15:53 -0800)]
[NFC][msan] Declare some getShadow vars later

2 years ago[Polly][CMake] Make PollyConfig.cmake relocatable like other projects'
John Ericson [Mon, 3 Jan 2022 21:09:33 +0000 (21:09 +0000)]
[Polly][CMake] Make PollyConfig.cmake relocatable like other projects'

This builds on D116521 to add this functionality to Polly without more copy-pasted code.

Reviewed By: beanz

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

2 years ago[MS] Implement on-demand TLS initialization for Microsoft CXX ABI
Maurice Heumann [Thu, 13 Jan 2022 02:26:30 +0000 (18:26 -0800)]
[MS] Implement on-demand TLS initialization for Microsoft CXX ABI

TLS initializers, for example constructors of thread-local variables, don't necessarily get called. If a thread was created before a module is loaded, the module's TLS initializers are not executed for this particular thread.

This is why Microsoft added support for dynamic TLS initialization. Before every use of thread-local variables, a check is added that runs the module's TLS initializers on-demand.

To do this, the method `__dyn_tls_on_demand_init` gets called. Internally, it simply calls `__dyn_tls_init`.

No additional TLS initializer that sets the guard needs to be emitted, as the guard always gets set by `__dyn_tls_init`.
The guard is also checked again within `__dyn_tls_init`. This makes our check redundant, however, as Microsoft's compiler also emits this check, the behaviour is adopted here.

Reviewed By: majnemer

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

2 years ago[mlir] Optimize OperationName construction and usage
River Riddle [Thu, 13 Jan 2022 07:46:59 +0000 (23:46 -0800)]
[mlir] Optimize OperationName construction and usage

When constructing an OperationName, the overwhelming majority of
cases are from registered operations. This revision adds a non-locked
lookup into the currently registered operations, which prevents locking
in the common case. This revision also optimizes several uses of
RegisteredOperationName that expect the operation to be registered,
e.g. such as in OpBuilder.

These changes provides a reasonable speedup (5-10%) in some
compilations, especially on platforms where locking is expensive.

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

2 years agoRevert "GlobalISel: Add G_ASSERT_ALIGN hint instruction"
James Y Knight [Fri, 14 Jan 2022 04:49:17 +0000 (04:49 +0000)]
Revert "GlobalISel: Add G_ASSERT_ALIGN hint instruction"

This commit sometimes causes a crash when compiling a vtable thunk. E.g.:

clang '--target=aarch64-grtev4-linux-gnu' -xc++ - -c -o /dev/null <<EOF
struct a {
  virtual int f();
};
struct c {
  virtual int &g() const;
};
struct d : a, c {
  int &g() const;
};
int &d::g() const {}
EOF

Some follow-up commits have been reverted as well:
Revert "IR: Make getRetAlign check callee function attributes"
Revert "Fix MSVC "32-bit shift implicitly converted to 64 bits" warning. NFC."
Revert "Fix MSVC "32-bit shift implicitly converted to 64 bits" warning. NFC."

This reverts commit 4f414af6a77cdbd9b6303a7afa525cfb3f9d792a.
This reverts commit a5507d2e253a2c94c3ca7794edf7385af8082b97.
This reverts commit 3d2d208f6a0a421b23937c39b9d371183a5913a3.
This reverts commit 07ddfa95e3b5ea8464e90545f592624221b854ae.

2 years ago[libc++] LWG3171: implement operator<< for filesystem::directory_entry.
Konstantin Varlamov [Fri, 14 Jan 2022 04:44:01 +0000 (20:44 -0800)]
[libc++] LWG3171: implement operator<< for filesystem::directory_entry.

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

2 years ago[mlir][sparse] Moving the sort from factory method to the constructor.
wren romano [Fri, 14 Jan 2022 01:46:30 +0000 (17:46 -0800)]
[mlir][sparse] Moving the sort from factory method to the constructor.

This guarantees the preconditions of fromCOO; whereas prior to this, one could call the constructor directly with an unsorted tensor, which would cause fromCOO to misbehave.

Reviewed By: aartbik

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

2 years ago[NFC] Apply the fix for different signedness warning in OpenMPIRBuilderTest.cpp
Peixin-Qiao [Fri, 14 Jan 2022 02:49:21 +0000 (10:49 +0800)]
[NFC] Apply the fix for different signedness warning in OpenMPIRBuilderTest.cpp

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

2 years ago[libc] Fix precision constants for long double in MPFRUtils.cpp.
Tue Ly [Fri, 14 Jan 2022 02:31:42 +0000 (21:31 -0500)]
[libc] Fix precision constants for long double in MPFRUtils.cpp.

2 years agoApply clang-tidy fixes for readability-simplify-boolean-expr to MLIR (NFC)
Mehdi Amini [Fri, 14 Jan 2022 01:36:05 +0000 (01:36 +0000)]
Apply clang-tidy fixes for readability-simplify-boolean-expr to MLIR (NFC)

2 years agoApply clang-tidy fixes for readability-identifier-naming to MLIR (NFC)
Mehdi Amini [Fri, 14 Jan 2022 01:36:04 +0000 (01:36 +0000)]
Apply clang-tidy fixes for readability-identifier-naming to MLIR (NFC)

2 years agoApply clang-tidy fixes for readability-avoid-const-params-in-decls to MLIR (NFC)
Mehdi Amini [Fri, 14 Jan 2022 01:35:56 +0000 (01:35 +0000)]
Apply clang-tidy fixes for readability-avoid-const-params-in-decls to MLIR (NFC)

2 years agoApply clang-tidy fixes for performance-unnecessary-value-param to MLIR (NFC)
Mehdi Amini [Fri, 14 Jan 2022 01:35:55 +0000 (01:35 +0000)]
Apply clang-tidy fixes for performance-unnecessary-value-param to MLIR (NFC)

2 years agoApply clang-tidy fixes for performance-move-const-arg to MLIR (NFC)
Mehdi Amini [Fri, 14 Jan 2022 01:35:44 +0000 (01:35 +0000)]
Apply clang-tidy fixes for performance-move-const-arg to MLIR (NFC)

2 years agoApply clang-tidy fixes for performance-for-range-copy to MLIR (NFC)
Mehdi Amini [Fri, 14 Jan 2022 01:35:41 +0000 (01:35 +0000)]
Apply clang-tidy fixes for performance-for-range-copy to MLIR (NFC)

2 years agoApply clang-tidy fixes for modernize-use-using to MLIR (NFC)
Mehdi Amini [Fri, 14 Jan 2022 01:35:39 +0000 (01:35 +0000)]
Apply clang-tidy fixes for modernize-use-using to MLIR (NFC)

2 years agoApply clang-tidy fixes for modernize-use-override to MLIR (NFC)
Mehdi Amini [Fri, 14 Jan 2022 01:35:38 +0000 (01:35 +0000)]
Apply clang-tidy fixes for modernize-use-override to MLIR (NFC)

2 years agoApply clang-tidy fixes for modernize-use-equals-default to MLIR (NFC)
Mehdi Amini [Fri, 14 Jan 2022 01:35:35 +0000 (01:35 +0000)]
Apply clang-tidy fixes for modernize-use-equals-default to MLIR (NFC)

2 years agoApply clang-tidy fixes for modernize-use-default-member-init to MLIR (NFC)
Mehdi Amini [Fri, 14 Jan 2022 01:35:30 +0000 (01:35 +0000)]
Apply clang-tidy fixes for modernize-use-default-member-init to MLIR (NFC)

2 years agoApply clang-tidy fixes for llvm-qualified-auto to MLIR (NFC)
Mehdi Amini [Fri, 14 Jan 2022 01:35:24 +0000 (01:35 +0000)]
Apply clang-tidy fixes for llvm-qualified-auto to MLIR (NFC)

2 years ago[C++20] [Modules] Exit early if export decl is not valid
Chuanqi Xu [Fri, 14 Jan 2022 02:21:42 +0000 (10:21 +0800)]
[C++20] [Modules] Exit early if export decl is not valid

This patch fixes a crash due to following simple program:
> export struct Unit {
>    bool operator<(const Unit&);
> };

It would crash since the compiler would set the module ownership for
Unit. And the declaration with a module ownership is assumed to own a
module. But here isn't one. So here is the crash.

This patch fixes this by exiting early if it finds the export decl is
already invalid.

Reviewed By: aaron.ballman

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

2 years ago[gn build] Port d3729bb38475
LLVM GN Syncbot [Fri, 14 Jan 2022 01:58:03 +0000 (01:58 +0000)]
[gn build] Port d3729bb38475

2 years ago[libc++][ranges] Add ranges::in_in_result
Nikolas Klauser [Fri, 14 Jan 2022 01:55:51 +0000 (02:55 +0100)]
[libc++][ranges] Add ranges::in_in_result

Add `std::ranges::in_in_result`

Reviewed By: Quuxplusone, Mordante, #libc

Spies: ldionne, libcxx-commits, mgorny

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

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