platform/upstream/llvm.git
2 years agoRevert "[LLDB][GUI] Refactor form drawing using subsurfaces"
Jason Molenda [Fri, 6 Aug 2021 02:27:55 +0000 (19:27 -0700)]
Revert "[LLDB][GUI] Refactor form drawing using subsurfaces"

Temporarily revert this patch to unbreak the bots/builds
until we can understand what was intended; is_pad() call
isn't defined.

This reverts commit 2b89f40a411cb9717232df61371b24d73ae84cb8.

2 years ago[AVR][clang] Pass '-fno-use-init-array' to cc1 as default
Matt Jacobson [Fri, 6 Aug 2021 02:12:00 +0000 (10:12 +0800)]
[AVR][clang] Pass '-fno-use-init-array' to cc1 as default

On AVR, '.ctors' is used, not '.init_array'. Make this the default
unless specifically overridden by driver argument.

This matches gcc, and it matches the behavior in (e.g.) the NetBSD
driver (for certain OS variants).

Reviewed by: MaskRay

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

2 years ago[mlir] Cleanup: Fix warnings in MLIR
Matthias Springer [Fri, 6 Aug 2021 01:28:12 +0000 (10:28 +0900)]
[mlir] Cleanup: Fix warnings in MLIR

Tested with gcc-10. Other compilers may generate additional warnings. This does not fix all warnings. There are a few extra ones in LLVMCore and MLIR.

* `OpEmitter::getAttrNameIndex`: -Wunused-function (function is private and not used anywhere)
* `PrintOpPass` copy constructor: -Wextra ("Base class should be explicitly initialized in the copy constructor")
* `LegalizeForLLVMExport.cpp`: -Woverflow (overflow is expected, silence warning by making the cast explicit)

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

2 years ago[AArch64][GlobalISel] Overhaul G_INSERT legalization
Jessica Paquette [Thu, 5 Aug 2021 21:26:36 +0000 (14:26 -0700)]
[AArch64][GlobalISel] Overhaul G_INSERT legalization

Similar cleanup to G_EXTRACT (51bd4e874fa51412e7399fe7f863169b4f4829bc).

Also swap the order of clamp/widen to avoid unnecessary complex merges.

Add a bunch of missing testcases to legalize-inserts while we're at it.

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

2 years ago[AArch64][GlobalISel] Widen G_IMPLICIT_DEF and G_FREEZE before clamping
Jessica Paquette [Thu, 5 Aug 2021 21:48:18 +0000 (14:48 -0700)]
[AArch64][GlobalISel] Widen G_IMPLICIT_DEF and G_FREEZE before clamping

Similar to other cleanup commits which widen instructions before clamping
during legalization. Purpose of this is to avoid weird type breakdowns.

In terms of G_IMPLICIT_DEF, this simplifies legalization for other instructions.
The legalizer has to emit G_IMPLICIT_DEF to legalize certain instructions, so
this can help with emitting merges elsewhere.

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

2 years ago[PowerPC][AIX] Create multiple constant sections.
Sean Fertile [Fri, 14 May 2021 17:55:13 +0000 (13:55 -0400)]
[PowerPC][AIX] Create multiple constant sections.

Fixes issue where late materialized constants can be more strictly
aligned then their containing csect.

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

2 years agoRevert "[GlobalISel][KnownBits] Implement G_CTPOP"
Jon Roelofs [Fri, 6 Aug 2021 00:46:33 +0000 (17:46 -0700)]
Revert "[GlobalISel][KnownBits] Implement G_CTPOP"

This reverts commit ce6eb4f15a159e652bdccf92a9d3da8a972d1596.

It's broken on the windows bots: https://reviews.llvm.org/D107606#2930121

2 years ago[GlobalISel] Allow the ArtifactValueFinder to return the best available register...
Amara Emerson [Thu, 29 Jul 2021 00:30:06 +0000 (17:30 -0700)]
[GlobalISel] Allow the ArtifactValueFinder to return the best available register on failure.

In some cases, like with inserts, we may have a matching size register already,
but still decide to try to look further. This change adds a CurrentBest
register to the value finder state, and any time a method fails to make progress,
returns that register (which may just be an empty Register).

To facilitate this, add a new entry point to the findValueFromDef() function
which initializes this state.

Also fix the build vector finder to return the current build_vector if all
sources are being requested.

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

2 years ago[GlobalISel][KnownBits] Implement G_CTPOP
Jon Roelofs [Thu, 5 Aug 2021 21:57:44 +0000 (14:57 -0700)]
[GlobalISel][KnownBits] Implement G_CTPOP

Implementation copied almost verbatim from ValueTracking.

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

2 years ago[llvm-profgen] Fix bug of loop scope mismatch
wlei [Thu, 5 Aug 2021 03:20:58 +0000 (20:20 -0700)]
[llvm-profgen] Fix bug of loop scope mismatch

One performance issue happened in profile generation and it turned out the line 525 loop is the bottleneck.
Moving the code outside of loop scope can fix this issue. The run time is improved from 30+mins to ~30s.

Reviewed By: hoy, wenlei

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

2 years ago[LLDB][GUI] Refactor form drawing using subsurfaces
Omar Emara [Thu, 5 Aug 2021 23:50:50 +0000 (16:50 -0700)]
[LLDB][GUI] Refactor form drawing using subsurfaces

This patch adds a new method SubSurface to the Surface class. The method
returns another surface that is a subset of this surface. This is
important to further abstract away drawing from the ncurses objects. For
instance, fields could previously be drawn on subpads only but can now
be drawn on any surface. This is needed to create the file search
dialogs and similar functionalities.

There is an opportunity to refactor window drawing in general using
surfaces, but we shall consider this separately later.

Reviewed By: clayborg

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

2 years agoMark getc_unlocked as unavailable by default
Ryan Prichard [Thu, 5 Aug 2021 23:35:02 +0000 (16:35 -0700)]
Mark getc_unlocked as unavailable by default

Before D45736, getc_unlocked was available by default, but turned off
for non-Cygwin/non-MinGW Windows. D45736 then added 9 more unlocked
functions, which were unavailable by default, but it also:
 * left getc_unlocked enabled by default,
 * removed the disabling line for Windows, and
 * added code to enable getc_unlocked for GNU, Android, and OSX.

For consistency, make getc_unlocked unavailable by default. Maybe this
was the intent of D45736 anyway.

Reviewed By: MaskRay, efriedma

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

2 years ago[AArch64][GlobalISel] Widen extloads before clamping during legalization
Jessica Paquette [Thu, 5 Aug 2021 18:25:41 +0000 (11:25 -0700)]
[AArch64][GlobalISel] Widen extloads before clamping during legalization

Allows us to avoid awkward type breakdowns on types like s88, like the other
commits.

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

2 years ago[AMDGPU] Improve v2i32/v2f32 insertelt patterns
Stanislav Mekhanoshin [Thu, 5 Aug 2021 21:25:18 +0000 (14:25 -0700)]
[AMDGPU] Improve v2i32/v2f32 insertelt patterns

Using REG_SEQUENCE produces better code than INSERT_SUBREG,
we can omit one move instruction in many cases.

Fixes: SWDEV-298028

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

2 years ago[PowerPC] Remove accidently left checks
Jinsong Ji [Thu, 5 Aug 2021 22:46:07 +0000 (22:46 +0000)]
[PowerPC] Remove accidently left checks

2 years ago[PowerPC] Add scalar vector test
Jinsong Ji [Thu, 5 Aug 2021 22:36:13 +0000 (22:36 +0000)]
[PowerPC] Add scalar vector test

2 years ago[WebAssembly] Don't do SjLj transformation when there's only setjmp
Heejin Ahn [Wed, 4 Aug 2021 23:27:51 +0000 (16:27 -0700)]
[WebAssembly] Don't do SjLj transformation when there's only setjmp

When there is a `setjmp` call in a function, we transform every callsite
of `setjmp` to record its information by calling `saveSetjmp` function,
and we also transform every callsite of a function that can longjmp to
to check if a longjmp occurred and if so jump to the corresponding
post-setjmp BB. Currently we are doing this for every function that
contains a call to `setjmp`, but if there is no other function call
within that function that can longjmp, this transformation of `setjmp`
callsite and all the preparation of `setjmpTable` in the entry of the
function are not necessary.

This checks if a setjmp-calling function has any other calls that can
longjmp, and if not, skips the function for the SjLj transformation.

Reviewed By: dschuff

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

2 years ago[AArch64] Expand the SVE min/max reduction costs to NEON
David Green [Thu, 5 Aug 2021 22:23:24 +0000 (23:23 +0100)]
[AArch64] Expand the SVE min/max reduction costs to NEON

This takes the existing SVE costing for the various min/max reduction
intrinsics and expands it to NEON, where I believe it applies equally
well.

In the process it changes the lowering to use min/max cost, as opposed
to summing up the cost of ICmp+Select.

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

2 years ago[AIX] "aligned" attribute should not decrease type alignment returned by __alignof__
Steven Wan [Thu, 5 Aug 2021 22:18:48 +0000 (18:18 -0400)]
[AIX] "aligned" attribute should not decrease type alignment returned by __alignof__

`__alignof__(x)` always returns `ABIAlign` if the "x" is marked `__attribute__((aligned()))`. However, the "aligned" attribute should only increase the alignment of a struct, or struct member, unless it's used together with the "packed" attribute, or used as a part of a typedef, in which case, the "aligned" attribute can both increase and decrease alignment.

Reviewed By: sfertile

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

2 years ago[AArch64][GlobalISel] Widen G_BSWAP before clamping
Jessica Paquette [Thu, 5 Aug 2021 22:04:33 +0000 (15:04 -0700)]
[AArch64][GlobalISel] Widen G_BSWAP before clamping

This allows us to avoid odd type breakdowns + allows us to legalize types like
s88 in the first place.

Add some testcases for known legal types + testcases for s4 and s88.

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

2 years ago[Thumb2] generate checks in ldr-str-imm12.ll. NFC.
Stanislav Mekhanoshin [Thu, 5 Aug 2021 18:59:53 +0000 (11:59 -0700)]
[Thumb2] generate checks in ldr-str-imm12.ll. NFC.

That seems this test does not check what was stated in the
comment anymore. Just switch to generated checks.

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

2 years ago[AMDGPU] add v2i32 and v2f32 insert_vector_elt tests. NFC.
Stanislav Mekhanoshin [Thu, 5 Aug 2021 21:28:32 +0000 (14:28 -0700)]
[AMDGPU] add v2i32 and v2f32 insert_vector_elt tests. NFC.

2 years ago[AArch64][GlobalISel] Overhaul G_EXTRACT legalization
Jessica Paquette [Wed, 4 Aug 2021 20:29:27 +0000 (13:29 -0700)]
[AArch64][GlobalISel] Overhaul G_EXTRACT legalization

This simplifies our existing G_EXTRACT rules and adds some test coverage. Mostly
changing this because it should make it easier to improve legalization for
instructions which use G_EXTRACT as part of the legalization process.

This also adds support for legalizing some weird types. Similar to other recent
legalizer changes, this changes the order of widening/clamping.

There was some dead code in our existing rules (e.g. the p0 case would never get
hit), so this knocks those out and makes the types we want to handle explicit.

This also removes some checks which, nowadays, are handled by the
MachineVerifier.

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

2 years ago[msan] Don't track origns in signal handlers
Vitaly Buka [Wed, 4 Aug 2021 08:00:46 +0000 (01:00 -0700)]
[msan] Don't track origns in signal handlers

Origin::CreateHeapOrigin is not async-signal-safe and can deadlock.

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

2 years ago[lldb] Stop referencing "host_lib" in cmake files
Nico Weber [Wed, 4 Aug 2021 11:47:36 +0000 (13:47 +0200)]
[lldb] Stop referencing "host_lib" in cmake files

It hasn't had an effect since https://reviews.llvm.org/rG7b968969db.

No behavior change.

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

2 years agoClean up instcombine stpcpy test
Nathan Lanza [Thu, 5 Aug 2021 03:08:08 +0000 (23:08 -0400)]
Clean up instcombine stpcpy test

Deduplicate some code and add an additional test to verify that the
sprintf->stpcpy optimization still works on android21 (which properly
supports it).

This follows up 58481663692b55.

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

2 years ago[lldb] Remove a few unused .exports files
Nico Weber [Wed, 4 Aug 2021 11:25:26 +0000 (13:25 +0200)]
[lldb] Remove a few unused .exports files

They used to be referenced from the .xcodeproj files, but those are long gone.

No behavior change.

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

2 years ago[gn build] manually port 4d293f215dfb (LLVMDiff lib)
Nico Weber [Thu, 5 Aug 2021 20:09:02 +0000 (22:09 +0200)]
[gn build] manually port 4d293f215dfb (LLVMDiff lib)

2 years ago[Polly][test] Add tests for IslMaxOperationsGuard.
Michael Kruse [Thu, 5 Aug 2021 19:51:29 +0000 (14:51 -0500)]
[Polly][test] Add tests for IslMaxOperationsGuard.

Add unittests for IslMaxOperationsGuard and the behaviour of the isl-noexception.h wrapper under exceeded max_operations.

Reviewed By: patacca

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

2 years ago[Polly][test] Test difference between isl::stat:ok() and isl::stat::error().
Michael Kruse [Thu, 5 Aug 2021 19:47:14 +0000 (14:47 -0500)]
[Polly][test] Test difference between isl::stat:ok() and isl::stat::error().

The foreach callback wrappers tests check the return values of isl::stat:ok() and isl::stat::error() separately. However, due to the the container they are iterating over containing just one element, they are actually not testing the difference between them.

This patch changes to set to be iterated over to contain 2 element to make returning sl::stat:ok (continue iterating the next element) and isl::stat::error (break after current element) have different effects other than the return value of the foreach itself.

Reviewed By: patacca

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

2 years ago[libFuzzer] Add missing include on Darwin.
Matt Morehouse [Thu, 5 Aug 2021 19:26:47 +0000 (12:26 -0700)]
[libFuzzer] Add missing include on Darwin.

2 years ago[clang] Implement -falign-loops=N (N is a power of 2) for non-LTO
Fangrui Song [Thu, 5 Aug 2021 19:17:50 +0000 (12:17 -0700)]
[clang] Implement -falign-loops=N (N is a power of 2) for non-LTO

GCC supports multiple forms of -falign-loops=.
-falign-loops= is currently ignored in Clang.

This patch implements the simplest but the most useful form where N is a
power of 2.

The underlying implementation uses a `llvm::TargetOptions` option for now.
Bitcode generation ignores this option.

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

2 years ago[llvm-diff] Create libLLVMDiff library
Bill Wendling [Tue, 3 Aug 2021 19:49:39 +0000 (12:49 -0700)]
[llvm-diff] Create libLLVMDiff library

Some tools may want to use the LLVM "diff" code. Move the code into a
library for easy use.

No functionality change intende.

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

2 years ago[AArch64][GlobalISel] Legalize ctpop s128
Jon Roelofs [Thu, 5 Aug 2021 18:52:26 +0000 (11:52 -0700)]
[AArch64][GlobalISel] Legalize ctpop s128

This is re-landing the same patch again, but without the changes to
LegalizerHelper that regressed the Mips test:

test/CodeGen/Mips/GlobalISel/llvm-ir/ctpop.ll

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

2 years agoEnable extra coverage counters on Windows
Matt Morehouse [Thu, 5 Aug 2021 17:38:46 +0000 (10:38 -0700)]
Enable extra coverage counters on Windows

- Enable extra coverage counters on Windows.
- Update extra_counters.test to run on Windows also.
- Update TableLookupTest.cpp to include the required pragma/declspec for the extra coverage counters.

Patch By: MichaelSquires

Reviewed By: morehouse

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

2 years ago[libc++] IWYU to fix complaints when compiling with Modules. NFCI.
Arthur O'Dwyer [Thu, 5 Aug 2021 17:19:05 +0000 (13:19 -0400)]
[libc++] IWYU to fix complaints when compiling with Modules. NFCI.

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

2 years ago{DebugInfo][LSR] Don't cache dbg.value that are already undef
Chris Jackson [Thu, 5 Aug 2021 14:46:09 +0000 (15:46 +0100)]
{DebugInfo][LSR] Don't cache dbg.value that are already undef

The SCEV-based salvaging method caches dbg.value information pre-LSR so
that salvaging may be attempted post-LSR. If the dbg.value are already
undef pre-LSR then a salvage attempt would be fruitless, so avoid
caching them.

Reviewed By: StephenTozer

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

2 years agoRevert "[llvm-diff] Create libLLVMDiff library"
Matt Morehouse [Thu, 5 Aug 2021 18:07:53 +0000 (11:07 -0700)]
Revert "[llvm-diff] Create libLLVMDiff library"

This reverts commit 9854f2f30f84123ca78aa3603102e7cef4ec33c8 since it
broke all the builds.

2 years agosanitizer_common: disable thread safety annotations for googletest
Dimitry Andric [Wed, 4 Aug 2021 18:33:48 +0000 (20:33 +0200)]
sanitizer_common: disable thread safety annotations for googletest

Recently in 0da172b1766e thread safety warnings-as-errors were enabled.
However, googletest is currently not compatible with thread safety
annotations. On FreeBSD, which has the pthread functions marked with
such annotations, this results in errors when building the compiler-rt
tests:

    In file included from compiler-rt/lib/interception/tests/interception_test_main.cpp:15:
    In file included from llvm/utils/unittest/googletest/include/gtest/gtest.h:62:
    In file included from llvm/utils/unittest/googletest/include/gtest/internal/gtest-internal.h:40:
    llvm/utils/unittest/googletest/include/gtest/internal/gtest-port.h:1636:3: error: mutex 'mutex_' is still held at the end of function [-Werror,-Wthread-safety-analysis]
      }
      ^
    llvm/utils/unittest/googletest/include/gtest/internal/gtest-port.h:1633:32: note: mutex acquired here
        GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_lock(&mutex_));
                                   ^
    llvm/utils/unittest/googletest/include/gtest/internal/gtest-port.h:1645:32: error: releasing mutex 'mutex_' that was not held [-Werror,-Wthread-safety-analysis]
        GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_unlock(&mutex_));
                                   ^
    2 errors generated.

At some point googletest will hopefully be made compatible with thread
safety annotations, but for now add corresponding `-Wno-thread-*` flags
to `COMPILER_RT_GTEST_CFLAGS` to silence these warnings-as-errors.

Reviewed By: dvyukov

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

2 years ago[Bazel] Update for 9854f2f30f (Diff library)
Geoffrey Martin-Noble [Thu, 5 Aug 2021 17:59:40 +0000 (10:59 -0700)]
[Bazel] Update for 9854f2f30f (Diff library)

Updates the Bazel build for
https://github.com/llvm/llvm-project/commit/9854f2f30f by extracting a
library from llvm-diff. Note that this does not include the new
llvm-livepatch binary, for which the CMake file was added accidentally
and reverted in https://github.com/llvm/llvm-project/commit/fec8f1a008.

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

2 years ago[libc] Add diff and perf targets for more math functions
Hedin Garca [Wed, 4 Aug 2021 13:49:41 +0000 (13:49 +0000)]
[libc] Add diff and perf targets for more math functions

Comparing the run time of math functions from LLVM libc
with the MSVCRT libc:
|function |perf-LLVM libc     |perf-MSVCRT
|ceilf |2.36 mins (141491389600 ns)|47.10 sec (47100940100 ns)
|exp2f             |6.37 mins (358441794700 ns)|12.39 mins (719404388300 ns)
|expf |6.35 mins (381204661800 ns)|6.17 mins (346150163200 ns)
|fabsf |1.18 mins (78425546600 ns) |53.75 sec (53745301900 ns)
|floorf |3.15 mins (164770963800 ns)|45.94 sec (45935988400 ns)
|logbf |4.38 mins (262508058800 ns)|55.47 sec (55466377700 ns)
|nearbyintf |3.20 mins (167972868000 ns)|9.13 mins (523822963600 ns)
|rintf |3.20 mins (168001498700 ns)|22.35 mins (1341266448800 ns)
|roundf |2.35 mins (141151500600 ns)|1.42 mins (85326429800 ns)
|truncf |2.31 mins (114846424000 ns)|59.41 sec (59414309100 ns)

Evaluating the number of differing results in Windows:
|function |diff
|ceilf          |8388606 differing results
|exp2f         |213303887 differing results
|expf           |193922 differing results
|fabsf          |8388606 differing results
|floorf         |8388606 differing results
|logbf          |0 differing results
|nearbyintf     |0 differing results
|rintf          |0 differing results
|roundf         |0 differing results
|truncf  |0 differing results

Reviewed By: sivachandra

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

2 years agoRemove unintended commit.
Bill Wendling [Thu, 5 Aug 2021 17:50:38 +0000 (10:50 -0700)]
Remove unintended commit.

2 years ago[clang] Replace asm with __asm__ in cuda header
Jon Chesterfield [Thu, 5 Aug 2021 17:46:57 +0000 (18:46 +0100)]
[clang] Replace asm with __asm__ in cuda header

Asm is a gnu extension for C, so at present -fopenmp -std=c99
and similar fail to compile on nvptx, bug 51344

Changing to `__asm__` or `__asm` works for openmp, all three appear to work
for cuda. Suggesting `__asm__` here as `__asm` is used by MSVC with different
syntax, so this should make for better error diagnostics if the header is
passed to a compiler other than clang.

Reviewed By: tra, emankov

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

2 years ago[NFC][X86] combineX86ShuffleChain(): hoist Mask variable higher up
Roman Lebedev [Thu, 5 Aug 2021 17:35:40 +0000 (20:35 +0300)]
[NFC][X86] combineX86ShuffleChain(): hoist Mask variable higher up

Having `NewMask` outside of an if and rebinding `BaseMask` `ArrayRef`
to it is confusing. Instead, just move the `Mask` vector higher up,
and change the code that earlier had no access to it but now does
to use `Mask` instead of `BaseMask`.

This has no other intentional changes.

This is a recommit of 35c0848b570214ed2b2d96cca4dd62bb7ae725cd,
that was reverted to simplify reversion of an earlier change.

2 years ago[NFC][Codegen][X86] Add testcase that hanged after D107009
Roman Lebedev [Thu, 5 Aug 2021 17:30:22 +0000 (20:30 +0300)]
[NFC][Codegen][X86] Add testcase that hanged after D107009

From Benjamin Kramer @ https://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20210802/945642.html

2 years ago[llvm-diff] Create libLLVMDiff library
Bill Wendling [Tue, 3 Aug 2021 19:49:39 +0000 (12:49 -0700)]
[llvm-diff] Create libLLVMDiff library

Some tools may want to use the LLVM "diff" code. Move the code into a
library for easy use.

No functionality change intende.

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

2 years ago[ELF] Support copy relocation on non-default version symbols
Fangrui Song [Thu, 5 Aug 2021 17:32:14 +0000 (10:32 -0700)]
[ELF] Support copy relocation on non-default version symbols

Copy relocation on a non-default version symbol is unsupported and can crash at
runtime. Fortunately there is a one-line fix which works for most cases:
ensure `getSymbolsAt` unconditionally returns `ss`.

If two non-default version symbols are defined at the same place and both
are copy relocated, our implementation will copy relocated them into different
addresses. The pointer inequality is very unlikely an issue. In GNU ld, copy
relocating version aliases seems to create more pointer inequality problems than
us.

(
In glibc, sys_errlist@GLIBC_2.2.5 sys_errlist@GLIBC_2.3 sys_errlist@GLIBC_2.4
are defined at the same place, but it is unlikely they are all copy relocated in
one executable. Even if so, the variables are read-only and pointer inequality
should not be a problem.
)

Reviewed By: peter.smith

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

2 years ago[lldb] Refactor IRExecutionUnit::FindInSymbols (NFC)
Jonas Devlieghere [Thu, 5 Aug 2021 16:35:37 +0000 (09:35 -0700)]
[lldb] Refactor IRExecutionUnit::FindInSymbols (NFC)

This patch refactors IRExecutionUnit::FindInSymbols. It eliminates a few
potential pitfalls and tries to be more explicit about the state carried
between symbol resolution attempts.

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

2 years ago[lldb] Use a struct to pass function search options to Module::FindFunction
Jonas Devlieghere [Thu, 5 Aug 2021 16:27:19 +0000 (09:27 -0700)]
[lldb] Use a struct to pass function search options to Module::FindFunction

Rather than passing two booleans around, which is especially error prone
with them being next to each other, use a struct with named fields
instead.

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

2 years agoFix COMPILER_RT_DEBUG build for targets that don't support thread local storage.
Dan Liew [Thu, 5 Aug 2021 02:24:56 +0000 (19:24 -0700)]
Fix COMPILER_RT_DEBUG build for targets that don't support thread local storage.

022439931f5be77efaf80b44d587666b0c9b13b5 added code that is only enabled
when COMPILER_RT_DEBUG is enabled. This code doesn't build on targets
that don't support thread local storage because the code added uses the
THREADLOCAL macro. Consequently the COMPILER_RT_DEBUG build broke for
some Apple targets (e.g. 32-bit iOS simulators).

```
/Volumes/user_data/dev/llvm/llvm.org/main/src/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_mutex.cpp:216:8: error: thread-local storage is not supported for the current target
static THREADLOCAL InternalDeadlockDetector deadlock_detector;
       ^
/Volumes/user_data/dev/llvm/llvm.org/main/src/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h:227:24: note: expanded from macro 'THREADLOCAL'
 # define THREADLOCAL   __thread
                        ^
1 error generated.
```

To fix this, this patch introduces a `SANITIZER_SUPPORTS_THREADLOCAL`
macro that is `1` iff thread local storage is supported by the current
target. That condition is then added to `SANITIZER_CHECK_DEADLOCKS` to
ensure the code is only enabled when thread local storage is available.

The implementation of `SANITIZER_SUPPORTS_THREADLOCAL` currently assumes
Clang. See `llvm-project/clang/include/clang/Basic/Features.def` for the
definition of the `tls` feature.

rdar://81543007

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

2 years ago[llvm-ar] Fix for handling thin archive with SYM64 and a test case for it
Ramesh Peri [Thu, 5 Aug 2021 17:04:28 +0000 (10:04 -0700)]
[llvm-ar] Fix for handling thin archive with SYM64 and a test case for it

WHen thin archives are created which have symbol table of type SYM64 then all the tools will not work since they cannot read the files properly.
One can reproduce the problem as follows:
1. Take a hello world program and create an archive out of it. The SYM64_THRESHOLD=0 will force the generation of SYM64 symbol table.
    clang -c hello.cpp
    SYM64_THRESHOLD=0 llvm-ar crsT mylib.a hello.o
2. Now try to use any of the tools on this mylib.a and it will fail.
    llvm-nm -M mylib.a

THis fix will eliminate these failures. A regression test is created in llvm/test/Object/archive-symtab.test

Reviewed By: MaskRay, Ramesh

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

2 years agoFix clang-interpreter build after 2487db1f286222e2501c2fa8e8244eda13f6afc3
Jon Roelofs [Thu, 5 Aug 2021 16:35:02 +0000 (09:35 -0700)]
Fix clang-interpreter build after 2487db1f286222e2501c2fa8e8244eda13f6afc3

2 years agoRevert "[X86] combineX86ShuffleChain(): canonicalize mask elts picking from splats"
Benjamin Kramer [Thu, 5 Aug 2021 16:53:00 +0000 (18:53 +0200)]
Revert "[X86] combineX86ShuffleChain(): canonicalize mask elts picking from splats"

This reverts commits f819e4c7d0f6efef3cc1042cc45582320bf6c0a2 and
35c0848b570214ed2b2d96cca4dd62bb7ae725cd. It triggers an infinite loop during
compilation.

$ cat t.ll
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

define void @MaxPoolGradGrad_1.65() local_unnamed_addr #0 {
entry:
  %wide.vec78 = load <64 x i32>, <64 x i32>* null, align 16
  %strided.vec83 = shufflevector <64 x i32> %wide.vec78, <64 x i32> poison, <8 x i32> <i32 4, i32 12, i32 20, i32 28, i32 36, i32 44, i32 52, i32 60>
  %0 = lshr <8 x i32> %strided.vec83, <i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16>
  %1 = add <8 x i32> zeroinitializer, %0
  %2 = shufflevector <8 x i32> %1, <8 x i32> undef, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
  %3 = shufflevector <16 x i32> %2, <16 x i32> undef, <32 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>
  %interleaved.vec = shufflevector <32 x i32> undef, <32 x i32> %3, <64 x i32> <i32 0, i32 8, i32 16, i32 24, i32 32, i32 40, i32 48, i32 56, i32 1, i32 9, i32 17, i32 25, i32 33, i32 41, i32 49, i32 57, i32 2, i32 10, i32 18, i32 26, i32 34, i32 42, i32 50, i32 58, i32 3, i32 11, i32 19, i32 27, i32 35, i32 43, i32 51, i32 59, i32 4, i32 12, i32 20, i32 28, i32 36, i32 44, i32 52, i32 60, i32 5, i32 13, i32 21, i32 29, i32 37, i32 45, i32 53, i32 61, i32 6, i32 14, i32 22, i32 30, i32 38, i32 46, i32 54, i32 62, i32 7, i32 15, i32 23, i32 31, i32 39, i32 47, i32 55, i32 63>
  store <64 x i32> %interleaved.vec, <64 x i32>* undef, align 16
  unreachable
}

$ llc < t.ll -mcpu=skylake
<hang>

2 years ago[AArch64][GlobalISel] Mark v16s8 <- v8s8, v8s8 G_CONCAT_VECTOR as legal
Jessica Paquette [Wed, 4 Aug 2021 23:33:40 +0000 (16:33 -0700)]
[AArch64][GlobalISel] Mark v16s8 <- v8s8, v8s8 G_CONCAT_VECTOR as legal

G_CONCAT_VECTORS shows up from time to time when legalizing other instructions.

We actually import patterns for the v16s8 <- v8s8, v8s8 case so marking it
as legal gives us selection for free.

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

2 years agoAdd llvm-stress binary to Bazel build configuration.
Daniele Vettorel [Thu, 5 Aug 2021 16:32:36 +0000 (12:32 -0400)]
Add llvm-stress binary to Bazel build configuration.

The `llvm-stress` binary is currently missing from the Bazel `BUILD` file for llvm. This patch adds it.

Reviewed By: GMNGeoffrey

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

2 years ago[SLP] Add additional memory version tests.
Florian Hahn [Thu, 5 Aug 2021 09:33:29 +0000 (10:33 +0100)]
[SLP] Add additional memory version tests.

2 years agoFix signal during the call to checkOpenMPLoop.
Jennifer Yu [Tue, 3 Aug 2021 18:16:29 +0000 (11:16 -0700)]
Fix signal during the call to checkOpenMPLoop.

The root problem is a null pointer is accessed during the call to
checkOpenMPLoop, because loop up bound expr is an error expression
due to error diagnostic was emit early.

To fix this, in setLCDeclAndLB, setUB and setStep instead return false,
return true when LB, UB or Step contains Error, so that the checking is
stopped in checkOpenMPLoop.

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

2 years ago[Transforms] Drop unnecessary const from return types (NFC)
Kazu Hirata [Thu, 5 Aug 2021 15:53:17 +0000 (08:53 -0700)]
[Transforms] Drop unnecessary const from return types (NFC)

Identified with readability-const-return-type.

2 years ago[SLP]Do not emit extra shuffle for insertelements vectorization.
Alexey Bataev [Wed, 4 Aug 2021 18:30:32 +0000 (11:30 -0700)]
[SLP]Do not emit extra shuffle for insertelements vectorization.

If the vectorized insertelements instructions form indentity subvector
(the subvector at the beginning of the long vector), it is just enough
to extend the vector itself, no need to generate inserting subvector
shuffle.

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

2 years ago[DAGCombiner][RISCV][AMDGPU] Call SimplifyDemandedBits at the end of visitMULHU to...
Craig Topper [Thu, 5 Aug 2021 15:31:24 +0000 (08:31 -0700)]
[DAGCombiner][RISCV][AMDGPU] Call SimplifyDemandedBits at the end of visitMULHU to enable known bits contant folding.

We don't have real demanded bits support for MULHU, but we can
still use the known bits based constant folding support at the end
of SimplifyDemandedBits to simplify a MULHU. This helps with cases
where we know the LHS and RHS have enough leading zeros so that
the high multiply result is always 0.

Reviewed By: RKSimon

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

2 years agoFix build issues caused by 95800da914938129083df2fa0165c1901909c273
David Sherwood [Thu, 5 Aug 2021 15:26:11 +0000 (16:26 +0100)]
Fix build issues caused by 95800da914938129083df2fa0165c1901909c273

2 years ago[LV] Consider ExtractValue as uniform.
Sander de Smalen [Thu, 5 Aug 2021 13:45:53 +0000 (14:45 +0100)]
[LV] Consider ExtractValue as uniform.

Since all operands to ExtractValue must be loop-invariant when we deem
the loop vectorizable, we can consider ExtractValue to be uniform.

Reviewed By: david-arm

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

2 years ago[PowerPC][AIX] attribute aligned cannot decrease align of a vector var.
Sean Fertile [Thu, 5 Aug 2021 14:53:27 +0000 (10:53 -0400)]
[PowerPC][AIX] attribute aligned cannot decrease align of a vector var.

On AIX an aligned attribute cannot decrease the alignment of a variable
when placed on a variable declaration of vector type.

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

2 years ago[NFC][LoopIdiom] rename boolean variable NegStride to IsNegStride
eopXD [Thu, 5 Aug 2021 14:30:28 +0000 (22:30 +0800)]
[NFC][LoopIdiom] rename boolean variable NegStride to IsNegStride

Rename variable for better code readability.

Reviewed By: lebedev.ri

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

2 years ago[AMDGPU][SDag] Better lowering for 32-bit ctlz/cttz
Jay Foad [Thu, 5 Aug 2021 13:32:25 +0000 (14:32 +0100)]
[AMDGPU][SDag] Better lowering for 32-bit ctlz/cttz

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

2 years ago[AMDGPU][SDag] Better lowering for 64-bit ctlz/cttz
Jay Foad [Thu, 5 Aug 2021 08:58:29 +0000 (09:58 +0100)]
[AMDGPU][SDag] Better lowering for 64-bit ctlz/cttz

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

2 years agotsan: pass thr/pc to MemoryResetRange
Dmitry Vyukov [Thu, 5 Aug 2021 12:41:36 +0000 (14:41 +0200)]
tsan: pass thr/pc to MemoryResetRange

Pass thr/pc args to MemoryResetRange as we do everywhere.
Currently they are unused by MemoryResetRange,
but there is no reason to be inconsistent.

Depends on D107562.

Reviewed By: melver

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

2 years agotsan: qualify autos
Dmitry Vyukov [Thu, 5 Aug 2021 12:37:06 +0000 (14:37 +0200)]
tsan: qualify autos

clang-tidy warning requires qualifying auto pointers:

clang-tidy: warning: 'auto ctx' can be declared as 'auto *ctx' [llvm-qualified-auto]

Fix remaing cases we have in tsan.

Depends on D107561.

Reviewed By: melver

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

2 years agotsan: don't include tsan_interceptors.h for Go
Dmitry Vyukov [Thu, 5 Aug 2021 12:31:57 +0000 (14:31 +0200)]
tsan: don't include tsan_interceptors.h for Go

None of the interceptors machinery is used/enabled for Go,
so don't include the header, it's not needed (must not be).
The problem is that we have fields in ThreadState that are
not present in the Go build, so changes in thread_interceptors.h
can cause Go build breakages due to missing fields.

Reviewed By: melver

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

2 years ago[SimpifyCFG] Speculate a store preceded by a local non-escaping load
Momchil Velikov [Thu, 5 Aug 2021 14:37:19 +0000 (15:37 +0100)]
[SimpifyCFG] Speculate a store preceded by a local non-escaping load

In SimplifyCFG we may simplify the CFG by speculatively executing
certain stores, when they are preceded by a store to the same
location.  This patch allows such speculation also when the stores are
similarly preceded by a load.

In order for this transformation to be correct we need to ensure that
the memory location is writable and the store in the new location does
not introduce a data race.

Local objects (created by an `alloca` instruction) are always
writable, so once we are past a read from a location it is valid to
also write to that same location.

Seeing just a load does not guarantee absence of a data race (unlike
if we see a store) - the load may still be part of a race, just not
causing undefined behaviour
(cf. https://llvm.org/docs/Atomics.html#optimization-outside-atomic).

In the original program, a data race might have been prevented by the
condition, but once we move the store outside the condition, we must
be sure a data race wasn't possible anyway, no matter what the
condition evaluates to.

One way to be sure that a local object is never concurrently
read/written is check that its address never escapes the function.

Hence this transformation is restricted to local, non-escaping
objects.

Reviewed By: nikic, lebedev.ri

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

2 years agotsan: handle bugs in symbolizer more gracefully
Dmitry Vyukov [Thu, 5 Aug 2021 13:21:37 +0000 (15:21 +0200)]
tsan: handle bugs in symbolizer more gracefully

For symbolizer we only process SIGSEGV signals synchronously
(which means bug in symbolizer or in tsan).
But we still want to reset in_symbolizer to fail gracefully.
Symbolizer and user code use different memory allocators,
so if we don't reset in_symbolizer we can get memory allocated
with one being feed with another, which can cause more crashes.

Reviewed By: melver

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

2 years agotsan: modernize MaybeReportThreadLeak
Dmitry Vyukov [Thu, 5 Aug 2021 13:48:19 +0000 (15:48 +0200)]
tsan: modernize MaybeReportThreadLeak

Use C++ casts and auto.
Rename to CollectThreadLeaks b/c it's only collecting, not reporting.

Reviewed By: melver

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

2 years ago[clang] [clang-repl] Fix linking against LLVMLineEditor
Michał Górny [Thu, 5 Aug 2021 12:00:34 +0000 (14:00 +0200)]
[clang] [clang-repl] Fix linking against LLVMLineEditor

LLVMLineEditor library is part of the LLVM dylib.  Move it into
LLVM_LINK_COMPONENTS to avoid duplicate linking when dylib is being
used.  This fixes building standalone clang against installed LLVM
without static libraries.

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

2 years ago[DAG] DAGCombiner::visitVECTOR_SHUFFLE - recognise INSERT_SUBVECTOR patterns
Simon Pilgrim [Thu, 5 Aug 2021 14:04:06 +0000 (15:04 +0100)]
[DAG] DAGCombiner::visitVECTOR_SHUFFLE - recognise INSERT_SUBVECTOR patterns

IR typically creates INSERT_SUBVECTOR patterns as a widening of the subvector with undefs to pad to the destination size, followed by a shuffle for the actual insertion - SelectionDAGBuilder has to do something similar for shuffles when source/destination vectors are different sizes.

This combine attempts to recognize these patterns by looking for a shuffle of a subvector (from a CONCAT_VECTORS) that starts at a modulo of its size into an otherwise identity shuffle of the base vector.

This uncovered a couple of target-specific issues as we haven't often created INSERT_SUBVECTOR nodes in generic code - aarch64 could only handle insertions into the bottom of undefs (i.e. a vector widening), and x86-avx512 vXi1 insertion wasn't keeping track of undef elements in the base vector.

Fixes PR50053

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

2 years ago[VectorCombine] Limit scalarization known non-poison indices.
Florian Hahn [Thu, 5 Aug 2021 13:50:37 +0000 (14:50 +0100)]
[VectorCombine] Limit scalarization known non-poison indices.

We can only trust the range of the index if it is guaranteed
non-poison.

Fixes PR50949.

Reviewed By: lebedev.ri

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

2 years ago[BuildLibCalls][NFC] Remove redundant attribute list from emitCalloc
Dawid Jurczak [Thu, 5 Aug 2021 11:01:07 +0000 (13:01 +0200)]
[BuildLibCalls][NFC] Remove redundant attribute list from emitCalloc

Additionally with this patch aligned DSE which is the only user of emitCalloc.

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

2 years ago[LoopVectorize] Add support for replication of more intrinsics with scalable vectors
David Sherwood [Fri, 30 Jul 2021 07:41:31 +0000 (08:41 +0100)]
[LoopVectorize] Add support for replication of more intrinsics with scalable vectors

This patch adds more instructions to the Uniforms list, for example certain
intrinsics that are uniform by definition or whose operands are loop invariant.
This list includes:

  1. The intrinsics 'experimental.noalias.scope.decl' and 'sideeffect', which
  are always uniform by definition.
  2. If intrinsics 'lifetime.start', 'lifetime.end' and 'assume' have
  loop invariant input operands then these are also uniform too.

Also, in VPRecipeBuilder::handleReplication we check if an instruction is
uniform based purely on whether or not the instruction lives in the Uniforms
list. However, there are certain cases where calls to some intrinsics can
be effectively treated as uniform too. Therefore, we now also treat the
following cases as uniform for scalable vectors:

  1. If the 'assume' intrinsic's operand is not loop invariant, then we
  are free to treat this as uniform anyway since it's only a performance
  hint. We will get the benefit for the first lane.
  2. When the input pointers for 'lifetime.start' and 'lifetime.end' are loop
  variant then for scalable vectors we assume these still ultimately come
  from the broadcast of an alloca. We do not support scalable vectorisation
  of loops containing alloca instructions, hence the alloca itself would
  be invariant. If the pointer does not come from an alloca then the
  intrinsic itself has no effect.

I have updated the assume test for fixed width, since we now treat it
as uniform:

  Transforms/LoopVectorize/assume.ll

I've also added new scalable vectorisation tests for other intriniscs:

  Transforms/LoopVectorize/scalable-assume.ll
  Transforms/LoopVectorize/scalable-lifetime.ll
  Transforms/LoopVectorize/scalable-noalias-scope-decl.ll

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

2 years agoRevert "[SystemZ][z/OS] Update target specific __attribute__((aligned)) value for...
Fanbo Meng [Thu, 5 Aug 2021 13:23:36 +0000 (09:23 -0400)]
Revert "[SystemZ][z/OS] Update target specific __attribute__((aligned)) value for test"

This reverts commit d91234b21c1a1a34d98157089a8769d8f9a32f06.

Reviewed By: abhina.sreeskantharajan

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

2 years ago[SimplifyLibCalls][NFC] Clean up LibCallSimplifier from 'memset + malloc into calloc...
Dawid Jurczak [Thu, 5 Aug 2021 10:30:19 +0000 (12:30 +0200)]
[SimplifyLibCalls][NFC] Clean up LibCallSimplifier from 'memset + malloc into calloc' transformation

FoldMallocMemset can be safely removed because since https://reviews.llvm.org/D103009
such transformation is already performed in DSE.

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

2 years agoDelay initialization of OptBisect
Krzysztof Parzyszek [Fri, 18 Jun 2021 17:24:03 +0000 (12:24 -0500)]
Delay initialization of OptBisect

When LLVM is used in other projects, it may happen that global cons-
tructors will execute before the call to ParseCommandLineOptions.
Since OptBisect is initialized via a constructor, and has no ability
to be updated at a later time, passing "-opt-bisect-limit" to the
parse function may have no effect.

To avoid this problem use a cl::cb (callback) to set the bisection
limit when the option is actually processed.

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

2 years ago[NFC] Clean up tests in test/Transforms/LoopVectorize/assume.ll
David Sherwood [Fri, 30 Jul 2021 13:25:27 +0000 (14:25 +0100)]
[NFC] Clean up tests in test/Transforms/LoopVectorize/assume.ll

The tests previously had lots of unnecessary CHECK lines, where
all we really need to check is the presence (or absence) of the
assume intrinsic and the correct input operands.

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

2 years ago[PowerPC][AIX] Limit attribute aligned to 4096.
Sean Fertile [Thu, 5 Aug 2021 13:46:58 +0000 (09:46 -0400)]
[PowerPC][AIX] Limit attribute aligned to 4096.

Limit the maximum alignment for attribute aligned to 4096 to match
the limit of the .align pseudo op in the system assembler.

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

2 years ago[DA] control compile-time spent by MIV tests
Bardia Mahjour [Thu, 5 Aug 2021 13:45:53 +0000 (09:45 -0400)]
[DA] control compile-time spent by MIV tests

Function exploreDirections() in DependenceAnalysis implements a recursive
algorithm for refining direction vectors. This algorithm has worst-case
complexity of O(3^(n+1)) where n is the number of common loop levels.
In this patch I'm adding a threshold to control the amount of time we
spend in doing MIV tests (which most of the time end up resulting in over
pessimistic direction vectors anyway).

Reviewed By: Meinersbur

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

2 years ago[LV] Remove a change that was added in D106164.
Sander de Smalen [Thu, 5 Aug 2021 07:30:31 +0000 (08:30 +0100)]
[LV] Remove a change that was added in D106164.

This change wasn't strictly necessary for D106164 and could be removed.
This patch addresses the post-commit comments from @fhahn on D106164, and
also changes sve-widen-gep.ll to use the same IR test as shown in
pointer-induction.ll.

Reviewed By: fhahn

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

2 years ago[NFC] Remove redundant test in Transforms/LoopVectorize/lifetime.ll
David Sherwood [Fri, 30 Jul 2021 10:43:14 +0000 (11:43 +0100)]
[NFC] Remove redundant test in Transforms/LoopVectorize/lifetime.ll

The two tests (@testloopvariant and @testbitcast) are actually
identical as in both loops the bitcast gets widened, forcing the
lifetime marker to be replicated using each lane of the input
vector.

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

2 years agoAdd a DIExpression const-folder to prevent silly expressions.
Paul Robinson [Tue, 27 Jul 2021 20:33:52 +0000 (13:33 -0700)]
Add a DIExpression const-folder to prevent silly expressions.

It's entirely possible (because it actually happened) for a bool
variable to end up with a 256-bit DW_AT_const_value.  This came about
when a local bool variable was initialized from a bitfield in a
32-byte struct of bitfields, and after inlining and constant
propagation, the variable did have a constant value. The sequence of
optimizations had it carrying "i256" values around, but once the
constant made it into the llvm.dbg.value, no further IR changes could
affect it.

Technically the llvm.dbg.value did have a DIExpression to reduce it
back down to 8 bits, but the compiler is in no way ready to emit an
oversized constant *and* a DWARF expression to manipulate it.
Depending on the circumstances, we had either just the very fat bool
value, or an expression with no starting value.

The sequence of optimizations that led to this state did seem pretty
reasonable, so the solution I came up with was to invent a DWARF
constant expression folder.  Currently it only does convert ops, but
there's no reason it couldn't do other ops if that became useful.

This broke three tests that depended on having convert ops survive
into the DWARF, so I added an operator that would abort the folder to
each of those tests.

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

2 years ago[VectorCombine] Add additional tests with freeze combinations.
Florian Hahn [Thu, 5 Aug 2021 12:58:04 +0000 (13:58 +0100)]
[VectorCombine] Add additional tests with freeze combinations.

Suggested in D107364.

2 years agoGlobalISel: Fix matchEqualDefs for instructions with multiple defs
Petar Avramovic [Thu, 5 Aug 2021 11:59:37 +0000 (13:59 +0200)]
GlobalISel: Fix matchEqualDefs for instructions with multiple defs

Instructions that produceSameValue produce same values for operands with
same index. matchEqualDefs used to return true for any two values from
different instructions that produce same values. Fix this by checking if
values are defined by operands with the same index.

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

2 years ago[flang][driver] Delete `f18` (i.e. the old Flang driver)
Andrzej Warzynski [Mon, 12 Jul 2021 08:44:38 +0000 (08:44 +0000)]
[flang][driver] Delete `f18` (i.e. the old Flang driver)

This patch removes `f18`, a.k.a. the old driver. It is being replaced
with the new driver, `flang-new`, which has reached feature parity with
`f18` a while ago. This was discussed in [1] and also in [2].

With this change, `FLANG_BUILD_NEW_DRIVER` is no longer needed and is
also deleted. This means that we are making the dependency on Clang permanent
(i.e. it cannot be disabled with a CMake flag).

LIT set-up is updated accordingly. All references to `f18` or `f18.cpp`
are either updated or removed.

The `F18_FC` variable from the `flang` bash script is replaced with
`FLANG_FC`. The former is still supported for backwards compatibility.

[1] https://lists.llvm.org/pipermail/flang-dev/2021-June/000742.html
[2] https://reviews.llvm.org/D103177

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

2 years ago[AMDGPU] Add globalisel checks for ctlz_zero_undef/cttz_zero_undef
Jay Foad [Thu, 5 Aug 2021 09:57:38 +0000 (10:57 +0100)]
[AMDGPU] Add globalisel checks for ctlz_zero_undef/cttz_zero_undef

2 years ago[X86] Rename Subtarget Tuning Feature Flag Prefix. NFC.
Simon Pilgrim [Thu, 5 Aug 2021 11:05:02 +0000 (12:05 +0100)]
[X86] Rename Subtarget Tuning Feature Flag Prefix. NFC.

As suggested on D107370, this patch renames the tuning feature flags to start with 'Tuning' instead of 'Feature'.

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

2 years ago[GlobalISel] Combine shr(shl x, c1), c2 to G_SBFX/G_UBFX
Dominik Montada [Tue, 3 Aug 2021 07:56:32 +0000 (09:56 +0200)]
[GlobalISel] Combine shr(shl x, c1), c2 to G_SBFX/G_UBFX

Reviewed By: foad

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

2 years agotsan: introduce RawShadow type
Dmitry Vyukov [Wed, 4 Aug 2021 16:55:00 +0000 (18:55 +0200)]
tsan: introduce RawShadow type

Currently we hardcode u64 type for shadow everywhere
and do lots of uptr<->u64* casts. It makes it hard to
change u64 to another type (e.g. u32) and makes it easy
to introduce bugs.
Introduce RawShadow type and use it in MemToShadow, ShadowToMem,
IsShadowMem and throughout the code base as u64 replacement.
This makes it possible to change u64 to something else in future
and generally improves static typing.

Depends on D107481.

Reviewed By: vitalybuka

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

2 years agotsan: make IsMetaMem accept u32*
Dmitry Vyukov [Wed, 4 Aug 2021 16:27:53 +0000 (18:27 +0200)]
tsan: make IsMetaMem accept u32*

MemToMeta returns u32*, so it's reasonable for IsMetaMem
to accept u32* as well.
Changing the argument type just removes few type casts.

Reviewed By: vitalybuka

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

2 years agoCorrect a lot of diagnostic wordings for the driver
Aaron Ballman [Thu, 5 Aug 2021 11:04:03 +0000 (07:04 -0400)]
Correct a lot of diagnostic wordings for the driver

Clang diagnostics should not start with a capital letter or use
trailing punctuation (https://clang.llvm.org/docs/InternalsManual.html#the-format-string),
but quite a few driver diagnostics were not following this advice. This
corrects the grammar and punctuation to improve consistency, but does
not change the circumstances under which the diagnostics are produced.

2 years ago[flang][driver] Refactor boolean options
Andrzej Warzynski [Wed, 30 Jun 2021 10:57:48 +0000 (10:57 +0000)]
[flang][driver] Refactor boolean options

For boolean options, e.g. `-fxor-operator`/`-fno-xor-operator`, we ought
to be using TableGen multi-classes. This way, we only have to write one
definition to have both forms auto-generated. This patch refactors all
of Flang's boolean options to use two new multi-classes:
`OptInFC1FFOption` and `OptOutFC1FFOption`. These multi-classes are
based on `OptInFFOption`/`OptOutFFOption`, respectively. I've also
simplified the processing of the updated options in
CompilerInvocation.cpp.

With the new approach, "empty" help text (i.e. no `HelpText`) is now
replaced with an empty string (i.e. HelpText<"">). When running
flang-new --help, that's considered as non-empty help messages, which is
then printed (that's controlled by `printHelp` from
llvm/lib/Option/OptTable.cpp). This means that with this patch,
flang-new --help will start printing e.g. -fno-backslash, even though
there is no actual help text to print for this option (apart from the
empty string ""). Tests are updated accordingly.

Note that with this patch, both `-fxor-operator` and `-fno-xor-operator`
(and other boolean options refactored here) remain available in
`flang-new` and `flang-new -fc1`. In this respect, nothing changes. In a
forthcoming patch, I will refine this so that `flang-new -fc1` only
accepts `-ffoo` (`OptInFC1FFOption`) or `-fno-foo` (`OptOutCC1FFOption`).

For clarity, `OptInFFOption`/`OptOutFFOption` are renamed as
`OptInCC1FFOption`/`OptOutCC1FFOption`, respectively. Otherwise, this is
an NFC from Clang's perspective.

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

2 years ago[OpenCL] Reduce duplicate defs by using multiclasses; NFC
Sven van Haastregt [Thu, 5 Aug 2021 10:06:33 +0000 (11:06 +0100)]
[OpenCL] Reduce duplicate defs by using multiclasses; NFC

Builtin definitions with pointer arguments were duplicated to provide
overloads differing in the pointer argument's address space.

Reduce this duplication by capturing the definitions in multiclasses.
This still results in the same number of builtins in the generated
tables, but the description is more concise now.

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

2 years agoRevert "D106035: Remove conditional compilation for WCHAR support in libedit"
Neal Sidhwaney [Thu, 5 Aug 2021 09:55:10 +0000 (02:55 -0700)]
Revert "D106035: Remove conditional compilation for WCHAR support in libedit"

This reverts commit 7529f0e3e1427fea93a6a66a2aed5394710e5fb5.

2 years ago[AMDGPU] Generate checks for ctlz_zero_undef/cttz_zero_undef
Jay Foad [Thu, 5 Aug 2021 09:22:06 +0000 (10:22 +0100)]
[AMDGPU] Generate checks for ctlz_zero_undef/cttz_zero_undef

2 years agoMark tests as requiring AMDGPU target
Oliver Stannard [Thu, 5 Aug 2021 09:02:51 +0000 (10:02 +0100)]
Mark tests as requiring AMDGPU target