platform/upstream/llvm.git
2 years agoReapply #2 of [runtimes] Fix building initial libunwind+libcxxabi+libcxx with compile...
Martin Storsjö [Sat, 23 Oct 2021 22:11:20 +0000 (01:11 +0300)]
Reapply #2 of [runtimes] Fix building initial libunwind+libcxxabi+libcxx with compiler implied -lunwind

This does mostly the same as D112126, but for the runtimes cmake files.
Most of that is straightforward, but the interdependency between
libcxx and libunwind is tricky:

Libunwind is built at the same time as libcxx, but libunwind is not
installed yet. LIBCXXABI_USE_LLVM_UNWINDER makes libcxx link directly
against the just-built libunwind, but the compiler implicit -lunwind
isn't found. This patch avoids that by adding --unwindlib=none if
supported, if we are going to link explicitly against a newly built
unwinder anyway.

Since the previous attempt, this no longer uses
llvm_enable_language_nolink (and thus doesn't set
CMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY during the compiler
sanity checks). Setting CMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY
during compiler sanity checks makes cmake not learn about some
aspects of the compiler, which can make further find_library or
find_package fail. This caused OpenMP to not detect libelf and libffi,
disabling some OpenMP target plugins.

Instead, require the caller to set CMAKE_{C,CXX}_COMPILER_WORKS=YES
when building in a configuration with an incomplete toolchain.

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

2 years ago[NFC][lsan] Change LeakSuppressionContext interface
Vitaly Buka [Wed, 8 Dec 2021 05:37:02 +0000 (21:37 -0800)]
[NFC][lsan] Change LeakSuppressionContext interface

Reviewed By: morehouse

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

2 years ago[SLP]Fix comparator for cmp instruction vectorization.
Alexey Bataev [Tue, 7 Dec 2021 18:16:14 +0000 (10:16 -0800)]
[SLP]Fix comparator for cmp instruction vectorization.

The comparator for the sort functions should provide strict weak
ordering relation between parameters. Current solution causes compiler
crash with some standard c++ library implementations, because it does
not meet this criteria. Tried to fix it + it improves the iverall
vectorization result.

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

2 years ago[reductions] Delete another piece of dead flag handling [NFC]
Philip Reames [Thu, 9 Dec 2021 18:52:35 +0000 (10:52 -0800)]
[reductions] Delete another piece of dead flag handling [NFC]

The code claimed to handle nsw/nuw, but those aren't passed via builder state and the explicit IR construction just above never sets them.

The only case this bit of code is actually relevant for is FMF flags.  However, dropPoisonGeneratingFlags currently doesn't know about FMF at all, so this was a noop.  It's also unneeded, as the caller explicitly configures the flags on the builder before this call, and the flags on the individual ops should be controled by the intrinsic flags anyways.  If any of the flags aren't safe to propagate, the caller needs to make that change.

2 years ago[dsymutil][NFC] Fix typo in help message
Ellis Hoag [Thu, 9 Dec 2021 18:41:13 +0000 (10:41 -0800)]
[dsymutil][NFC] Fix typo in help message

Just a simple typo fix that allows me to test landing a commit now that
I have commit access.

Reviewed By: xgupta

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

2 years ago[recurrence] Delete dead flag/fmf handling [NFC]
Philip Reames [Thu, 9 Dec 2021 18:42:18 +0000 (10:42 -0800)]
[recurrence] Delete dead flag/fmf handling [NFC]

The recurrence lowering code has handling which claims to be about flag intersection, but all the callers pass empty arrays to the arguments.  The sole exception is a caller of a method which has the argument, but no implementation.

I don't know what the intent was here, but it certaintly doesn't actually do anything today.

2 years ago[asan] Run background thread for asan only on THUMB
Vitaly Buka [Wed, 8 Dec 2021 20:28:12 +0000 (12:28 -0800)]
[asan] Run background thread for asan only on THUMB

As in D114934, or lsan crashes on the same bot.

2 years ago[sanitizer] Run Stack compression in background thread
Vitaly Buka [Tue, 23 Nov 2021 05:24:10 +0000 (21:24 -0800)]
[sanitizer] Run Stack compression in background thread

Depends on D114495.

Reviewed By: dvyukov

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

2 years ago[instcombine] Do demanded elts last when visiting extractelement
Philip Reames [Thu, 9 Dec 2021 17:54:45 +0000 (09:54 -0800)]
[instcombine] Do demanded elts last when visiting extractelement

This reorders existing transforms to put demanded elements last. The reasoning here is that when we have an example which can be scalarized or handled via demanded bits, we should prefer scalarization as that doesn't require dropping flags on arithmetic instructions.

This doesn't show major changes in the tests today, but once I add support for fast math flags to dropPoisonGeneratingFlags this becomes glaringly obvious.

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

2 years agoThread safety analysis: Remove unused variable. NFC.
Benjamin Kramer [Thu, 9 Dec 2021 17:56:13 +0000 (18:56 +0100)]
Thread safety analysis: Remove unused variable. NFC.

2 years agoRevert "[sanitizer] Run Stack compression in background thread"
Petr Hosek [Thu, 9 Dec 2021 17:55:49 +0000 (09:55 -0800)]
Revert "[sanitizer] Run Stack compression in background thread"

This reverts commit e5c2a46c5e8fc038b9f6c898df9628f9524dc10e as this
change introduced a linker error when building sanitizer runtimes:

  ld.lld: error: undefined symbol: __sanitizer::internal_start_thread(void* (*)(void*), void*)
  >>> referenced by sanitizer_stackdepot.cpp:133 (compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.cpp:133)
  >>>               compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_stackdepot.cpp.obj:(__sanitizer::(anonymous namespace)::CompressThread::NewWorkNotify())

2 years agoCompute estimated trip counts for multiple exit loops
Philip Reames [Thu, 9 Dec 2021 17:40:03 +0000 (09:40 -0800)]
Compute estimated trip counts for multiple exit loops

This change allows us to estimate trip count from profile metadata for all multiple exit loops. We still do the estimate only from the latch, but that's fine as it causes us to over estimate the trip count at worst.

Reviewing the uses of the API, all but one are cases where we restrict a loop transformation (unroll, and vectorize respectively) when we know the trip count is short enough. So, as a result, the change makes these passes strictly less aggressive. The test change illustrates a case where we'd previously have runtime unrolled a loop which ran fewer iterations than the unroll factor. This is definitely unprofitable.

The one case where an upper bound on estimate trip count could drive a more aggressive transform is peeling, and I duplicated the logic being removed from the generic estimation there to keep it the same. The resulting heuristic makes no sense and should probably be immediately removed, but we can do that in a separate change.

This was noticed when analyzing regressions on D113939.

I plan to come back and incorporate estimated trip counts from other exits, but that's a minor improvement which can follow separately.

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

2 years ago[InstCombine] (~a & b & c) | ~(a | b | c) -> ~(a | (b ^ c))
Stanislav Mekhanoshin [Wed, 17 Nov 2021 20:33:31 +0000 (12:33 -0800)]
[InstCombine] (~a & b & c) | ~(a | b | c) -> ~(a | (b ^ c))

Transform
```
(~a & b & c) | ~(a | b | c) -> ~(a | (b ^ c))
```
And swapped case:
```
(~a | b | c) & ~(a & b & c) -> ~a | (b ^ c)
```

```
----------------------------------------
define i4 @src(i4 %a, i4 %b, i4 %c) {
%0:
  %or1 = or i4 %b, %a
  %or2 = or i4 %or1, %c
  %not1 = xor i4 %or2, 15
  %not2 = xor i4 %a, 15
  %and1 = and i4 %b, %not2
  %and2 = and i4 %and1, %c
  %or3 = or i4 %and2, %not1
  ret i4 %or3
}
=>
define i4 @tgt(i4 %a, i4 %b, i4 %c) {
%0:
  %1 = xor i4 %c, %b
  %2 = or i4 %1, %a
  %or3 = xor i4 %2, 15
  ret i4 %or3
}
Transformation seems to be correct!
```
```
----------------------------------------
define i4 @src(i4 %a, i4 %b, i4 %c) {
%0:
  %and1 = and i4 %b, %a
  %and2 = and i4 %and1, %c
  %not1 = xor i4 %and2, 15
  %not2 = xor i4 %a, 15
  %or1 = or i4 %not2, %b
  %or2 = or i4 %or1, %c
  %and3 = and i4 %or2, %not1
  ret i4 %and3
}
=>
define i4 @tgt(i4 %a, i4 %b, i4 %c) {
%0:
  %xor = xor i4 %b, %c
  %not = xor i4 %a, 15
  %or = or i4 %xor, %not
  ret i4 %or
}
Transformation seems to be correct!
```

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

2 years agoPrevent abseil-cleanup-ctad check from stomping on surrounding context
CJ Johnson [Thu, 9 Dec 2021 17:28:07 +0000 (17:28 +0000)]
Prevent abseil-cleanup-ctad check from stomping on surrounding context

This change applies two fixes to the abseil-cleanup-ctad check. It uses hasSingleDecl() to ensure only declStmt()s with one varDecl() are matched (leaving compount declStmt()s unchanged). It also addresses a bug in the handling of comments that surround the absl::MakeCleanup() calls by switching to the callArgs() combinator from Clang Transformer.

Reviewed By: ymandel

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

2 years ago[llvm] Use range-based for loops (NFC)
Kazu Hirata [Thu, 9 Dec 2021 17:37:29 +0000 (09:37 -0800)]
[llvm] Use range-based for loops (NFC)

2 years ago[mlir][Vector] Avoid infinite loop in InnerOuterDimReductionConversion.
MaheshRavishankar [Thu, 9 Dec 2021 17:18:00 +0000 (09:18 -0800)]
[mlir][Vector] Avoid infinite loop in InnerOuterDimReductionConversion.

This patterns tries to convert an inner (outer) dim reduction to an
outer (inner) dim reduction. Doing this on a 1D or 0D vector results
in an infinite loop since the converted op is same as the original
operation. Just returning failure when source rank <= 1 fixes the
issue.

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

2 years ago[fir] Keep runtime function name in comment
Valentin Clement [Thu, 9 Dec 2021 17:28:36 +0000 (18:28 +0100)]
[fir] Keep runtime function name in comment

Some of the function name in the comment didn't match
their actual name in the runtime. This patch fixes that.

Reviewed By: schweitz

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

2 years agoRevert "tsan: new runtime (v3)"
Jonas Devlieghere [Thu, 9 Dec 2021 17:18:10 +0000 (09:18 -0800)]
Revert "tsan: new runtime (v3)"

This reverts commit 5a33e412815b8847610425a2a3b86d2c7c313b71 becuase it
breaks LLDB.

https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/39208/

2 years ago[RISCV] Use MULHU for more division by constant cases.
Craig Topper [Thu, 9 Dec 2021 16:53:46 +0000 (08:53 -0800)]
[RISCV] Use MULHU for more division by constant cases.

D113805 improved handling of i32 divu/remu on RV64. The basic idea
from that can be extended to (mul (and X, C2), C1) where C2 is any
mask constant.

We can replace the and with an SLLI by shifting by the number of
leading zeros in C2 if we also shift C1 left by XLen - lzcnt(C1)
bits. This will give the full product XLen additional trailing zeros,
putting the result in the output of MULHU. If we can't use ANDI,
ZEXT.H, or ZEXT.W, this will avoid materializing C2 in a register.

The downside is it make take 1 additional instruction to create C1.
But since that's not on the critical path, it can hopefully be
interleaved with other operations.

The previous tablegen pattern is replaced by custom isel code.

Reviewed By: asb

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

2 years ago[amdgpu][nfc] Drop dead PtrSet, fix a comment
Jon Chesterfield [Thu, 9 Dec 2021 16:47:41 +0000 (16:47 +0000)]
[amdgpu][nfc] Drop dead PtrSet, fix a comment

2 years ago[lldb] Remove unused lldb.cpp
Haojian Wu [Thu, 9 Dec 2021 11:10:58 +0000 (12:10 +0100)]
[lldb] Remove unused lldb.cpp

lldb.cpp is unused after https://github.com/llvm/llvm-project/commit/ccf1469a4cdb03cb2bc7868f76164e85d90ebee1

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

2 years ago[NFC] Replace some deprecated getAlignment() calls with getAlign()
Arthur Eubanks [Wed, 8 Dec 2021 19:49:12 +0000 (11:49 -0800)]
[NFC] Replace some deprecated getAlignment() calls with getAlign()

Reviewed By: gchatelet

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

2 years ago[RISCV] Reduce duplicate FP test cases.
Craig Topper [Thu, 9 Dec 2021 16:04:43 +0000 (08:04 -0800)]
[RISCV] Reduce duplicate FP test cases.

-Remove feq, fle, flt tests from *-arith.ll in favor of *-fcmp.ll which tests all predicates.

Reviewed By: asb

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

2 years agoAvoid unnecessary output buffer allocation and initialization.
Bixia Zheng [Tue, 7 Dec 2021 23:15:42 +0000 (15:15 -0800)]
Avoid unnecessary output buffer allocation and initialization.

The sparse tensor code generator allocates memory for the output tensor. As
such, we only need to allocate a MemRefDescriptor to receive the output tensor
and do not need to allocate and initialize the storage for the tensor.

Reviewed By: aartbik

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

2 years ago[NFC][mlir][OpenMP] Added documentation for omp.atomic ops
Shraiysh Vaishay [Thu, 9 Dec 2021 14:28:25 +0000 (19:58 +0530)]
[NFC][mlir][OpenMP] Added documentation for omp.atomic ops

This patch adds the documentation for the operations `omp.atomic.read`,
`omp.atomic.write` and `omp.atomic.update`.

Reviewed By: peixin

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

2 years ago[AArch64][Analysis] Add on overhead costs for SVE gathers and scatters
David Sherwood [Mon, 6 Dec 2021 11:02:29 +0000 (11:02 +0000)]
[AArch64][Analysis] Add on overhead costs for SVE gathers and scatters

This patch adds on an overhead cost for gathers and scatters, which
is a rough estimate based on performance investigations I have
performed on SVE hardware for various micro-benchmarks.

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

2 years ago[MLIR][GPU] Define gpu.printf op and its lowerings
Krzysztof Drewniak [Wed, 8 Dec 2021 23:28:06 +0000 (23:28 +0000)]
[MLIR][GPU] Define gpu.printf op and its lowerings

- Define a gpu.printf op, which can be lowered to any GPU printf() support (which is present in CUDA, HIP, and OpenCL). This op only supports constant format strings and scalar arguments
- Define the lowering of gpu.pirntf to a call to printf() (which is what is required for AMD GPUs when using OpenCL) as well as to the hostcall interface present in the AMD Open Compute device library, which is the interface present when kernels are running under HIP.
- Add a "runtime" enum that allows specifying which of the possible runtimes a ROCDL kernel will be executed under or that the runtime is unknown. This enum controls how gpu.printf is lowered

This change does not enable lowering for Nvidia GPUs, but such a lowering should be possible in principle.

And:
[MLIR][AMDGPU] Always set amdgpu-implicitarg-num-bytes=56 on kernels

This is something that Clang always sets on both OpenCL and HIP kernels, and failing to include it causes mysterious crashes with printf() support.

In addition, revert the max-flat-work-group-size to (1, 256) to avoid triggering bugs in the AMDGPU backend.

Reviewed By: mehdi_amini

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

2 years ago[LoopVectorize][AArch64] Add vectoriser cost model tests for gathers/scatters
David Sherwood [Wed, 1 Dec 2021 14:55:10 +0000 (14:55 +0000)]
[LoopVectorize][AArch64] Add vectoriser cost model tests for gathers/scatters

I've added some tests that were previously missing for the gather-scatter costs
being calculated by the vectorizer for AArch64:

  Transforms/LoopVectorize/AArch64/sve-gather-scatter-cost.ll

The costs are sometimes different to the ones in

  Analysis/CostModel/AArch64/sve-gather.ll

because the vectorizer also adds on the address computation cost.

2 years agoRevert "[xray] add support for hexagon"
Brian Cain [Thu, 9 Dec 2021 15:30:27 +0000 (07:30 -0800)]
Revert "[xray] add support for hexagon"

This reverts commit 543a9ad7c460bb8d641b1b7c67bbc032c9bfdb45.

2 years ago[mlir] AsyncParallelFor: align block size to be a multiple of inner loops iterations
Eugene Zhulenev [Thu, 9 Dec 2021 11:21:22 +0000 (03:21 -0800)]
[mlir] AsyncParallelFor: align block size to be a multiple of inner loops iterations

Depends On D115263

By aligning block size to inner loop iterations parallel_compute_fn LLVM can later unroll and vectorize some of the inner loops with small number of trip counts. Up to 2x speedup in multiple benchmarks.

Reviewed By: bkramer

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

2 years ago[mlir] AsyncParallelFor: sink constants into the parallel compute function
Eugene Zhulenev [Wed, 8 Dec 2021 02:45:31 +0000 (18:45 -0800)]
[mlir] AsyncParallelFor: sink constants into the parallel compute function

With complex recursive structure of async dispatch function LLVM can't always propagate constants to the parallel_compute_fn and it often prevents optimizations like loop unrolling and vectorization. We help LLVM by pushing known constants into the parallel_compute_fn explicitly.

Reviewed By: bkramer

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

2 years ago[test-release.sh] Respect the given width in LIT runs by adding `-j` in LLVM_LIT_ARGS.
Amy Kwan [Thu, 9 Dec 2021 01:54:57 +0000 (19:54 -0600)]
[test-release.sh] Respect the given width in LIT runs by adding `-j` in LLVM_LIT_ARGS.

This patch adds allows the LIT runs within test-release.sh to obey the width that
is passed into the script. This is accomplished by adding the width in the LLVM_LIT_ARGS
CMake configuration.

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

2 years ago[InlineAdvisor] Remove outdated comment (NFC)
Nikita Popov [Thu, 9 Dec 2021 13:18:32 +0000 (14:18 +0100)]
[InlineAdvisor] Remove outdated comment (NFC)

This just returns None nowadays, so this comment doesn't apply
anymore.

2 years ago[Inliner] Add debug message for history skip (NFC)
Nikita Popov [Wed, 8 Dec 2021 13:03:46 +0000 (14:03 +0100)]
[Inliner] Add debug message for history skip (NFC)

2 years ago[AIX] Disable failing tests because of missing DWARF sections
Jake Egan [Thu, 9 Dec 2021 14:03:16 +0000 (09:03 -0500)]
[AIX] Disable failing tests because of missing DWARF sections

The following tests are failing due to missing DWARF sections: `DwarfAccelNamesSection` and `DwarfAddrSection`. This patch sets these tests as `XFAIL` until the sections can be implemented for AIX.

Reviewed By: dblaikie

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

2 years ago[xray] add support for hexagon
Brian Cain [Thu, 9 Dec 2021 01:57:20 +0000 (17:57 -0800)]
[xray] add support for hexagon

Adds x-ray support for hexagon to llvm codegen, clang driver,
compiler-rt libs.

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

2 years ago[ARM][clang] Option b-key must not affect __ARM_FEATURE_PAC_DEFAULT
Ties Stuij [Thu, 9 Dec 2021 11:51:31 +0000 (11:51 +0000)]
[ARM][clang] Option b-key must not affect __ARM_FEATURE_PAC_DEFAULT

When using -mbranch-protection=pac-ret+b-key, macro __ARM_FEATURE_PAC_DEFAULT
should still have the value corresponding to a-key, because b-key is only valid
for AArch64.

This patch is part of a series that adds support for the PACBTI-M extension of
the Armv8.1-M architecture, as detailed here:

https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/armv8-1-m-pointer-authentication-and-branch-target-identification-extension

The PACBTI-M specification can be found in the Armv8-M Architecture Reference
Manual:

https://developer.arm.com/documentation/ddi0553/latest

The following people contributed to this patch:

- Victor Campos

Reviewed By: danielkiss

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

2 years ago[mlir][linalg][bufferize] LinalgOps can bufferize inplace with input args
Matthias Springer [Thu, 9 Dec 2021 10:50:47 +0000 (19:50 +0900)]
[mlir][linalg][bufferize] LinalgOps can bufferize inplace with input args

LinalgOp results usually bufferize inplace with output args. With this change, they may buffer inplace with input args if the value of the output arg is not used in the computation.

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

2 years ago[clang][clangd] Desugar array type.
lh123 [Thu, 9 Dec 2021 12:12:48 +0000 (20:12 +0800)]
[clang][clangd] Desugar array type.

Desugar array type.

Reviewed By: sammccall

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

2 years ago[MetaRenamer] Add command line options to disable renaming name with specified prefixes
Dmitry Makogon [Thu, 9 Dec 2021 11:41:48 +0000 (18:41 +0700)]
[MetaRenamer] Add command line options to disable renaming name with specified prefixes

This patch adds 4 options for specifying functions, aliases, globals and
structs name prefixes hat don't need to be renamed by MetaRenamer pass.
This is useful if one has some downstream logic that depends directly
on an entity name. MetaRenamer can break this logic, but with the patch
you can tell it not to rename certain names.

Reviewed By: nikic

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

2 years ago[lldb][NFC] clang-format some files as preparation for https://reviews.llvm.org/D114627
Lasse Folger [Thu, 9 Dec 2021 11:09:56 +0000 (12:09 +0100)]
[lldb][NFC] clang-format some files as preparation for https://reviews.llvm.org/D114627

Reviewed By: werat

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

2 years ago[MLIR] Move Presburger Math from FlatAffineConstraints to Presburger/IntegerPolyhedron
Groverkss [Thu, 9 Dec 2021 10:41:00 +0000 (16:11 +0530)]
[MLIR] Move Presburger Math from FlatAffineConstraints to Presburger/IntegerPolyhedron

This patch factors out math functionality that is a subset of Presburger arithmetic and moves it from FlatAffineConstraints to Presburger/IntegerPolyhedron. This patch only moves some parts of the functionality planned to be moved, with subsequent patches moving more functionality. There are three main reasons for this:

1. This split makes the Presburger Library easier and more flexible to use
    across MLIR, by not depending on IR.
2. This split allows the Presburger library to be developed independently from
    Affine Analysis, with Affine Analysis using this library.
3. With more functionality being upstreamed to the Presburger Library, the
    mlir/Analysis directory will be cluttered with Presburger library components
    since they depend on math functionality from FlatAffineConstraints. Moving this
    functionality to the Presburger directory allows keeping the new functionality
    in the Presburger directory.

This patch is part of an ongoing effort to make the Presburger Library easier to use. The motivation for this effort is the feedback received at the LLVM conference from Mehdi and others.

Reviewed By: bondhugula

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

2 years agoRevert "Reapply [runtimes] Fix building initial libunwind+libcxxabi+libcxx with compi...
Martin Storsjö [Thu, 9 Dec 2021 10:54:37 +0000 (12:54 +0200)]
Revert "Reapply [runtimes] Fix building initial libunwind+libcxxabi+libcxx with compiler implied -lunwind"

This reverts commit 317dc31e53b83c1d2a468d7a541925f0cc7d9dce.

After that change, OpenMP doesn't find dependencies in the host
system (it fails do find e.g. /usr/lib/x86_64-linux-gnu/libelf.so
which it found before), which causes some OpenMP target offloading
plugins to not be found. This doesn't break the build, but just
causes the AMDGPU OpenMP target plugin to be omitted. See
https://reviews.llvm.org/D113253#3181934 for the report of this
issue.

2 years ago[LV] Mark various functions as const (NFC).
Florian Hahn [Thu, 9 Dec 2021 10:51:29 +0000 (10:51 +0000)]
[LV] Mark various functions as const (NFC).

Make sure various accessors do not modify any state, in preparation for
D115111.

2 years ago[ARM][clang] Define feature test macro for the PACBTI-M extension
Ties Stuij [Thu, 9 Dec 2021 09:40:46 +0000 (09:40 +0000)]
[ARM][clang] Define feature test macro for the PACBTI-M extension

If the extension string "+pacbti" was given in -march=... or -mcpu=... options the compiler shall define the following preprocessor macros:

    __ARM_FEATURE_PAUTH with value 1.
    __ARM_FEATURE_BTI with value 1.

This patch is part of a series that adds support for the PACBTI-M extension of
the Armv8.1-M architecture, as detailed here:

https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/armv8-1-m-pointer-authentication-and-branch-target-identification-extension

The PACBTI-M specification can be found in the Armv8-M Architecture Reference
Manual:

https://developer.arm.com/documentation/ddi0553/latest

The following people contributed to this patch:

- Momchil Velikov
- Ties Stuij

Reviewed By: miyuki

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

2 years ago[clang-format] PR48916 PointerAlignment not working when using C++20 init-statement...
mydeveloperday [Thu, 9 Dec 2021 10:34:55 +0000 (10:34 +0000)]
[clang-format] PR48916 PointerAlignment not working when using C++20 init-statement in for loop

https://bugs.llvm.org/show_bug.cgi?id=48916

Left and Right Alignment inside a loop is misaligned.

Reviewed By: HazardyKnusperkeks, curdeius

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

2 years ago[clang][deps] Use MemoryBuffer in minimizing FS
Jan Svoboda [Thu, 9 Dec 2021 09:47:54 +0000 (10:47 +0100)]
[clang][deps] Use MemoryBuffer in minimizing FS

This patch avoids unnecessarily copying contents of `mmap`-ed files into `CachedFileSystemEntry` by storing `MemoryBuffer` instead. The change leads to ~50% reduction of peak memory footprint when scanning LLVM+Clang via `clang-scan-deps`.

Depends on D115331.

Reviewed By: dexonsmith

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

2 years ago[llvm] Add null-termination capability to SmallVectorMemoryBuffer
Jan Svoboda [Wed, 8 Dec 2021 12:24:45 +0000 (13:24 +0100)]
[llvm] Add null-termination capability to SmallVectorMemoryBuffer

Most of `MemoryBuffer` interfaces expose a `RequiresNullTerminator` parameter that's being used to:
* determine how to open a file (`mmap` vs `open`),
* assert newly initialized buffer indeed has an implicit null terminator.

This patch adds the paramater to the `SmallVectorMemoryBuffer` constructors, meaning:
* null terminator can now be added to `SmallVector`s that didn't have one before,
* `SmallVectors` that had a null terminator before keep it even after the move.

In line with existing code, the new parameter is defaulted to `true`. This patch makes sure all calls to the `SmallVectorMemoryBuffer` constructor set it to `false` to preserve the current semantics.

Reviewed By: dexonsmith

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

2 years ago[llvm][lldb] Remove unused SmallVectorMemoryBuffer.h includes
Jan Svoboda [Thu, 9 Dec 2021 09:45:10 +0000 (10:45 +0100)]
[llvm][lldb] Remove unused SmallVectorMemoryBuffer.h includes

2 years ago[MLIR] Introduce coalesce for PresburgerSet
Michel Weber [Thu, 9 Dec 2021 10:16:31 +0000 (15:46 +0530)]
[MLIR] Introduce coalesce for PresburgerSet

This patch provides functionality for simplifying `PresburgerSet`s by checking if any `FlatAffineConstraints` in the set is contained in another, and removing such redundant FACs.

This is part of a series of patches to provide functionality for [integer set coalescing](http://impact.gforge.inria.fr/impact2015/papers/impact2015-verdoolaege.pdf) in MLIR.

Reviewed By: arjunp

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

2 years ago[MLIR][OpenMP] Added omp.atomic.update
Shraiysh Vaishay [Thu, 9 Dec 2021 05:35:55 +0000 (11:05 +0530)]
[MLIR][OpenMP] Added omp.atomic.update

This patch supports the atomic construct (update) following section 2.17.7 of OpenMP 5.0 standard. Also added tests and verifier for the same.

Reviewed By: kiranchandramohan, peixin

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

2 years ago[clang] Fix a misadjusted path style comparison in a unittest
Martin Storsjö [Fri, 5 Nov 2021 09:28:21 +0000 (11:28 +0200)]
[clang] Fix a misadjusted path style comparison in a unittest

This was changed incorrectly by accident in
99023627010bbfefb71e25a2b4d056de1cbd354e.

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

2 years ago[clang][deps] Use lock_guard instead of unique_lock
Jan Svoboda [Thu, 9 Dec 2021 09:42:47 +0000 (10:42 +0100)]
[clang][deps] Use lock_guard instead of unique_lock

This patch changes uses of `std::unique_lock` to `std::lock_guard`.

The `std::unique_lock` template provides some advanced capabilities (deferred locking, time-constrained locking attempts, etc.) we don't use in the caching filesystem. Plain `std::lock_guard` will do here.

Reviewed By: dexonsmith

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

2 years ago[Test] [GVN] Add test showing equivalent PHIs generation by GVN
Dmitry Makogon [Thu, 9 Dec 2021 09:22:39 +0000 (16:22 +0700)]
[Test] [GVN] Add test showing equivalent PHIs generation by GVN

2 years ago[ARM] Fix gcc warning about mix of enumeral and non-enumeral types
Mikael Holmen [Thu, 9 Dec 2021 09:20:27 +0000 (10:20 +0100)]
[ARM] Fix gcc warning about mix of enumeral and non-enumeral types

gcc warned with
../lib/Target/ARM/ARMFrameLowering.cpp:797:31: warning: enumeral and non-enumeral type in conditional expression [-Wextra]
  797 |               Reg == ARM::R12 ? ARM::RA_AUTH_CODE : Reg, true);
      |               ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~

2 years ago[PowerPC] Fix gcc warning about unused variable [NFC]
Mikael Holmen [Thu, 9 Dec 2021 09:18:29 +0000 (10:18 +0100)]
[PowerPC] Fix gcc warning about unused variable [NFC]

gcc warned about
../lib/Target/PowerPC/PPCTargetTransformInfo.cpp:1401:13: warning: unused variable 'VecTy' [-Wunused-variable]
 1401 |   if (auto *VecTy = dyn_cast<FixedVectorType>(DataType)) {
      |             ^~~~~

2 years agotsan: new runtime (v3)
Dmitry Vyukov [Thu, 2 Dec 2021 07:36:44 +0000 (08:36 +0100)]
tsan: new runtime (v3)

This change switches tsan to the new runtime which features:
 - 2x smaller shadow memory (2x of app memory)
 - faster fully vectorized race detection
 - small fixed-size vector clocks (512b)
 - fast vectorized vector clock operations
 - unlimited number of alive threads/goroutimes

Depends on D112602.

Reviewed By: melver

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

2 years ago[NewPM] Port FlattenCFGPass to NPM
Fraser Cormack [Wed, 8 Dec 2021 17:54:30 +0000 (17:54 +0000)]
[NewPM] Port FlattenCFGPass to NPM

Reviewed By: aeubanks

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

2 years ago[mlir][memref] Fix subview offset verification.
Nicolas Vasilache [Thu, 9 Dec 2021 07:40:19 +0000 (07:40 +0000)]
[mlir][memref] Fix subview offset verification.

Offset-specific verification seems to have been lost in one of the recent refactorings.
Also add proper tests that would have caught this omission.

This addresses the immediate issues discussed in:
https://llvm.discourse.group/t/memref-subview-affine-map-and-symbols/4851

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

2 years ago[NFC][Verifier] Remove checks for atomic loads/stores that alignment is non-zero
Arthur Eubanks [Wed, 8 Dec 2021 21:03:43 +0000 (13:03 -0800)]
[NFC][Verifier] Remove checks for atomic loads/stores that alignment is non-zero

The alignment is never 0 since getAlign() returns 1 << bits.

Reviewed By: dexonsmith

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

2 years ago[C++20] [Coroutines] Mark coroutine done if unhandled_exception throws
Chuanqi Xu [Thu, 9 Dec 2021 06:55:18 +0000 (14:55 +0800)]
[C++20] [Coroutines] Mark coroutine done if unhandled_exception throws

According to [dcl.fct.def.coroutine]/p14:
> If the evaluation of the expression promise.unhandled_­exception()
> exits via an exception, the coroutine is considered suspended at the
> final suspend point.

But this is not implemented in clang before. This patch would implement
this feature by marking the coroutine as done at the place of
coro.end(frame, /*InUnwindPath=*/true ).

Reviewed By: rjmccall

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

2 years ago[RISCV] Fix vm operand constraint to fit GCC's behavior
Kito Cheng [Thu, 7 Oct 2021 12:38:37 +0000 (20:38 +0800)]
[RISCV] Fix vm operand constraint to fit GCC's behavior

- `vm` constraint is used for masking operand, which always v0.

- Update testcase, only masking operand should use `vm`, vector mask operations
  should just use `vr` for any vector register.

 - Revise the description of `vm` constraint.

- This patch also fix issue on RISCVRegisterInfo.td and RISCVISelLowering.cpp.

  RISCVRegisterInfo.td:
  - The first VT in the list must be the largest total size since the
    SelectionDAGBuilder uses the first register in the list as the canonical
    type for the register.

  RISCVISelLowering.cpp:
  - Fix RISCVTargetLowering::splitValueIntoRegisterParts and
    RISCVTargetLowering::joinRegisterPartsIntoValue for handling vectors
    with different total size, that will happened on fractional LMUL since
    fractional LMUL is always occupy one vector register.

Reviewed By: frasercrmck

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

2 years ago[Coroutines] Remove unused coroutine builtin/intrinsics llvm.coro.param (NFC-ish)
Chuanqi Xu [Thu, 9 Dec 2021 06:37:05 +0000 (14:37 +0800)]
[Coroutines] Remove unused coroutine builtin/intrinsics llvm.coro.param (NFC-ish)

I found that the coroutine intrinsic llvm.coro.param in documentation
(https://llvm.org/docs/Coroutines.html#id101) didn't get used actually
since there isn't lowering codes in LLVM. I also checked the
implementation of libstdc++ and libc++. Both of them didn't use
llvm.coro.param. So I am pretty sure that the llvm.coro.param intrinsic
is unused. I think it would be better t to remove it to avoid possible
misleading understandings.

Note: according to [class.copy.elision]/p1.3, this optimization is
allowed by the C++ language specification. Let's make it someday.

Reviewed By: rjmccall

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

2 years ago[mlir][Linalg] Bufferize the region of LinalgOps as well.
MaheshRavishankar [Thu, 9 Dec 2021 06:10:12 +0000 (22:10 -0800)]
[mlir][Linalg] Bufferize the region of LinalgOps as well.

The region of `linalg.generic` might contain `tensor` operations. For
example, current lowering of `gather` uses a `tensor.extract` in the
body of the `LinalgOp`. Bufferize the ops within a `LinalgOp` region
as well to catch such cases.

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

2 years agotsan: fork runtime
Dmitry Vyukov [Thu, 9 Dec 2021 06:18:20 +0000 (07:18 +0100)]
tsan: fork runtime

Fork the current version of tsan runtime before commiting
rewrite of the runtime (D112603). The old runtime can be
enabled with TSAN_USE_OLD_RUNTIME option.
This is a temporal measure for emergencies and is required
for Chromium rollout (for context see http://crbug.com/1275581).
The old runtime is supposed to be deleted soon.

Reviewed By: thakis

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

2 years ago[C++20 Modules] Don't create global module fragment for extern linkage declaration...
Chuanqi Xu [Thu, 9 Dec 2021 05:52:28 +0000 (13:52 +0800)]
[C++20 Modules] Don't create global module fragment for extern linkage declaration in GMF already

Previously we would create global module fragment for extern linkage
declaration which is alreday in global module fragment. However, it is
clearly redundant to do so. This patch would check if the extern linkage
declaration are already in GMF before we create a GMF for it.

2 years ago[NFC] Rename MachineFunction::cloneMachineInstrBundle (coding style)
Mircea Trofin [Thu, 9 Dec 2021 05:12:54 +0000 (21:12 -0800)]
[NFC] Rename MachineFunction::cloneMachineInstrBundle (coding style)

2 years ago[NFC] Rename MachineFunction::deleteMachineInstr (coding style)
Mircea Trofin [Thu, 9 Dec 2021 04:35:33 +0000 (20:35 -0800)]
[NFC] Rename MachineFunction::deleteMachineInstr (coding style)

2 years ago[llvm] Use range-based for loops (NFC)
Kazu Hirata [Thu, 9 Dec 2021 04:35:39 +0000 (20:35 -0800)]
[llvm] Use range-based for loops (NFC)

2 years ago[gn build] Port 059e03476cbb
LLVM GN Syncbot [Thu, 9 Dec 2021 04:11:22 +0000 (04:11 +0000)]
[gn build] Port 059e03476cbb

2 years ago[NFC][mlgo] Generalize model runner interface
Mircea Trofin [Tue, 7 Dec 2021 23:07:39 +0000 (15:07 -0800)]
[NFC][mlgo] Generalize model runner interface

This prepares it for the regalloc work. Part of it is making model
evaluation accross 'development' and 'release' scenarios more reusable.
This patch:
- extends support to tensors of any shape (not just scalars, like we had
in the inliner -Oz case). While the tensor shape can be anything, we
assume row-major layout and expose the tensor as a buffer.
- exposes the NoInferenceModelRunner, which we use in the 'development'
mode to keep the evaluation code path consistent and simplify logging,
as we'll want to reuse it in the regalloc case.

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

2 years ago[CSKY] Complete codegen of basic arithmetic and load/store operations
Zi Xuan Wu [Thu, 9 Dec 2021 03:35:34 +0000 (11:35 +0800)]
[CSKY] Complete codegen of basic arithmetic and load/store operations

Complete basic arithmetic operations such as add/sub/mul/div, and it also includes converions
and some specific operations such as bswap.Add load/store patterns to generate different addressing mode instructions.

Also enable some infra such as copy physical register and eliminate frame index.

2 years ago[libc++][NFC] Remove test/support/tracked_value.h
Joe Loser [Thu, 9 Dec 2021 01:01:39 +0000 (20:01 -0500)]
[libc++][NFC] Remove test/support/tracked_value.h

No tests are using `libcxx/test/support/tracked_value.h`. So, remove it.

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

2 years ago[NFC] Rename MachineFunction::DeleteMachineBasicBlock
Mircea Trofin [Thu, 9 Dec 2021 01:36:37 +0000 (17:36 -0800)]
[NFC] Rename MachineFunction::DeleteMachineBasicBlock

Renamed to conform to coding style

2 years ago[Support] [Debuginfod] Use libcurl imported library.
Noah Shutty [Thu, 9 Dec 2021 00:51:33 +0000 (00:51 +0000)]
[Support] [Debuginfod] Use libcurl imported library.

A [[ https://lists.llvm.org/pipermail/llvm-dev/2021-December/154203.html | report on llvm-dev ]] indicated that `curl.h` could be found during build configuration but not during compilation. This diff uses the libcurl imported library created by findcurl, so that includes and libs are automatically managed correctly by cmake.

Reviewed By: phosek

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

2 years ago[PowerPC] copy byval parameter to caller's stack when needed
Chen Zheng [Sat, 9 Oct 2021 09:06:53 +0000 (09:06 +0000)]
[PowerPC] copy byval parameter to caller's stack when needed

Now we won't copy the byval parameter (bigger than 8 bytes) to
caller's parameter save area. Instead, we will only copy the
byval parameter when it can not be passed entirely in registers
which means we have to use parameter save area according to the
64 bit SVR4 ABI.

Reviewed By: jsji

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

2 years ago[gn build] (manually) port ccf1469a4cdb (lldbVersion)
Nico Weber [Thu, 9 Dec 2021 00:45:17 +0000 (19:45 -0500)]
[gn build] (manually) port ccf1469a4cdb (lldbVersion)

2 years agoRevert "[asan] Run background thread for asan only on THUMB"
Andrew Browne [Thu, 9 Dec 2021 00:41:36 +0000 (16:41 -0800)]
Revert "[asan] Run background thread for asan only on THUMB"

This reverts commit 5c27740238007d22f2d0cd0ebe2aaffa90a9c92b.

Reverting due to Windows build issue:

sanitizer_stackdepot.cpp.obj : error LNK2005: "void __cdecl __sanitizer::StackDepotStopBackgroundThread(void)" (?StackDepotStopBackgroundThread@__sanitizer@@YAXXZ) already defined in sanitizer_common_libcdep.cpp.obj
LINK : fatal error LNK1181: cannot open input file 'projects\compiler-rt\lib\asan\CMakeFiles\RTAsan_dynamic.x86_64.dir\asan_rtl_x86_64.S.obj'

2 years agoSupport: Avoid using SmallVector::set_size() in zlib
Duncan P. N. Exon Smith [Thu, 9 Dec 2021 00:18:00 +0000 (16:18 -0800)]
Support: Avoid using SmallVector::set_size() in zlib

Stop using `SmallVector::set_size()` in zlib. Replace pairs of
`reserve()` / `set_size()` with `resize_for_overwrite()` and
`truncate()`.

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

2 years agoSupport: Avoid using SmallVector::set_size() in sys::path
Duncan P. N. Exon Smith [Wed, 8 Dec 2021 01:22:44 +0000 (17:22 -0800)]
Support: Avoid using SmallVector::set_size() in sys::path

Stop using `SmallVector::set_size()` in sys::path APIs. In both cases,
use `truncate()` instead.

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

2 years ago[gn build] (manually) port f75cce0be861
Nico Weber [Thu, 9 Dec 2021 00:20:52 +0000 (19:20 -0500)]
[gn build] (manually) port f75cce0be861

2 years ago[libc] Add a .clang-tidy file for the toplevel libc directory.
Siva Chandra Reddy [Wed, 8 Dec 2021 07:02:48 +0000 (07:02 +0000)]
[libc] Add a .clang-tidy file for the toplevel libc directory.

Generation of the .yaml has been removed to prevent lint from
running with every ninja invocation. The new .clang-tidy file is copied
to the libc build directory so that generated files also get checked.

Reviewed By: michaelrj

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

2 years agoRevert "[ASan] Shared optimized callbacks implementation."
Kirill Stoimenov [Thu, 9 Dec 2021 00:16:14 +0000 (00:16 +0000)]
Revert "[ASan] Shared optimized callbacks implementation."

This reverts commit f71c553a30cc52c0b4a6abbaa82ce97c30c13979.

Reviewed By: kstoimenov

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

2 years agoADT: Make StringRef::size() and StringRef::empty() constexpr
Duncan P. N. Exon Smith [Wed, 8 Dec 2021 21:41:31 +0000 (13:41 -0800)]
ADT: Make StringRef::size() and StringRef::empty() constexpr

This unblocks using `StringLiteral::size()` for a SmallVector size in
another patch.

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

2 years ago[gn build] (manually) port f71c553a30cc
Nico Weber [Thu, 9 Dec 2021 00:10:53 +0000 (19:10 -0500)]
[gn build] (manually) port f71c553a30cc

2 years ago[ASan] Shared optimized callbacks implementation.
Kirill Stoimenov [Wed, 17 Nov 2021 22:39:48 +0000 (22:39 +0000)]
[ASan] Shared optimized callbacks implementation.

This change moves optimized callbacks from each .o file to compiler-rt. Instead of using code generation it uses direct assembly implementation. Please note that the 'or' version is not implemented and it will produce unresolved external if somehow 'or' version is requested.

Reviewed By: vitalybuka

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

2 years agoAMDGPU: Mark scc defs dead in SGPR to VMEM path for no free SGPRs
Matt Arsenault [Wed, 8 Dec 2021 17:46:27 +0000 (12:46 -0500)]
AMDGPU: Mark scc defs dead in SGPR to VMEM path for no free SGPRs

This introduces verifier errors into this broken situation which we do
not handle correctly, which is better than being silently
miscompiled. For the emergency stack slot, the scavenger likes to move
the restore instruction as late as possible, which ends up separating
the SCC def from the conditional branch.

2 years agoAMDGPU: Simplify test for SGPR spilling bug
Matt Arsenault [Wed, 8 Dec 2021 17:44:40 +0000 (12:44 -0500)]
AMDGPU: Simplify test for SGPR spilling bug

Remove the control flow from the test from
25eb7fa01d7ebbe67648ea03841cda55b4239ab2. It's not necessary to
reproduce the original assert with the patch reverted. The control
flow happens to expose a different issue that calls for a separate
test in a future change.

2 years agoAMDGPU: Mark SCC def as dead when expanding frame indexes
Matt Arsenault [Tue, 7 Dec 2021 23:24:29 +0000 (18:24 -0500)]
AMDGPU: Mark SCC def as dead when expanding frame indexes

This improves liveness queries in a future change.

2 years ago[RISCV] Improve tracking of EndLoc in the assembly parser.
Craig Topper [Wed, 8 Dec 2021 23:13:40 +0000 (15:13 -0800)]
[RISCV] Improve tracking of EndLoc in the assembly parser.

The SMLoc::getFromPointer(S.getPointer() - 1) pattern used in
several place didn't make sense since that puts the End before the
Start location.

This patch corrects this to properly calculate the end location as
we parse. Unsure how much this matters, a lot of these are for custom
operand parsing. If the custom parsing succeeds, the instruction
matching probably won't fail, so the end loc won't be used to build
a range for a diagnostic.

I've also fixed the creation functions for the CSR and VType operands
to assign the EndLoc of the RISCVOperand class using the StartLoc
instead of an empty SMLoc. I don't think these will ever be accessed,
but it makes the code look less like we forgot to assign it. This is
consistent with some operands on the ARM target.

Reviewed By: luismarques

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

2 years ago[lldb/Target] Slide source display for artificial locations at function start
Med Ismail Bennani [Wed, 8 Dec 2021 01:49:44 +0000 (17:49 -0800)]
[lldb/Target] Slide source display for artificial locations at function start

It can happen that a line entry reports that some source code is located
at line 0. In DWARF, line 0 is a special location which indicates that
code has no 1-1 mapping with source.

When stopping in one of those artificial locations, lldb doesn't know which
line to display and shows the beginning of the file instead.

This patch mitigates this behaviour by checking if the current symbol context
of the line entry has a matching function, in which case, it slides the
source listing to the start of that function.

This patch also shows the user a warning explaining why lldb couldn't
show sources at that location.

rdar://83118425

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2 years agoOpenMP: Avoid using SmallVector::set_size()
Duncan P. N. Exon Smith [Wed, 8 Dec 2021 01:22:37 +0000 (17:22 -0800)]
OpenMP: Avoid using SmallVector::set_size()

Update `OpenMPIRBuilder::collapseLoops()` to call `resize()` instead of
`set_size()`. The latter asserts on capacity limits and cannot grow,
which seems likely to be unintentional here (if it is, I think a local
assertion would be good for clarity).

Also update `CodeGenFunction::EmitOMPCollapsedCanonicalLoopNest()` to
use `pop_back_n()` instead of `set_size()`.

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

2 years ago[lldb] Make lldbVersion a full fledged library
Jonas Devlieghere [Wed, 8 Dec 2021 20:23:57 +0000 (12:23 -0800)]
[lldb] Make lldbVersion a full fledged library

Because of its dependency on clang (and potentially other compilers
downstream, such as swift) lldb_private::GetVersion already lives in its
own library called lldbBase. Despite that, its implementation was spread
across unrelated files. This patch improves things by introducing a
Version library with its own directory, header and implementation file.

The benefits of this patch include:

 - We can get rid of the ugly quoting macros.
 - Other parts of LLDB can read the version number from
   lldb/Version/Version.inc.
 - The implementation can be swapped out for tools like lldb-server than
   don't need to depend on clang at all.

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

2 years ago[OpenMP][AMDGPU] Switch host-device memory copy to asynchronous version
Carlo Bertolli [Wed, 8 Dec 2021 23:02:19 +0000 (23:02 +0000)]
[OpenMP][AMDGPU] Switch host-device memory copy to asynchronous version

Prepare amdgpu plugin for asynchronous implementation. This patch switches to using HSA API for asynchronous memory copy.
Moving away from hsa_memory_copy means that plugin is responsible for locking/unlocking host memory pointers.

Reviewed By: JonChesterfield

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

2 years ago[dfsan] Add a flag to ignore personality routines.
Taewook Oh [Wed, 8 Dec 2021 04:56:28 +0000 (20:56 -0800)]
[dfsan] Add a flag to ignore personality routines.

This diff adds "dfsan-ignore-personality-routine" flag, which makes
the dfsan pass to not to generate wrappers for the personality functions if the
function is marked uninstrumented.

This flag is to support dfsan with the cases where the exception handling
routines cannot be instrumented (e.g. use the prebuilt version of c++ standard
library). When the personality function cannot be instrumented it is supposed
to be marked "uninstrumented" from the abi list file. While DFSan generates a
wrapper function for uninstrumented functions, it cannot cannot generate a
valid wrapper for vararg functions, and indirect invocation of vararg function
wrapper terminates the execution of dfsan-instrumented programs. This makes
invocation of personality routine to crash the program, because 1) clang adds a
declaration of personality functions as a vararg function with no fixed
argument, and 2) personality routines are always called indirectly.

To address this issue, the flag introduced in this diff makes dfsan to not to
instrument the personality function. This is not the "correct" solution in the
sense that return value label from the personality function will be undefined.
However, in practice, if the exception handling routines are uninstrumented we
wouldn't expect precise label propagation around them, and it would be more
beneficial to make the rest of the program run without termination.

Reviewed By: browneee

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

2 years ago[mlir] Added ctlz and cttz to math dialect and LLVM dialect
Rob Suderman [Wed, 8 Dec 2021 22:32:09 +0000 (14:32 -0800)]
[mlir] Added ctlz and cttz to math dialect and LLVM dialect

Count leading/trailing zeros are an existing LLVM intrinsic. Added LLVM
support for the intrinsics with lowerings from the math dialect to LLVM
dialect.

Reviewed By: ftynse

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

2 years ago[llvm-profgen] remove check Attributes to fix build failure
wlei [Wed, 8 Dec 2021 22:12:53 +0000 (14:12 -0800)]
[llvm-profgen] remove check Attributes to fix build failure

2 years agoRevert "A new hidden option test-changed=exe that calls exe after each time IR changes"
Arthur Eubanks [Wed, 8 Dec 2021 21:57:25 +0000 (13:57 -0800)]
Revert "A new hidden option test-changed=exe that calls exe after each time IR changes"

This reverts commit f9235e45fd1f5ca21f95105427184a6afd0f9d95.

Causes breakages on Windows: http://45.33.8.238/win/50453/step_11.txt.

2 years agoADT: Add SmallVectorImpl::truncate() to replace uses of set_size()
Duncan P. N. Exon Smith [Wed, 8 Dec 2021 00:20:18 +0000 (16:20 -0800)]
ADT: Add SmallVectorImpl::truncate() to replace uses of set_size()

Add `SmallVectorImpl::truncate()`, a variant of `resize()` that cannot
increase the size.

- Compared to `resize()`, this has no code path for growing the
  allocation and can be better optimized.
- Compared to `set_size()`, this formally calls destructors, and does
  not skip any constructors.
- Compared to `pop_back_n()`, this takes the new desired size, which in
  many contexts is more intuitive than the number of elements to remove.

The immediate motivation is to pair this with `resize_for_overwrite()`
to remove uses of `set_size()`, which can then be made private.

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

2 years agoUpdate sink instruction testcase
Anna Thomas [Wed, 8 Dec 2021 21:53:09 +0000 (16:53 -0500)]
Update sink instruction testcase

Add inferable writeonly attribute. Simplify testcase.