platform/upstream/llvm.git
2 years ago[NFC][SCEV] Add test with umin_seq w/ 1op and constant
Roman Lebedev [Fri, 14 Jan 2022 13:52:54 +0000 (16:52 +0300)]
[NFC][SCEV] Add test with umin_seq w/ 1op and constant

2 years ago[MLIR] NFC. affine data copy generate utility return value cleanup
Uday Bondhugula [Thu, 13 Jan 2022 10:50:11 +0000 (16:20 +0530)]
[MLIR] NFC. affine data copy generate utility return value cleanup

Clean up return value on affineDataCopyGenerate utility. Return the
actual success/failure status instead of the "number of bytes" which
isn't being used in the codebase in any way. The success/failure status
wasn't being sent out earlier.

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

2 years ago[Clang] Add __builtin_reduce_or and __builtin_reduce_and
Jun Zhang [Wed, 5 Jan 2022 09:20:57 +0000 (17:20 +0800)]
[Clang] Add __builtin_reduce_or and __builtin_reduce_and

This patch implements two builtins specified in D111529.
The last __builtin_reduce_add will be seperated into another one.

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

2 years ago[LLDB][NFC] Fix a typo in comment
Coelacanthus [Fri, 14 Jan 2022 08:27:44 +0000 (16:27 +0800)]
[LLDB][NFC] Fix a typo in comment

fix typo in comment: libcstd++ -> libstdc++

Reviewed By: wallace

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

2 years ago[mlir][linalg][bufferize] Support custom insertion point for buffer copies
Matthias Springer [Fri, 14 Jan 2022 13:46:52 +0000 (22:46 +0900)]
[mlir][linalg][bufferize] Support custom insertion point for buffer copies

By default, copies are inserted right before the tensor OpOperand use. With this change, `bufferize` implementation can change the insertion point. This is needed for some ops where it would be illegal to insert a copy right before the use.

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

2 years ago[mlir][memref] Fold self copies
Matthias Springer [Fri, 14 Jan 2022 13:31:01 +0000 (22:31 +0900)]
[mlir][memref] Fold self copies

Fold `memref.copy %x, %x`.

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

2 years ago[clang-format] Add missing test for loops formatting. NFC.
Marek Kurdej [Fri, 14 Jan 2022 13:40:03 +0000 (14:40 +0100)]
[clang-format] Add missing test for loops formatting. NFC.

The case with an inner while loop wasn't tested before. Same for outer loop with a ForeachMacro.

2 years ago[LoopVersioning] Add test case with foldable icmp in runtime check.
Florian Hahn [Fri, 14 Jan 2022 13:42:20 +0000 (13:42 +0000)]
[LoopVersioning] Add test case with foldable icmp in runtime check.

Test case showing a foldable icmp ('icmp ult i8* [[SCEVGEP1]], [[SCEVGEP1]]').
This can be simplified in a follow-up change.

2 years agoRevert "[clangd] Elide even more checks in SelectionTree."
Kadir Cetinkaya [Fri, 14 Jan 2022 13:32:43 +0000 (14:32 +0100)]
Revert "[clangd] Elide even more checks in SelectionTree."

This reverts commit 07f9fb8b51417ec3e6f46508e1b5ef78287b32ad.

2 years ago[mlir][linalg][bufferize] Use memref.copy instead of linalg.copy
Matthias Springer [Fri, 14 Jan 2022 12:57:30 +0000 (21:57 +0900)]
[mlir][linalg][bufferize] Use memref.copy instead of linalg.copy

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

2 years ago[mlir][memref] Implement fast lowering of memref.copy
Stephan Herhut [Fri, 7 Jan 2022 09:00:19 +0000 (10:00 +0100)]
[mlir][memref] Implement fast lowering of memref.copy

In the absence of maps, we can lower memref.copy to a memcpy.

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

2 years ago[DebugInfo][DWARF][NFC] Refactor DWARFTypePrinter usages. Create functions to print...
Alexey Lapshin [Wed, 12 Jan 2022 15:42:48 +0000 (18:42 +0300)]
[DebugInfo][DWARF][NFC] Refactor DWARFTypePrinter usages. Create functions to print type dies.

This patch creates functions which might be used to dump types.
This functionality was already implemented by  DWARFTypePrinter.
Now it could be reused. It will help D96035, which uses DWARFTypePrinter.

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

2 years ago[mlir][memref] Fold copy of cast
Matthias Springer [Fri, 14 Jan 2022 12:50:33 +0000 (21:50 +0900)]
[mlir][memref] Fold copy of cast

If the source/dest is a cast that does not change shape/element type, the cast can be skipped.

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

2 years ago[SCEV] `getSequentialMinMaxExpr()`: rewrite deduplication to be fully recursive
Roman Lebedev [Fri, 14 Jan 2022 12:11:20 +0000 (15:11 +0300)]
[SCEV] `getSequentialMinMaxExpr()`: rewrite deduplication to be fully recursive

Since we don't merge/expand non-sequential umin exprs into umin_seq exprs,
we may have umin_seq(umin(umin_seq())) chain, and the innermost umin_seq
can have duplicate operands still.

2 years ago[clang-format] Fix typos in test. NFC.
Marek Kurdej [Fri, 14 Jan 2022 12:24:16 +0000 (13:24 +0100)]
[clang-format] Fix typos in test. NFC.

2 years ago[RISCV][NFC] Use TableGen 'foreach' to simplify repetitive CSR definitions
Alex Bradbury [Fri, 14 Jan 2022 11:58:27 +0000 (11:58 +0000)]
[RISCV][NFC] Use TableGen 'foreach' to simplify repetitive CSR definitions

Make the definitions of hpmcounter3-hpmcounter31,
hpmcounter3h-hpmcounter31h, mhpmcounter3-mhpmcounter31,
mhpmcounter3h-mhpmcounter31h, pmpaddr0-pmpaddr63, mhpmevent3-31, and
pmpcfg0-15 substantially less repetitive using a foreach loop.

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

2 years ago[mlir] Fix invalid assertion in ModuleTranslation.cpp
Alex Zinenko [Thu, 13 Jan 2022 13:29:09 +0000 (14:29 +0100)]
[mlir] Fix invalid assertion in ModuleTranslation.cpp

LLVM dialect supports terminators with repeated successor blocks that take
different operands. This cannot be directly expressed in LLVM IR though since
it uses the number of the predecessor block to differentiate values in its PHI
nodes. Therefore, the translation to LLVM IR inserts dummy blocks to forward
arguments in case of repeated succesors with arguments. The insertion works
correctly. However, when connecting PHI nodes to their source values, the
assertion of the insertion having worked correctly was incorrect: it would only
trigger if repeated blocks were adjacent in the successor list (not guaranteed
by anything) and would not check if the successors have operands (no need for
dummy blocks in absence of operands since no PHIs are being created). Change
the assertion to only trigger in case of duplicate successors with operands,
and don't expect them to be adjacent.

Reviewed By: wsmoses

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

2 years ago[IRBuilder] Migrate gep-folding to value-based FoldGEP.
Florian Hahn [Fri, 14 Jan 2022 11:23:50 +0000 (11:23 +0000)]
[IRBuilder] Migrate gep-folding to value-based FoldGEP.

Depends on D117038.

Reviewed By: lebedev.ri

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

2 years ago[Verifier] Avoid asserting on invalid cleanuppad chain
Nikita Popov [Fri, 14 Jan 2022 11:08:33 +0000 (12:08 +0100)]
[Verifier] Avoid asserting on invalid cleanuppad chain

The invalid undef value already triggers a verifier failure, but
then the upwards scan from the cleanuppad ends up asserting. Make
sure this is handled gacefully instead.

2 years ago[mlir] Use .empty() instead of checking size() == 0.
Adrian Kuegel [Fri, 14 Jan 2022 10:58:52 +0000 (11:58 +0100)]
[mlir] Use .empty() instead of checking size() == 0.

Based on a finding by ClangTidy readability-container-size-empty check.

2 years ago[llvm-dwp] Simplify FileCheck patterns. NFC.
Jay Foad [Fri, 14 Jan 2022 10:37:55 +0000 (10:37 +0000)]
[llvm-dwp] Simplify FileCheck patterns. NFC.

Take advantage of D117117 to simplify {{\[}}[[ to [[[.

2 years agoUse {LITERAL} instead of regex escaping in some lit tests. NFC.
Jay Foad [Fri, 14 Jan 2022 10:35:03 +0000 (10:35 +0000)]
Use {LITERAL} instead of regex escaping in some lit tests. NFC.

2 years ago[LLDB] Skip TestIOHandlerPythonREPLSigint.py on Arm/Linux
Muhammad Omair Javaid [Fri, 14 Jan 2022 10:46:02 +0000 (15:46 +0500)]
[LLDB] Skip TestIOHandlerPythonREPLSigint.py on Arm/Linux

TestIOHandlerPythonREPLSigint.py is failing on Arm/Linux buildbot. I am
marking it as skip for now.

2 years ago[clang-format] Fix namespace end comments fixer with anonymous namespaces.
Marek Kurdej [Fri, 14 Jan 2022 10:37:04 +0000 (11:37 +0100)]
[clang-format] Fix namespace end comments fixer with anonymous namespaces.

Previously, a strange trailing comment was produced:
```
namespace out { namespace {
}} // namespace out::
```
(mind the "out::").

Reviewed By: MyDeveloperDay, owenpan

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

2 years ago[InstSimplify] Pass pointer and indices separately to SimplifyGEPInst.
Florian Hahn [Fri, 14 Jan 2022 09:59:43 +0000 (09:59 +0000)]
[InstSimplify] Pass pointer and indices separately to SimplifyGEPInst.

This doesn't require callers to put the pointer operand and the indices
in a container like a vector when calling the function. This is not
really an issue with the existing callers. But when using it from
IRBuilder the inputs are available as separate pointer value and indices
ArrayRef.

Reviewed By: lebedev.ri

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

2 years ago[InstCombine] Fold for masked scatters to a uniform address
Caroline Concatto [Mon, 13 Dec 2021 12:03:26 +0000 (12:03 +0000)]
[InstCombine] Fold for masked scatters to a uniform address

When masked scatter intrinsic does a uniform store to a destination
address from a source vector, and in this case, the mask is all one value.
This patch replaces the masked scatter with an extracted element of the
last lane of the source vector and stores it in the destination vector.
This patch also folds when the value in the masked scatter is a splat.
In this case, the mask cannot be all zero, and it folds to a scalar store
of the value in the destination pointer.

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

2 years ago[ConstantFold] Check for uniform value before reinterpret load
Nikita Popov [Fri, 14 Jan 2022 09:07:37 +0000 (10:07 +0100)]
[ConstantFold] Check for uniform value before reinterpret load

The reinterpret load code will convert undef values into zero.
Check the uniform value case before it to produce a better result
for all-undef initializers.

However, the uniform value handling will return the uniform value
even if the access is out of bounds, while the reinterpret load
code will return undef. Add an explicit check to retain the
previous result in this case.

2 years ago[InstSimplify] Add test for load from undef (NFC)
Nikita Popov [Fri, 14 Jan 2022 08:57:03 +0000 (09:57 +0100)]
[InstSimplify] Add test for load from undef (NFC)

If we're loading from an all-undef value, we sometimes still
return zero rather than undef.

2 years ago[GlobalOpt] Add test for SRA with i8 array type (NFC)
Nikita Popov [Fri, 14 Jan 2022 08:51:13 +0000 (09:51 +0100)]
[GlobalOpt] Add test for SRA with i8 array type (NFC)

2 years ago[CMake] Do not override user specified CMAKE_{C,CXX}_ARCHIVE_FINISH on Linux
Fangrui Song [Fri, 14 Jan 2022 09:10:23 +0000 (01:10 -0800)]
[CMake] Do not override user specified CMAKE_{C,CXX}_ARCHIVE_FINISH on Linux

Respect the user choice, e.g. -DCMAKE_CXX_ARCHIVE_FINISH=: (to skip the
(usually) no-op step).

2 years ago[clang-check] Adjust argument adjusters for clang-check to strip options blocking...
Sam McCall [Fri, 14 Jan 2022 07:34:11 +0000 (08:34 +0100)]
[clang-check] Adjust argument adjusters for clang-check to strip options blocking the static analyzer

Output generation options (like `-save-temps`) will make the analyzer not executed even `--analyze` option is provided in the driver arguments.
Besides, the original approach of adding `--analyze` option will not work when (more than one) `-fsyntax-only` options are provided in the driver arguments.

This patch fixes these two problems by using the syntax-only adjuster to remove output generation options and manually filter out redundant `-fsyntax-only` options.

In the new implementation, the adjusters added by `ClangTool` will not be removed but used as dependencies for clang-check adjusters for analyzer options.

Reviewed By: sammccall

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

2 years ago[NFC][CSKY] Remove duplicate setOperationAction in CSKYTargetLowering constructor
Zi Xuan Wu [Fri, 14 Jan 2022 09:01:43 +0000 (17:01 +0800)]
[NFC][CSKY] Remove duplicate setOperationAction in CSKYTargetLowering constructor

2 years agoAdd -fsanitize-address-param-retval to clang.
Kevin Athey [Fri, 14 Jan 2022 08:20:33 +0000 (00:20 -0800)]
Add -fsanitize-address-param-retval to clang.

With the introduction of this flag, it is no longer necessary to enable noundef analysis with 4 separate flags.
(-Xclang -enable-noundef-analysis -mllvm -msan-eager-checks=1).
This change only covers the introduction into the compiler.

This is a follow up to: https://reviews.llvm.org/D116855

Reviewed By: vitalybuka

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

2 years agoRevert unrelated change from: [clang-format] Fix break being added to macro define...
Marek Kurdej [Fri, 14 Jan 2022 07:43:59 +0000 (08:43 +0100)]
Revert unrelated change from: [clang-format] Fix break being added to macro define with ColumnLimit: 0

2 years ago[clang-format] Fix break being added to macro define with ColumnLimit: 0
Armen Khachkinaev [Thu, 13 Jan 2022 14:49:50 +0000 (15:49 +0100)]
[clang-format] Fix break being added to macro define with ColumnLimit: 0

Fix for #[[ https://github.com/llvm/llvm-project/issues/49164 | 49164 ]] issue.

Reviewed By: MyDeveloperDay, HazardyKnusperkeks, curdeius, owenpan

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

2 years ago[NFC] [Coroutines] Refactor implementation in checkFinalSuspendNoThrow
Chuanqi Xu [Fri, 14 Jan 2022 07:37:01 +0000 (15:37 +0800)]
[NFC] [Coroutines] Refactor implementation in checkFinalSuspendNoThrow

Now when we are checking if the expression `co_await
promise.final_suspend()` is not throw, we would check unconditionally
for its child expressions recursively. It takes unnecessary time. And
the compiler would complains if the implementation in final_suspend()
may throw even if the higher level function signature marked noexcept
already.

This fixes bug48453 too.

2 years agoFix a comment in CMake (NFC)
Mehdi Amini [Fri, 14 Jan 2022 07:33:06 +0000 (07:33 +0000)]
Fix a comment in CMake (NFC)

2 years agoDo not build llc and mlir-cpu-runner to run MLIR tests with the native target isn...
Mehdi Amini [Fri, 14 Jan 2022 07:29:50 +0000 (07:29 +0000)]
Do not build llc and mlir-cpu-runner to run MLIR tests with the native target isn't configured (NFC)

The relevant tests are already disabled in this case.

2 years ago[mlir] Expose a function to get vector::CombiningKind from Operation*.
Alexander Belyaev [Fri, 14 Jan 2022 07:23:27 +0000 (08:23 +0100)]
[mlir] Expose a function to get vector::CombiningKind from Operation*.

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

2 years agoMark some MLIR tests as requiring the native target to be configured
Mehdi Amini [Fri, 14 Jan 2022 06:57:51 +0000 (06:57 +0000)]
Mark some MLIR tests as requiring the native target to be configured

This makes `ninja check-mlir` work without the host targets configured.

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.