platform/upstream/llvm.git
2 years ago[amdgpu] Handle the case where there is no scavenged register.
Michael Liao [Fri, 16 Jul 2021 16:14:49 +0000 (12:14 -0400)]
[amdgpu] Handle the case where there is no scavenged register.

- When an unconditional branch is expanded into an indirect branch, if
  there is no scavenged register, an SGPR pair needs spilling to enable
  the destination PC calculation. In addition, before jumping into the
  destination, that clobbered SGPR pair need restoring.
- As SGPR cannot be spilled to or restored from memory directly, the
  spilling/restoring of that SGPR pair reuses the regular SGPR spilling
  support but without spilling it into memory. As that spilling and
  restoring points are fully controlled, we only need to spill that SGPR
  into the temporary VGPR, which needs spilling into its emergency slot.
- The target-specific hook is revised to take additional restore block,
  where the restoring code is filled. After that, the relaxation will
  place that restore block directly before the destination block and
  insert an unconditional branch in any fall-through block into the
  destination block.

Reviewed By: arsenm

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

2 years ago[clang] NFC: remove carriage return from AST tests
Matheus Izvekov [Sat, 23 Oct 2021 22:44:17 +0000 (00:44 +0200)]
[clang] NFC: remove carriage return from AST tests

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
Reviewed By: rsmith

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

2 years agoRevert "[lldb] [Host/ConnectionFileDescriptor] Refactor to improve code reuse"
Med Ismail Bennani [Wed, 27 Oct 2021 21:49:49 +0000 (23:49 +0200)]
Revert "[lldb] [Host/ConnectionFileDescriptor] Refactor to improve code reuse"

This reverts commit e1acadb61dfc0810656219c6314019d5132f2c61.

2 years ago[InstCombine] add tests for select-of-constants; NFC
Sanjay Patel [Wed, 27 Oct 2021 19:50:57 +0000 (15:50 -0400)]
[InstCombine] add tests for select-of-constants; NFC

2 years ago[InstCombine] add tests for icmp with trunc operand; NFC
Sanjay Patel [Wed, 27 Oct 2021 14:22:10 +0000 (10:22 -0400)]
[InstCombine] add tests for icmp with trunc operand; NFC

2 years ago[lldb] Fixup code addresses in the Objective-C language runtime
Jonas Devlieghere [Wed, 27 Oct 2021 21:23:32 +0000 (14:23 -0700)]
[lldb] Fixup code addresses in the Objective-C language runtime

Upstream the calls to ABI::FixCodeAddress in the Objective-C language
runtime.

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

2 years ago[libc++] Make __decay_copy constexpr
Louis Dionne [Wed, 27 Oct 2021 19:12:07 +0000 (15:12 -0400)]
[libc++] Make __decay_copy constexpr

This is going to be necessary to implement some range adaptors.
As a fly-by fix, rename _LIBCPP_INLINE_VISIBILITY to _LIBCPP_HIDE_FROM_ABI
and remove a redundant inline keyword.

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

2 years ago[libunwind] Simplify the executor used in the tests
Louis Dionne [Wed, 27 Oct 2021 19:04:18 +0000 (15:04 -0400)]
[libunwind] Simplify the executor used in the tests

Instead of going through libc++'s run.py, we can simply run the executable
directly since we don't need to setup a working directory or control the
environment.

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

2 years ago[libc++][test] Fix invalid test for views::view_interface
Joe Loser [Wed, 27 Oct 2021 21:12:33 +0000 (17:12 -0400)]
[libc++][test] Fix invalid test for views::view_interface

The type `MoveOnlyForwardRange` violates the precondition stated in
`view.interface.general`. Specifically, the type passed to
`view_interface` shall model the `view` concept. In turn, this requires the
type to satisfy `movable` concept (and others), but this type
`MoveOnlyForwardRange` does not satisfy the `movable` concept.

Add a move assignment operator so that `MoveOnlyForwardRange` satisfies the
`movable` concept. While we're here, ensure the neighboring types that inherit
from `view_interface` also satisfy the `view` concept to avoid similar issues.

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

Reviewed By: Quuxplusone, Mordante, #libc

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

2 years ago[clang] NFC: include non friendly types and missing sugar in test expectations
Matheus Izvekov [Wed, 22 Sep 2021 00:33:45 +0000 (02:33 +0200)]
[clang] NFC: include non friendly types and missing sugar in test expectations

The dump of all diagnostics of all tests under `clang/test/{CXX,SemaCXX,SemaTemplate}` was analyzed , and all the cases where there were obviously bad canonical types being printed, like `type-parameter-*-*` and `<overloaded function type>` were identified. Also a small amount of cases of missing sugar were analyzed.

This patch then spells those explicitly in the test expectations, as preparatory work for future fixes for these problems.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
Reviewed By: rsmith

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

2 years ago[clang] deprecate frelaxed-template-template-args, make it on by default
Matheus Izvekov [Thu, 9 Sep 2021 10:11:03 +0000 (12:11 +0200)]
[clang] deprecate frelaxed-template-template-args, make it on by default

A resolution to the ambiguity issues created by P0522, which is a DR solving
CWG 150, did not come as expected, so we are just going to accept the change,
and watch how users digest it.

For now we deprecate the flag with a warning, and make it on by default.
We don't remove the flag completely in order to give users a chance to
work around any problems by disabling it.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
Reviewed By: rsmith

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

2 years ago[AST] fail rather than crash when const evaluating invalid c++ foreach
Sam McCall [Wed, 27 Oct 2021 16:50:24 +0000 (18:50 +0200)]
[AST] fail rather than crash when const evaluating invalid c++ foreach

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

2 years ago[ORC][ORC-RT] Enable the MachO platform for arm64
Ben Langmuir [Wed, 27 Oct 2021 18:53:37 +0000 (11:53 -0700)]
[ORC][ORC-RT] Enable the MachO platform for arm64

Enables the arm64 MachO platform, adds basic tests, and implements the
missing TLV relocations and runtime wrapper function. The TLV
relocations are just handled as GOT accesses.

rdar://84671534

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

2 years ago[lld/mac] Don't crash on undefined symbols with --icf=all
Nico Weber [Wed, 27 Oct 2021 18:40:00 +0000 (14:40 -0400)]
[lld/mac] Don't crash on undefined symbols with --icf=all

ICF runs before relocation processing, but undefined symbol errors
are only emitted during relocation processing.

So just ignore Undefineds during ICF (instead of crashing) -- lld
will emit an error once ICF is done.

Fixes PR52330.

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

2 years ago[Clang] Add elementwise abs builtin.
Florian Hahn [Wed, 27 Oct 2021 17:15:17 +0000 (18:15 +0100)]
[Clang] Add elementwise abs builtin.

This patch implements __builtin_elementwise_abs as specified in
D111529.

Reviewed By: aaron.ballman, scanon

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

2 years agoutils/release: Add script for building release documentation
Tom Stellard [Wed, 27 Oct 2021 19:56:55 +0000 (12:56 -0700)]
utils/release: Add script for building release documentation

Reviewed By: hans, kuhnel

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

2 years agoRevert "[NFC] `IRBuilderBase::CreateAdd()`: place constant onto RHS"
Roman Lebedev [Wed, 27 Oct 2021 19:19:59 +0000 (22:19 +0300)]
Revert "[NFC] `IRBuilderBase::CreateAdd()`: place constant onto RHS"

Clang OpenMP codegen tests are failing,
will recommit afterwards.

This reverts commit 4723c9b3c6c46632a5d66e65d198899894b1e2c5.

2 years agoRevert "[IR] `IRBuilderBase::CreateAdd()`: short-circuit `x + 0` --> `x`"
Roman Lebedev [Wed, 27 Oct 2021 19:19:10 +0000 (22:19 +0300)]
Revert "[IR] `IRBuilderBase::CreateAdd()`: short-circuit `x + 0` --> `x`"

Clang OpenMP codegen tests are failing.

This reverts commit 288f1f8abe5835180a0021f142043ee261ab3846.
This reverts commit cb90e5356ac1594e95fed8e208d6e0e9b6a87db1.

2 years ago[ConstantRange] Optimize smul_sat() (NFC)
Nikita Popov [Wed, 27 Oct 2021 13:12:02 +0000 (15:12 +0200)]
[ConstantRange] Optimize smul_sat() (NFC)

Base the implementation on the APInt smul_sat() implementation,
which is much more efficient than performing calculations in
double the bitwidth.

2 years ago[lld-macho] If export_size is zero, export_off must be zero
Jez Ng [Wed, 27 Oct 2021 18:58:15 +0000 (14:58 -0400)]
[lld-macho] If export_size is zero, export_off must be zero

Otherwise tools like codesign_allocate will choke. We were already
handling this correctly for the other DYLD_INFO sections.

Doing this correctly is a bit subtle: we don't know if export_size will
be zero until we have run `ExportSection::finalizeContents()`. However,
we must still add the ExportSection to the `__LINKEDIT` segment in order
that it gets sorted during `sortSectionsAndSegments()`.

Reviewed By: #lld-macho, oontvoo

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

2 years ago[BasicAA] Remove misleading overflow check
Nikita Popov [Wed, 27 Oct 2021 12:58:34 +0000 (14:58 +0200)]
[BasicAA] Remove misleading overflow check

GEP decomposition currently checks whether the multiplication of
the linear expression offset and GEP scale overflows. However, if
everything else works correctly, this overflow check is both
unnecessary and dangerously misleading. While it will avoid an
overflow in Scale * Offset in particular, other parts of the
calculation (including those on dynamic values) may still overflow.
The code working on the decomposed GEPs is responsible for ensuring
that it remains correct in the presence of overflow. D112611 fixes
the last issue of that kind that I'm aware of (in fact, the overflow
check was originally introduced to work around precisely that issue).

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

2 years ago[formatters] Add a libstdcpp formatter for set and unify tests across stdlibs
Danil Stefaniuc [Wed, 27 Oct 2021 18:54:19 +0000 (11:54 -0700)]
[formatters] Add a libstdcpp formatter for set and unify tests across stdlibs

This diff adds a data formatter for libstdcpp's set. Besides, it unifies the tests for set for libcxx and libstdcpp for maintainability.

Reviewed By: wallace

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

2 years agoFix MLIR LLVMIR test after 4723c9b3c6c46632a5d66e65d198899894b1e2c5
Roman Lebedev [Wed, 27 Oct 2021 18:52:32 +0000 (21:52 +0300)]
Fix MLIR LLVMIR test after 4723c9b3c6c46632a5d66e65d198899894b1e2c5

2 years ago[LowerTypeTests] Emit cfi_jt aliases regardless of function export
Nick Desaulniers [Wed, 27 Oct 2021 18:36:23 +0000 (11:36 -0700)]
[LowerTypeTests] Emit cfi_jt aliases regardless of function export

A constant complaint we get is that the __typeid__ symbols in the CFI
jump tables causes confusing stack traces in applications. Emit the more
readable cfi_jt aliases regardless of function export (LTO vs Thin LTO).

Reviewed By: pcc, tejohnson

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

2 years ago[IR] `IRBuilderBase::CreateAdd()`: short-circuit `x + 0` --> `x`
Roman Lebedev [Wed, 27 Oct 2021 17:35:55 +0000 (20:35 +0300)]
[IR] `IRBuilderBase::CreateAdd()`: short-circuit `x + 0` --> `x`

There's precedent for that in `CreateOr()`/`CreateAnd()`.

The motivation here is to avoid bloating the run-time check's IR
in `SCEVExpander::generateOverflowCheck()`.

Refs. https://reviews.llvm.org/D109368#3089809

2 years ago[NFC] `IRBuilderBase::CreateAdd()`: place constant onto RHS
Roman Lebedev [Wed, 27 Oct 2021 16:58:10 +0000 (19:58 +0300)]
[NFC] `IRBuilderBase::CreateAdd()`: place constant onto RHS

2 years ago[Operator] Add hasPoisonGeneratingFlags [mostly NFC]
Philip Reames [Wed, 27 Oct 2021 17:51:03 +0000 (10:51 -0700)]
[Operator] Add hasPoisonGeneratingFlags [mostly NFC]

This method parallels the dropPoisonGeneratingFlags on Instruction, but is hoisted to operator to handle constant expressions as well.

This is mostly code movement, but I did go ahead and add the inrange constexpr gep case.  This had been discussed previously, but apparently never followed up o.

2 years agoRevert "[SLP]Improve/fix reordering of the gathered graph nodes."
Alexey Bataev [Wed, 27 Oct 2021 18:16:20 +0000 (11:16 -0700)]
Revert "[SLP]Improve/fix reordering of the gathered graph nodes."

This reverts commit 64d1617d18cb8b6f9511d0eda481fc5a5d0ebddf to fix test
non-stability.

2 years ago[libc][obvious] fix strdup being listed twice
Michael Jones [Wed, 27 Oct 2021 18:11:29 +0000 (11:11 -0700)]
[libc][obvious] fix strdup being listed twice

strdup was being included even if malloc wasn't and that was causing
a build failure.

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

2 years agoAdd "REQUIRES: native" to test.
Douglas Yung [Wed, 27 Oct 2021 17:49:52 +0000 (10:49 -0700)]
Add "REQUIRES: native" to test.

This test was failing on the PS4 bot because the test attempts to link, but the PS4 platform requires an external
linker that is not present, causing the test to fail. This should get the PS4 bot green again.

2 years ago[lld/mac] Don't assert when ICFing arm64 code
Nico Weber [Mon, 25 Oct 2021 14:25:14 +0000 (10:25 -0400)]
[lld/mac] Don't assert when ICFing arm64 code

WordLiteralSection dedupes literals by content.
WordLiteralInputSection::getOffset() used to read a literal at the passed-in
offset and look up this value in the deduping map to find the offset of the
deduped value.

But it's possible that (e.g.) a 16-byte literal's value is accessed 4 bytes in.
To get the offset at that address, we have to get the deduped value at offset 0
and then apply the offset 4 to the result.

(See also WordLiteralSection::finalizeContents() which fills in those maps.)

Only a problem on arm64 because in x86_64 the offset is part of the instruction
instead of a separate ARM64_RELOC_ADDEND relocation. (See bug for more details.)

Fixes PR51999.

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

2 years ago[MLIR] Remove the unused `ArithmeticCastOp`.
Alexandre Rames [Wed, 27 Oct 2021 17:51:35 +0000 (10:51 -0700)]
[MLIR] Remove the unused `ArithmeticCastOp`.

This was deprecated as part of a54f4eae0e1d0ef5adccdcf9f6c2b518dc1101aa.

Reviewed By: rriddle

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

2 years ago[lld][WebAssebmly] Convert tests to use disassembly. NFC
Sam Clegg [Wed, 27 Oct 2021 01:31:05 +0000 (18:31 -0700)]
[lld][WebAssebmly] Convert tests to use disassembly. NFC

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

2 years ago[clangd] IncludeCleaner: Do not process locations in built-in files
Kirill Bobyrev [Wed, 27 Oct 2021 17:31:39 +0000 (19:31 +0200)]
[clangd] IncludeCleaner: Do not process locations in built-in files

Doing otherwise leads to crashing. Way to reproduce: open "gmock/gmock.h" in
the LLVM source tree.

Reviewed By: kadircet

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

2 years ago[libc] add strdup implementation
Michael Jones [Tue, 19 Oct 2021 23:14:22 +0000 (16:14 -0700)]
[libc] add strdup implementation

Add an implementation for strdup.

Reviewed By: lntue, sivachandra

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

2 years ago[libc] add malloc funcs as external entrypoints
Michael Jones [Tue, 19 Oct 2021 23:06:52 +0000 (16:06 -0700)]
[libc] add malloc funcs as external entrypoints

malloc, calloc, realloc, and free are all functions that other libc
functions depend on, but are pulled from external sources, instead of
having an internal implementation. This patch adds a way to include
functions like that as entrypoints in the list of external entrypoints,
and includes the malloc functions using this new path.

Reviewed By: sivachandra

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

2 years ago[cmake] Surpress cmake warning on that EH requires RTTI. NFC.
Michael Liao [Wed, 27 Oct 2021 16:45:18 +0000 (12:45 -0400)]
[cmake] Surpress cmake warning on that EH requires RTTI. NFC.

- Both LLVM_REQUIRES_RTTI and LLVM_REQUIRES_EH are internal flags that
  individual targets can use to force RTTI/EH. Turning off
  LLVM_REQUIRES_RTTI should honor if that variable is set explicitly for
  an individual target.

2 years ago[ELF] Replace InputBaseSection::{areRelocsRela,firstRelocation,numRelocation} with...
Fangrui Song [Wed, 27 Oct 2021 16:51:06 +0000 (09:51 -0700)]
[ELF] Replace InputBaseSection::{areRelocsRela,firstRelocation,numRelocation} with relSecIdx

For `InputSection` `.foo`, its `InputBaseSection::{areRelocsRela,firstRelocation,numRelocation}` basically
encode the information of `.rel[a].foo`. However, one uint32_t (the relocation section index)
suffices. See the implementation of `relsOrRelas`.

This change decreases sizeof(InputSection) from 184 to 176 on 64-bit Linux.

The maximum resident set size linking a large application (1.2G output) decreases by 0.39%.

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

2 years ago[IR] `SCEVExpander::generateOverflowCheck()`: short-circuit `umul_with_overflow`...
Roman Lebedev [Wed, 27 Oct 2021 16:13:49 +0000 (19:13 +0300)]
[IR] `SCEVExpander::generateOverflowCheck()`: short-circuit `umul_with_overflow`-by-one

It's a no-op, no overflow happens ever: https://alive2.llvm.org/ce/z/Zw89rZ

While generally i don't like such hacks,
we have a very good reason to do this: here we are expanding
a run-time correctness check for the vectorization,
and said `umul_with_overflow` will not be optimized out
before we query the cost of the checks we've generated.

Which means, the cost of run-time checks would be artificially inflated,
and after https://reviews.llvm.org/D109368 that will affect
the minimal trip count for which these checks are even evaluated.
And if they aren't even evaluated, then the vectorized code
certainly won't be run.

We could consider doing this in IRBuilder,  but then we'd need to
also teach `CreateExtractValue()` to look into chain of `insertvalue`'s,
and i'm not sure there's precedent for that.

Refs. https://reviews.llvm.org/D109368#3089809

2 years ago[ELF][X86] Write R_X86_64_TLSDESC addends with -z rel
Fangrui Song [Wed, 27 Oct 2021 16:35:30 +0000 (09:35 -0700)]
[ELF][X86] Write R_X86_64_TLSDESC addends with -z rel

Similar to D100544 for AArch64.

Reviewed By: arichardson

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

2 years ago[X86] Remove getSETOpc (NFC)
Kazu Hirata [Wed, 27 Oct 2021 16:22:31 +0000 (09:22 -0700)]
[X86] Remove getSETOpc (NFC)

This function seems to be unused for at least one year.

2 years ago[X86] Remove NeedsRetpoline in X86AsmPrinter (NFC)
Kazu Hirata [Wed, 27 Oct 2021 16:22:29 +0000 (09:22 -0700)]
[X86] Remove NeedsRetpoline in X86AsmPrinter (NFC)

This field seems to be unused for at least one year.

2 years ago[X86] Remove CallOperand in X86Operand (NFC)
Kazu Hirata [Wed, 27 Oct 2021 16:22:27 +0000 (09:22 -0700)]
[X86] Remove CallOperand in X86Operand (NFC)

This field seems to be unused for at least one year.

2 years agosanitizer_common: fix up onprint.cpp test
Dmitry Vyukov [Wed, 27 Oct 2021 16:01:38 +0000 (18:01 +0200)]
sanitizer_common: fix up onprint.cpp test

Commit D112602 ("sanitizer_common: tighten on_print hook test")
changed fopen to open in this test. fopen created the file
if if does not exist, but open does not. This was unnoticed
during local testing because lit is not hermetic and reuses
files from previous runs, but it started failing on bots.
Fix the open call.

Reviewed By: melver

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

2 years ago[pstl] A hot fix for a reduction parallel pattern of OpenMP backend
Mikhail Dvorskiy [Wed, 27 Oct 2021 15:51:36 +0000 (18:51 +0300)]
[pstl] A hot fix for a reduction parallel pattern of OpenMP backend

Reviewed By: nadiasvertex, ldionne

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

2 years ago[SLP]Improve/fix reordering of the gathered graph nodes.
Alexey Bataev [Mon, 25 Oct 2021 14:32:35 +0000 (07:32 -0700)]
[SLP]Improve/fix reordering of the gathered graph nodes.

Gathered loads/extractelements/extractvalue instructions should be
checked if they can represent a vector reordering node too and their
order should ve taken into account for better graph reordering analysis/
Also, if the gather node has reused scalars, they must be reordered
instead of the scalars themselves.

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

2 years ago[lldb][NFC] Move a declaration in DWARFASTParserClang to its first use.
Raphael Isemann [Wed, 27 Oct 2021 15:42:57 +0000 (17:42 +0200)]
[lldb][NFC] Move a declaration in DWARFASTParserClang to its first use.

2 years ago[llvm-locstats] Move the test from D110621 into test/llvm-locstats/ dir
Djordje Todorovic [Wed, 27 Oct 2021 15:36:05 +0000 (17:36 +0200)]
[llvm-locstats] Move the test from D110621 into test/llvm-locstats/ dir

2 years agoFix consteval crash when transforming 'this' expressions
Aaron Ballman [Wed, 27 Oct 2021 15:24:00 +0000 (11:24 -0400)]
Fix consteval crash when transforming 'this' expressions

When reaching the end of a function body, we need to ensure that the
ExitFunctionBodyRAII object is destroyed before we pop the declaration context
for the function. Exiting the function body causes us to handle immediate
invocations, which involves template transformations that need to know the
correct type for this.

This addresses PR48235.

2 years ago[Analyzer][solver] Handle adjustments in constraint assignor remainder
Gabor Marton [Fri, 22 Oct 2021 08:12:38 +0000 (10:12 +0200)]
[Analyzer][solver] Handle adjustments in constraint assignor remainder

We can reuse the "adjustment" handling logic in the higher level
of the solver by calling `State->assume`.

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

2 years ago[NFC][LoopVectorize] Change getStepVector to take a Value* for the StartIdx
David Sherwood [Fri, 15 Oct 2021 11:54:58 +0000 (12:54 +0100)]
[NFC][LoopVectorize] Change getStepVector to take a Value* for the StartIdx

This patch changes the definition of getStepVector from:

  Value *getStepVector(Value *Val, int StartIdx, Value *Step, ...

to

  Value *getStepVector(Value *Val, Value *StartIdx, Value *Step, ...

because:

1. it seems inconsistent to pass some values as Value* and some as
   integer, and
2. future work will require the StartIdx to be an expression made up
   of runtime calculations of the VF.

In widenIntOrFpInduction I've changed the code to pass in the
value returned from getRuntimeVF, but the presence of the assert:

  assert(!VF.isScalable() && "scalable vectors not yet supported.");

means that currently this code path is only exercised for fixed-width
VFs and so the patch is still NFC.

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

2 years ago[IR] `IRBuilderBase::CreateAnd()`: short-circuit `x & 0` --> `0`
Roman Lebedev [Wed, 27 Oct 2021 14:31:29 +0000 (17:31 +0300)]
[IR] `IRBuilderBase::CreateAnd()`: short-circuit `x & 0` --> `0`

https://alive2.llvm.org/ce/z/YzPhSb

Refs. https://reviews.llvm.org/D109368#3089809

2 years ago[IR] `IRBuilderBase::CreateAnd()`: fix short-circuiting for constant on LHS
Roman Lebedev [Wed, 27 Oct 2021 14:04:07 +0000 (17:04 +0300)]
[IR] `IRBuilderBase::CreateAnd()`: fix short-circuiting for constant on LHS

Refs. https://reviews.llvm.org/D109368#3089809

2 years ago[IR] `IRBuilderBase::CreateOr()`: fix short-circuiting for constant on LHS
Roman Lebedev [Wed, 27 Oct 2021 13:38:01 +0000 (16:38 +0300)]
[IR] `IRBuilderBase::CreateOr()`: fix short-circuiting for constant on LHS

There is no guarantee that the constant is on RHS here,
we have to handle both cases.

Refs. https://reviews.llvm.org/D109368#3089809

2 years ago[IR] `IRBuilderBase::CreateSelect()`: if cond is a constant i1, short-circuit
Roman Lebedev [Wed, 27 Oct 2021 13:05:09 +0000 (16:05 +0300)]
[IR] `IRBuilderBase::CreateSelect()`: if cond is a constant i1, short-circuit

While we could emit such a tautological `select`,
it will stick around until the next instsimplify invocation,
which may happen after we count the cost of this redundant `select`.
Which is precisely what happens with loop vectorization legality checks,
and that artificially increases the cost of said checks,
which is bad.

There is prior art for this in `IRBuilderBase::CreateAnd()`/`IRBuilderBase::CreateOr()`.

Refs. https://reviews.llvm.org/D109368#3089809

2 years ago[NFC] Re-autogenerate check lines in some tests to ease of future update
Roman Lebedev [Wed, 27 Oct 2021 12:58:40 +0000 (15:58 +0300)]
[NFC] Re-autogenerate check lines in some tests to ease of future update

2 years ago[Analyzer][solver] Simplification: reorganize equalities with adjustment
Gabor Marton [Mon, 25 Oct 2021 16:10:12 +0000 (18:10 +0200)]
[Analyzer][solver] Simplification: reorganize equalities with adjustment

Initiate the reorganization of the equality information during symbol
simplification. E.g., if we bump into `c + 1 == 0` during simplification
then we'd like to express that `c == -1`. It makes sense to do this only
with `SymIntExpr`s.

Reviewed By: steakhal

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

2 years ago[dexter] Fix failing regression tests
OCHyams [Wed, 27 Oct 2021 14:27:16 +0000 (15:27 +0100)]
[dexter] Fix failing regression tests

D109833 makes the flags `--builder` and `--binary` mutually exclusive, which
caused some regression tests to fail. Add a new substitution
`%dexter_regression_base` that doesn't include the `--builder`, `--cflags` or
`--ldflags` flags and use that for tests that use the `--binary` flag.

Reviewed By: jmorse

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

2 years agoRevert "[SLP]Improve/fix reordering of the gathered graph nodes."
Alexey Bataev [Wed, 27 Oct 2021 14:31:36 +0000 (07:31 -0700)]
Revert "[SLP]Improve/fix reordering of the gathered graph nodes."

This reverts commit f719b794bcaa1df8fa82659d6d4e754c77d2f94e to fix
instability in tests.

2 years ago[OpenMP][NFC] disable test on power because of -mlong-double-80 option
AndreyChurbanov [Wed, 27 Oct 2021 13:54:25 +0000 (16:54 +0300)]
[OpenMP][NFC] disable test on power because of -mlong-double-80 option

2 years ago[OpenMP] libomp: Fix possible NULL dereference.
AndreyChurbanov [Wed, 27 Oct 2021 13:38:09 +0000 (16:38 +0300)]
[OpenMP] libomp: Fix possible NULL dereference.

According to dlsym description, the value of symbol could be NULL,
and there is no error in this case. Thus dlerror will also return NULL in
this case. We need to check the value returned by dlerror before printing it.

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

2 years agofix comment typos to cycle bots
Nico Weber [Wed, 27 Oct 2021 13:52:17 +0000 (09:52 -0400)]
fix comment typos to cycle bots

2 years ago[gn build] Use LLD as host linker by default on macOS if clang_base_path is set
Nico Weber [Wed, 27 Oct 2021 13:37:45 +0000 (09:37 -0400)]
[gn build] Use LLD as host linker by default on macOS if clang_base_path is set

lld/mac should be stable enough to use it as host linker. I've been
using `use_lld=true` in my local args.gn for many months now and it
works fine (and links much faster than ld64).

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

2 years agofix comment typos to cycle bots
Nico Weber [Wed, 27 Oct 2021 13:43:42 +0000 (09:43 -0400)]
fix comment typos to cycle bots

2 years ago[gn build] Add lldb to default target on Windows
Nico Weber [Wed, 27 Oct 2021 13:34:25 +0000 (09:34 -0400)]
[gn build] Add lldb to default target on Windows

It seems to build fine (even though some tests fail), so might
as well let the bots build it. If it turns out to break a lot,
we can always turn it back off.

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

2 years ago[DebugInfo][NFC] Initialize a new object field in unittests
Jeremy Morse [Wed, 27 Oct 2021 13:19:16 +0000 (14:19 +0100)]
[DebugInfo][NFC] Initialize a new object field in unittests

Over in e7084ceab3122 the InstrRefBasedLDV class grew a MachineRegisterInfo
pointer to lookup register sizes -- however, that field wasn't initialized
in the corresponding unit tests. This patch initializes it!

Fixes a buildbot failure reported on D112006

2 years ago[SVE][CodeGen] Fix incorrect legalisation of zero-extended masked loads
Kerry McLaughlin [Tue, 26 Oct 2021 09:37:52 +0000 (10:37 +0100)]
[SVE][CodeGen] Fix incorrect legalisation of zero-extended masked loads

PromoteIntRes_MLOAD always sets the extension type to `EXTLOAD`, which
results in a sign-extended load. If the type returned by getExtensionType()
for the load being promoted is something other than `NON_EXTLOAD`, we
should instead pass this to getMaskedLoad() as the extension type.

Reviewed By: CarolineConcatto

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

2 years agosanitizer_common: tighten on_print hook test
Dmitry Vyukov [Wed, 27 Oct 2021 08:42:26 +0000 (10:42 +0200)]
sanitizer_common: tighten on_print hook test

The new tsan runtime does not support arbitrary forms
of recursing into the runtime from hooks.
Disable instrumentation of the hook and use write instead
of fwrite (calls malloc internally).
The new version still recurses (write is intercepted),
but does not fail now (the issue at hand was malloc).

Depends on D112601.

Reviewed By: melver

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

2 years agotsan: switch sync test from EXPECT to CHECK
Dmitry Vyukov [Wed, 27 Oct 2021 08:57:42 +0000 (10:57 +0200)]
tsan: switch sync test from EXPECT to CHECK

Gtest's EXPECT calls whole lot of libc functions
(mem*, malloc) even when EXPECT does not fail.
This does not play well with tsan runtime unit tests
b/c e.g. we call some EXPECTs with runtime mutexes locked.

Reviewed By: melver

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

2 years ago[SLP]Improve/fix reordering of the gathered graph nodes.
Alexey Bataev [Mon, 25 Oct 2021 14:32:35 +0000 (07:32 -0700)]
[SLP]Improve/fix reordering of the gathered graph nodes.

Gathered loads/extractelements/extractvalue instructions should be
checked if they can represent a vector reordering node too and their
order should ve taken into account for better graph reordering analysis/
Also, if the gather node has reused scalars, they must be reordered
instead of the scalars themselves.

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

2 years ago[gn build] add build rule for llvm-locstats
Nico Weber [Wed, 27 Oct 2021 13:07:24 +0000 (09:07 -0400)]
[gn build] add build rule for llvm-locstats

Needed by tests after 30a3652b6ade.

2 years ago[clang] Add range accessor for ObjCAtTryStmt catch_stmts and use it
Nico Weber [Tue, 26 Oct 2021 14:53:33 +0000 (10:53 -0400)]
[clang] Add range accessor for ObjCAtTryStmt catch_stmts and use it

No behavior change.

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

2 years ago[clang] Convert ObjCAtTryStmt to llvm::TrailingObjects
Nico Weber [Tue, 26 Oct 2021 14:35:21 +0000 (10:35 -0400)]
[clang] Convert ObjCAtTryStmt to llvm::TrailingObjects

And make it final while here.

No behavior change.

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

2 years ago[SelectionDAG] Widening the result of INSERT_SUBVECTOR.
Caroline Concatto [Wed, 20 Oct 2021 21:38:02 +0000 (22:38 +0100)]
[SelectionDAG] Widening the result of INSERT_SUBVECTOR.

Widens the result and first input vector because they have the same size.
The subvector to be inserted is widened in the operand widen function.

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

2 years ago[BasicAA] Handle known bits as ranges
Nikita Popov [Mon, 25 Oct 2021 13:47:21 +0000 (15:47 +0200)]
[BasicAA] Handle known bits as ranges

BasicAA currently tries to determine that the offset is positive by
checking whether all variable indices are positive based on known
bits, multiplied by a positive scale. However, this is incorrect
if the scale multiplication might overflow. In the modified test
case the original value is positive, but may be negative after a
left shift.

Fix this by converting known bits into a constant range and reusing
the range-based logic, which handles overflow correctly.

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

2 years ago[llvm-locstats] Report a warning if overflow was detected by llvm-dwarfdump
djtodoro [Fri, 15 Oct 2021 11:00:04 +0000 (13:00 +0200)]
[llvm-locstats] Report a warning if overflow was detected by llvm-dwarfdump

Catch that llvm-dwarfdump detected an overflow in statistics.

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

2 years agoRevert "[ARM] __cxa_end_cleanup should be called instead of _UnwindResume."
Daniel Kiss [Wed, 27 Oct 2021 12:29:35 +0000 (14:29 +0200)]
Revert "[ARM] __cxa_end_cleanup should be called instead of _UnwindResume."

This reverts commit da1d1a08694bbfe0ea7a23ea094612436e8a2dd0.

2 years ago[clang][deps] Fix fragile test
Jan Svoboda [Wed, 27 Oct 2021 11:57:35 +0000 (13:57 +0200)]
[clang][deps] Fix fragile test

This test was failing on GreenDragon.

2 years ago[mlir] gen_spirv_dialect.py: Some support for OCL ops generation
Caitlyn Cano [Thu, 1 Jul 2021 20:41:51 +0000 (20:41 +0000)]
[mlir] gen_spirv_dialect.py: Some support for OCL ops generation

It is not complete and disabled by default, but it can be still useful.

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

2 years ago[x86] enhance mayFoldLoad to check alignment
Sanjay Patel [Wed, 27 Oct 2021 11:53:14 +0000 (07:53 -0400)]
[x86] enhance mayFoldLoad to check alignment

As noted in D112464, a pre-AVX target may not be able to fold an
under-aligned vector load into another op, so we shouldn't report
that as a load folding candidate. I only found one caller where
this would make a difference -- combineCommutableSHUFP() -- so
that's where I added a test to show the (minor) regression.

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

2 years ago[clangd] NFC: Remove single-line braces in IncludeCleaner
Kirill Bobyrev [Wed, 27 Oct 2021 11:52:44 +0000 (13:52 +0200)]
[clangd] NFC: Remove single-line braces in IncludeCleaner

2 years ago[lldb] [docs] Remove obsolete recommonmark use
Michał Górny [Wed, 27 Oct 2021 11:31:35 +0000 (13:31 +0200)]
[lldb] [docs] Remove obsolete recommonmark use

The recommonmark package is no longer required since all the documents
have been converted to .rst.  Remove the related support code from
docs/conf.py.

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

2 years ago[AArch64][SVE] Combine predicated FMUL/FADD into FMA
Matt [Tue, 12 Oct 2021 10:18:59 +0000 (10:18 +0000)]
[AArch64][SVE] Combine predicated FMUL/FADD into FMA

Combine FADD and FMUL intrinsics into FMA when the result of the FMUL is an FADD operand
with one only use and both use the same predicate.

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

2 years ago[AArch64] Add support for the 'R' architecture profile.
Alexandros Lamprineas [Mon, 20 Sep 2021 10:49:30 +0000 (11:49 +0100)]
[AArch64] Add support for the 'R' architecture profile.

This change introduces subtarget features to predicate certain
instructions and system registers that are available only on
'A' profile targets. Those features are not present when
targeting a generic CPU, which is the default processor.

In other words the generic CPU now means the intersection of
'A' and 'R' profiles. To maintain backwards compatibility we
enable the features that correspond to -march=armv8-a when the
architecture is not explicitly specified on the command line.

References: https://developer.arm.com/documentation/ddi0600/latest

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

2 years ago[SLP]Fix logical and/or reductions.
Alexey Bataev [Tue, 26 Oct 2021 14:12:45 +0000 (07:12 -0700)]
[SLP]Fix logical and/or reductions.

Need to emit select(cmp) instructions for poison-safe forms of select
ops. Currently alive reports that `Target is more poisonous than source`
for operations we generating for such instructions.

https://alive2.llvm.org/ce/z/FiNiAA

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

2 years ago[OpenMP][OMPD] Implementation of OMPD debugging library - libompd.
Vignesh Balasubramanian [Wed, 27 Oct 2021 10:49:07 +0000 (16:19 +0530)]
[OpenMP][OMPD] Implementation of OMPD debugging library - libompd.

This is a continuation of the review: https://reviews.llvm.org/D100183
It contains routines that retrieve OpenMP ICV values for OMPD.

Reviewed By: @hbae
Differential Revision: https://reviews.llvm.org/D100184

2 years ago[lldb] Modernize TestVLA.py
Pavel Labath [Wed, 27 Oct 2021 10:47:11 +0000 (12:47 +0200)]
[lldb] Modernize TestVLA.py

Use expect_expr/var_path instead of regular expect and substring checks

2 years ago[lldb] [Host/ConnectionFileDescriptor] Refactor to improve code reuse
Michał Górny [Mon, 25 Oct 2021 20:55:48 +0000 (22:55 +0200)]
[lldb] [Host/ConnectionFileDescriptor] Refactor to improve code reuse

Refactor ConnectionFileDescriptor to improve code reuse for different
types of sockets.  Unify method naming.

While at it, remove some (now-)dead code from Socket.

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

2 years ago[BasicAA] Make range check more precise
Nikita Popov [Mon, 25 Oct 2021 16:47:51 +0000 (18:47 +0200)]
[BasicAA] Make range check more precise

Make the range check more precise by calculating the range of
potentially accessed bytes for both accesses and checking whether
their intersection is empty. In that case there can be no overlap
between the accesses and the result is NoAlias.

This is more powerful than the previous approach, because it can
deal with sign-wrapped ranges. In the test case the original range
is [-1, INT_MAX] but becomes [0, INT_MIN] after applying the offset.
This is a wrapping range, so getSignedMin/getSignedMax will treat
it as a full range. However, the range excludes the elements
[INT_MIN+1, -1], which is enough to prove NoAlias with an access
at offset -1.

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

2 years ago[NFC][LV][X86] Improve test coverage for masked mem ops
Roman Lebedev [Wed, 27 Oct 2021 09:48:16 +0000 (12:48 +0300)]
[NFC][LV][X86] Improve test coverage for masked mem ops

2 years ago[mlir] Reduce the number of iterations in async microbenchmarks
Eugene Zhulenev [Wed, 27 Oct 2021 10:18:47 +0000 (03:18 -0700)]
[mlir] Reduce the number of iterations in async microbenchmarks

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

2 years ago[DSE] Add test case with 2 memcpys that should not be eliminated.
Florian Hahn [Wed, 27 Oct 2021 10:15:58 +0000 (11:15 +0100)]
[DSE] Add test case with 2 memcpys that should not be eliminated.

2 years ago[clang-repl] Remove redundant link libraries and drop unused file.
Vassil Vassilev [Wed, 27 Oct 2021 10:11:29 +0000 (10:11 +0000)]
[clang-repl] Remove redundant link libraries and drop unused file.

Many thanks to @thakis for pointing this out.

That commit should have been a part of https://reviews.llvm.org/D107049

2 years ago[pstl] A hot compilation fix for MacOS, OpenMP backend; + full qualified names for...
Mikhail Dvorskiy [Fri, 22 Oct 2021 15:58:06 +0000 (18:58 +0300)]
[pstl] A hot compilation fix for MacOS, OpenMP backend; + full qualified names for some internal functions

Reviewed By: nadiasvertex, ldionne

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

2 years ago[clangd] Add integration test for crash handling
Sam McCall [Tue, 26 Oct 2021 13:27:07 +0000 (15:27 +0200)]
[clangd] Add integration test for crash handling

This replaces the test removed in 51be7061d025139ba66869d5d99c7157a3ae9edd
It is more principled and tests more critical cases: a crash while parsing.

We need two pieces of plumbing:
 - a way to re-enable the crashing #pragmas via a flag, to test parse crashes
 - a bit of reshuffling around ASTWorker execution so that we set up the
   crash handler in both sync/async modes.
   Sync mode is useful for debugging, so I tested both.

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

2 years ago[clangd] IncludeCleaner: Don't warn on system headers
Kirill Bobyrev [Wed, 27 Oct 2021 09:50:35 +0000 (11:50 +0200)]
[clangd] IncludeCleaner: Don't warn on system headers

This is a temporary hack to disable diagnostics for system headers. As of right
now, IncludeCleaner does not handle the Standard Library correctly and will
report most system headers as unused because very few symbols are defined in
top-level system headers. This will eventually be fixed, but for now we are
aiming for the most conservative approach with as little false-positive
warnings as possible. After the initial prototype and core functionality is
polished, I will turn back to handling the Standard Library as it requires
custom logic.

Reviewed By: sammccall

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

2 years ago[clang-tidy] Correct typo in bugprone-easily-swappable-parameters
Salman Javed [Wed, 27 Oct 2021 09:38:52 +0000 (22:38 +1300)]
[clang-tidy] Correct typo in bugprone-easily-swappable-parameters

The string table `DefaultIgnoredParameterTypeSuffixes` has a typo:
`ForwardIt` is mistyped as `FowardIt`.

Correct typo and add test coverage.

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

2 years agoModernize Platform::GetOSKernelDescription
Pavel Labath [Tue, 26 Oct 2021 08:52:39 +0000 (10:52 +0200)]
Modernize Platform::GetOSKernelDescription

2 years ago[LiveInterval] Add RemoveDeadValNo argument to removeSegment(iterator)
Jay Foad [Mon, 27 Sep 2021 15:05:54 +0000 (16:05 +0100)]
[LiveInterval] Add RemoveDeadValNo argument to removeSegment(iterator)

Add an optional bool RemoveDeadValNo argument to the
removeSegment(iterator) overload, for consistency with the other
overloads. This gives clients a way to remove dead valnos while also
getting an updated iterator returned (in the manner of vector::erase).

Use this to clean up some inefficient code in
LiveIntervals::repairOldRegInRange. NFC.

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

2 years ago[ARM] __cxa_end_cleanup should be called instead of _UnwindResume.
Daniel Kiss [Wed, 27 Oct 2021 08:32:11 +0000 (10:32 +0200)]
[ARM] __cxa_end_cleanup should be called instead of _UnwindResume.

ARM EHABI[1] specifies the __cxa_end_cleanup to be called after cleanup.
It will call the UnwindResume.
__cxa_begin_cleanup will be called from libcxxabi while __cxa_end_cleanup is never called.
This will trigger a termination when a foreign exception is processed while UnwindResume is called
because the global state will be wrong due to the missing __cxa_end_cleanup call.

Additional test here: D109856
[1] https://github.com/ARM-software/abi-aa/blob/main/ehabi32/ehabi32.rst#941compiler-helper-functions

Reviewed By: logan

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