platform/upstream/llvm.git
3 years ago[InstCombine] Transform (A + B) - (A | B) to A & B (PR48604)
Dávid Bolvanský [Thu, 31 Dec 2020 13:02:44 +0000 (14:02 +0100)]
[InstCombine] Transform (A + B) - (A | B) to A & B (PR48604)

define i32 @src(i32 %x, i32 %y) {
%0:
  %a = add i32 %x, %y
  %o = or i32 %x, %y
  %r = sub i32 %a, %o
  ret i32 %r
}
=>
define i32 @tgt(i32 %x, i32 %y) {
%0:
  %b = and i32 %x, %y
  ret i32 %b
}
Transformation seems to be correct!

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

3 years ago[NFC] Added tests for PR48604
Dávid Bolvanský [Thu, 31 Dec 2020 12:57:20 +0000 (13:57 +0100)]
[NFC] Added tests for PR48604

3 years agoRevert "[LoopDeletion] Allows deletion of possibly infinite side-effect free loops"
Bogdan Graur [Thu, 31 Dec 2020 11:47:30 +0000 (11:47 +0000)]
Revert "[LoopDeletion] Allows deletion of possibly infinite side-effect free loops"

Test clang/test/Misc/loop-opt-setup.c fails when executed in Release.

This reverts commit 6f1503d59854b331f1f970d39839619b0a26bbc7.

Reviewed By: SureYeaah

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

3 years agoRevert "[ThinLTO][test] Add visibility related tests"
Bogdan Graur [Thu, 31 Dec 2020 11:41:03 +0000 (11:41 +0000)]
Revert "[ThinLTO][test] Add visibility related tests"

Both newly added tests fail in Release.

This reverts commit 52aa4e210744361a5ed6dc50fef78ed91706e508.

Reviewed By: SureYeaah

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

3 years agoLangRef: fix significand bits of fp128
Nuno Lopes [Thu, 31 Dec 2020 11:13:25 +0000 (11:13 +0000)]
LangRef: fix significand bits of fp128

3 years ago[sanitizer] Include fstab.h on glibc/FreeBSD/NetBSD/macOS
Fangrui Song [Thu, 31 Dec 2020 08:55:57 +0000 (00:55 -0800)]
[sanitizer] Include fstab.h on glibc/FreeBSD/NetBSD/macOS

3 years ago[sanitizer] Define SANITIZER_GLIBC to refine SANITIZER_LINUX feature detection and...
Fangrui Song [Thu, 31 Dec 2020 08:44:25 +0000 (00:44 -0800)]
[sanitizer] Define SANITIZER_GLIBC to refine SANITIZER_LINUX feature detection and support musl

Several `#if SANITIZER_LINUX && !SANITIZER_ANDROID` guards are replaced
with the more appropriate `#if SANITIZER_GLIBC` (the headers are glibc
extensions, not specific to Linux (i.e. if we ever support GNU/kFreeBSD
or Hurd, the guards may automatically work)).

Several `#if SANITIZER_LINUX && !SANITIZER_ANDROID` guards are refined
with `#if SANITIZER_GLIBC` (the definitions are available on Linux glibc,
but may not be available on other libc (e.g. musl) implementations).

This patch makes `ninja asan cfi msan stats tsan ubsan xray` build on a musl based Linux distribution (apk install musl-libintl)
Notes about disabled interceptors for musl:

* `SANITIZER_INTERCEPT_GLOB`: musl does not implement `GLOB_ALTDIRFUNC` (GNU extension)
* Some ioctl structs and functions operating on them.
* `SANITIZER_INTERCEPT___PRINTF_CHK`: `_FORTIFY_SOURCE` functions are GNU extension
* `SANITIZER_INTERCEPT___STRNDUP`: `dlsym(RTLD_NEXT, "__strndup")` errors so a diagnostic is formed. The diagnostic uses `write` which hasn't been intercepted => SIGSEGV
* `SANITIZER_INTERCEPT_*64`: the `_LARGEFILE64_SOURCE` functions are glibc specific. musl does something like `#define pread64 pread`
* Disabled `msg_iovlen msg_controllen cmsg_len` checks: musl is conforming while many implementations (Linux/FreeBSD/NetBSD/Solaris) are non-conforming. Since we pick the glibc definition, exclude the checks for musl (incompatible sizes but compatible offsets)

Pass through LIBCXX_HAS_MUSL_LIBC to make check-msan/check-tsan able to build libc++ (https://bugs.llvm.org/show_bug.cgi?id=48618).

Many sanitizer features are available now.

```
% ninja check-asan
(known issues:
* ASAN_OPTIONS=fast_unwind_on_malloc=0 odr-violations hangs
)
...
Testing Time: 53.69s
  Unsupported      : 185
  Passed           : 512
  Expectedly Failed:   1
  Failed           :  12

% ninja check-ubsan check-ubsan-minimal check-memprof # all passed

% ninja check-cfi
( all cross-dso/)
...
Testing Time: 8.68s
  Unsupported      : 264
  Passed           :  80
  Expectedly Failed:   8
  Failed           :  32

% ninja check-msan
(Many are due to functions not marked unsupported.)
Testing Time: 23.09s
  Unsupported      :   6
  Passed           : 764
  Expectedly Failed:   2
  Failed           :  58

% ninja check-tsan
Testing Time: 23.21s
  Unsupported      :  86
  Passed           : 295
  Expectedly Failed:   1
  Failed           :  25
```

Used `ASAN_OPTIONS=verbosity=2` to verify no unneeded interceptors.

Partly based on Jari Ronkainen's https://reviews.llvm.org/D63785#1921014

Reviewed By: vitalybuka

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

3 years ago[test] Add {{.*}} to make ELF tests immune to dso_local/dso_preemptable/(none) differ...
Fangrui Song [Thu, 31 Dec 2020 08:27:11 +0000 (00:27 -0800)]
[test] Add {{.*}} to make ELF tests immune to dso_local/dso_preemptable/(none) differences

For a default visibility external linkage definition, dso_local is set for ELF
-fno-pic/-fpie and COFF and Mach-O. Since default clang -cc1 for ELF is similar
to -fpic ("PIC Level" is not set), this nuance causes unneeded binary format differences.

To make emitted IR similar, ELF -cc1 -fpic will default to -fno-semantic-interposition,
which sets dso_local for default visibility external linkage definitions.

To make this flip smooth and enable future (dso_local as definition default),
this patch replaces (function) `define ` with `define{{.*}} `,
(variable/constant/alias) `= ` with `={{.*}} `, or inserts appropriate `{{.*}} `.

3 years ago[test] Fix -triple and delete UNSUPPORTED: system-windows
Fangrui Song [Thu, 31 Dec 2020 08:13:34 +0000 (00:13 -0800)]
[test] Fix -triple and delete UNSUPPORTED: system-windows

3 years agoUpdate inselt tests at llvm/test/Analysis to have poison as shufflevector's placehold...
Juneyoung Lee [Thu, 31 Dec 2020 08:11:31 +0000 (17:11 +0900)]
Update inselt tests at llvm/test/Analysis to have poison as shufflevector's placeholder (NFC)

File listed by:

grep -R -E "^[^;]*shufflevector <.*> .*, <.*> undef" . | grep inseltpoison

Updated with:

sed -i -E 's/shufflevector <(.*)> (.*), <(.*)> undef/shufflevector <\1> \2, <\3> poison/g' $1

3 years ago[mlir][python] Fix python extension building on windows.
Stella Laurenzo [Thu, 31 Dec 2020 08:11:39 +0000 (00:11 -0800)]
[mlir][python] Fix python extension building on windows.

3 years ago[mlir][python] Tweaks to make python extensions packagable/distributable.
Stella Laurenzo [Wed, 30 Dec 2020 07:34:58 +0000 (23:34 -0800)]
[mlir][python] Tweaks to make python extensions packagable/distributable.

* Works in tandem with prototype packaging scripts here: https://github.com/stellaraccident/mlir-py-release
* The `mlir` top-level now differentiates between in-tree builds where all packages are co-located and distribution mode where all native components are under a top-level `_mlir_libs` package.
* Also fixes the generated dialect python installation again. Hopefully the last tweak.
* With this, I am able to install and generate archives with the above setup script on Linux. Archive size=31M with just host codegen and headers/shared-libraries. Will need more linker tweaks when wiring up the next dependent project.

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

3 years ago[lld/mac] fix typo
Thorsten Schütt [Thu, 31 Dec 2020 07:23:29 +0000 (08:23 +0100)]
[lld/mac] fix typo

3 years agoSupport tilezero intrinsic and c interface for AMX.
Luo, Yuanke [Tue, 8 Dec 2020 12:47:48 +0000 (20:47 +0800)]
Support tilezero intrinsic and c interface for AMX.

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

3 years ago[CodeGenModule] Set dso_local for Mach-O GlobalValue
Fangrui Song [Thu, 31 Dec 2020 04:52:01 +0000 (20:52 -0800)]
[CodeGenModule] Set dso_local for Mach-O GlobalValue

* static relocation model: always
* other relocation models: if isStrongDefinitionForLinker

This will make LLVM IR emitted for COFF/Mach-O and executable ELF similar.

3 years ago[test] Add {{.*}} to make tests immune to dso_local/dso_preemptable/(none) differences
Fangrui Song [Thu, 31 Dec 2020 04:45:56 +0000 (20:45 -0800)]
[test] Add {{.*}} to make tests immune to dso_local/dso_preemptable/(none) differences

For a definition (of most linkage types), dso_local is set for ELF -fno-pic/-fpie
and COFF, but not for Mach-O.  This nuance causes unneeded binary format differences.

This patch replaces (function) `define ` with `define{{.*}} `,
(variable/constant/alias) `= ` with `={{.*}} `, or inserts appropriate `{{.*}} `
if there is an explicit linkage.

* Clang will set dso_local for Mach-O, which is currently implied by TargetMachine.cpp. This will make COFF/Mach-O and executable ELF similar.
* Eventually I hope we can make dso_local the textual LLVM IR default (write explicit "dso_preemptable" when applicable) and -fpic ELF will be similar to everything else. This patch helps move toward that goal.

3 years ago[RISCV] Define vector single-width type-convert intrinsic.
Monk Chiang [Thu, 31 Dec 2020 03:37:13 +0000 (11:37 +0800)]
[RISCV] Define vector single-width type-convert intrinsic.

Define intrinsics:
  1. vfcvt.xu.f.v/vfcvt.x.f.v
  2. vfcvt.rtz.xu.f.v/vfcvt.rtz.x.f.v
  3. vfcvt.f.xu.v/vfcvt.f.x.v

We work with @rogfer01 from BSC to come out this patch.

Authored-by: Roger Ferrer Ibanez <rofirrim@gmail.com>
Co-Authored-by: Monk Chiang <monk.chiang@sifive.com>
Differential Revision: https://reviews.llvm.org/D93933

3 years ago[RISCV] Define vector narrowing type-convert intrinsic.
Monk Chiang [Thu, 31 Dec 2020 03:35:37 +0000 (11:35 +0800)]
[RISCV] Define vector narrowing type-convert intrinsic.

Define intrinsics:
  1. vfncvt.xu.f.w/vfncvt.x.f.w
  2. vfncvt.rtz.xu.f.w/vfncvt.rtz.x.f.w
  3. vfncvt.f.xu.w/vfncvt.f.x.w
  4. vfncvt.f.f.w/vfncvt.rod.f.f.w

We work with @rogfer01 from BSC to come out this patch.

Authored-by: Roger Ferrer Ibanez <rofirrim@gmail.com>
Co-Authored-by: Monk Chiang <monk.chiang@sifive.com>
Differential Revision: https://reviews.llvm.org/D93932

3 years ago[RISCV] Define vector widening type-convert intrinsic.
Monk Chiang [Thu, 31 Dec 2020 03:31:46 +0000 (11:31 +0800)]
[RISCV] Define vector widening type-convert intrinsic.

Define intrinsics:
  1. vfwcvt.xu.f.v/vfwcvt.x.f.v
  2. vfwcvt.rtz.xu.f.v/vfwcvt.rtz.x.f.v
  3. vfwcvt.f.xu.v/vfwcvt.f.x.v
  4. vfwcvt.f.f.v

We work with @rogfer01 from BSC to come out this patch.

Authored-by: Roger Ferrer Ibanez <rofirrim@gmail.com>
Co-Authored-by: Monk Chiang <monk.chiang@sifive.com>
Differential Revision: https://reviews.llvm.org/D93855

3 years agoAdd intrinsic testcase for some missing widening reduction.
Monk Chiang [Thu, 31 Dec 2020 03:12:40 +0000 (11:12 +0800)]
Add intrinsic testcase for some missing widening reduction.

Add vfredosum/vfredsum/vwredsum/vwredsumu testcase.

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

3 years ago[lsan] Ignore inderect leaks referenced by suppressed blocks
Vitaly Buka [Tue, 29 Dec 2020 03:19:38 +0000 (19:19 -0800)]
[lsan] Ignore inderect leaks referenced by suppressed blocks

This makes suppression list to work similar to __lsan_ignore_object.

Existing behavior was inconsistent and very inconvenient for complex
data structures.

Example:

struct B;
struct A { B* ptr; };
A* t = makeA();
t->ptr = makeB();

Before the patch: if makeA suppressed by suppression file, lsan will
still report the makeB() leak, so we need two suppressions.

After the patch: a single makeA suppression is enough (the same as a
single __lsan_ignore_object(t)).

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

3 years ago[X86] Don't fold negative offset into 32-bit absolute address (e.g. movl $foo-1,...
Fangrui Song [Thu, 31 Dec 2020 02:47:26 +0000 (18:47 -0800)]
[X86] Don't fold negative offset into 32-bit absolute address (e.g. movl $foo-1, %eax)

When building abseil-cpp `bin/absl_hash_test` with Clang in -fno-pic
mode, an instruction like `movl $foo-2147483648, $eax` may be produced
(subtracting a number from the address of a static variable). If foo's
address is smaller than 2147483648, GNU ld/gold/LLD will error because
R_X86_64_32 cannot represent a negative value.

```
using absl::Hash;
struct NoOp {
  template < typename HashCode >
  friend HashCode AbslHashValue(HashCode , NoOp );
};
template <typename> class HashIntTest : public testing::Test {};
TYPED_TEST_SUITE_P(HashIntTest);
TYPED_TEST_P(HashIntTest, BasicUsage) {
  if (std::numeric_limits< TypeParam >::min )
    EXPECT_NE(Hash< NoOp >()({}),
              Hash< TypeParam >()(std::numeric_limits< TypeParam >::min()));
}
REGISTER_TYPED_TEST_CASE_P(HashIntTest, BasicUsage);
using IntTypes = testing::Types< int32_t>;
INSTANTIATE_TYPED_TEST_CASE_P(My, HashIntTest, IntTypes);

ld: error: hash_test.cc:(function (anonymous namespace)::gtest_suite_HashIntTest_::BasicUsage<int>::TestBody(): .text+0x4E472): relocation R_X86_64_32 out of range: 18446744071564237392 is not in [0, 4294967295]; references absl::hash_internal::HashState::kSeed
```

Actually any negative offset is not allowed because the symbol address
can be zero (e.g. set by `-Wl,--defsym=foo=0`). So disallow such folding.

Reviewed By: pengfei

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

3 years ago[LoopDeletion] Allows deletion of possibly infinite side-effect free loops
Atmn Patel [Wed, 23 Dec 2020 02:54:21 +0000 (21:54 -0500)]
[LoopDeletion] Allows deletion of possibly infinite side-effect free loops

From C11 and C++11 onwards, a forward-progress requirement has been
introduced for both languages. In the case of C, loops with non-constant
conditionals that do not have any observable side-effects (as defined by
6.8.5p6) can be assumed by the implementation to terminate, and in the
case of C++, this assumption extends to all functions. The clang
frontend will emit the `mustprogress` function attribute for C++
functions (D86233, D85393, D86841) and emit the loop metadata
`llvm.loop.mustprogress` for every loop in C11 or later that has a
non-constant conditional.

This patch modifies LoopDeletion so that only loops with
the `llvm.loop.mustprogress` metadata or loops contained in functions
that are required to make progress (`mustprogress` or `willreturn`) are
checked for observable side-effects. If these loops do not have an
observable side-effect, then we delete them.

Loops without observable side-effects that do not satisfy the above
conditions will not be deleted.

Reviewed By: jdoerfert

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

3 years ago[lld/mac] Add -adhoc_codesign / -no_adhoc_codesign flags
Nico Weber [Thu, 31 Dec 2020 01:56:19 +0000 (20:56 -0500)]
[lld/mac] Add -adhoc_codesign / -no_adhoc_codesign flags

These are new in Xcode 12's ld64. lld never codesigns at the moment, so
-no_adhoc_codesign doesn't even have to warn that it's not implemented.

3 years ago[Analysis] Remove unused code recursivelySimplifyInstruction (NFC)
Kazu Hirata [Thu, 31 Dec 2020 01:45:39 +0000 (17:45 -0800)]
[Analysis] Remove unused code recursivelySimplifyInstruction (NFC)

The last use of the function, located in RemovePredecessorAndSimplify,
was removed on Dec 25, 2020 in commit
46bea9b29714ba77010612b04ba13aff56d62e7b.

The last use of RemovePredecessorAndSimplify was removed on Sep 29,
2010 in commit 99c985c37dd45dd0fbd03863037d8e93153783e6.

3 years ago[PGO] Use isa instead of dyn_cast (NFC)
Kazu Hirata [Thu, 31 Dec 2020 01:45:37 +0000 (17:45 -0800)]
[PGO] Use isa instead of dyn_cast (NFC)

3 years ago[ARM] Declare Op within an if statement (NFC)
Kazu Hirata [Thu, 31 Dec 2020 01:45:36 +0000 (17:45 -0800)]
[ARM] Declare Op within an if statement (NFC)

3 years ago[ThinLTO][test] Add visibility related tests
Fangrui Song [Thu, 31 Dec 2020 00:58:20 +0000 (16:58 -0800)]
[ThinLTO][test] Add visibility related tests

Reviewed By: tejohnson

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

3 years ago[TargetMachine] Drop implied dso_local for definitions in ELF static relocation model/PIE
Fangrui Song [Thu, 31 Dec 2020 00:57:50 +0000 (16:57 -0800)]
[TargetMachine] Drop implied dso_local for definitions in ELF static relocation model/PIE

TargetMachine::shouldAssumeDSOLocal currently implies dso_local for such definitions.

Since clang -fno-pic add the dso_local specifier, we don't need to special case.

3 years ago[test] Add explicit dso_local to definitions in ELF static relocation model tests
Fangrui Song [Thu, 31 Dec 2020 00:52:23 +0000 (16:52 -0800)]
[test] Add explicit dso_local to definitions in ELF static relocation model tests

3 years ago[LowerEmuTls] Copy dso_local from <var> to __emutls_v.<var>
Fangrui Song [Thu, 31 Dec 2020 00:11:31 +0000 (16:11 -0800)]
[LowerEmuTls] Copy dso_local from <var> to __emutls_v.<var>

This effect is not testable until we drop the implied dso_local for ELF
static/PIE defined symbols from TargetMachine::shouldAssumeDSOLocal.

3 years ago[test] Add explicit dso_local to definitions in ELF static relocation model tests
Fangrui Song [Wed, 30 Dec 2020 23:47:16 +0000 (15:47 -0800)]
[test] Add explicit dso_local to definitions in ELF static relocation model tests

3 years ago[ORC] Remove some stale debugging output.
Lang Hames [Wed, 30 Dec 2020 04:34:44 +0000 (15:34 +1100)]
[ORC] Remove some stale debugging output.

3 years ago[RISCV][test] Add explicit dso_local to definitions in ELF static relocation model...
Fangrui Song [Wed, 30 Dec 2020 23:28:10 +0000 (15:28 -0800)]
[RISCV][test] Add explicit dso_local to definitions in ELF static relocation model tests

3 years ago[SystemZ][test] Add explicit dso_local to definitions in ELF static relocation model...
Fangrui Song [Wed, 30 Dec 2020 23:26:09 +0000 (15:26 -0800)]
[SystemZ][test] Add explicit dso_local to definitions in ELF static relocation model tests

3 years ago[ARM][test] Add explicit dso_local to definitions in ELF static relocation model...
Fangrui Song [Wed, 30 Dec 2020 23:23:20 +0000 (15:23 -0800)]
[ARM][test] Add explicit dso_local to definitions in ELF static relocation model tests

TargetMachine::shouldAssumeDSOLocal currently implies dso_local for such definitions.

Adding explicit dso_local makes these tests align with the clang -fno-pic behavior
and allow the removal of the TargetMachine::shouldAssumeDSOLocal special case.

3 years ago[AArch64][test] Add explicit dso_local to definitions in ELF static relocation model...
Fangrui Song [Wed, 30 Dec 2020 23:03:06 +0000 (15:03 -0800)]
[AArch64][test] Add explicit dso_local to definitions in ELF static relocation model tests

TargetMachine::shouldAssumeDSOLocal currently implies dso_local for such definitions.

Adding explicit dso_local makes these tests align with the clang -fno-pic behavior
and allow the removal of the TargetMachine::shouldAssumeDSOLocal special case.

Split tiny_model.ll to tiny-model-{static,pic}.ll

3 years ago[test] Fix linux-preemption.ll
Fangrui Song [Wed, 30 Dec 2020 22:44:43 +0000 (14:44 -0800)]
[test] Fix linux-preemption.ll

3 years ago[X86][test] Add explicit dso_local to definitions in ELF static relocation model...
Fangrui Song [Wed, 30 Dec 2020 22:40:50 +0000 (14:40 -0800)]
[X86][test] Add explicit dso_local to definitions in ELF static relocation model tests

TargetMachine::shouldAssumeDSOLocal currently implies dso_local for such definitions.

Adding explicit dso_local makes these tests align with the clang -fno-pic behavior
and allow the removal of the TargetMachine::shouldAssumeDSOLocal special case.

3 years agoAvoid using /dev/null in test
Jacques Pienaar [Wed, 30 Dec 2020 22:16:13 +0000 (14:16 -0800)]
Avoid using /dev/null in test

Windows build bot was not happy with this
(http://lab.llvm.org:8011/#/builders/13/builds/3327/steps/7/logs/FAIL__MLIR__run-reproducer_mlir)

3 years ago[OpenMP] libomp: Handle implicit conversion warnings
Terry Wilmarth [Wed, 30 Dec 2020 21:39:48 +0000 (00:39 +0300)]
[OpenMP] libomp: Handle implicit conversion warnings

This patch partially prepares the runtime source code to be built with
-Wconversion, which should trigger warnings if any implicit conversions
can possibly change a value. For builds done with icc or gcc, all such
warnings are handled in this patch. clang gives a much longer list of
warnings, particularly for sign conversions, which the other compilers
don't report. The -Wconversion flag is commented into cmake files, but
I'm not going to turn it on. If someone thinks it is important, and wants
to fix all the clang warnings, they are welcome to.

Types of changes made here involve either improving the consistency of types
used so that no conversion is needed, or else performing careful explicit
conversions, when we're sure a problem won't arise.

Patch is a combination of changes by Terry Wilmarth and Johnny Peyton.

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

3 years ago[PowerPC] Add addtional test that retroactively catches PR47259
Brandon Bergren [Wed, 30 Dec 2020 21:22:26 +0000 (15:22 -0600)]
[PowerPC] Add addtional test that retroactively catches PR47259

Due to the unfortunate way the bug could only be triggered when reading SPRG[0-3] into a register lower than %r4 with the "mfsprg %rX, 0" syntax, the tests did not detect it.

(It could not be triggered for "mfsprg0, %r2" because that pattern was already in the table, so the earlier "correct" match took effect)

As a canary, add an intentionally ambiguous "mfsprg 2, 2" and "mtsprg 2, 2" check that would have caught the problem.

Reviewed By: ZhangKang

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

3 years ago[libc][NFC] Use ASSERT_FP_EQ to compare nan values in tests.
Siva Chandra Reddy [Wed, 30 Dec 2020 20:38:23 +0000 (12:38 -0800)]
[libc][NFC] Use ASSERT_FP_EQ to compare nan values in tests.

This change "fixes" one of the uses that was missed in
0524da67b448dcce6569fae0f54c10f208c2dc56.

3 years ago[LoopIdiom] 'left-shift until bittest': don't forget to check that PHI node is in...
Roman Lebedev [Wed, 30 Dec 2020 20:53:23 +0000 (23:53 +0300)]
[LoopIdiom] 'left-shift until bittest': don't forget to check that PHI node is in loop header

Fixes an issue reported by Peter Collingbourne in
https://reviews.llvm.org/D91726#2475301

3 years ago[SimplifyCFG] Teach SwitchToLookupTable() to preserve DomTree
Roman Lebedev [Wed, 30 Dec 2020 20:33:55 +0000 (23:33 +0300)]
[SimplifyCFG] Teach SwitchToLookupTable() to preserve DomTree

3 years ago[SimplifyCFG] Teach switchToSelect() to preserve DomTree
Roman Lebedev [Wed, 30 Dec 2020 20:11:06 +0000 (23:11 +0300)]
[SimplifyCFG] Teach switchToSelect() to preserve DomTree

3 years ago[SimplifyCFG] Teach SimplifyBranchOnICmpChain() to preserve DomTree
Roman Lebedev [Wed, 30 Dec 2020 17:48:40 +0000 (20:48 +0300)]
[SimplifyCFG] Teach SimplifyBranchOnICmpChain() to preserve DomTree

3 years ago[RISCV] Cleanup some V intrinsic names used in tests to match the type overloads...
Craig Topper [Wed, 30 Dec 2020 18:41:41 +0000 (10:41 -0800)]
[RISCV] Cleanup some V intrinsic names used in tests to match the type overloads used. Add some missing double tests on rv32. NFC

The matching for intrinsic names is forgiving about types in the
name being absent or wrong. Once the intrinsic is parsed its
name will remangled to include the real types.

This commit fixes the names to have at least enough correct types
so that the name used in the test is a prefix of the canonical name.
The big missing part is the type for the VL parameter which changes
size between rv32 and rv64.

While I was in here I noticed that we were missing some tests for
double on rv32 so I fixed that by copying from rv64 and fixing up
the VL argument type.

3 years ago[update_llc_test_checks] Support Windows .seh_proc for x86
Fangrui Song [Wed, 30 Dec 2020 20:32:46 +0000 (12:32 -0800)]
[update_llc_test_checks] Support Windows .seh_proc for x86

3 years ago[LoopUtils] reduce FMF and min/max complexity when forming reductions
Sanjay Patel [Wed, 30 Dec 2020 20:22:26 +0000 (15:22 -0500)]
[LoopUtils] reduce FMF and min/max complexity when forming reductions

I don't know if there's some way this changes what the vectorizers
may produce for reductions, but I have added test coverage with
3567908 and 5ced712 to show that both passes already have bugs in
this area. Hopefully this does not make things worse before we can
really fix it.

3 years ago[LoopVectorizer] add test to show wrong FMF propagation; NFC
Sanjay Patel [Wed, 30 Dec 2020 19:25:51 +0000 (14:25 -0500)]
[LoopVectorizer] add test to show wrong FMF propagation; NFC

3 years ago[update_llc_test_checks] Support .Lfunc$local for x86 -relocation-model=pic dsolocal...
Fangrui Song [Wed, 30 Dec 2020 19:59:36 +0000 (11:59 -0800)]
[update_llc_test_checks] Support .Lfunc$local for x86 -relocation-model=pic dsolocal tests

3 years ago[gn build] Switch copy_bundle_data from pax to cpio
Nico Weber [Wed, 30 Dec 2020 18:57:42 +0000 (13:57 -0500)]
[gn build] Switch copy_bundle_data from pax to cpio

This will hopefully fix the build not becoming clean when using Ninja
1.9+. Ninja 1.9 enabled high-resolution time stamps, but pax doesn't
correctly set high-resolution timestamps on its output.

See https://github.com/nico/hack/blob/master/notes/copydir.md for a
detailed writeup of problem and alternatives.

3 years agoFix `LLVM_ENABLE_MODULES=On` build
Yuanfang Chen [Wed, 30 Dec 2020 07:15:03 +0000 (23:15 -0800)]
Fix `LLVM_ENABLE_MODULES=On` build

for commit 480936e741d588d53b9e2d9c5935b5daa0fdee25.

3 years ago[mlir] Add option to read reproducer options from file
Jacques Pienaar [Wed, 30 Dec 2020 18:46:01 +0000 (10:46 -0800)]
[mlir] Add option to read reproducer options from file

Add command line option to read the configuration dumped by the MLIR crash
reproducer and adds those to the other command line options parsed by mlir-opt.

Simple convenience that enables `mlir-opt --run-reproducer /tmp/repro.mlir`
instead of needing to copy&paste the configuration.

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

3 years ago[PowerPC][test] Add explicit dso_local to definitions in ELF static relocation model...
Fangrui Song [Wed, 30 Dec 2020 18:32:34 +0000 (10:32 -0800)]
[PowerPC][test] Add explicit dso_local to definitions in ELF static relocation model tests

TargetMachine::shouldAssumeDSOLocal currently implies dso_local for such definitions.

Adding explicit dso_local makes these tests align with the clang -fpic behavior
and allow the removal of the TargetMachine::shouldAssumeDSOLocal special case.

Rewrite preemption.ll to dsolocal-static.ll and dsolocal-pic.ll, and add
"PIC Level" metadata.

3 years ago[compiler-rt] FuzzedDataProvider: Add PickValueInArray for std::array
Max Moroz [Wed, 30 Dec 2020 18:10:23 +0000 (10:10 -0800)]
[compiler-rt] FuzzedDataProvider: Add PickValueInArray for std::array

This makes `PickValueInArray` work for `std::array<T, s>` (C++11). I've also tested the C++17 `std::array` (with compiler-deduced template parameters)

```
Author:
MarcoFalke <falke.marco@gmail.com>
```

Reviewed By: Dor1s

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

3 years ago[IROutliner] Adding option to enable outlining from linkonceodr functions
Andrew Litteken [Wed, 16 Sep 2020 03:02:18 +0000 (22:02 -0500)]
[IROutliner] Adding option to enable outlining from linkonceodr functions

There are functions that the linker is able to automatically
deduplicate, we do not outline from these functions by default. This
allows for outlining from those functions.

Tests:
llvm/test/Transforms/IROutliner/outlining-odr.ll

Reviewers: jroelofs, paquette

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

3 years ago[CMake][tsan] Remove --sysroot=.
Fangrui Song [Wed, 30 Dec 2020 17:30:58 +0000 (09:30 -0800)]
[CMake][tsan] Remove --sysroot=.

rL254966 added `--sysroot=.` to prevent accidental including system headers.
It caused hassle to FreeBSD (D17383)/NetBSD. The next problem is that
we want to include `features.h` (usually `/usr/include/features.h`) to detect `__GLIBC__`.

At this point it seems that `--sysroot=.` adds lots of inconvenience so we disable it for now.
If there is a better way preventing accidental system header inclusion we can consider it again.

Reviewed By: #sanitizers, vitalybuka

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

3 years ago[ELF] Drop '>>> defined in ' for locations of linker synthesized symbols
Fangrui Song [Wed, 30 Dec 2020 17:16:26 +0000 (09:16 -0800)]
[ELF] Drop '>>> defined in ' for locations of linker synthesized symbols

Reviewed By: grimar

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

3 years ago[mlir] Fix indexing of first offset operand in ops that implement OffsetSizeAndStride...
Nicolas Vasilache [Wed, 30 Dec 2020 16:42:21 +0000 (16:42 +0000)]
[mlir] Fix indexing of first offset operand in ops that implement OffsetSizeAndStrideOpInterface

OffsetSizeAndStrideOpInterface ops may have a varying number of operands before the first
offset operand. This revision adds a method that such ops much implement to properly specify
the position of the first offset operand.

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

3 years ago[mlir] NFC - Fix SubViewOp printing
Nicolas Vasilache [Wed, 30 Dec 2020 16:33:32 +0000 (16:33 +0000)]
[mlir] NFC - Fix SubViewOp printing

Avoid casting the source operand type allows better debugging when conversion patterns
fail to produce a proper MemRefType.

3 years ago[SLP] add fadd reduction test to show broken FMF propagation; NFC
Sanjay Patel [Wed, 30 Dec 2020 16:27:23 +0000 (11:27 -0500)]
[SLP] add fadd reduction test to show broken FMF propagation; NFC

3 years agoFixes warning 'enumeration value not handled in switch'.
Bogdan Graur [Wed, 30 Dec 2020 14:56:29 +0000 (06:56 -0800)]
Fixes warning 'enumeration value not handled in switch'.

This was introduced in commit: 981a0bd85811fe49379fdbef35528e2c2f3511a3.

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

3 years ago[IR] remove 'NoNan' param when creating FP reductions
Sanjay Patel [Wed, 30 Dec 2020 14:11:10 +0000 (09:11 -0500)]
[IR] remove 'NoNan' param when creating FP reductions

This is no-functional-change-intended (AFAIK, we can't
isolate this difference in a regression test).

That's because the callers should be setting the IRBuilder's
FMF field when creating the reduction and/or setting those
flags after creating. It doesn't make sense to override this
one flag alone.

This is part of a multi-step process to clean up the FMF
setting/propagation. See PR35538 for an example.

3 years agoRemove functions from *-inseltpoison.ll tests if unnecessary
Juneyoung Lee [Wed, 30 Dec 2020 14:49:09 +0000 (23:49 +0900)]
Remove functions from *-inseltpoison.ll tests if unnecessary

X-inseltpoison.ll is a copy of X.ll with insertelement/shufflevector's
placeholder replaced with poison.
This commit removes a few redundant functions which do not contain any
shufflevector/insertelement.

3 years ago[X86][AMX] Fix compilation warning introduced by 981a0bd8.
Wang, Pengfei [Wed, 30 Dec 2020 14:22:13 +0000 (22:22 +0800)]
[X86][AMX] Fix compilation warning introduced by 981a0bd8.

3 years agoclang-format, address warnings
Juneyoung Lee [Wed, 30 Dec 2020 14:05:07 +0000 (23:05 +0900)]
clang-format, address warnings

3 years agoUse unary CreateShuffleVector if possible
Juneyoung Lee [Tue, 29 Dec 2020 22:28:17 +0000 (07:28 +0900)]
Use unary CreateShuffleVector if possible

As mentioned in D93793, there are quite a few places where unary `IRBuilder::CreateShuffleVector(X, Mask)` can be used
instead of `IRBuilder::CreateShuffleVector(X, Undef, Mask)`.
Let's update them.

Actually, it would have been more natural if the patches were made in this order:
(1) let them use unary CreateShuffleVector first
(2) update IRBuilder::CreateShuffleVector to use poison as a placeholder value (D93793)

The order is swapped, but in terms of correctness it is still fine.

Reviewed By: spatel

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

3 years ago[mlir] Fix a typo MemRefType -> UnrankedMemRefType
Alexander Belyaev [Wed, 30 Dec 2020 13:35:25 +0000 (14:35 +0100)]
[mlir] Fix a typo MemRefType -> UnrankedMemRefType

3 years ago[libc++] [docs] Mark contract-related papers as removed from C++20.
Marek Kurdej [Wed, 30 Dec 2020 13:24:02 +0000 (14:24 +0100)]
[libc++] [docs] Mark contract-related papers as removed from C++20.

3 years ago[SimplifyCFG] Add tests for select form and/or for creating select from icmps
Juneyoung Lee [Wed, 30 Dec 2020 13:13:10 +0000 (22:13 +0900)]
[SimplifyCFG] Add tests for select form and/or for creating select from icmps

3 years ago[ConstraintElimination] Add support for select form of and/or
Juneyoung Lee [Wed, 30 Dec 2020 07:11:54 +0000 (16:11 +0900)]
[ConstraintElimination] Add support for select form of and/or

This patch adds support for select form of and/or.
Currently there is an ongoing effort for moving towards using `select a, b, false` instead of `and i1 a, b` and
`select a, true, b` instead of `or i1 a, b` as well.
D93065 has links to relevant changes.

Alive2 proof: (undef input was disabled due to timeout :( )
- and: https://alive2.llvm.org/ce/z/AgvFbQ
- or: https://alive2.llvm.org/ce/z/KjLJyb

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

3 years ago[mlir][Python] Initial Affine Map Python Bindings.
zhanghb97 [Mon, 14 Dec 2020 10:43:05 +0000 (18:43 +0800)]
[mlir][Python] Initial Affine Map Python Bindings.

- Add `PyAffineMap` to wrap around `MlirAffineMap`.
- Add `mlirPythonAffineMapToCapsule` and `mlirPythonCapsuleToAffineMap` to interoperate with python capsule.
- Add and test some simple bindings of `PyAffineMap`.

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

3 years ago[X86] Refactor AMX test case, remove unnecessary code.
Luo, Yuanke [Wed, 30 Dec 2020 07:22:19 +0000 (15:22 +0800)]
[X86] Refactor AMX test case, remove unnecessary code.

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

3 years agoMove -fno-semantic-interposition dso_local logic from TargetMachine to Clang CodeGenM...
Fangrui Song [Wed, 30 Dec 2020 07:37:55 +0000 (23:37 -0800)]
Move -fno-semantic-interposition dso_local logic from TargetMachine to Clang CodeGenModule

This simplifies TargetMachine::shouldAssumeDSOLocal and and gives frontend the
decision to use dso_local. For LLVM synthesized functions/globals, they may lose
inferred dso_local but such optimizations are probably not very useful.

Note: the hasComdat() condition in canBenefitFromLocalAlias (D77429) may be dead now.
(llvm/CodeGen/X86/semantic-interposition-comdat.ll)
(Investigate whether we need test coverage when Fuchsia C++ ABI is clearer)

3 years ago[IROutliner] Adding support for swift errors in the IROutliner
Andrew Litteken [Mon, 24 Aug 2020 09:25:54 +0000 (04:25 -0500)]
[IROutliner] Adding support for swift errors in the IROutliner

Since some values can be swift errors, we need to make sure that we
correctly propagate the parameter attributes.

Tests found at:
llvm/test/Transforms/IROutliner/outlining-swift-error.ll

Reviewers: jroelofs, paquette

Recommit of: 71867ed5e6606a93f0c1413f205afe3bb16317fe

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

3 years agoRevert "[IROutliner] Adding support for swift errors"
Andrew Litteken [Wed, 30 Dec 2020 07:15:48 +0000 (01:15 -0600)]
Revert "[IROutliner] Adding support for swift errors"

This reverts commit 71867ed5e6606a93f0c1413f205afe3bb16317fe.

Reverting for lack of commit messages.

3 years ago[IROutliner] Adding support for swift errors
Andrew Litteken [Mon, 24 Aug 2020 09:25:54 +0000 (04:25 -0500)]
[IROutliner] Adding support for swift errors

3 years ago[ConstraintElimination] Add tests for select form and/or (NFC)
Juneyoung Lee [Wed, 30 Dec 2020 07:05:19 +0000 (16:05 +0900)]
[ConstraintElimination] Add tests for select form and/or (NFC)

3 years ago[libc] Add implementations of rounding functions which depend rounding mode.
Siva Chandra Reddy [Mon, 21 Dec 2020 17:16:41 +0000 (09:16 -0800)]
[libc] Add implementations of rounding functions which depend rounding mode.

Namely, implementations for rint, rintf, rintl, lrint, lrintf, lrintl,
llrint, llrintf and llrintl have been added.

Reviewed By: lntue

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

3 years ago[X86] Add x86_amx type for intel AMX.
Luo, Yuanke [Fri, 20 Nov 2020 07:19:34 +0000 (15:19 +0800)]
[X86] Add x86_amx type for intel AMX.

The x86_amx is used for AMX intrisics. <256 x i32> is bitcast to x86_amx when
it is used by AMX intrinsics, and x86_amx is bitcast to <256 x i32> when it
is used by load/store instruction. So amx intrinsics only operate on type x86_amx.
It can help to separate amx intrinsics from llvm IR instructions (+-*/).
Thank Craig for the idea. This patch depend on https://reviews.llvm.org/D87981.

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

3 years ago[X86][test] Improve global address offset folding tests
Fangrui Song [Wed, 30 Dec 2020 05:26:30 +0000 (21:26 -0800)]
[X86][test] Improve global address offset folding tests

3 years ago[Verifier] Remove declaration of method that was removed 8.5 years ago. NFC
Craig Topper [Wed, 30 Dec 2020 05:04:19 +0000 (21:04 -0800)]
[Verifier] Remove declaration of method that was removed 8.5 years ago. NFC

3 years ago[llvm-elfabi] Add flag to preserve timestamp when output is the same
Haowei Wu [Wed, 9 Dec 2020 01:23:53 +0000 (17:23 -0800)]
[llvm-elfabi] Add flag to preserve timestamp when output is the same

This change adds '--write-if-changed' flag to llvm-elfabi tool. When
enabled, llvm-elfabi will not overwrite the existing file if the
content of the file will not be changed, which preserves the
timestamp.

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

3 years ago[mlir][python] Install generated dialect sources.
Stella Laurenzo [Wed, 30 Dec 2020 02:06:24 +0000 (18:06 -0800)]
[mlir][python] Install generated dialect sources.

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

3 years ago[Analysis, IR] Use *Map::lookup (NFC)
Kazu Hirata [Wed, 30 Dec 2020 03:23:24 +0000 (19:23 -0800)]
[Analysis, IR] Use *Map::lookup (NFC)

3 years ago[Transforms/Utils] Construct SmallVector with iterator ranges (NFC)
Kazu Hirata [Wed, 30 Dec 2020 03:23:22 +0000 (19:23 -0800)]
[Transforms/Utils] Construct SmallVector with iterator ranges (NFC)

3 years ago[Analysis] Use llvm::append_range (NFC)
Kazu Hirata [Wed, 30 Dec 2020 03:23:21 +0000 (19:23 -0800)]
[Analysis] Use llvm::append_range (NFC)

3 years ago[RISCV] Add intrinsics for vcompress instruction
ShihPo Hung [Fri, 25 Dec 2020 02:56:24 +0000 (18:56 -0800)]
[RISCV] Add intrinsics for vcompress instruction

This patch defines vcompress intrinsics and lower to V instructions.

We work with @rogfer01 from BSC to come out this patch.

Authored-by: Roger Ferrer Ibanez <rofirrim@gmail.com>
Co-Authored-by: ShihPo Hung <shihpo.hung@sifive.com>
Differential revision: https://reviews.llvm.org/D93809

3 years ago[PowerPC] Add mir test to show effect of `optimizeCompareInstr` when `equalityOnly...
Kai Luo [Wed, 30 Dec 2020 02:23:05 +0000 (02:23 +0000)]
[PowerPC] Add mir test to show effect of `optimizeCompareInstr` when `equalityOnly` is true. NFC.

3 years ago[PowerPC] Remaining KnownBits should be constant when performing non-sign comparison
Kai Luo [Tue, 29 Dec 2020 12:11:55 +0000 (12:11 +0000)]
[PowerPC] Remaining KnownBits should be constant when performing non-sign comparison

In `PPCTargetLowering::DAGCombineTruncBoolExt`, when checking if it's correct to perform the transformation for non-sign comparison, as the comment says
```
      // This is neither a signed nor an unsigned comparison, just make sure
      // that the high bits are equal.
```
Origin check
```
      if (Op1Known.Zero != Op2Known.Zero || Op1Known.One != Op2Known.One)
        return SDValue();
```
is not strong enough. For example,
```
Op1Known = 111x000x;
Op2Known = 111x000x;
```
Bit 4, besides bit 0, is still unknown and affects the final result.

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

Reviewed By: nemanjai, #powerpc

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

3 years ago[ORC] Move Orc RPC code into Shared, rename some RPC types.
Lang Hames [Tue, 29 Dec 2020 09:27:41 +0000 (20:27 +1100)]
[ORC] Move Orc RPC code into Shared, rename some RPC types.

Moves all headers from Orc/RPC to Orc/Shared, and from the llvm::orc::rpc
namespace into llvm::orc::shared. Also renames RPCTypeName to
SerializationTypeName and Function to RPCFunction.

In addition to being a more reasonable home for this code, this will make it
easier for the upcoming Orc runtime to re-use the Serialization system for
creating and parsing wrapper-function binary blobs.

3 years ago[mlir][python] Aggressively avoid name collisions in generated python ODS code.
Stella Laurenzo [Wed, 30 Dec 2020 01:43:04 +0000 (17:43 -0800)]
[mlir][python] Aggressively avoid name collisions in generated python ODS code.

* When porting npcomp to use these bindings, I ran into enough patterns of collisions that I decided to be somewhat draconian about not polluting the namespace.
* With these changes all of the npcomp dialects generate and pass what tests we have.

Reviewed By: mehdi_amini

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

3 years ago[NFC][lsan] Extract PrintResults function
Vitaly Buka [Wed, 30 Dec 2020 01:27:53 +0000 (17:27 -0800)]
[NFC][lsan] Extract PrintResults function

3 years ago[lsan] Parse suppressions just before leak reporting
Vitaly Buka [Wed, 30 Dec 2020 01:18:39 +0000 (17:18 -0800)]
[lsan] Parse suppressions just before leak reporting

Without leaks suppressions are not needed.

3 years agoRevert "[llvm-elfabi] Add flag to preserve timestamp when output is the same"
Haowei Wu [Wed, 30 Dec 2020 01:26:22 +0000 (17:26 -0800)]
Revert "[llvm-elfabi] Add flag to preserve timestamp when output is the same"

This reverts commit fddb41744958d21635a60622cfb4067122810bcc. which
causes test failures on Mac builders.

3 years ago[RISCV] Define vsext/vzext intrinsics.
Zakk Chen [Mon, 28 Dec 2020 16:44:38 +0000 (08:44 -0800)]
[RISCV] Define vsext/vzext intrinsics.

Define vsext/vzext intrinsics.and lower to V instructions.
Define new fraction register class fields in LMULInfo and a
NoReg to present invalid LMUL register classes.

Authored-by: ShihPo Hung <shihpo.hung@sifive.com>
Co-Authored-by: Zakk Chen <zakk.chen@sifive.com>
Reviewed By: craig.topper

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

3 years ago[gn build] Port 480936e741d
LLVM GN Syncbot [Wed, 30 Dec 2020 00:40:53 +0000 (00:40 +0000)]
[gn build] Port 480936e741d

3 years agoReland "[NewPM][CodeGen] Introduce CodeGenPassBuilder to help build codegen pipeline...
Yuanfang Chen [Wed, 30 Dec 2020 00:30:16 +0000 (16:30 -0800)]
Reland "[NewPM][CodeGen] Introduce CodeGenPassBuilder to help build codegen pipeline" (again)

This reverts commit 16c8f6e91344ec9840d6aa9ec6b8d0c87a104ca3 with fix.

-Wswitch catched an unhandled enum value due to recent commits in
TargetPassConfig.cpp.