platform/upstream/llvm.git
4 years ago[AArch64] Consider instruction-level contract FMFs in combiner patterns.
Florian Hahn [Tue, 4 Aug 2020 09:25:16 +0000 (10:25 +0100)]
[AArch64] Consider instruction-level contract FMFs in combiner patterns.

Currently, instruction level fast math flags are not considered when
generating patterns for the machine combiner.

This currently leads to some missed opportunities to generate FMAs in
combination with `#pragma clang fp contract (fast)`.

For example, when building the example below with -O3 for AArch64, no
FMADD is generated. If built with -O2 and the DAGCombiner is used
instead of the MachineCombiner for FMAs, an FMADD is generated.

With this patch, the same code is generated in both cases.

    float madd_contract(float a, float b, float c) {
    #pragma clang fp contract (fast)
      return (a * b) + c;
    }

Reviewed By: dmgreen

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

4 years ago[SCEV] Consolidate some smin/smax folding tests into single test file.
Florian Hahn [Tue, 4 Aug 2020 08:55:38 +0000 (09:55 +0100)]
[SCEV] Consolidate some smin/smax folding tests into single test file.

This patch moves a few spread out smin/smax tests to smin-smax-folds.ll
and adds additional test cases that expose further potential for
folds.

4 years agoPartially revert "[cmake] Make MSVC generate appropriate __cplusplus macro definition"
Tatyana Krasnukha [Mon, 3 Aug 2020 11:30:12 +0000 (14:30 +0300)]
Partially revert "[cmake] Make MSVC generate appropriate __cplusplus macro definition"

The /Zc:__cplusplus option fixes GTEST_LANG_CXX11 value but not GTEST_HAS_TR1_TUPLE,
so we still need to force the latter off.

Still pass the option since it is required by https://reviews.llvm.org/D78186 too.

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

4 years ago[X86][AVX] Add v8f32 'reverse' HADD(SHUFFLE,SHUFFLE) test coverage
Simon Pilgrim [Tue, 4 Aug 2020 09:16:20 +0000 (10:16 +0100)]
[X86][AVX] Add v8f32 'reverse' HADD(SHUFFLE,SHUFFLE) test coverage

Shows missed opportunity for HADD on AVX1 targets with a relatively simple lane crossing post shuffle

4 years ago[llvm-readobj] - A second attempt to fix BB.
Georgii Rymar [Tue, 4 Aug 2020 09:13:43 +0000 (12:13 +0300)]
[llvm-readobj] - A second attempt to fix BB.

The failure is:
http://lab.llvm.org:8011/builders/clang-cmake-x86_64-avx2-linux/builds/15711/steps/build%20stage%201/logs/stdio

FAILED: /usr/bin/c++  -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools/llvm-readobj -I/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj -Iinclude -I/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/include -march=broadwell -fPIC -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment -fdiagnostics-color -ffunction-sections -fdata-sections -O3     -fno-exceptions -fno-rtti -UNDEBUG -std=c++14 -MD -MT tools/llvm-readobj/CMakeFiles/llvm-readobj.dir/ELFDumper.cpp.o -MF tools/llvm-readobj/CMakeFiles/llvm-readobj.dir/ELFDumper.cpp.o.d -o tools/llvm-readobj/CMakeFiles/llvm-readobj.dir/ELFDumper.cpp.o -c /home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj/ELFDumper.cpp
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj/ELFDumper.cpp: In function ‘llvm::Expected<const llvm::object::Elf_Mips_Options<ELFT>*> readMipsOptions(const uint8_t*, llvm::ArrayRef<unsigned char>&, bool&)’:
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj/ELFDumper.cpp:3373:12: error: parse error in template argument list
     if (O->size < ExpectedSize)
            ^
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj/ELFDumper.cpp: In instantiation of ‘llvm::Expected<const llvm::object::Elf_Mips_Options<ELFT>*> readMipsOptions(const uint8_t*, llvm::ArrayRef<unsigned char>&, bool&) [with ELFT = llvm::object::ELFType<(llvm::support::endianness)0u, true>; uint8_t = unsigned char]’:
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj/ELFDumper.cpp:3400:30:   required from ‘void {anonymous}::ELFDumper<ELFT>::printMipsOptions() [with ELFT = llvm::object::ELFType<(llvm::support::endianness)0u, true>]’
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj/ELFDumper.cpp:2878:21:   required from ‘void {anonymous}::ELFDumper<ELFT>::printArchSpecificInfo() [with ELFT = llvm::object::ELFType<(llvm::support::endianness)0u, true>]’
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj/ELFDumper.cpp:6999:1:   required from here
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj/ELFDumper.cpp:3373:5: error: ‘size’ is not a member template function
     if (O->size < ExpectedSize)
     ^
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj/ELFDumper.cpp: In instantiation of ‘llvm::Expected<const llvm::object::Elf_Mips_Options<ELFT>*> readMipsOptions(const uint8_t*, llvm::ArrayRef<unsigned char>&, bool&) [with ELFT = llvm::object::ELFType<(llvm::support::endianness)1u, true>; uint8_t = unsigned char]’:
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj/ELFDumper.cpp:3400:30:   required from ‘void {anonymous}::ELFDumper<ELFT>::printMipsOptions() [with ELFT = llvm::object::ELFType<(llvm::support::endianness)1u, true>]’
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj/ELFDumper.cpp:2878:21:   required from ‘void {anonymous}::ELFDumper<ELFT>::printArchSpecificInfo() [with ELFT = llvm::object::ELFType<(llvm::support::endianness)1u, true>]’
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj/ELFDumper.cpp:6999:1:   required from here
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj/ELFDumper.cpp:3373:5: error: ‘size’ is not a member template function
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj/ELFDumper.cpp: In instantiation of ‘llvm::Expected<const llvm::object::Elf_Mips_Options<ELFT>*> readMipsOptions(const uint8_t*, llvm::ArrayRef<unsigned char>&, bool&) [with ELFT = llvm::object::ELFType<(llvm::support::endianness)0u, false>; uint8_t = unsigned char]’:
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj/ELFDumper.cpp:3400:30:   required from ‘void {anonymous}::ELFDumper<ELFT>::printMipsOptions() [with ELFT = llvm::object::ELFType<(llvm::support::endianness)0u, false>]’
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj/ELFDumper.cpp:2878:21:   required from ‘void {anonymous}::ELFDumper<ELFT>::printArchSpecificInfo() [with ELFT = llvm::object::ELFType<(llvm::support::endianness)0u, false>]’
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj/ELFDumper.cpp:6999:1:   required from here
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj/ELFDumper.cpp:3373:5: error: ‘size’ is not a member template function
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj/ELFDumper.cpp: In instantiation of ‘llvm::Expected<const llvm::object::Elf_Mips_Options<ELFT>*> readMipsOptions(const uint8_t*, llvm::ArrayRef<unsigned char>&, bool&) [with ELFT = llvm::object::ELFType<(llvm::support::endianness)1u, false>; uint8_t = unsigned char]’:
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj/ELFDumper.cpp:3400:30:   required from ‘void {anonymous}::ELFDumper<ELFT>::printMipsOptions() [with ELFT = llvm::object::ELFType<(llvm::support::endianness)1u, false>]’
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj/ELFDumper.cpp:2878:21:   required from ‘void {anonymous}::ELFDumper<ELFT>::printArchSpecificInfo() [with ELFT = llvm::object::ELFType<(llvm::support::endianness)1u, false>]’
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj/ELFDumper.cpp:6999:1:   required from here
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj/ELFDumper.cpp:3373:5: error: ‘size’ is not a member template function
ninja: build stopped: subcommand failed.

Fix: stop using `auto` for `O` variable.

4 years ago[analyzer] Model iterator random incrementation symmetrically
Endre Fülöp [Tue, 21 Jul 2020 07:31:42 +0000 (09:31 +0200)]
[analyzer] Model iterator random incrementation symmetrically

Summary:
In case a pointer iterator is incremented in a binary plus expression
(operator+), where the iterator is on the RHS, IteratorModeling should
now detect, and track the resulting value.

Reviewers: Szelethus, baloghadamsoftware

Reviewed By: baloghadamsoftware

Subscribers: rnkovacs, whisperity, xazax.hun, baloghadamsoftware, szepet, a.sidorin, mikhail.ramalho, Szelethus, donat.nagy, dkrupp, Charusso, steakhal, martong, ASDenysPetrov, cfe-commits

Tags: #clang

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

4 years ago[llvm-readobj] - An attempt to fix BB.
Georgii Rymar [Tue, 4 Aug 2020 08:56:58 +0000 (11:56 +0300)]
[llvm-readobj] - An attempt to fix BB.

http://lab.llvm.org:8011/builders/clang-cmake-x86_64-avx2-linux/builds/15710/steps/build%20stage%201/logs/stdio
fails with:

/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj/ELFDumper.cpp: In function ‘llvm::Expected<const llvm::object::Elf_Mips_Options<ELFT>*> readMipsOptions(const uint8_t*, llvm::ArrayRef<unsigned char>&, bool&)’:
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj/ELFDumper.cpp:3373:19: error: the value of ‘ExpectedSize’ is not usable in a constant expression
     if (O->size < ExpectedSize)
                   ^
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj/ELFDumper.cpp:3369:10: note: ‘size_t ExpectedSize’ is not const
   size_t ExpectedSize =
          ^
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj/ELFDumper.cpp:3373:12: error: parse error in template argument list
     if (O->size < ExpectedSize)
            ^
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj/ELFDumper.cpp: In instantiation of ‘llvm::Expected<const llvm::object::Elf_Mips_Options<ELFT>*> readMipsOptions(const uint8_t*, llvm::ArrayRef<unsigned char>&, bool&) [with ELFT = llvm::object::ELFType<(llvm::support::endianness)0u, true>; uint8_t = unsigned char]’:
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj/ELFDumper.cpp:3400:30:   required from ‘void {anonymous}::ELFDumper<ELFT>::printMipsOptions() [with ELFT = llvm::object::ELFType<(llvm::support::endianness)0u, true>]’
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj/ELFDumper.cpp:2878:21:   required from ‘void {anonymous}::ELFDumper<ELFT>::printArchSpecificInfo() [with ELFT = llvm::object::ELFType<(llvm::support::endianness)0u, true>]’
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj/ELFDumper.cpp:6999:1:   required from here
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj/ELFDumper.cpp:3373:5: error: ‘size’ is not a member template function

Fix: add 2 `const` words to variables.

4 years ago[llvm-readobj/readelf] - Refine the implementation of printMipsOptions().
Georgii Rymar [Wed, 29 Jul 2020 14:06:44 +0000 (17:06 +0300)]
[llvm-readobj/readelf] - Refine the implementation of printMipsOptions().

`printMipsOptions()` and the test related has the following issues currently:

1) It does not check the value of Elf_Mips_Options<ELFT>::size field.
2) For ODK_REGINFO options it is possible to read past the end of buffer,
   because there is no check against the `sizeof(Elf_Mips_RegInfo<ELFT>)`.
3) The error about the broken size is just printed to the standard output.
4) The binary input is used for the test.
5) There is no testing for multiple options in the .MIPS.options section,
   though the code supports it.
6) Only llvm-readobj is tested, but not llvm-readelf.
7) "Unsupported MIPS options tag" message does not reveal the tag ID/name.

This patch fixes all of these points.

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

4 years ago[DebugInfo][unittest] Use YAML to generate the .debug_loclists section.
Xing GUO [Tue, 4 Aug 2020 08:37:20 +0000 (16:37 +0800)]
[DebugInfo][unittest] Use YAML to generate the .debug_loclists section.

DWARFYAML supports generating the .debug_loclists section. We can use it
to simplify tests.

Reviewed By: jhenderson, grimar

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

4 years ago[MLIR] Add an integration test for 2 D vector.transfer_read
Nicolas Vasilache [Tue, 4 Aug 2020 08:28:11 +0000 (04:28 -0400)]
[MLIR] Add an integration test for 2 D vector.transfer_read

Added a "clone" of the 1D vector's test_transfer_read and added a second dimensionality. The test is not as generic as I would like it to be, because more generic versions appear to break the compiler or the runtime at this stage. As bug are fixed, I will be happy to add another more complete test.

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

4 years ago[clang-tidy] Fix regression in RenamerClangTidy
Nathan James [Tue, 4 Aug 2020 08:27:01 +0000 (09:27 +0100)]
[clang-tidy] Fix regression in RenamerClangTidy

See bug https://bugs.llvm.org/show_bug.cgi\?id\=46976

4 years ago[llvm-readobj] - Simplify findSectionByName(). NFCI.
Georgii Rymar [Mon, 3 Aug 2020 14:21:58 +0000 (17:21 +0300)]
[llvm-readobj] - Simplify findSectionByName(). NFCI.

It turns out that findSectionByName can return
const Elf_Shdr * instead of Expected<>, because its
code never returns an error currently (it reports warnings instead).

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

4 years ago[JumpThreading] Merge/rename thread-two-bbsN.ll tests; NFC
Juneyoung Lee [Tue, 4 Aug 2020 08:07:28 +0000 (17:07 +0900)]
[JumpThreading] Merge/rename thread-two-bbsN.ll tests; NFC

4 years ago[NFC] [PowerPC] Refactor fp/int conversion lowering
Qiu Chaofan [Tue, 4 Aug 2020 07:48:16 +0000 (15:48 +0800)]
[NFC] [PowerPC] Refactor fp/int conversion lowering

For FP_TO_INT and INT_TO_FP lowering, we have direct-move and
non-direct-move methods. But they share some conversion logic, so we can
reduce redundant code by introducing new methods.

Reviewed By: steven.zhang

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

4 years ago[JumpThreading] Don't limit the type of an operand
Juneyoung Lee [Thu, 30 Jul 2020 14:46:26 +0000 (23:46 +0900)]
[JumpThreading] Don't limit the type of an operand

Compared to the optimized code with branch conditions never frozen,
limiting the type of freeze's operand causes generation of suboptimal code in
some cases.
I would like to suggest removing the constraint, as this patch does.
If the number of freeze instructions becomes significant, this can be revisited.

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

4 years ago[mlir][Linalg] Conv ops lowering to std calls added.
Jakub Lichman [Mon, 3 Aug 2020 07:57:06 +0000 (07:57 +0000)]
[mlir][Linalg] Conv ops lowering to std calls added.

Lowering of newly defined Conv ops in TC syntax to standard
dialect is not supported and therefore this commit adds support
for it.

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

4 years ago[clang] Include trailing-requires-clause in FunctionDecl's source range
Nathan Ridge [Mon, 3 Aug 2020 07:21:01 +0000 (03:21 -0400)]
[clang] Include trailing-requires-clause in FunctionDecl's source range

Fixes https://github.com/clangd/clangd/issues/476

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

4 years ago[YAMLParser] Fix a typo: iff -> if. NFC.
Xing GUO [Tue, 4 Aug 2020 04:42:09 +0000 (12:42 +0800)]
[YAMLParser] Fix a typo: iff -> if. NFC.

4 years ago[PGO] Use multiple comdat groups for COFF
Fangrui Song [Tue, 4 Aug 2020 04:32:44 +0000 (21:32 -0700)]
[PGO] Use multiple comdat groups for COFF

D84723 caused multiple definition issues (related to comdat) on Windows:
http://lab.llvm.org:8011/builders/sanitizer-windows/builds/67465

4 years ago[X86][AVX512] Fix build fail after D81548
Wang, Pengfei [Tue, 4 Aug 2020 03:39:21 +0000 (11:39 +0800)]
[X86][AVX512] Fix build fail after D81548

Test function mask_cmp_128 failed during ISEL
LLVM ERROR: Cannot select: t37: v8i1 = X86ISD::KSHIFTL t48, TargetConstant:i8<4>
due to v8i1 only available under AVX512DQ.

Reviewed By: RKSimon

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

4 years ago[PowerPC] mark r+i as legal address mode for vector type after pwr9
Chen Zheng [Tue, 4 Aug 2020 03:46:52 +0000 (23:46 -0400)]
[PowerPC] mark r+i as legal address mode for vector type after pwr9

Reviewed By: steven.zhang

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

4 years ago[AMDGPU] Make GCNRegBankReassign assign based on subreg banks
Carl Ritson [Tue, 4 Aug 2020 03:20:12 +0000 (12:20 +0900)]
[AMDGPU] Make GCNRegBankReassign assign based on subreg banks

When scavenging consider the sub-register of the source operand
to determine the bank of a candidate register (not just sub0).
Without this it is possible to introduce an infinite loop,
e.g. $sgpr15_sgpr16_sgpr17 can be assigned for a conflict between
$sgpr0 and SGPR_96:sub1.

Reviewed By: rampitec

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

4 years agoAdd test utility 'split-file'
Fangrui Song [Mon, 3 Aug 2020 17:17:55 +0000 (10:17 -0700)]
Add test utility 'split-file'

See https://lists.llvm.org/pipermail/llvm-dev/2020-July/143373.html
"[llvm-dev] Multiple documents in one test file" for some discussions.

This patch has explored several alternatives. The current semantics are similar to
what @dblaikie proposed.
`split-file filename output` splits the input file into multiple parts separated by
regex `^(.|//)--- filename` and write each part to the file `output/filename`
(`filename` can include path separators).

Use case A (organizing input of different formats (e.g. linker
script+assembly) in one file).

```
# RUN: split-file %s %t
# RUN: llvm-mc %t/asm -o %t.o
# RUN: ld.lld -T %t/lds %t.o -o %t
This is sometimes better than the %S/Inputs/ approach because the user
can see the auxiliary files immediately and don't have to open another file.

# asm
...
# lds
...
```

Use case B (for utilities which don't have built-in input splitting
feature):

```
// RUN: split-file %s %t
// RUN: llc < %t/1.ll | FileCheck %s --check-prefix=CASE1
// RUN: llc < %t/2.ll | FileCheck %s --check-prefix=CASE2
Combing tests prudently can improve readability.
For example, when testing parsing errors if the recovery mechanism isn't possible,
grouping the tests in one file can more readily see test coverage/strategy.

//--- 1.ll
...
//--- 2.ll
...
```

Since this is a new utility, there is no git history concerns for
UpperCase variable names. I use lowerCase variable names like mlir/lld.

Reviewed By: jhenderson, lattner

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

4 years ago[PGO] Move __profc_ and __profvp_ from their own comdat groups to __profd_'s comdat...
Fangrui Song [Tue, 4 Aug 2020 03:35:50 +0000 (20:35 -0700)]
[PGO] Move __profc_ and __profvp_ from their own comdat groups to __profd_'s comdat group

D68041 placed `__profc_`,  `__profd_` and (if exists) `__profvp_` in different comdat groups.
There are some issues:

* Cost: one or two additional section headers (`.group` section(s)): 64 or 128 bytes on ELF64.
* `__profc_`,  `__profd_` and (if exists) `__profvp_` should be retained or
  discarded. Placing them into separate comdat groups is conceptually inferior.
* If the prevailing group does not include `__profvp_` (value profiling not
  used) but a non-prevailing group from another translation unit has `__profvp_`
  (the function is inlined into another and triggers value profiling), there
  will be a stray `__profvp_` if --gc-sections is not enabled.
  This has been fixed by 3d6f53018f845e893ad34f64ff2851a2e5c3ba1d.

Actually, we can reuse an existing symbol (we choose `__profd_`) as the group
signature to avoid a string in the string table (the sole reason that D68041
could improve code size is that `__profv_` was an otherwise unused symbol which
wasted string table space). This saves one or two section headers.

For a -DCMAKE_BUILD_TYPE=Release -DLLVM_BUILD_INSTRUMENTED=IR build, `ninja
clang lld`, the patch has saved 10.5MiB (2.2%) for the total .o size.

Reviewed By: davidxl

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

4 years ago[SimpleLoopUnswitch][NFC] Add option to always drop make.implicit metadata in non...
Max Kazantsev [Tue, 4 Aug 2020 03:16:40 +0000 (10:16 +0700)]
[SimpleLoopUnswitch][NFC] Add option to always drop make.implicit metadata in non-trivial unswitching and save compile time

We might want this if we find out that using of MustExecute analysis is too expensive.
By default we do the analysis because its complexity does not exceed the complexity
of whole loop copying in unswitching. Follow-up for D84925.

Differential Revision: https://reviews.llvm.org/D85001
Reviewed By: asbirlea

4 years ago[lldb/Test] Fix skipTestIfFn for fucntions that return a value
Jonas Devlieghere [Tue, 4 Aug 2020 02:56:10 +0000 (19:56 -0700)]
[lldb/Test] Fix skipTestIfFn for fucntions that return a value

Sometimes the decorator is used on a common function rather than the
test method, which can return a value. This fails with decorators that
use skipTestIfFn under the hood.

4 years agoTemporarily revert "[test] Exit with an error if no tests are run."
Jordan Rupprecht [Tue, 4 Aug 2020 01:37:50 +0000 (18:37 -0700)]
Temporarily revert "[test] Exit with an error if no tests are run."

This reverts commit adb5c23f8c0d60eeec41dcbe21d1b26184e1c97d. It surprisingly fails on a windows build bot: http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/18009

Will reland after some investigation and/or after adding some extra logging to help debug the issue.

4 years ago[SCEVExpander][PowerPC]clear scev rewriter before deleting instructions.
Chen Zheng [Mon, 3 Aug 2020 12:37:52 +0000 (08:37 -0400)]
[SCEVExpander][PowerPC]clear scev rewriter before deleting instructions.

Reviewed By: lebedev.ri
Differential Revision: https://reviews.llvm.org/D85130

4 years ago[flang] Implement runtime support for INQUIRE statements
peter klausler [Mon, 3 Aug 2020 18:35:29 +0000 (11:35 -0700)]
[flang] Implement runtime support for INQUIRE statements

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

4 years ago[Attributor][NFC] Clang format
Shinji Okumura [Mon, 3 Aug 2020 23:59:23 +0000 (08:59 +0900)]
[Attributor][NFC] Clang format

4 years agoOpenMP: Fix typo variabls -> variables
David Blaikie [Mon, 3 Aug 2020 23:37:25 +0000 (16:37 -0700)]
OpenMP: Fix typo variabls -> variables

4 years ago[ELF] Add --dependency-file option
Petr Hosek [Wed, 24 Jun 2020 03:00:04 +0000 (20:00 -0700)]
[ELF] Add --dependency-file option

Clang and GCC have a feature (-MD flag) to create a dependency file
in a format that build systems such as Make or Ninja can read, which
specifies all the additional inputs such .h files.

This change introduces the same functionality to lld bringing it to
feature parity with ld and gold which gained this feature recently.
See https://sourceware.org/bugzilla/show_bug.cgi?id=22843 for more
details and discussion.

The implementation corresponds to -MD -MP compiler flag where the
generated dependency file also includes phony targets which works
around the errors where the dependency is removed. This matches the
format used by ld and gold.

Fixes PR42806

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

4 years agoFix use-after-scope in 7209f83112db caught by the sanitizer bots
Daniel Sanders [Mon, 3 Aug 2020 23:53:41 +0000 (16:53 -0700)]
Fix use-after-scope in 7209f83112db caught by the sanitizer bots

4 years ago[flang] Defer "next input record" processing until handlers established
peter klausler [Mon, 3 Aug 2020 18:31:13 +0000 (11:31 -0700)]
[flang] Defer "next input record" processing until handlers established

External input was detecting "end of file" conditions in
BeginExternal...Input() and BeginUnformattedInput() routines
before EnableHandlers() could have been called.  Defer the
"start next record" processing to the input data item
handlers (and EndIoStatement() for when there are no data
items).

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

4 years ago[flang] Acquire file accessibility, size, positioning
peter klausler [Mon, 3 Aug 2020 18:29:15 +0000 (11:29 -0700)]
[flang] Acquire file accessibility, size, positioning

Extend the raw file wrapper to get accessibility, positioning,
and size information.  This is needed for INQUIRE (to follow).

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

4 years ago[SVE] Remove bad calls to VectorType::getNumElements() from X86
Christopher Tetreault [Mon, 3 Aug 2020 23:15:45 +0000 (16:15 -0700)]
[SVE] Remove bad calls to VectorType::getNumElements() from X86

Reviewed By: RKSimon

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

4 years ago[test] Exit with an error if no tests are run.
Jordan Rupprecht [Mon, 3 Aug 2020 23:30:41 +0000 (16:30 -0700)]
[test] Exit with an error if no tests are run.

If the test suite is misconfigured when it's run (a bad regexp, wrong test directory, etc.), the test suite may not discover any tests. When this happens, the test runner exits happily because no tests failed:

```
Ran 0 tests in 0.000s
RESULT: PASSED (0 passes, 0 failures, 0 errors, 0 skipped, 0 expected failures, 0 unexpected successes)
```

Change this to return an error so the misconfiguration can be more easily detected. Verified that `lldb-dotest -p TestDoesNotExist.py` successfully fails.

Reviewed By: JDevlieghere

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

4 years ago[clang-tidy][NFC] Use correct size call for reserve
Nathan James [Mon, 3 Aug 2020 23:31:19 +0000 (00:31 +0100)]
[clang-tidy][NFC] Use correct size call for reserve

4 years agoRemove unneeded RoundDefault enumerator, and fix spelling in comments
peter klausler [Mon, 3 Aug 2020 18:11:39 +0000 (11:11 -0700)]
Remove unneeded RoundDefault enumerator, and fix spelling in comments

4 years ago[flang] Handle spaces (more) correctly in REAL input
peter klausler [Mon, 3 Aug 2020 18:20:35 +0000 (11:20 -0700)]
[flang] Handle spaces (more) correctly in REAL input

Fixes problems in FCVS test fm110.f.
Add more comments, too.

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

4 years ago[MC] Fix memory leak when allocating MCInst with bump allocator
hgreving [Wed, 29 Jul 2020 23:48:03 +0000 (16:48 -0700)]
[MC] Fix memory leak when allocating MCInst with bump allocator

Adds the function createMCInst() to MCContext that creates a MCInst using
a typed bump alloctor.

MCInst contains a SmallVector<MCOperand, 8>. The SmallVector is POD only
for <= 8 operands. The default untyped bump pointer allocator of MCContext
does not delete the MCInst, so if the SmallVector grows, it's a leak.

This fixes https://bugs.llvm.org/show_bug.cgi?id=46900.

4 years ago[VE] Extend integer arguments and return values smaller than 64 bits
Kazushi (Jam) Marukawa [Sat, 25 Jul 2020 07:31:07 +0000 (16:31 +0900)]
[VE] Extend integer arguments and return values smaller than 64 bits

In order to follow NEC Aurora SX VE ABI correctly, change to sign/zero
extend integer arguments and return values smaller than 64 bits in clang.
Also update regression test.

Reviewed By: simoll

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

4 years ago[SVE] Remove bad call to VectorType::getNumElements() from AMDGPU
Christopher Tetreault [Mon, 3 Aug 2020 22:42:13 +0000 (15:42 -0700)]
[SVE] Remove bad call to VectorType::getNumElements() from AMDGPU

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

4 years ago[SVE] Remove bad call to VectorType::getNumElements() from ARM
Christopher Tetreault [Mon, 3 Aug 2020 22:16:16 +0000 (15:16 -0700)]
[SVE] Remove bad call to VectorType::getNumElements() from ARM

Reviewed By: dmgreen

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

4 years ago[UBSan] Increase robustness of tests
Julian Lettner [Mon, 3 Aug 2020 20:21:08 +0000 (13:21 -0700)]
[UBSan] Increase robustness of tests

These UBSan tests assert the absence of runtime errors via `count 0`,
which means "expect no output".  This fails the test unnecessarily in
some environments (e.g., iOS simulator in our case).  Alter the test to
be a bit more specific and "expect no error" instead of "expect no
output".

rdar://65503408

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

4 years ago[NFC][ARM] Silence unused variable in release builds
Jordan Rupprecht [Mon, 3 Aug 2020 22:21:44 +0000 (15:21 -0700)]
[NFC][ARM] Silence unused variable in release builds

4 years ago[SVE] Remove bad calls to VectorType::getNumElements() from PowerPC
Christopher Tetreault [Mon, 3 Aug 2020 20:35:49 +0000 (13:35 -0700)]
[SVE] Remove bad calls to VectorType::getNumElements() from PowerPC

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

4 years agoReland D61689 Change -gz and -Wa,--compress-debug-sections to use gABI compression...
Fangrui Song [Mon, 3 Aug 2020 22:11:28 +0000 (15:11 -0700)]
Reland D61689 Change -gz and -Wa,--compress-debug-sections to use gABI compression (SHF_COMPRESSED) with integrated assembler

This fixes an inconsistency: clang -c -gz -fno-integrated-as means SHF_COMPRESSED
while clang -c -gz -fintegrated-as means zlib-gnu.

---

Since July 15, 2015 (binutils-gdb commit
19a7fe52ae3d0971e67a134bcb1648899e21ae1c, included in 2.26), gas
--compress-debug-sections=zlib (gcc -gz) means zlib-gabi:
SHF_COMPRESSED. Before that GCC/binutils used zlib-gnu (.zdebug).

clang's -gz was introduced in rC306115 (Jun 2017) to indicate zlib-gnu. It
is 2020 now and it is not unreasonable to assume users of the new
feature to have new linkers (ld.bfd/gold >= 2.26, lld >= rLLD273661).

Change clang's default accordingly to improve standard conformance.
zlib-gnu becomes out of fashion and gets poorer toolchain support.
Its mangled names confuse tools and are more likely to cause problems.

Reviewed By: compnerd

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

4 years ago[flang] Make preprocessing behavior tests runnable as regression tests
peter klausler [Mon, 3 Aug 2020 17:50:42 +0000 (10:50 -0700)]
[flang] Make preprocessing behavior tests runnable as regression tests

And fix a minor bug exposed by doing so.

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

4 years ago[MemorySSA] Restrict optimizations after a PhiTranslation.
Alina Sbirlea [Thu, 25 Jun 2020 23:50:15 +0000 (16:50 -0700)]
[MemorySSA] Restrict optimizations after a PhiTranslation.

Merging alias results from different paths, when a path did phi
translation is not necesarily correct. Conservatively terminate such paths.
Aimed to fix PR46156.

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

4 years ago[mlir][OpFormatGen] Add support for eliding UnitAttr when used to anchor an optional...
River Riddle [Mon, 3 Aug 2020 21:20:50 +0000 (14:20 -0700)]
[mlir][OpFormatGen] Add support for eliding UnitAttr when used to anchor an optional group

Unit attributes are given meaning by their existence, and thus have no meaningful value beyond "is it present". As such, in the format of an operation unit attributes are generally used to guard the printing of other elements and aren't generally printed themselves; as the presence of the group when parsing means that the unit attribute should be added. This revision adds support to the declarative format for eliding unit attributes in situations where they anchor an optional group, but aren't the first element.

For example,
```
let assemblyFormat = "(`is_optional` $unit_attr^)? attr-dict";
```

would print `foo.op is_optional` when $unit_attr is present, instead of the current `foo.op is_optional unit`.

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

4 years ago[HWASan] [GlobalISel] Add +tagged-globals backend feature for GlobalISel
Mitch Phillips [Mon, 3 Aug 2020 20:55:27 +0000 (13:55 -0700)]
[HWASan] [GlobalISel] Add +tagged-globals backend feature for GlobalISel

GlobalISel is the default ISel for aarch64 at -O0. Prior to D78465, GlobalISel
didn't have support for dealing with address-of-global lowerings, so it fell
back to SelectionDAGISel.

HWASan Globals require special handling, as they contain the pointer tag in the
top 16-bits, and are thus outside the code model. We need to generate a `movk`
in the instruction sequence with a G3 relocation to ensure the bits are
relocated properly. This is implemented in SelectionDAGISel, this patch does
the same for GlobalISel.

GlobalISel and SelectionDAGISel differ in their lowering sequence, so there are
differences in the final instruction sequence, explained in
`tagged-globals.ll`. Both of these implementations are correct, but GlobalISel
is slightly larger code size / slightly slower (by a couple of arithmetic
instructions). I don't see this as a problem for now as GlobalISel is only on
by default at `-O0`.

Reviewed By: aemerson, arsenm

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

4 years ago[ARM] Convert VPSEL to VMOV in tail predicated loops
David Green [Mon, 3 Aug 2020 21:03:14 +0000 (22:03 +0100)]
[ARM] Convert VPSEL to VMOV in tail predicated loops

VPSEL has slightly different semantics under tail predication (it can
end up selecting from Qn, Qm and Qd). We do not model that at the moment
so they block tail predicated loops from being formed.

This just converts them into a predicated VMOV instead (via a VORR),
allowing tail predication to happen whilst still modelling the original
behaviour of the input.

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

4 years ago[WebAssembly] Implement prototype v128.load{32,64}_zero instructions
Thomas Lively [Mon, 3 Aug 2020 20:54:00 +0000 (13:54 -0700)]
[WebAssembly] Implement prototype v128.load{32,64}_zero instructions

Specified in https://github.com/WebAssembly/simd/pull/237, these
instructions load the first vector lane from memory and zero the other
lanes. Since these instructions are not officially part of the SIMD
proposal, they are only available on an opt-in basis via LLVM
intrinsics and clang builtin functions. If these instructions are
merged to the proposal, this implementation will change so that the
instructions will be generated from normal IR. At that point the
intrinsics and builtin functions would be removed.

This PR also changes the opcodes for the experimental f32x4.qfm{a,s}
instructions because their opcodes conflicted with those of the
v128.load{32,64}_zero instructions. The new opcodes were chosen to
match those used in V8.

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

4 years agoRevert "[X86][SSE] Shuffle combine blends to OR(X,Y) if the relevant elements are...
Mitch Phillips [Mon, 3 Aug 2020 20:48:30 +0000 (13:48 -0700)]
Revert "[X86][SSE] Shuffle combine blends to OR(X,Y) if the relevant elements are known zero."

This reverts commit 219f32f4b68679563443cdaae7b8174c9976409a.

Commit contains unsigned compasions that break bots that build with
-Wsign-compare.

4 years ago[ARM] Test for converting VPSEL to VMOVT. NFC
David Green [Mon, 3 Aug 2020 20:46:07 +0000 (21:46 +0100)]
[ARM] Test for converting VPSEL to VMOVT. NFC

4 years ago[MC] Set sh_link to 0 if the associated symbol is undefined
Fangrui Song [Mon, 3 Aug 2020 20:35:59 +0000 (13:35 -0700)]
[MC] Set sh_link to 0 if the associated symbol is undefined

Part of https://bugs.llvm.org/show_bug.cgi?id=41734

LTO can drop externally available definitions. Such AssociatedSymbol is
not associated with a symbol. ELFWriter::writeSection() will assert.

Allow a SHF_LINK_ORDER section to have sh_link=0.

We need to give sh_link a syntax, a literal zero in the linked-to symbol
position, e.g. `.section name,"ao",@progbits,0`

Reviewed By: pcc

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

4 years ago[CodeGen][ObjC] Mark calls to objc_unsafeClaimAutoreleasedReturnValue as
Akira Hatanaka [Mon, 3 Aug 2020 20:25:25 +0000 (13:25 -0700)]
[CodeGen][ObjC] Mark calls to objc_unsafeClaimAutoreleasedReturnValue as
notail on x86-64

This is needed because the epilogue code inserted before tail calls on
x86-64 breaks the handshake between the caller and callee.

Calls to objc_retainAutoreleasedReturnValue used to have the same
problem, which was fixed in https://reviews.llvm.org/D59656.

rdar://problem/66029552

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

4 years agoAllow .dSYM's to be directly placed in an alternate directory
Daniel Sanders [Mon, 3 Aug 2020 19:46:49 +0000 (12:46 -0700)]
Allow .dSYM's to be directly placed in an alternate directory

Once available in the relevant toolchains this will allow us to implement
LLVM_EXTERNALIZE_DEBUGINFO_OUTPUT_DIR after D84127 by directly placing the dSYM
in the desired location instead of emitting next to the output file and moving
it.

Reviewed By: JDevlieghere

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

4 years agoFix typo: s/epomymous/eponymous/ NFC
Jon Roelofs [Mon, 3 Aug 2020 20:09:46 +0000 (14:09 -0600)]
Fix typo: s/epomymous/eponymous/ NFC

4 years ago[AArch64] Add missing isel patterns for fcvtzs/u intrinsic on v1f64.
Eli Friedman [Mon, 3 Aug 2020 19:29:40 +0000 (12:29 -0700)]
[AArch64] Add missing isel patterns for fcvtzs/u intrinsic on v1f64.

Fixes test-suite compile failure caused by 8dfb5d7.

While I'm in the area, add some more test coverage to related
operations, to make sure we aren't missing any other patterns.

4 years ago[llvm-jitlink] Add support for static archives and MachO universal archives.
Lang Hames [Mon, 3 Aug 2020 18:55:57 +0000 (11:55 -0700)]
[llvm-jitlink] Add support for static archives and MachO universal archives.

Archives can now be specified as input files the same way that object
files are. Archives will always be linked after all objects (regardless
of the relative order of the inputs) but before any dynamic libraries or
process symbols.

This patch also relaxes matching for slice triples in
StaticLibraryDefinitionGenerator in order to support this feature:
Vendors need not match if the source vendor is unknown.

4 years ago[PGO] Enable the extended value profile buckets for mem op sizes.
Hiroshi Yamauchi [Mon, 3 Aug 2020 18:37:22 +0000 (11:37 -0700)]
[PGO] Enable the extended value profile buckets for mem op sizes.

Following up D81682 and enable the new, extended value profile buckets for mem
op sizes.

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

4 years ago[flang] Fix bug detecting intrinsic function
Tim Keith [Mon, 3 Aug 2020 19:21:57 +0000 (12:21 -0700)]
[flang] Fix bug detecting intrinsic function

Don't set the INTRINSIC attribute on a dummy procedure.

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

4 years ago[InstSimplify] fold variations of max-of-min with common operand
Sanjay Patel [Mon, 3 Aug 2020 18:02:09 +0000 (14:02 -0400)]
[InstSimplify] fold variations of max-of-min with common operand

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

4 years ago[InstSimplify] add tests for min-of-max variants; NFC
Sanjay Patel [Mon, 3 Aug 2020 17:50:54 +0000 (13:50 -0400)]
[InstSimplify] add tests for min-of-max variants; NFC

4 years agoFix layering violation Transforms/Utils -> Scalar
Arthur Eubanks [Mon, 3 Aug 2020 18:50:07 +0000 (11:50 -0700)]
Fix layering violation Transforms/Utils -> Scalar

Introduced in D85063.

4 years ago[X86] support .nops directive
Jian Cai [Fri, 31 Jul 2020 01:33:33 +0000 (18:33 -0700)]
[X86] support .nops directive

Add support of .nops on X86. This addresses llvm.org/PR45788.

Reviewed By: craig.topper

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

4 years ago[ArgPromotion] Replace all md uses of promoted values with undef.
Florian Hahn [Mon, 3 Aug 2020 18:18:13 +0000 (19:18 +0100)]
[ArgPromotion] Replace all md uses of promoted values with undef.

Currently, ArgPromotion may leave metadata uses of promoted values,
which will end up in the wrong function, creating invalid IR.

PR33641 fixed this for dead arguments, but it can be also be triggered
arguments with users that are promoted (see the updated test case).

We also have to drop uses to them after promoting them. We need to do
this after dealing with the non-metadata uses, so I also moved the empty
use case to the loop that deals with updating the arguments of the new
function.

Reviewed By: aprantl

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

4 years ago[gn build] Port f78f509c758
LLVM GN Syncbot [Mon, 3 Aug 2020 18:05:15 +0000 (18:05 +0000)]
[gn build] Port f78f509c758

4 years ago[PGO] Extend the value profile buckets for mem op sizes.
Hiroshi Yamauchi [Mon, 3 Aug 2020 17:35:47 +0000 (10:35 -0700)]
[PGO] Extend the value profile buckets for mem op sizes.

Extend the memop value profile buckets to be more flexible (could accommodate a
mix of individual values and ranges) and to cover more value ranges (from 11 to
22 buckets).

Disabled behind a flag (to be enabled separately) and the existing code to be
removed later.

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

4 years ago[compiler-rt][profile] Fix various InstrProf tests on Solaris
Rainer Orth [Mon, 3 Aug 2020 17:56:05 +0000 (19:56 +0200)]
[compiler-rt][profile] Fix various InstrProf tests on Solaris

Currently, several InstrProf tests `FAIL` on Solaris (both sparc and x86):

  Profile-i386 :: Posix/instrprof-visibility.cpp
  Profile-i386 :: instrprof-merging.cpp
  Profile-i386 :: instrprof-set-file-object-merging.c
  Profile-i386 :: instrprof-set-file-object.c

On sparc there's also

  Profile-sparc :: coverage_comments.cpp

The failure mode is always the same:

  error: /var/llvm/local-amd64/projects/compiler-rt/test/profile/Profile-i386/Posix/Output/instrprof-visibility.cpp.tmp: Failed to load coverage: Malformed coverage data

The error is from `llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp`
(`loadBinaryFormat`), l.926:

  InstrProfSymtab ProfileNames;
  std::vector<SectionRef> NamesSectionRefs = *NamesSection;
  if (NamesSectionRefs.size() != 1)
    return make_error<CoverageMapError>(coveragemap_error::malformed);

where .size() is 2 instead.

Looking at the executable, I find (with `elfdump -c -N __llvm_prf_names`):

  Section Header[15]:  sh_name: __llvm_prf_names
      sh_addr:      0x8053ca5       sh_flags:   [ SHF_ALLOC ]
      sh_size:      0x86            sh_type:    [ SHT_PROGBITS ]
      sh_offset:    0x3ca5          sh_entsize: 0
      sh_link:      0               sh_info:    0
      sh_addralign: 0x1

  Section Header[31]:  sh_name: __llvm_prf_names
      sh_addr:      0x8069998       sh_flags:   [ SHF_WRITE SHF_ALLOC ]
      sh_size:      0               sh_type:    [ SHT_PROGBITS ]
      sh_offset:    0x9998          sh_entsize: 0
      sh_link:      0               sh_info:    0
      sh_addralign: 0x1

Unlike GNU `ld` (which primarily operates on section names) the Solaris
linker, following the ELF spirit, only merges input sections into an output
section if both section name and section flags match, so two separate
sections are maintained.

The read-write one comes from `lib/clang/12.0.0/lib/sunos/libclang_rt.profile-i386.a(InstrProfilingPlatformLinux.c.o)`
while the read-only one is generated by
`llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp` (`InstrProfiling::emitNameData`)
at l.1004 where `isConstant = true`.

The easiest way to avoid the mismatch is to change the definition in
`compiler-rt/lib/profile/InstrProfilingPlatformLinux.c` to `const`.

This fixes all failures observed.

Tested on `amd64-pc-solaris2.11`, `sparcv9-sun-solaris2.11`, and
`x86_64-pc-linux-gnu`.

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

4 years ago[X86] Make ENDBR instruction a scheduling boundary
Joao Moreira [Mon, 3 Aug 2020 17:26:31 +0000 (10:26 -0700)]
[X86] Make ENDBR instruction a scheduling boundary

Instructions should not be scheduled across ENDBR instructions, as this would result in the ENDBR being displaced, breaking the parity needed for the Indirect Branch Tracking feature of CET.

Currently, the X86IndirectBranchTracking pass is later than the instruction scheduling in the pipeline, what causes the bug to be unnoticeable and very hard (if not unfeasible) to be triggered while compiling C files with the standard LLVM setup. Yet, for correctness and to prevent issues in future changes, the compiler should prevent the such scheduling.

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

4 years ago[X86][SSE] Shuffle combine blends to OR(X,Y) if the relevant elements are known zero.
Simon Pilgrim [Mon, 3 Aug 2020 16:53:32 +0000 (17:53 +0100)]
[X86][SSE] Shuffle combine blends to OR(X,Y) if the relevant elements are known zero.

This allows us to remove the (depth violating) code in getFauxShuffleMask where we were combining the OR(SHUFFLE,SHUFFLE) shuffle inputs as well, and not just the OR().

This is a minor step toward being able to shuffle combine from/to SELECT/BLENDV as a faux shuffle.

4 years ago[NewPM][LoopVersioning] Port LoopVersioning to NPM
Arthur Eubanks [Sat, 1 Aug 2020 00:30:30 +0000 (17:30 -0700)]
[NewPM][LoopVersioning] Port LoopVersioning to NPM

Reviewed By: ychen, fhahn

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

4 years ago[FPEnv] IRBuilder fails to add strictfp attribute
Kevin P. Neal [Wed, 29 Jul 2020 14:33:01 +0000 (10:33 -0400)]
[FPEnv] IRBuilder fails to add strictfp attribute

The strictfp attribute is required on all function calls in a function
that is itself marked with the strictfp attribute. The IRBuilder knows
this and has a method for adding the attribute to function call instructions.

If a function being called has the strictfp attribute itself then the
IRBuilder will refuse to add the attribute to the calling instruction
despite being asked to add it. Eliminate this error.

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

4 years ago[PGO] Change a `NumVSites == 0` workaround to assert
Fangrui Song [Mon, 3 Aug 2020 17:09:51 +0000 (10:09 -0700)]
[PGO] Change a `NumVSites == 0` workaround to assert

The root cause was fixed by 3d6f53018f845e893ad34f64ff2851a2e5c3ba1d.
The workaround added in 99ad956fdaee5398fdcf46fa49cb433cf52dc461 can be changed
to an assert now. (In case the fix regresses, there will be a heap-use-after-free.)

4 years ago[X86] Use h-register for final XOR of __builtin_parity on 64-bit targets.
Craig Topper [Mon, 3 Aug 2020 17:09:57 +0000 (10:09 -0700)]
[X86] Use h-register for final XOR of __builtin_parity on 64-bit targets.

This adds an isel pattern and special XOR8rr_NOREX instruction
to enable the use of h-registers for __builtin_parity. This avoids
a copy and a shift instruction. The NOREX instruction is in case
register allocation doesn't use the matching l-register for some
reason. If a R8-R15 register gets picked instead, we won't be
able to encode the instruction since an h-register can't be used
with a REX prefix.

Fixes PR46954

4 years ago[mlir][DialectConversion] Remove usage of std::distance to track position.
MaheshRavishankar [Mon, 3 Aug 2020 17:04:48 +0000 (10:04 -0700)]
[mlir][DialectConversion] Remove usage of std::distance to track position.

Remove use of iterator::difference_type to know where to insert a
moved or erased block during undo actions.

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

4 years ago[mlir][DialectConversion] Add support for mergeBlocks in ConversionPatternRewriter.
MaheshRavishankar [Mon, 3 Aug 2020 17:04:16 +0000 (10:04 -0700)]
[mlir][DialectConversion] Add support for mergeBlocks in ConversionPatternRewriter.

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

4 years ago[mlir][Vector] Add transformation + pattern to split vector.transfer_read into full...
Nicolas Vasilache [Mon, 3 Aug 2020 16:24:53 +0000 (12:24 -0400)]
[mlir][Vector] Add transformation + pattern to split vector.transfer_read into full and partial copies.

This revision adds a transformation and a pattern that rewrites a "maybe masked" `vector.transfer_read %view[...], %pad `into a pattern resembling:

```
   %1:3 = scf.if (%inBounds) {
      scf.yield %view : memref<A...>, index, index
    } else {
      %2 = vector.transfer_read %view[...], %pad : memref<A...>, vector<...>
      %3 = vector.type_cast %extra_alloc : memref<...> to
      memref<vector<...>> store %2, %3[] : memref<vector<...>> %4 =
      memref_cast %extra_alloc: memref<B...> to memref<A...> scf.yield %4 :
      memref<A...>, index, index
   }
   %res= vector.transfer_read %1#0[%1#1, %1#2] {masked = [false ... false]}
```
where `extra_alloc` is a top of the function alloca'ed buffer of one vector.

This rewrite makes it possible to realize the "always full tile" abstraction where vector.transfer_read operations are guaranteed to read from a padded full buffer.
The extra work only occurs on the boundary tiles.

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

4 years ago[llvm] Add a parser from JSON to TensorSpec
Mircea Trofin [Thu, 30 Jul 2020 19:44:07 +0000 (12:44 -0700)]
[llvm] Add a parser from JSON to TensorSpec

A JSON->TensorSpec utility we will use subsequently to specify
additional outputs needed for certain training scenarios.

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

4 years ago[Utils] Add noundef attribute to vim/emacs/vscode syntax scripts
Gui Andrade [Mon, 3 Aug 2020 16:45:35 +0000 (16:45 +0000)]
[Utils] Add noundef attribute to vim/emacs/vscode syntax scripts

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

4 years ago[MSAN] Instrument freeze instruction by clearing shadow
Gui Andrade [Fri, 31 Jul 2020 18:53:15 +0000 (18:53 +0000)]
[MSAN] Instrument freeze instruction by clearing shadow

Freeze always returns a defined value. This also prevents msan from
checking the input shadow, which happened because freeze wasn't
explicitly visited.

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

4 years ago[SCEV] If Start>=RHS, simplify (Start smin RHS) = RHS for trip counts.
Florian Hahn [Mon, 3 Aug 2020 15:19:06 +0000 (16:19 +0100)]
[SCEV] If Start>=RHS, simplify (Start smin RHS) = RHS for trip counts.

In some cases, it seems like we can get rid of unnecessary s/umins by
using information from the loop guards (unless I am missing something).

One place where this seems to be helpful in practice is when computing
loop trip counts. This patch just changes howManyGreaterThans for now.
Note that this requires a loop for which we can check 'is guarded'.

On SPEC2000/SPEC2006/MultiSource, there are some notable changes for
some programs in the number of loops unrolled and trip counts computed.

```
Same hash: 179 (filtered out)
Remaining: 58
Metric: scalar-evolution.NumTripCountsComputed

Program                                        base    patch   diff
 test-suite...langs-C/compiler/compiler.test    25.00   31.00  24.0%
 test-suite.../Applications/SPASS/SPASS.test   2020.00 2323.00 15.0%
 test-suite...langs-C/allroots/allroots.test    29.00   32.00  10.3%
 test-suite.../Prolangs-C/loader/loader.test    17.00   18.00   5.9%
 test-suite...fice-ispell/office-ispell.test   253.00  265.00   4.7%
 test-suite...006/450.soplex/450.soplex.test   3552.00 3692.00  3.9%
 test-suite...chmarks/MallocBench/gs/gs.test   453.00  470.00   3.8%
 test-suite...ngs-C/assembler/assembler.test    29.00   30.00   3.4%
 test-suite.../Benchmarks/Ptrdist/bc/bc.test   263.00  270.00   2.7%
 test-suite...rks/FreeBench/pifft/pifft.test   722.00  741.00   2.6%
 test-suite...count/automotive-bitcount.test    41.00   42.00   2.4%
 test-suite...0/253.perlbmk/253.perlbmk.test   1417.00 1451.00  2.4%
 test-suite...000/197.parser/197.parser.test   387.00  396.00   2.3%
 test-suite...lications/sqlite3/sqlite3.test   1168.00 1189.00  1.8%
 test-suite...000/255.vortex/255.vortex.test   173.00  176.00   1.7%

Metric: loop-unroll.NumUnrolled

Program                                        base   patch  diff
 test-suite...langs-C/compiler/compiler.test     1.00   3.00 200.0%
 test-suite.../Applications/SPASS/SPASS.test   134.00 234.00 74.6%
 test-suite...count/automotive-bitcount.test     3.00   4.00 33.3%
 test-suite.../Prolangs-C/loader/loader.test     3.00   4.00 33.3%
 test-suite...langs-C/allroots/allroots.test     3.00   4.00 33.3%
 test-suite...Source/Benchmarks/sim/sim.test    10.00  12.00 20.0%
 test-suite...fice-ispell/office-ispell.test    21.00  25.00 19.0%
 test-suite.../Benchmarks/Ptrdist/bc/bc.test    32.00  38.00 18.8%
 test-suite...006/450.soplex/450.soplex.test   300.00 352.00 17.3%
 test-suite...rks/FreeBench/pifft/pifft.test    60.00  69.00 15.0%
 test-suite...chmarks/MallocBench/gs/gs.test    57.00  63.00 10.5%
 test-suite...ngs-C/assembler/assembler.test    10.00  11.00 10.0%
 test-suite...0/253.perlbmk/253.perlbmk.test   145.00 157.00  8.3%
 test-suite...000/197.parser/197.parser.test    43.00  46.00  7.0%
 test-suite...TimberWolfMC/timberwolfmc.test   205.00 214.00  4.4%
 Geomean difference                                           7.6%
```

Fixes https://bugs.llvm.org/show_bug.cgi?id=46939
Fixes https://bugs.llvm.org/show_bug.cgi?id=46924 on X86.

Reviewed By: mkazantsev

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

4 years agoRevert "[mlir][Vector] Add transformation + pattern to split vector.transfer_read...
Mehdi Amini [Mon, 3 Aug 2020 16:16:47 +0000 (16:16 +0000)]
Revert "[mlir][Vector] Add transformation + pattern to split vector.transfer_read into full and partial copies."

This reverts commit 35b65be041127db9fe23d3128a004c888893cbae.

Build is broken with -DBUILD_SHARED_LIBS=ON with some undefined
references like:

VectorTransforms.cpp:(.text._ZN4llvm12function_refIFvllEE11callback_fnIZL24createScopedInBoundsCondN4mlir25VectorTransferOpInterfaceEE3$_8EEvlll+0xa5): undefined reference to `mlir::edsc::op::operator+(mlir::Value, mlir::Value)'

4 years ago[FPEnv] Don't transform FSUB(-0,X)->FNEG(X) in SelectionDAGBuilder.
Cameron McInally [Mon, 3 Aug 2020 15:19:33 +0000 (10:19 -0500)]
[FPEnv] Don't transform FSUB(-0,X)->FNEG(X) in SelectionDAGBuilder.

This patch stops unconditionally transforming FSUB(-0,X) into an FNEG(X) while building the DAG. There is also one small change to handle the new FSUB(-0,X) similarly to FNEG(X) in the AMDGPU backend.

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

4 years ago[analyzer][tests] Fix SATest update functionality
Valeriy Savchenko [Wed, 22 Jul 2020 10:36:13 +0000 (13:36 +0300)]
[analyzer][tests] Fix SATest update functionality

Summary:
Not all projects in the project map file might have newer results
for updating, we should handle this situation gracefully.

Additionally, not every user of the test system would want storing
reference results in git.  For this reason, git functionality is now
optional.

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

4 years ago[DWARFYAML] Implement the .debug_loclists section.
Xing GUO [Mon, 3 Aug 2020 15:19:42 +0000 (23:19 +0800)]
[DWARFYAML] Implement the .debug_loclists section.

This patch implements the .debug_loclists section. There are only two
DWARF expressions are implemented in this patch (DW_OP_consts,
DW_OP_stack_value). We will implement more in the future.

The YAML description of the .debug_loclists section is:

```
debug_loclists:
  - Format:              DWARF32 ## Optional
    Length:              0x1234  ## Optional
    Version:             5       ## Optional (5 by default)
    AddressSize:         8       ## Optional
    SegmentSelectorSize: 0       ## Optional (0 by default)
    OffsetEntryCount:    1       ## Optional
    Offsets:             [ 1 ]   ## Optional
    Lists:
      - Entries:
          - Operator:          DW_LLE_startx_endx
            Values:            [ 0x1234, 0x4321 ]
            DescriptorsLength: 0x1234             ## Optional
            Descriptors:
              - Operator: DW_OP_consts
                Values:   [ 0x1234 ]
```

Reviewed By: jhenderson

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

4 years ago[NFC][APInt][DenseMapInfo] Move DenseMapAPIntKeyInfo into DenseMap.h as DenseMapInfo...
Shinji Okumura [Mon, 3 Aug 2020 14:31:13 +0000 (23:31 +0900)]
[NFC][APInt][DenseMapInfo] Move DenseMapAPIntKeyInfo into DenseMap.h as DenseMapInfo<APInt>

`DenseMapAPIntKeyInfo` is now located in `lib/IR/LLVMContextImpl.h`.
Moved it into `include/ADT/DenseMapInfo.h` to use it.

Reviewed By: jdoerfert

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

4 years ago[InstCombine] reduce xor-of-or's bitwise logic (PR46955); 2nd try
Sanjay Patel [Mon, 3 Aug 2020 13:19:11 +0000 (09:19 -0400)]
[InstCombine] reduce xor-of-or's bitwise logic (PR46955); 2nd try

The 1st try at this (rG2265d01f2a5b) exposed what looks like
unspecified behavior in C/C++ resulting in test variations.

The arguments to BinaryOperator::CreateAnd() were both IRBuilder
function calls, and the order in which they execute determines
the order of the new instructions in the IR. But the order of
function arg evaluation is not fixed by the rules of C/C++, so
depending on compiler config, the test would fail because the
test expected a single fixed ordering of instructions.

Original commit message:
I tried to use m_Deferred() on this, but didn't find
a clean way to do that.

http://bugs.llvm.org/PR46955

https://alive2.llvm.org/ce/z/2h6QTq

4 years ago[DWARFYAML] Offsets should be omitted when the OffsetEntryCount is 0.
Xing GUO [Mon, 3 Aug 2020 14:04:33 +0000 (22:04 +0800)]
[DWARFYAML] Offsets should be omitted when the OffsetEntryCount is 0.

The offsets field should be omitted when the 'OffsetEntryCount' entry is
specified to be 0.

Reviewed By: jhenderson

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

4 years ago[mlir] First-party modeling of LLVM types
Alex Zinenko [Wed, 29 Jul 2020 12:58:09 +0000 (14:58 +0200)]
[mlir] First-party modeling of LLVM types

The current modeling of LLVM IR types in MLIR is based on the LLVMType class
that wraps a raw `llvm::Type *` and delegates uniquing, printing and parsing to
LLVM itself. This model makes thread-safe type manipulation hard and is being
progressively replaced with a cleaner MLIR model that replicates the type
system.  Introduce a set of classes reflecting the LLVM IR type system in MLIR
instead of wrapping the existing types. These are currently introduced as
separate classes without affecting the dialect flow, and are exercised through
a test dialect. Once feature parity is reached, the old implementation will be
gradually substituted with the new one.

Depends On D84171

Reviewed By: rriddle

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

4 years agoGlobalISel: Handle arbitrary FewerElementsVector for G_IMPLICIT_DEF
Matt Arsenault [Tue, 28 Jul 2020 14:15:30 +0000 (10:15 -0400)]
GlobalISel: Handle arbitrary FewerElementsVector for G_IMPLICIT_DEF

4 years agoAMDGPU/GlobalISel: Remove old hacks for boolean selection
Matt Arsenault [Sun, 26 Jul 2020 14:47:08 +0000 (10:47 -0400)]
AMDGPU/GlobalISel: Remove old hacks for boolean selection

There were various hacks used to try to avoid making s1 SGPR vs. s1
VCC ambiguous after constraining the register before we had a strategy
to deal with this. This also attempted to handle undef operands, which
are now illegal gMIR.

4 years agoGlobalISel: Reimplement moreElementsVectorDst
Matt Arsenault [Sun, 2 Feb 2020 22:42:02 +0000 (17:42 -0500)]
GlobalISel: Reimplement moreElementsVectorDst

Use pad with undef and unmerge with unused results. This is annoyingly
similar to several other places in LegalizerHelper, but they're all
slightly different.

4 years agoRevert "[InstCombine] reduce xor-of-or's bitwise logic (PR46955)"
Sanjay Patel [Mon, 3 Aug 2020 12:58:41 +0000 (08:58 -0400)]
Revert "[InstCombine] reduce xor-of-or's bitwise logic (PR46955)"

This reverts commit 2265d01f2a5bd153959701e22f5be2a40e1674a3.
Seeing bot failures after this change like:
http://lab.llvm.org:8011/builders/clang-cmake-x86_64-sde-avx512-linux/builds/42586

4 years agoAMDGPU/GlobalISel: Apply load bitcast to s.buffer.load intrinsic
Matt Arsenault [Tue, 16 Jun 2020 18:52:14 +0000 (14:52 -0400)]
AMDGPU/GlobalISel: Apply load bitcast to s.buffer.load intrinsic

Should also apply this to the non-scalar buffer loads.

4 years ago[X86][SSE] Start shuffle combining from ANY_EXTEND_VECTOR_INREG on SSE targets
Simon Pilgrim [Mon, 3 Aug 2020 11:18:21 +0000 (12:18 +0100)]
[X86][SSE] Start shuffle combining from ANY_EXTEND_VECTOR_INREG on SSE targets

We already do this on AVX (+ for ZERO_EXTEND_VECTOR_INREG), but this enables it for all SSE targets - we attempted something similar back at rL357057 but hit issues with the ZERO_EXTEND_VECTOR_INREG handling (PR41249).

I'm still looking at the vector-mul.ll regression - which is due to 32-bit targets performing the load as a f64, resulting in the shuffle combiner thinking it has to create a shuffle in the float domain.

4 years agoAMDGPU/GlobalISel: Fix selecting broken copies for s32->s64 anyext
Matt Arsenault [Thu, 23 Jul 2020 01:07:03 +0000 (21:07 -0400)]
AMDGPU/GlobalISel: Fix selecting broken copies for s32->s64 anyext

These should probably not be legal in the first place, but that might
also be a pain.