platform/upstream/llvm.git
3 years ago[DAGCombiner] Pre-commit test to demonstrate mulhi const folding
David Stuttard [Mon, 5 Jul 2021 10:08:03 +0000 (11:08 +0100)]
[DAGCombiner] Pre-commit test to demonstrate mulhi const folding

D103323 will fold this

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

Change-Id: I64947215eb531fbd70b52a72203b39e43fefafcc

3 years ago[AArch64] Cost-model i8 vector loads/stores
Sjoerd Meijer [Thu, 1 Jul 2021 13:45:54 +0000 (14:45 +0100)]
[AArch64] Cost-model i8 vector loads/stores

Loads of <4 x i8> vectors were modeled as extremely expensive. And while we
don't have a load instruction that supports this, it isn't that expensive to
create a vector of i8 elements. The codegen for this was fixed/optimised in
D105110. This now tweaks the cost model and enables SLP vectorisation of my
motivating case loadi8.ll.

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

3 years ago[mlir] Escape strings of opaque attributes
Markus Böck [Mon, 5 Jul 2021 10:13:36 +0000 (12:13 +0200)]
[mlir] Escape strings of opaque attributes

Opaque attributes that currently contain string literals can't currently be properly roundtripped as they are not printed as escaped strings. This leads to incorrect tokens being generated and the parser to almost certainly fail. This patch simply uses llvm::printEscapedString from LLVM. It escapes all non printable characters and quotes to \xx hex literals, and backslashes to two backslashes. This syntax is supported by MLIRs Lexer as well. The same function is also currently in use for the same purpose in printSymbolReference, printAttribute for StringAttr and many more in AsmPrinter.cpp.

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

3 years ago[DebugInfo] CGP+HWasan: Handle dbg.values with duplicate location ops
Stephen Tozer [Mon, 5 Jul 2021 08:45:08 +0000 (09:45 +0100)]
[DebugInfo] CGP+HWasan: Handle dbg.values with duplicate location ops

This patch fixes an issue which occurred in CodeGenPrepare and
HWAddressSanitizer, which both at some point create a map of Old->New
instructions and update dbg.value uses of these. They did this by
iterating over the dbg.value's location operands, and if an instance of
the old instruction was found, replaceVariableLocationOp would be
called on that dbg.value. This would cause an error if the same operand
appeared multiple times as a location operand, as the first call to
replaceVariableLocationOp would update all uses of the old instruction,
invalidating the old iterator and eventually hitting an assertion.

This has been fixed by no longer iterating over the dbg.value's location
operands directly, but by first collecting them into a set and then
iterating over that, ensuring that we never attempt to replace a
duplicated operand multiple times.

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

3 years ago[AMDGPU] Stop mulhi from doing 24 bit mul for uniform values
David Stuttard [Thu, 13 May 2021 13:08:36 +0000 (14:08 +0100)]
[AMDGPU] Stop mulhi from doing 24 bit mul for uniform values

Added support to check if architecture supports s_mulhi which is used as part of
the decision whether or not to use valu 24 bit mul (if the mulhi gets
transformed to a valu op anyway, then may as well use it).

This is an extension of the work in D97063

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

Change-Id: I80b1323de640a52623d69ac005a97d06a5d42a14

3 years ago[docs] Fix linking issues in LibASTMatchers tutorial
Georgy Komarov [Sun, 4 Jul 2021 17:45:40 +0000 (20:45 +0300)]
[docs] Fix linking issues in LibASTMatchers tutorial

Update CMakeLists.txt in the tutorial to reflect the latest changes in
LLVM. The demo project cannot be linked without added libraries.

Reviewed By: xgupta

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

3 years ago[lld-macho][nfc] Add REQUIRES: x86 to test
Jez Ng [Mon, 5 Jul 2021 07:39:35 +0000 (03:39 -0400)]
[lld-macho][nfc] Add REQUIRES: x86 to test

I didn't realize that llvm-objdump's features were arch-specific.

This should fix the non-x86 buildbots.

3 years ago[mlir] Add LogOp lowering from Complex dialect to Standard/Math dialect.
Adrian Kuegel [Fri, 2 Jul 2021 11:20:13 +0000 (13:20 +0200)]
[mlir] Add LogOp lowering from Complex dialect to Standard/Math dialect.

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

3 years ago[RISCV] Pass FeatureBitset by reference rather than by value. NFCI
Craig Topper [Mon, 5 Jul 2021 05:59:20 +0000 (22:59 -0700)]
[RISCV] Pass FeatureBitset by reference rather than by value. NFCI

FeatureBitset is 4 64-bit values in an array. It's better passed by
reference rather than copying it.

I may be adding FeatureBitset as an argument to another function
and noticed this while working on that.

3 years ago[lld-macho] Parse relocations quickly by assuming sorted order
Jez Ng [Mon, 5 Jul 2021 05:13:30 +0000 (01:13 -0400)]
[lld-macho] Parse relocations quickly by assuming sorted order

clang and gcc both seem to emit relocations in reverse order of
address. That means we can match relocations to their containing
subsections in `O(relocs + subsections)` rather than the `O(relocs *
log(subsections))` that our previous binary search implementation
required.

Unfortunately, `ld -r` can still emit unsorted relocations, so we have a
fallback code path for that (less common) case.

Numbers for linking chromium_framework on my 3.2 GHz 16-Core Intel Xeon W:

      N           Min           Max        Median           Avg        Stddev
  x  20          4.04          4.11         4.075        4.0775   0.018027756
  +  20          3.95          4.02          3.98         3.985   0.020900768
  Difference at 95.0% confidence
          -0.0925 +/- 0.0124919
          -2.26855% +/- 0.306361%
          (Student's t, pooled s = 0.0195172)

Reviewed By: #lld-macho, thakis

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

3 years ago[llvm-readobj][XCOFF] Add support for printing the String Table.
Esme-Yi [Mon, 5 Jul 2021 04:16:58 +0000 (04:16 +0000)]
[llvm-readobj][XCOFF] Add support for printing the String Table.

Summary: The patch adds the StringTable dumping to
llvm-readobj. Currently only XCOFF is supported.

Reviewed By: jhenderson

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

3 years ago[XCOFF][NFC] add DWARF section support in XCOFF object writer
Chen Zheng [Mon, 5 Jul 2021 02:53:30 +0000 (02:53 +0000)]
[XCOFF][NFC] add DWARF section support in XCOFF object writer

Reviewed By: jsji

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

3 years ago[mlir-reduce] Improve diagnostic message and clean build dependency
Chia-hung Duan [Mon, 5 Jul 2021 02:15:11 +0000 (10:15 +0800)]
[mlir-reduce] Improve diagnostic message and clean build dependency

Reviewed By: rriddle

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

3 years ago[mlir-tblgen] Avoid ODS verifier duplication
Chia-hung Duan [Tue, 29 Jun 2021 10:38:55 +0000 (18:38 +0800)]
[mlir-tblgen] Avoid ODS verifier duplication

Different constraints may share the same predicate, in this case, we
will generate duplicate ODS verification function.

Reviewed By: jpienaar

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

3 years ago[clangd] Type hints for structured bindings
Nathan Ridge [Mon, 14 Jun 2021 07:23:35 +0000 (03:23 -0400)]
[clangd] Type hints for structured bindings

Hints are shown for the individual bindings, not the aggregate.

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

3 years ago[X86] Refine code of generating BB labels in Keylocker
Xiang1 Zhang [Fri, 2 Jul 2021 08:21:39 +0000 (16:21 +0800)]
[X86] Refine code of generating BB labels in Keylocker

Reviewed By: craig.topper

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

3 years ago[mlir][NFC] MemRef cleanup: Remove helper functions
Matthias Springer [Mon, 5 Jul 2021 01:04:01 +0000 (10:04 +0900)]
[mlir][NFC] MemRef cleanup: Remove helper functions

Remove `getDynOperands` and `createOrFoldDimOp` from MemRef.h to decouple MemRef a bit from Tensor. These two functions are used in other dialects/transforms.

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

3 years ago[lld/mac] Fix function offset on 1st-level unwind table sentinel
Nico Weber [Sun, 4 Jul 2021 02:23:42 +0000 (22:23 -0400)]
[lld/mac] Fix function offset on 1st-level unwind table sentinel

Two bugs:
1. This tries to take the address of the last symbol plus the length
   of the last symbol. However, the sorted vector is cuPtrVector,
   not cuVector. Also, cuPtrVector has tombstone values removed
   and cuVector doesn't. If there was a stripped value at the end,
   the "last" element's value was UINT64_MAX, which meant the
   sentinel value was one less than the length of that "last"
   dead symbol.

2. We have to subtract in.header->addr. For 64-bit binaries that's
   (1 << 32) and functionAddress is 32-bit so this is a no-op, but
   for 32-bit binaries the sentinel's value was too large.

I believe this has no effect in practice since the first-level
binary search code in libunwind (in UnwindCursor.hpp) does:

    uint32_t low = 0;
    uint32_t high = sectionHeader.indexCount();
    uint32_t last = high - 1;
    while (low < high) {
      uint32_t mid = (low + high) / 2;
        if ((mid == last) ||
            (topIndex.functionOffset(mid + 1) > targetFunctionOffset)) {
          low = mid;
          break;
        } else {
        low = mid + 1;
      }

So the address of the last entry in the first-level table isn't really
checked -- except for the very end, but the check against `last` means
we just run the loop once more than necessary. But it makes `unwinddump` output
look less confusing, and it's what it looks was the intention here.

(No test since I can't think of a way to make FileCheck check that one
number is larger than another.)

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

3 years ago[lld/mac] Don't crash on 32-bit output binaries when dead-stripping
Nico Weber [Sun, 4 Jul 2021 01:57:43 +0000 (21:57 -0400)]
[lld/mac] Don't crash on 32-bit output binaries when dead-stripping

Fixes PR50974.

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

3 years ago[libunwind] reflow some debug logs for better greppability
Nico Weber [Fri, 2 Jul 2021 14:03:32 +0000 (10:03 -0400)]
[libunwind] reflow some debug logs for better greppability

"bad second level page" and "second level compressed unwind table"
can now be grepped for.

(Also remove one of the two spaces between "second" and "level"
in the second message.)

3 years ago[Polly][Isl] Update isl to isl-0.24-47-g8853f375
patacca [Sun, 4 Jul 2021 17:49:41 +0000 (19:49 +0200)]
[Polly][Isl] Update isl to isl-0.24-47-g8853f375

This is needed for the new functions exposed in the C++ interface as used in https://reviews.llvm.org/D104994

Reviewed By: Meinersbur

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

3 years ago[mlir][OpAsmParser] Add parseString method
Markus Böck [Sun, 4 Jul 2021 15:12:02 +0000 (17:12 +0200)]
[mlir][OpAsmParser] Add parseString method

Basically every kind of parseOptional* method in DialectAsmParser has a corresponding parse* method which will emit an error if the requested token has not been found. An odd one out of this rule is parseOptionalString which does not have a corresponding parseString method.

This patch adds that method and implements it in basically the same fashion as parseKeyword, by first going through parseOptionalString and emitting an error on failure.

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

3 years ago[IR] Deprecate GetElementPtrInst::CreateInBounds without element type
Nikita Popov [Sun, 4 Jul 2021 14:30:18 +0000 (16:30 +0200)]
[IR] Deprecate GetElementPtrInst::CreateInBounds without element type

This API is not compatible with opaque pointers, the method
accepting an explicit pointer element type should be used instead.

Thankfully there were few in-tree users. The BPF case still ends
up using the pointer element type for now and needs something like
D105407 to avoid doing so.

3 years ago[NFC] Fix a few whitespace issues and typos.
Paul Walker [Thu, 1 Jul 2021 12:07:28 +0000 (13:07 +0100)]
[NFC] Fix a few whitespace issues and typos.

3 years ago[IRBuilder] Add type argument to CreateMaskedLoad/Gather
Nikita Popov [Sat, 3 Jul 2021 12:57:41 +0000 (14:57 +0200)]
[IRBuilder] Add type argument to CreateMaskedLoad/Gather

Same as other CreateLoad-style APIs, these need an explicit type
argument to support opaque pointers.

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

3 years ago[llvm][iwyu] explicitly includes <functional> and <utility>
Christopher Di Bella [Sun, 4 Jul 2021 02:22:37 +0000 (02:22 +0000)]
[llvm][iwyu] explicitly includes <functional> and <utility>

Compiling LLVM with Clang modules and libc++ identified that
`Support/Printable.h` and `ADL/SmallVector.h` were using features that
live in these headers.

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

3 years ago[clangd][iwyu] explicitly includes `<atomic>`
Christopher Di Bella [Sun, 4 Jul 2021 02:17:43 +0000 (02:17 +0000)]
[clangd][iwyu] explicitly includes `<atomic>`

Compiling clangd with Clang modules and libc++ revealed that
`support/Threading.h` uses `std::atomic` but wasn't including the
correct header.

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

3 years ago[analyzer] Fix calculating offset for fields with an empty type
Georgy Komarov [Fri, 28 May 2021 08:58:50 +0000 (11:58 +0300)]
[analyzer] Fix calculating offset for fields with an empty type

Fix offset calculation routines in padding checker to avoid assertion
errors described in bugzilla issue 50426. The fields that are subojbects
of zero size, marked with [[no_unique_address]] or empty bitfields will
be excluded from padding calculation routines.

Reviewed By: NoQ

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

3 years ago[KnownBits] Merge const/non-const KnownBits::extractBits implementations. NFC.
Simon Pilgrim [Sat, 3 Jul 2021 18:00:25 +0000 (19:00 +0100)]
[KnownBits] Merge const/non-const KnownBits::extractBits implementations. NFC.

These are identical and can be just const.

3 years ago[X86][SSE] Add mulhu/mulhs constant folding tests
Simon Pilgrim [Sat, 3 Jul 2021 16:01:59 +0000 (17:01 +0100)]
[X86][SSE] Add mulhu/mulhs constant folding tests

These should be folded by D103323

3 years ago[SelectionDAG] Replace APInt.lshr().trunc() with APInt.extractBits() where possible...
Simon Pilgrim [Sat, 3 Jul 2021 15:32:41 +0000 (16:32 +0100)]
[SelectionDAG] Replace APInt.lshr().trunc() with APInt.extractBits() where possible. NFC.

This also allows us to use KnownBits::extractBits in one case.

3 years ago[SelectionDAG] Use KnownBits::insertBits instead of separate APInt::insertBits calls...
Simon Pilgrim [Sat, 3 Jul 2021 14:58:52 +0000 (15:58 +0100)]
[SelectionDAG] Use KnownBits::insertBits instead of separate APInt::insertBits calls. NFC.

3 years ago[IRBuilder] Avoid fetching pointer element type in some assertions
Nikita Popov [Sat, 3 Jul 2021 10:44:21 +0000 (12:44 +0200)]
[IRBuilder] Avoid fetching pointer element type in some assertions

Specifically the CreateMaskedStore and CreateMaskedScatter APIs.
The CreateMaskedLoad and CreateMaskedGather APIs will need an
additional type argument.

3 years ago[flang][driver] Add support for `--version` in the bash wrapper
Andrzej Warzynski [Fri, 2 Jul 2021 15:02:08 +0000 (16:02 +0100)]
[flang][driver] Add support for `--version` in the bash wrapper

The bash wrapper script, `flang`, calls `flang-new -fc1` under the hood,
which does not support `--version` (this is consistent with `clang -cc1
--version`). This change is needed for `flang --version` to work as
expected.

Note that `flang --version` (the Flang bash wrapper script for the
compiler driver) gives rather minimal output compared to `flang-new
--version` (the Flang compiler driver). As the wrapper script is just a
temporary solution for us, this should be sufficient.

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

3 years ago[SimplifyCFG] simplifyUnreachable(): erase instructions iff they are guaranteed to...
Roman Lebedev [Sat, 3 Jul 2021 07:45:44 +0000 (10:45 +0300)]
[SimplifyCFG] simplifyUnreachable(): erase instructions iff they are guaranteed to transfer execution to unreachable

This replaces the current ad-hoc implementation,
by syncing the code from InstCombine's implementation in `InstCombinerImpl::visitUnreachableInst()`,
with one exception that here in SimplifyCFG we are allowed to remove EH instructions.

Effectively, this now allows SimplifyCFG to remove calls (iff they won't throw and will return),
arithmetic/logic operations, etc.

Reviewed By: nikic

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

3 years ago[AArch64] Add S/UQXTRN tablegen patterns.
David Green [Sat, 3 Jul 2021 06:57:19 +0000 (07:57 +0100)]
[AArch64] Add S/UQXTRN tablegen patterns.

This adds simple patterns for signed and unsigned saturating extract
narrow instructions. They combine a min/max/truncate into a single
instruction, providing that the immediates on the min/max are correct
for the saturation type. This is just handled in tablegen with some
extra patterns.

v2i64->v2i32 is not handled here as the min/max nodes are not legal,
making the lowering quite different.

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

3 years ago[AIX] Adjust CSR order to avoid breaking ABI regarding traceback
Kai Luo [Sat, 3 Jul 2021 04:45:11 +0000 (04:45 +0000)]
[AIX] Adjust CSR order to avoid breaking ABI regarding traceback

Allocate non-volatile registers in order to be compatible with ABI, regarding gpr_save.

Quoted from https://www.ibm.com/docs/en/ssw_aix_72/assembler/assembler_pdf.pdf page55,
> The preferred method of using GPRs is to use the volatile registers first. Next, use the nonvolatile registers
> in descending order, starting with GPR31.

This patch is based on @jsji 's initial draft.

Tested on test-suite and SPEC, found no degradation.

Reviewed By: jsji, ZarkoCA, xingxue

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

3 years ago[SelectionDAG] Rename memory VT argument for getMaskedGather/getMaskedScatter from...
Craig Topper [Sat, 3 Jul 2021 00:36:27 +0000 (17:36 -0700)]
[SelectionDAG] Rename memory VT argument for getMaskedGather/getMaskedScatter from VT to MemVT.

Use getMemoryVT() in MGATHER/MSCATTER DAG combines instead of
using the passthru or store value VT for this argument.

3 years ago[ThinLTO] Respect ClearDSOLocalOnDeclarations for unimported functions
Fangrui Song [Sat, 3 Jul 2021 00:08:25 +0000 (17:08 -0700)]
[ThinLTO] Respect ClearDSOLocalOnDeclarations for unimported functions

D74751 added `ClearDSOLocalOnDeclarations` and dropped dso_local for
isDeclarationForLinker `GlobalValue`s. It missed a case for imported
declarations (`doImportAsDefinition` is false while `isPerformingImport` is
true). This can lead to a linker error for a default visibility symbol in
`ld.lld -shared`.

When `ClearDSOLocalOnDeclarations` is true, we check
`isPerformingImport() && !doImportAsDefinition(&GV)` along with
`GV.isDeclarationForLinker()`. The new condition checks an imported declaration.

This patch fixes a `LLVMPolly.so` link error using a trunk clang -DLLVM_ENABLE_LTO=Thin.

Reviewed By: tejohnson

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

3 years agoRevert "Create synthetic symbol names on demand to improve memory consumption and...
Jonas Devlieghere [Fri, 2 Jul 2021 23:17:25 +0000 (16:17 -0700)]
Revert "Create synthetic symbol names on demand to improve memory consumption and startup times."

This reverts commit c8164d0276b97679e80db01adc860271ab4a5d11 and
43f6dad2344247976d5777f56a1fc29e39c6c717 because it breaks
TestDyldTrieSymbols.py on GreenDragon.

3 years agoRevert "[DebugInfo] Enforce implicit constraints on `distinct` MDNodes"
Jonas Devlieghere [Fri, 2 Jul 2021 22:45:15 +0000 (15:45 -0700)]
Revert "[DebugInfo] Enforce implicit constraints on `distinct` MDNodes"

This reverts commit 8cd35ad854ab4458fd509447359066ea3578b494.

It breaks `TestMembersAndLocalsWithSameName.py` on GreenDragon and
Mikael Holmén points out in D104827 that bitcode files created with the
patch cannot be parsed with binaries built before it.

3 years ago[mlir][sparse] support for negation and subtractions
Aart Bik [Fri, 2 Jul 2021 19:26:18 +0000 (12:26 -0700)]
[mlir][sparse] support for negation and subtractions

This revision extends the sparse compiler support from fp/int addition and multiplication to fp/int negation and subtraction, thereby increasing the scope of sparse kernels that can be compiled.

Reviewed By: gussmith23

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

3 years agoLex: add a callback for `#pragma mark`
Saleem Abdulrasool [Fri, 2 Jul 2021 19:43:01 +0000 (19:43 +0000)]
Lex: add a callback for `#pragma mark`

Allow a preprocessor observer to be notified of mark pragmas.  Although
this does not impact code generation in any way, it is useful for other
clients, such as clangd, to be able to identify any marked regions.

Reviewed By: dgoldman

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

3 years ago[lldb] Update shebang in heap.py and crashlog.py
Jonas Devlieghere [Fri, 2 Jul 2021 22:33:46 +0000 (15:33 -0700)]
[lldb] Update shebang in heap.py and crashlog.py

3 years agoFix test so it doesn't try to write to the test directory, only to %t
David Blaikie [Fri, 2 Jul 2021 21:59:50 +0000 (14:59 -0700)]
Fix test so it doesn't try to write to the test directory, only to %t

3 years ago[mlir][Vector] NFC - Compress vector to outerproduct lowering.
Nicolas Vasilache [Fri, 2 Jul 2021 15:32:53 +0000 (15:32 +0000)]
[mlir][Vector] NFC - Compress vector to outerproduct lowering.

The implementation has become too unwieldy and cognitive overhead wins.
Instead compress the implementation in preparation for additional lowering paths.

This is a resubmit of https://reviews.llvm.org/D105359 without ordering ambiguities.

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

3 years agoName all DEATH tests using 'DeathTest' suffix.
Mitch Phillips [Fri, 2 Jul 2021 20:50:52 +0000 (13:50 -0700)]
Name all DEATH tests using 'DeathTest' suffix.

gtest highly recommends this prefix, and runs death tests first
(https://github.com/google/googletest/blob/master/docs/advanced.md#death-test-naming).
This may help with some spurious bot failures like
https://lab.llvm.org/buildbot/#/builders/169/builds/1290/steps/25/logs/stdio.

Reviewed By: cryptoad, vitalybuka

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

3 years ago[NFC][Codegen] Autogenerate check lines in PowerPC/2007-11-16-landingpad-split.ll
Roman Lebedev [Fri, 2 Jul 2021 20:29:18 +0000 (23:29 +0300)]
[NFC][Codegen] Autogenerate check lines in PowerPC/2007-11-16-landingpad-split.ll

It is being affected by an upcoming SimplifyCFG change.

3 years ago[NFC][Codegen] Tune a few tests to not end with a naked `unreachable` terminator
Roman Lebedev [Fri, 2 Jul 2021 20:14:21 +0000 (23:14 +0300)]
[NFC][Codegen] Tune a few tests to not end with a naked `unreachable` terminator

These rely on the fact that currently simplifycfg won't really propagate
said `unreachable`, but that is about to change.

3 years ago[lldb/test] Fix failure caused by synthetic symbol name refactoring
Med Ismail Bennani [Fri, 2 Jul 2021 20:01:21 +0000 (20:01 +0000)]
[lldb/test] Fix failure caused by synthetic symbol name refactoring

This patch fixes a failure in `TestFunctionStarts.py` that appeared
following a change of implementation for synthetic symbol names:

https://reviews.llvm.org/D105160

The failure is caused because the previously mentioned patch removes the
object file basename from the generated synthetic symbol names to allow
them to be shared in the constant string pool.

Hence, that last check is not necessary anymore.

rdar://80092322

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
3 years ago[GlobalISel] Clean up CombinerHelper::apply* functions to return void.
Amara Emerson [Fri, 2 Jul 2021 20:07:00 +0000 (13:07 -0700)]
[GlobalISel] Clean up CombinerHelper::apply* functions to return void.

For some reason we/I started writing these as returning bool when the return value
is actually ignored by the combiner.

3 years ago[NFC][CUDA] Fix order of round(f) definition in __clang_cuda_math.h for non-LP64.
Joachim Meyer [Fri, 2 Jul 2021 19:54:39 +0000 (21:54 +0200)]
[NFC][CUDA] Fix order of round(f) definition in __clang_cuda_math.h for non-LP64.

This broke ARM builds e.g.: https://lab.llvm.org/buildbot/#/builders/187/builds/212

3 years ago[NFC][SimplifyCFG] Autogenerate checklines in a few tests
Roman Lebedev [Fri, 2 Jul 2021 19:35:14 +0000 (22:35 +0300)]
[NFC][SimplifyCFG] Autogenerate checklines in a few tests

3 years ago[lldb] [gdb-remote client] Support switching PID along with TID
Michał Górny [Sun, 11 Apr 2021 11:04:54 +0000 (13:04 +0200)]
[lldb] [gdb-remote client] Support switching PID along with TID

Extend the SetCurrentThread() method to support specifying an alternate
PID to switch to.  This makes it possible to issue requests to forked
processes.

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

3 years ago[GlobalISel] Add re-association combine for G_PTR_ADD to allow better addressing...
Amara Emerson [Sun, 27 Jun 2021 06:36:46 +0000 (23:36 -0700)]
[GlobalISel] Add re-association combine for G_PTR_ADD to allow better addressing mode usage.

We're trying to match a few pointer computation patterns here for
re-association opportunities.
1) Isolating a constant operand to be on the RHS, e.g.:
   G_PTR_ADD(BASE, G_ADD(X, C)) -> G_PTR_ADD(G_PTR_ADD(BASE, X), C)

2) Folding two constants in each sub-tree as long as such folding
   doesn't break a legal addressing mode.
   G_PTR_ADD(G_PTR_ADD(BASE, C1), C2) -> G_PTR_ADD(BASE, C1+C2)

AArch64 code size improvements on CTMark with -Os:
Program              before  after   diff
 pairlocalalign      251048  251044 -0.0%
 consumer-typeset    421820  421812 -0.0%
 kc                  431348  431320 -0.0%
 SPASS               413404  413300 -0.0%
 clamscan            384396  384220 -0.0%
 tramp3d-v4          370640  370412 -0.1%
 lencod              432096  431772 -0.1%
 bullet              479400  478796 -0.1%
 sqlite3             288504  288072 -0.1%
 7zip-benchmark      573796  570768 -0.5%
 Geomean difference                 -0.1%

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

3 years ago[NFCI][SimplifyCFG] simplifyUnreachable(): Use poison constant to represent the resul...
Roman Lebedev [Fri, 2 Jul 2021 18:57:49 +0000 (21:57 +0300)]
[NFCI][SimplifyCFG] simplifyUnreachable(): Use poison constant to represent the result of unreachable instrs

Mimics similar change for InstCombine:
  ce192ced2b901be67444c481ab5ca0d731e6d982 / D104602

All these uses are in blocks that aren't reachable from function's entry,
and said blocks are removed by SimplifyCFG itself,
so we can't really test this change.

3 years ago[InstCombine] Don't combine PHI before catchswitch
Heejin Ahn [Thu, 1 Jul 2021 19:22:41 +0000 (12:22 -0700)]
[InstCombine] Don't combine PHI before catchswitch

This tries to bail out if the PHI is in a `catchswitch` BB in
InstCombine. A PHI cannot be combined into a non-PHI instruction if it
is in a `catchswitch` BB, because `catchswitch` BB cannot have any
non-PHI instruction other than `catchswitch` itself.

The given test case started crashing after D98058.

Reviewed By: lebedev.ri, rnk

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

3 years agoAdd C API files for the LLVM dialect
Adam Paszke [Fri, 2 Jul 2021 17:03:46 +0000 (10:03 -0700)]
Add C API files for the LLVM dialect

For now only expose a builder for the LLVM pointer type.

Reviewed By: jpienaar, ftynse

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

3 years ago[SimplifyCFG] Volatile memory operations do not trap
Roman Lebedev [Fri, 2 Jul 2021 18:47:12 +0000 (21:47 +0300)]
[SimplifyCFG] Volatile memory operations do not trap

Somewhat related to D105338.
While it is up for discussion whether or not volatile store traps,
so far there has been no complaints that volatile load/cmpxchg/atomicrmw also may trap.
And even if simplifycfg currently concervatively believes that to be the case,
instcombine does not: https://godbolt.org/z/5vhv4K5b8

Reviewed By: nikic

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

3 years ago[lldb] Replace default bodies of special member functions with = default;
Jonas Devlieghere [Fri, 2 Jul 2021 18:27:37 +0000 (11:27 -0700)]
[lldb] Replace default bodies of special member functions with = default;

Replace default bodies of special member functions with = default;

$ run-clang-tidy.py -header-filter='lldb' -checks='-*,modernize-use-equals-default' -fix ,

https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-equals-default.html

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

3 years ago[ms] [llvm-ml] Standardize blocking of lexical substitution
Eric Astor [Fri, 2 Jul 2021 18:17:15 +0000 (14:17 -0400)]
[ms] [llvm-ml] Standardize blocking of lexical substitution

In MASM, the ifdef family of directives treats its argument literally, without expanding it as a text macro. Add support for this, and also replace the special handling that was previously used for echo.

Reviewed By: thakis

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

3 years ago[mlir][Linalg] Fix incorrect logic in deciding when to fuse reshapes by linearization.
MaheshRavishankar [Fri, 2 Jul 2021 17:43:29 +0000 (10:43 -0700)]
[mlir][Linalg] Fix incorrect logic in deciding when to fuse reshapes by linearization.

Fusion by linearization should not happen when
- The reshape is expanding and it is a consumer
- The reshape is collapsing and is a producer.

The bug introduced in this logic by some recent refactoring resulted
in a crash.
To enforce this (negetive) use case, add a test that reproduces the
error and verifies the fix.

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

3 years ago[OpaquePtr] Add type parameter to emitLoadLinked
Krzysztof Parzyszek [Fri, 2 Jul 2021 15:20:41 +0000 (10:20 -0500)]
[OpaquePtr] Add type parameter to emitLoadLinked

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

3 years ago[Hexagon] Handle opaque pointers in vector combine
Krzysztof Parzyszek [Fri, 2 Jul 2021 14:39:56 +0000 (09:39 -0500)]
[Hexagon] Handle opaque pointers in vector combine

3 years ago[clang][emscripten] Reduce alignof long double from 16 to 8 bytes
Sam Clegg [Wed, 23 Jun 2021 19:02:32 +0000 (12:02 -0700)]
[clang][emscripten] Reduce alignof long double from 16 to 8 bytes

This means `max_align_t` is 8 bytes which also sets the alignment
malloc.  Since this is technically and ABI breaking change we have
limited to just the emscripten OS target.  It is also relatively low
import breakage since it will only effect the alignement of struct that
contai `long double`s (extremerly rare I imagine).

Emscripten's malloc implementation already use 8 byte alignement
(dlmalloc uses and alignement of 2*sizeof(void*) == 8 rather than
checking max_align_t) so will not be effected by this change.  By
bringing the ABI in line with the current malloc code this will fix
several issue we have seen in the wild.

See: https://github.com/emscripten-core/emscripten/pull/14456

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

3 years agoRevert "[clang-repl] Allow passing in code as positional arguments."
Mitch Phillips [Fri, 2 Jul 2021 17:54:20 +0000 (10:54 -0700)]
Revert "[clang-repl] Allow passing in code as positional arguments."

This reverts commit e386871e1d21cf206a1287356e88c5853563fc77.

Reason: Broke the ASan buildbots
(https://lab.llvm.org/buildbot/#/builders/5/builds/9291). See comments
on https://reviews.llvm.org/D104898 for more information.

3 years agoRevert "[mlir][Vector] NFC - Compress vector to outerproduct lowering."
Mehdi Amini [Fri, 2 Jul 2021 17:55:06 +0000 (17:55 +0000)]
Revert "[mlir][Vector] NFC - Compress vector to outerproduct lowering."

This reverts commit db188adfb12f6783c5419d5165a1123b9f5b56b0.

Breaks the GCC tests, likely because of some order of evaluation
difference between clang and gcc.

3 years ago[lld-macho] Ignore debug symbols while preparing relocations.
Vy Nguyen [Wed, 30 Jun 2021 16:50:24 +0000 (12:50 -0400)]
[lld-macho] Ignore debug symbols while preparing relocations.

Details: see https://bugs.llvm.org/show_bug.cgi?id=50812

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

3 years ago[X86] Modify LOOP*, HLT control flow attributes
Amir Ayupov [Fri, 2 Jul 2021 17:26:22 +0000 (10:26 -0700)]
[X86] Modify LOOP*, HLT control flow attributes

Add missing control flow attributes:
- LOOP*: isBranch, isTerminator
- HLT: isTerminator

This helps downstream disassemblers (such as BOLT) reconstruct the control
flow graph more accurately.

Reviewed By: craig.topper

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

3 years ago[SLP][NFC]Refactor findLaneForValue and make it static member, NFC, by
Alexey Bataev [Fri, 2 Jul 2021 17:12:41 +0000 (10:12 -0700)]
[SLP][NFC]Refactor findLaneForValue and make it static member, NFC, by
V.Dmitriev.

Reduces number of arguments

3 years ago[MLGO] Update Oz model url.
Jacob Hegna [Fri, 2 Jul 2021 17:28:25 +0000 (17:28 +0000)]
[MLGO] Update Oz model url.

3 years ago[Intrinsics] Make MemCpyInlineInst a MemCpyInst
Jon Roelofs [Wed, 30 Jun 2021 23:49:48 +0000 (16:49 -0700)]
[Intrinsics] Make MemCpyInlineInst a MemCpyInst

This opens up more optimization opportunities in passes that already handle MemCpyInst's.

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

3 years ago[libcxx][type_traits] remove `std::is_literal_type` and `std::result_of` for C++20
wmbat [Fri, 2 Jul 2021 17:08:36 +0000 (17:08 +0000)]
[libcxx][type_traits] remove `std::is_literal_type` and `std::result_of` for C++20

C++17 deprecated `std::is_literal_type` and `std::result_of`, C++20 removed them.

Implements parts of:
    * P0174R2 'Deprecating Vestigial Library Parts in C++17'.
    * P0619R4 'Reviewing Deprecated Facilities of C++17 for C++20'.

Reviewed By: ldionne, Mordante, Quuxplusone, #libc

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

3 years ago[gn build] Port 99f00635d7ac
LLVM GN Syncbot [Fri, 2 Jul 2021 17:03:49 +0000 (17:03 +0000)]
[gn build] Port 99f00635d7ac

3 years ago[NFC][OpenMP][CUDA] Add test for using `-x cuda -fopenmp`
Joachim Meyer [Thu, 1 Jul 2021 23:24:29 +0000 (01:24 +0200)]
[NFC][OpenMP][CUDA] Add test for using `-x cuda -fopenmp`

This adds a very basic test in `cuda_with_openmp.cu` that just checks whether the CUDA & OpenMP integrated headers do compile, when a CUDA file is compiled with OpenMP (CPU) enabled.
Thus this basically adds the missing test for https://reviews.llvm.org/D90415.

Reviewed By: jdoerfert

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

3 years agoUnpack the CostEstimate feature in ML inlining models.
Jacob Hegna [Thu, 10 Jun 2021 02:16:04 +0000 (02:16 +0000)]
Unpack the CostEstimate feature in ML inlining models.

This change yields an additional 2% size reduction on an internal search
binary, and an additional 0.5% size reduction on fuchsia.

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

3 years ago[libc] Make ULP error reflect the bit distance more closely.
Siva Chandra Reddy [Thu, 1 Jul 2021 20:41:05 +0000 (20:41 +0000)]
[libc] Make ULP error reflect the bit distance more closely.

Reviewed By: lntue

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

3 years agoRevert "Refactor mutation strategies into a standalone library"
Marco Vanotti [Fri, 2 Jul 2021 16:44:54 +0000 (09:44 -0700)]
Revert "Refactor mutation strategies into a standalone library"

This reverts commit 361f742f168de0f0f256802a329c19d081615d0d.

3 years ago[mlir][Vector] NFC - Compress vector to outerproduct lowering.
Nicolas Vasilache [Fri, 2 Jul 2021 15:32:53 +0000 (15:32 +0000)]
[mlir][Vector] NFC - Compress vector to outerproduct lowering.

The implementation has become too unwieldy and cognitive overhead wins.
Instead compress the implementation in preparation for additional lowering paths.

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

3 years ago[Libomptarget] Experimental Remote Plugin Fixes
Atmn Patel [Fri, 2 Jul 2021 00:00:02 +0000 (20:00 -0400)]
[Libomptarget] Experimental Remote Plugin Fixes

D97883 introduced a compile-time error in the experimental remote offloading
libomptarget plugin, this patch fixes it and resolves a number of
inconsistencies in the plugin as well:

1. Non-functional Asynchronous API
2. Unnecessarily verbose debug printing
3. Misc. code clean ups

This is not intended to make any functional changes to the plugin.

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

3 years ago[mlir][linalg][python] Add min operation in OpDSL.
Tobias Gysi [Fri, 2 Jul 2021 16:08:22 +0000 (16:08 +0000)]
[mlir][linalg][python] Add min operation in OpDSL.

Add the min operation to OpDSL and introduce a min pooling operation to test the implementation. The patch is a sibling of the max operation patch https://reviews.llvm.org/D105203 and the min operation is again lowered to a compare and select pair.

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

3 years ago[Bazel] Fix build for c0a6318d96
Geoffrey Martin-Noble [Fri, 2 Jul 2021 16:09:59 +0000 (09:09 -0700)]
[Bazel] Fix build for c0a6318d96

This adds explicit deps to satisfy layering_check

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

3 years agoRefactor mutation strategies into a standalone library
Aaron Green [Fri, 2 Jul 2021 16:15:17 +0000 (09:15 -0700)]
Refactor mutation strategies into a standalone library

This change introduces libMutagen/libclang_rt.mutagen.a as a subset of libFuzzer/libclang_rt.fuzzer.a. This library contains only the fuzzing strategies used by libFuzzer to produce new test inputs from provided inputs, dictionaries, and SanitizerCoverage feedback.

Most of this change is simply moving sections of code to one side or the other of the library boundary. The only meaningful new code is:

* The Mutagen.h interface and its implementation in Mutagen.cpp.
* The following methods in MutagenDispatcher.cpp:
  * UseCmp
  * UseMemmem
  * SetCustomMutator
  * SetCustomCrossOver
  * LateInitialize (similar to the MutationDispatcher's original constructor)
  * Mutate_AddWordFromTORC (uses callbacks instead of accessing TPC directly)
  * StartMutationSequence
  * MutationSequence
  * DictionaryEntrySequence
  * RecommendDictionary
  * RecommendDictionaryEntry
* FuzzerMutate.cpp (which now justs sets callbacks and handles printing)
* MutagenUnittest.cpp (which adds tests of Mutagen.h)

A note on performance: This change was tested with a 100 passes of test/fuzzer/LargeTest.cpp with 1000 runs per pass, both with and without the change. The running time distribution was qualitatively similar both with and without the change, and the average difference was within 30 microseconds (2.240 ms/run vs 2.212 ms/run, respectively). Both times were much higher than observed with the fully optimized system clang (~0.38 ms/run), most likely due to the combination of CMake "dev mode" settings (e.g. CMAKE_BUILD_TYPE="Debug", LLVM_ENABLE_LTO=OFF, etc.). The difference between the two versions built similarly seems to be "in the noise" and suggests no meaningful performance degradation.

Reviewed By: morehouse

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

3 years ago[gn build] Port bf64210fd88f
LLVM GN Syncbot [Fri, 2 Jul 2021 16:12:54 +0000 (16:12 +0000)]
[gn build] Port bf64210fd88f

3 years ago[AIX] Use AsmParser to do inline asm parsing
Jinsong Ji [Fri, 2 Jul 2021 15:46:49 +0000 (15:46 +0000)]
[AIX] Use AsmParser to do inline asm parsing

Add a flag so that target can choose to use AsmParser for parsing inline asm.
And set the flag by default for AIX.

-no-intergrated-as will override this default if specified explicitly.

Reviewed By: #powerpc, shchenz

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

3 years ago[AIX] Add dummy XCOFF MCAsmParserExtension
Jinsong Ji [Fri, 2 Jul 2021 15:46:26 +0000 (15:46 +0000)]
[AIX] Add dummy XCOFF MCAsmParserExtension

Implement XCOFFMCAsmParser so that we can use MC to parse inline asm.

The directives and storage mapping classes will be added later
iteratively.

Reviewed By: xgupta

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

3 years ago[AArch64] Neon saturated truncate tests. NFC
David Green [Fri, 2 Jul 2021 16:03:49 +0000 (17:03 +0100)]
[AArch64] Neon saturated truncate tests. NFC

3 years agoRefactor TensorExp parameters into a union
Gus Smith [Thu, 1 Jul 2021 21:45:18 +0000 (21:45 +0000)]
Refactor TensorExp parameters into a union

To make TensorExp clearer, this change refactors the e0/e1 fields into a union: e0/e1 for a binary op tensor expression, and tensor_num for a tensor-kinded tensor expression.

Reviewed By: aartbik

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

3 years agoReapply [clangd] Fix possible assertion fail in TUScheduler
Sam McCall [Fri, 2 Jul 2021 14:30:19 +0000 (16:30 +0200)]
Reapply [clangd] Fix possible assertion fail in TUScheduler

This reverts commit fff966b6855aee6fc0d0d4cd401cdd525a838572.

Seems I managed to delete a critical ! after running the tests :-\

3 years ago[NFC][InstCombine] visitUnreachableInst(): enhance comments somewhat
Roman Lebedev [Fri, 2 Jul 2021 14:28:33 +0000 (17:28 +0300)]
[NFC][InstCombine] visitUnreachableInst(): enhance comments somewhat

3 years agoRevert "[clangd] Unbreak mac build differently 0c96a92d8666b8"
Sam McCall [Fri, 2 Jul 2021 14:26:01 +0000 (16:26 +0200)]
Revert "[clangd] Unbreak mac build differently 0c96a92d8666b8"

This reverts commit 2f79acb7b701c41494abff588b5f03a74ea2e11d.

Should no longer be needed after 26e1553a107f52667be879e99739a4153f8799d8

3 years ago[mlir][Linalg] Add comprehensive bufferization support for TiledLoopOp (14/n)
Nicolas Vasilache [Fri, 2 Jul 2021 07:41:22 +0000 (07:41 +0000)]
[mlir][Linalg] Add comprehensive bufferization support for TiledLoopOp (14/n)

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

3 years ago[InstCombine] visitUnreachableInst(): iteratively erase instructions leading to unrea...
Roman Lebedev [Fri, 2 Jul 2021 14:18:48 +0000 (17:18 +0300)]
[InstCombine] visitUnreachableInst(): iteratively erase instructions leading to unreachable

In the original review D87149 it was mentioned that this approach was tried,
and it lead to infinite combine loops, but i'm not seeing anything like that now,
neither in the `check-llvm`, nor on some codebases i tried.

This is a recommit of d9d65527c289fb27a9f92f150723bbb3c58e413f,
which i immediately reverted because i have messed up something
during branch switch, and 597ccc92ce4b0f90883406d1f78d9d776f602804
accidentally ended up being pushed, which was very much not the intention.

Reviewed By: spatel

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

3 years agoRevert "https://godbolt.org/z/5vhv4K5b8"
Roman Lebedev [Fri, 2 Jul 2021 14:17:55 +0000 (17:17 +0300)]
Revert "https://godbolt.org/z/5vhv4K5b8"

This reverts commit 597ccc92ce4b0f90883406d1f78d9d776f602804.

3 years agoRevert "[NFCI][InstCombine] visitUnreachableInst(): iteratively erase instructions...
Roman Lebedev [Fri, 2 Jul 2021 14:17:47 +0000 (17:17 +0300)]
Revert "[NFCI][InstCombine] visitUnreachableInst(): iteratively erase instructions leading to unreachable"

This reverts commit d9d65527c289fb27a9f92f150723bbb3c58e413f.

3 years ago[NFCI][InstCombine] visitUnreachableInst(): iteratively erase instructions leading...
Roman Lebedev [Fri, 2 Jul 2021 14:16:33 +0000 (17:16 +0300)]
[NFCI][InstCombine] visitUnreachableInst(): iteratively erase instructions leading to unreachable

In the original review D87149 it was mentioned that this approach was tried,
and it lead to infinite combine loops, but i'm not seeing anything like that now,
neither in the `check-llvm`, nor on some codebases i tried.

Reviewed By: spatel

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

3 years agohttps://godbolt.org/z/5vhv4K5b8
Roman Lebedev [Fri, 2 Jul 2021 10:06:37 +0000 (13:06 +0300)]
https://godbolt.org/z/5vhv4K5b8

3 years agoRevert "[clangd] Fix possible assertion fail in TUScheduler"
Sam McCall [Fri, 2 Jul 2021 14:07:11 +0000 (16:07 +0200)]
Revert "[clangd] Fix possible assertion fail in TUScheduler"

This reverts commit 50566947e98ea845030cfa3b4c199fb9a2052d53.

3 years ago[clangd] Fix possible assertion fail in TUScheduler
Sam McCall [Fri, 2 Jul 2021 13:55:43 +0000 (15:55 +0200)]
[clangd] Fix possible assertion fail in TUScheduler

BlockUntilIdle is supposed to return false if it fails.
If an intermediate step fails to clear the queue, we shouldn't
charge ahead and assert on the state of the queue.

3 years ago[llvm-dwarfdump] Add comment saying where DumpDebugFrame comes from
Nico Weber [Fri, 2 Jul 2021 13:56:21 +0000 (09:56 -0400)]
[llvm-dwarfdump] Add comment saying where DumpDebugFrame comes from