platform/upstream/llvm.git
3 years ago[lldb] Make Platform::DebugProcess take a Target reference
Pavel Labath [Thu, 16 Sep 2021 09:14:16 +0000 (11:14 +0200)]
[lldb] Make Platform::DebugProcess take a Target reference

instead of a pointer. There are just two callers of this function, and
both of them have a valid target pointer, so there's no need for all
implementations to concern themselves with whether the pointer is null.

3 years agoBe more flexible on the storage type allowed for llvm::Any::TypeId::Id
serge-sans-paille [Thu, 16 Sep 2021 08:59:58 +0000 (10:59 +0200)]
Be more flexible on the storage type allowed for llvm::Any::TypeId::Id

This is a follow-up to 2c42a73d6c39af3833e697c0b306cb8cf8de5143.

3 years ago[GlobalISel] Add a combine for and(load , mask) -> zextload
Konstantin Schwarz [Mon, 6 Sep 2021 14:17:44 +0000 (16:17 +0200)]
[GlobalISel] Add a combine for and(load , mask) -> zextload

This only handles simple masks, not shifted masks, for now.

Reviewed By: aemerson

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

3 years ago[Test] Add test showing missing opportunity in range inference for SCEV
Max Kazantsev [Thu, 16 Sep 2021 08:08:24 +0000 (15:08 +0700)]
[Test] Add test showing missing opportunity in range inference for SCEV

3 years agoDon't set executable file in ObjectFileMachO::LoadCoreFileImages
Jason Molenda [Thu, 16 Sep 2021 08:36:56 +0000 (01:36 -0700)]
Don't set executable file in ObjectFileMachO::LoadCoreFileImages

When the corefile reader is adding binaries from the "all image
infos" LC_NOTE in a Mach-O corefile, it would detect if the binary
being added was an executable binary and set it as the Target's
executable binary.  This has the side effect of clearing the Target's
image list, so if the executable was in the middle of the all image
infos, the initial images would be dropped.  There's no need to set
the executable binary in the Target for these corefile processes,
so instead of doing multiple passes over the list to find the
executable, I'm dropping that.

3 years ago[clangd] Fix clangd crash when including a header
Queen Dela Cruz [Thu, 16 Sep 2021 08:17:37 +0000 (10:17 +0200)]
[clangd] Fix clangd crash when including a header

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

SourceLocation of macros change when a header file is included above it. This is not checked when creating a PreamblePatch, resulting in reusing previously built preamble with an incorrect source location for the macro in the example test case.
This patch stores the SourceLocation in the struct TextualPPDirective so that it gets checked when comparing old vs new preambles.

Also creates a preamble patch for code completion parsing so that clangd does not crash when following the example test case with a large file.

Reviewed By: kadircet

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

3 years ago[AggressiveInstCombine] Add `{insert/extract}element` to `TruncInstCombine` DAG
Anton Afanasyev [Sun, 5 Sep 2021 14:29:22 +0000 (17:29 +0300)]
[AggressiveInstCombine] Add `{insert/extract}element` to `TruncInstCombine` DAG

Alive2 for `{insert/extract}element`: https://alive2.llvm.org/ce/z/hwy_E-

Actually, no one file of test suite is touched by this change,
which means that is rare pattern not generated by frontend. But
it's worth being in place.

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

3 years ago[Test][AggressiveInstCombine] Add test for truncation of vector instructions
Anton Afanasyev [Fri, 3 Sep 2021 16:44:23 +0000 (19:44 +0300)]
[Test][AggressiveInstCombine] Add test for truncation of vector instructions

Precommit test for D109236

3 years ago[lldb] [ABI/AArch64] Recognize special regs by their xN names too
Michał Górny [Mon, 13 Sep 2021 14:49:16 +0000 (16:49 +0200)]
[lldb] [ABI/AArch64] Recognize special regs by their xN names too

Recognize lr/sp/fp by their numeric register names in the ABI plugin.
This is necessary to mark them appropriately when interfacing with
gdbserver.

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

3 years ago[lldb] [gdb-remote] Try using <architecture/> for remote arch unconditionally
Michał Górny [Sat, 4 Sep 2021 13:19:39 +0000 (15:19 +0200)]
[lldb] [gdb-remote] Try using <architecture/> for remote arch unconditionally

Try determining the process architecture from <architecture/> tag
unconditionally, rather than for very specific cases.  Generic gdbserver
implementations do not support LLDB-specific packets used to determine
the process architecture, therefore this fallback is necessary to
support architecture-specific behavior on these targets.  Rather than
maintaining a mapping of all known architectures, just try mapping
the GDB values into triplets, as that is going to work most of the time.

This change is confirmed to fix LLDB against gdbserver when debugging
i386 and aarch64 executables.

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

3 years ago[FuncSpec] Add a test for specialising on a non-constant global argument. NFC.
Sjoerd Meijer [Tue, 14 Sep 2021 19:13:18 +0000 (20:13 +0100)]
[FuncSpec] Add a test for specialising on a non-constant global argument. NFC.

3 years ago[AMDGPU] Fix upcoming TableGen warnings on unused template arguments. NFC.
Jay Foad [Wed, 15 Sep 2021 13:30:18 +0000 (14:30 +0100)]
[AMDGPU] Fix upcoming TableGen warnings on unused template arguments. NFC.

The warning is implemented by D109359 which is still in review.

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

3 years ago[HardwareLoops] Loop guard intrinsic to recognise zext
Sam Parker [Thu, 16 Sep 2021 07:08:31 +0000 (08:08 +0100)]
[HardwareLoops] Loop guard intrinsic to recognise zext

If a loop count was initially represented by a 32b unsigned int in C
then the hardware-loop pass can recognise the loop guard and insert
the llvm.test.set.loop.iterations intrinsic. If this was instead a
unsigned short/char then clang inserts a zext instruction to expand
the loop count to an i32. This patch adds the necessary pattern
matching to enable the use of lvm.test.set.loop.iterations in those
cases.

Patch by: sherwin-dc

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

3 years ago[AArch64] Regenerate some test checks. NFC
David Green [Thu, 16 Sep 2021 07:30:08 +0000 (08:30 +0100)]
[AArch64] Regenerate some test checks. NFC

This regenerates some of the tests that had very-close-to-updated check
line already, in order to make them more maintainable.

3 years ago[flang][driver] Add documentation for Plugins
Stuart Ellis [Thu, 16 Sep 2021 06:47:00 +0000 (06:47 +0000)]
[flang][driver] Add documentation for Plugins

Adding documentation covering the Frontend Driver Plugins

Reviewed By: awarzynski, kiranchandramohan

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

3 years ago[mlir][OpDSL] Update op definitions to make shapes more concise (NFC).
Tobias Gysi [Thu, 16 Sep 2021 06:01:38 +0000 (06:01 +0000)]
[mlir][OpDSL] Update op definitions to make shapes more concise (NFC).

Express the input shape definitions of convolution and pooling operations in terms of the output shapes, filter shapes, strides, and dilations.

Reviewed By: shabalin, rsuderman, stellaraccident

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

3 years ago[DebugInfo] Enhance DIImportedEntity to accept children entities
Alok Kumar Sharma [Tue, 7 Sep 2021 05:55:44 +0000 (11:25 +0530)]
[DebugInfo] Enhance DIImportedEntity to accept children entities

New field `elements` is added to '!DIImportedEntity', representing
list of aliased entities.
This is needed to dump optimized debugging information where all names
in a module are imported, but a few names are imported with overriding
aliases.

Reviewed By: dblaikie

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

3 years ago[ORC] Add MethodWrapperHandler utility for WrapperFunction.
Lang Hames [Wed, 15 Sep 2021 00:45:19 +0000 (10:45 +1000)]
[ORC] Add MethodWrapperHandler utility for WrapperFunction.

MethodWrapperHandler removes some of the boilerplate when writing wrapper
functions to wrap method calls. It can be used as a handler for wrapper
functions whose first argument is an ExecutorAddress: the address is cast to a
pointer of the given class type, then the given method function pointer is
called on that object pointer (passing the rest of the arguments).

E.g.

class MyClass {
public:
  void myMethod(uint32_t, bool) { ... }
};

// SPS Method signature for myMethod -- note MyClass object address as first
// argument.
using SPSMyMethodWrapperSignature =
  SPSTuple<SPSExecutorAddress, uint32_t, bool>;

// Wrapper function for myMethod.
WrapperFunctionResult
myMethodCallWrapper(const char *ArgData, size_t ArgSize) {
  return WrapperFunction<SPSMyMethodWrapperSignature>::handle(
     ArgData, ArgSize, makeMethodWrapperHandler(&MyClass::myMethod));
}

3 years agoDelete unused GlobalIndirectSymbol::getBaseObject overloads
Fangrui Song [Thu, 16 Sep 2021 03:44:24 +0000 (20:44 -0700)]
Delete unused GlobalIndirectSymbol::getBaseObject overloads

3 years ago[mlir][sparse] add affine subscripts to sparse compilation pass
Aart Bik [Wed, 15 Sep 2021 22:18:19 +0000 (15:18 -0700)]
[mlir][sparse] add affine subscripts to sparse compilation pass

This enables the sparsification of more kernels, such as convolutions
where there is a x(i+j) subscript. It also enables more tensor invariants
such as x(1) or other affine subscripts such as x(i+1). Currently, we
reject sparsity altogether for such tensors. Despite this restriction,
however, we can already handle a lot more kernels with compound subscripts
for dense access (viz. convolution with dense input and sparse filter).
Some unit tests and an integration test demonstrate new capability.

Reviewed By: bixia

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

3 years ago[Transforms] Use make_early_inc_range (NFC)
Kazu Hirata [Thu, 16 Sep 2021 02:55:24 +0000 (19:55 -0700)]
[Transforms] Use make_early_inc_range (NFC)

3 years ago[AArch64][GlobalISel] Ensure atomic loads always get assigned GPR destinations
Jessica Paquette [Tue, 14 Sep 2021 17:03:42 +0000 (10:03 -0700)]
[AArch64][GlobalISel] Ensure atomic loads always get assigned GPR destinations

The default register bank selection code for G_LOAD assumes that we ought to
use a FPR when the load is casted to a float/double.

For atomics, this isn't true; we should always use GPRs.

Without this patch, we crash in the following example:

https://godbolt.org/z/MThjas441

Also make the code a little more stylistically consistent while we're here.

Also test some other weird cast combinations as well.

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

3 years ago[AArch64][GlobalISel] Use MI::getIntrinsicID in more spots. NFC.
Ahmed Bougacha [Wed, 15 Sep 2021 20:52:32 +0000 (13:52 -0700)]
[AArch64][GlobalISel] Use MI::getIntrinsicID in more spots. NFC.

There's technically a difference in the logic used by these
findIntrinsicID and MachineInstr::getIntrinsicID, but it shouldn't
be a meaningful difference here, with G_INTRINSIC instructions.
getIntrinsicID's "first non-def" logic should be correct for those.

3 years ago[GlobalISel] Fix CombinerHelper::isPredecessor for same def/use MI.
Ahmed Bougacha [Wed, 15 Sep 2021 20:52:01 +0000 (13:52 -0700)]
[GlobalISel] Fix CombinerHelper::isPredecessor for same def/use MI.

The doc comment for isPredecessor says:
  Returns true if \p DefMI precedes \p UseMI or they are the same
  instruction.
And dominates relies on that behavior for its own:
  Returns true if \p DefMI dominates \p UseMI. By definition an
  instruction dominates itself.

Make both statements correct by fixing isPredecessor.
Found by inspection.

3 years ago[MemProf] Fix format warnings
Teresa Johnson [Wed, 15 Sep 2021 23:27:21 +0000 (16:27 -0700)]
[MemProf] Fix format warnings

Fix the warnings that show up with -Wformat in this file.

3 years ago[lldb-vscode] Fix focus thread when previous thread exits
Ted Woodward [Wed, 15 Sep 2021 23:03:42 +0000 (18:03 -0500)]
[lldb-vscode] Fix focus thread when previous thread exits

The thread that Visual Studio Code displays on a stop is called the focus thread. When the previous focus thread exits and we stop in a new thread, lldb-vscode does not tell vscode to set the new thread as the focus thread, so it selects the first thread in the thread list.

This patch changes lldb-vscode to tell vscode that the new thread is the focus thread. It also includes a test that verifies the DAP stop message for this case contains the correct values.

Reviewed By: clayborg, wallace

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

3 years ago[MemProf] Avoid global lock when updating MIB cache
Teresa Johnson [Wed, 15 Sep 2021 21:04:51 +0000 (14:04 -0700)]
[MemProf] Avoid global lock when updating MIB cache

Previously we used a global Allocator-scope mutex to lock when adding a
deallocation to the MIB cache. This resulted in a lot of contention.
Instead add and use per-set mutexes.

Along with this, we now need to remove the global miss and access count
variables and instead utilize the per-set statistics to report the
overall miss rate.

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

3 years agoPR51874: Fix diagnostics for defaulted, implicitly deleted 'operator!='.
Richard Smith [Wed, 15 Sep 2021 22:40:27 +0000 (15:40 -0700)]
PR51874: Fix diagnostics for defaulted, implicitly deleted 'operator!='.

Don't say we couldn't find an 'operator<=>' when we were actually
looking for an 'operator=='. Also fix a crash when attempting to
diagnose if we select a built-in 'operator!=' in this lookup.

3 years ago[test] Move some llvm-extract tests into the proper directory
Arthur Eubanks [Wed, 15 Sep 2021 22:42:04 +0000 (15:42 -0700)]
[test] Move some llvm-extract tests into the proper directory

3 years ago[NFC] Split up PassBuilder.cpp
Arthur Eubanks [Tue, 14 Sep 2021 23:44:29 +0000 (16:44 -0700)]
[NFC] Split up PassBuilder.cpp

PassBuilder.cpp is the slowest file to compile in LLVM.
When trying to test changes to pipelines, it takes a long time to recompile.

This doesn't actually speedup building PassBuilder.cpp itself since most
of the time is spent in other large/duplicated functions caused by
PassRegistry.def.

Reviewed By: asbirlea

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

3 years ago[gn build] Port d249200fa7d5
LLVM GN Syncbot [Wed, 15 Sep 2021 22:14:18 +0000 (22:14 +0000)]
[gn build] Port d249200fa7d5

3 years ago[Polly] Remove autotools build systems from Externals. NFC.
Michael Kruse [Wed, 15 Sep 2021 21:37:29 +0000 (16:37 -0500)]
[Polly] Remove autotools build systems from Externals. NFC.

Building a source distribution using autotools adds GPL-licenced
files into the the sources. Although redistribution of theses files is
explicitly allowed with an exception, these are not used by Polly
which uses a CMake replacement. Use the direct source checkout
instead (replacing the output of 'make dist').

Some m4 scripts with the same licence are also included in isl/ppcg
repository. Removing them renders the autotools-based build scipts
inoperable, so remove the autotools build system altogether.

3 years agoTeach SimplifyCFG to fold switches into lookup tables in more cases.
Owen Anderson [Fri, 10 Sep 2021 04:59:23 +0000 (04:59 +0000)]
Teach SimplifyCFG to fold switches into lookup tables in more cases.

In particular, it couldn't handle cases where lookup table constant
expressions involved bitcasts. This does not seem to come up
frequently in C++, but comes up reasonably often in Rust via
`#[derive(Debug)]`.

Originally reported by pcwalton.

Reviewed By: nikic

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

3 years agoRevert "[InstCombine] Improve TryToSinkInstruction with multiple uses"
Anna Thomas [Wed, 15 Sep 2021 21:58:25 +0000 (17:58 -0400)]
Revert "[InstCombine] Improve TryToSinkInstruction with multiple uses"

This reverts commit 4ac4e52189aa6d80c3d59dc2c8f7dcc0cb7f9d58.
There are couple of test failures, which needs update of the test cases.

Doing a clean revert and will recommit the change along with fixed
testcases.

3 years ago[clang-format] Top-level unwrapped lines don't follow a left brace
owenca [Tue, 14 Sep 2021 09:34:11 +0000 (02:34 -0700)]
[clang-format] Top-level unwrapped lines don't follow a left brace

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

3 years agoNFC: DWARFTypePrinter: Remove "type" from member function names to reduce redundancy
David Blaikie [Wed, 15 Sep 2021 21:45:12 +0000 (14:45 -0700)]
NFC: DWARFTypePrinter: Remove "type" from member function names to reduce redundancy

3 years agoRevert use of getUniqueUndroppableUser in AssumeBundleBuilder
Anna Thomas [Wed, 15 Sep 2021 21:43:46 +0000 (17:43 -0400)]
Revert use of getUniqueUndroppableUser in AssumeBundleBuilder

Fix build bot failure in rG4ac4e521 caused due to assumeBundleBuilder
using new API (getUniqueUndroppableUser).
We now continue using the existing API for AssumeBundleBuilder
(getSingleUndroppableUser).

Sorry for the noise here.

Tests-Run: failing testcase passes.

3 years agoSplitKit: Remove decade old live interval hack
Matt Arsenault [Sat, 28 Aug 2021 14:32:29 +0000 (10:32 -0400)]
SplitKit: Remove decade old live interval hack

This was trying to fixup broken live intervals coming out of the
coalescer. The verifier is more complete now and no tests seem to fail
without this.

3 years ago[DRR] Explicit Return Types in Rewrites
Mogball [Wed, 15 Sep 2021 21:25:29 +0000 (14:25 -0700)]
[DRR] Explicit Return Types in Rewrites

Adds a new rewrite directive returnType that can be added at the end of an op's
argument list to explicitly specify return types.

```
(OpX $v0, $v1, (returnType "$_builder.getI32Type()"))
```

Pass in a bound value to copy its return type, or pass a native code call to
dynamically create new types.

```
(OpX $v0, $v1, (returnType $v0, (NativeCodeCall<"..."> $v1)))
```

Reviewed By: jpienaar

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

3 years ago[Compiler-RT] For arm64e test suites use the SDK version as the minimum deployment...
Dan Liew [Wed, 15 Sep 2021 00:05:20 +0000 (17:05 -0700)]
[Compiler-RT] For arm64e test suites use the SDK version as the minimum deployment target.

Previously we used the minimum deployment target used for the platform
(e.g. iOS is 9.0). Unfortunately this leads to ABI incompatibilities with
arm64e devices running newer OSs. In particular the following TSan test
cases that used libcxx would fail due to the ABI mismatch.

* Darwin/libcxx-shared-ptr-recursive.mm
* Darwin/libcxx-shared-ptr-stress.mm
* Darwin/libcxx-shared-ptr.mm
* libcxx/std_shared_ptr.cpp

Given that arm64e is not ABI stable we should ideally match the
deployment target for sanitizer runtimes and their tests cases to the
device when building for arm64e. Unfortunately having a mixed deployment
target (based on architecture) isn't currently supported by the build system
and is non-trivial to implement.

As a stop-gap measure this patch changes the sanitizer test suites (but not the
sanitizer runtimes themselves) to use a newer deployment target when
targetting arm64e.

The deployment target used for arm64e is the SDK version because this
"should" match the OS version running on the target device (it is a
configuration error to not match them).

rdar://83080611

3 years ago[mlir][linalg] Add canonicalizers for depthwise conv
Rob Suderman [Wed, 15 Sep 2021 19:44:17 +0000 (12:44 -0700)]
[mlir][linalg] Add canonicalizers for depthwise conv

There are two main versions of depthwise conv depending whether the multiplier
is 1 or not. In cases where m == 1 we should use the version without the
multiplier channel as it can perform greater optimization.

Add lowering for the quantized/float versions to have a multiplier of one.

Reviewed By: antiagainst

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

3 years agoRe-add getSingleUndroppableUse API
Anna Thomas [Wed, 15 Sep 2021 21:06:18 +0000 (17:06 -0400)]
Re-add getSingleUndroppableUse API

The API was removed in 4ac4e52189aa in favor of
getUniqueUndroppableUser.
However, this caused a buildbot failure in AbstractCallSiteTest.cpp,
which uses the API and the AbstractCallSite class requires a "use"
rather than a user.
Retain the API so that the unittest compiles and passes.

3 years agoTest commit to check commit access
Kim-Anh Tran [Tue, 3 Aug 2021 06:51:38 +0000 (08:51 +0200)]
Test commit to check commit access

3 years ago[NFC] Test commit to verify commit access
Mats Larsen [Wed, 28 Jul 2021 16:53:46 +0000 (18:53 +0200)]
[NFC] Test commit to verify commit access

3 years agoSenticify some comments - post-commit review for e4b9f5e851d1fe0ba93cbb11b2ed4558602c379e
David Blaikie [Wed, 15 Sep 2021 20:58:29 +0000 (13:58 -0700)]
Senticify some comments - post-commit review for e4b9f5e851d1fe0ba93cbb11b2ed4558602c379e

Based on feedback from Paul Robinson.

3 years ago[OpenMP][libomptarget] Minor fix in x86_64 plugin
Hansang Bae [Wed, 15 Sep 2021 19:04:35 +0000 (14:04 -0500)]
[OpenMP][libomptarget] Minor fix in x86_64 plugin

Call to remove() was passing invalid address for the file name.

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

3 years agoRevert "Re-Revert "clang-tidy: introduce readability-containter-data-pointer check""
Saleem Abdulrasool [Wed, 15 Sep 2021 20:07:51 +0000 (20:07 +0000)]
Revert "Re-Revert "clang-tidy: introduce readability-containter-data-pointer check""

This reverts commit 626586fc253c6f032aedb325dba6b1ff3f11875e.

Tweak the test for Windows.  Windows defaults to delayed template
parsing, which resulted in the main template definition not registering
the test on Windows.  Process the file with the additional
`-fno-delayed-template-parsing` flag to change the default beahviour.
Additionally, add an extra check for the fix it and use a more robust
test to ensure that the value is always evaluated.

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

3 years agoImprove type printing of size-dependent const arrays to normalize array-of-const...
David Blaikie [Wed, 15 Sep 2021 20:37:24 +0000 (13:37 -0700)]
Improve type printing of size-dependent const arrays to normalize array-of-const and const-array

Follow-on from 2bd84938470bf2e337801faafb8a67710f46429d based on
postcommit feedback from Richard Smith.

The VariableArray case I couldn't figure out how to test/provoke - you
can't write/form a variable array in any context other than a local
variable that I know of, and in that case `const int x[n]` is the
normalized form already (array-of-const) and you can't use typedefs
(since you can't typedef int[n] with variable 'n') to force the
const-array AST that would produce the undesirable type printing "int
const [n]".

3 years ago[InstCombine] Improve TryToSinkInstruction with multiple uses
Anna Thomas [Wed, 15 Sep 2021 18:42:44 +0000 (18:42 +0000)]
[InstCombine] Improve TryToSinkInstruction with multiple uses

This patch allows sinking an instruction which can have multiple uses in a
single user. We were previously over-restrictive by looking for exactly one use,
rather than one user.

Also, the API for retrieving undroppable user has been updated accordingly since
in both usecases (Attributor and InstCombine), we seem to care about the user,
rather than the use.

Reviewed-By: nikic
Differential Revision: https://reviews.llvm.org/D109700

3 years agoprecommit test for D109845/D106852
Philip Reames [Wed, 15 Sep 2021 19:53:30 +0000 (12:53 -0700)]
precommit test for D109845/D106852

3 years ago[HWASan] Test longjmp(jmpbuf, 0).
Matt Morehouse [Wed, 15 Sep 2021 19:10:21 +0000 (12:10 -0700)]
[HWASan] Test longjmp(jmpbuf, 0).

Our interceptor needs to change retval to 1 when 0 is passed.

Reviewed By: eugenis

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

3 years ago[MemorySSA] Fix "set but not used" warnings
Kazu Hirata [Wed, 15 Sep 2021 18:41:41 +0000 (11:41 -0700)]
[MemorySSA] Fix "set but not used" warnings

3 years ago[InstCombine] move extend after insertelement if both operands are extended
Sanjay Patel [Wed, 15 Sep 2021 18:28:47 +0000 (14:28 -0400)]
[InstCombine] move extend after insertelement if both operands are extended

I was wondering how instcombine does on the examples in D109236,
and we're missing a basic transform:

inselt (ext X), (ext Y), Index --> ext (inselt X, Y, Index)

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

Note that there are several possible extensions of this fold
(see TODO comments).

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

3 years ago[SCEV] (udiv X, Y) * Y is always NUW
Philip Reames [Wed, 15 Sep 2021 18:33:31 +0000 (11:33 -0700)]
[SCEV] (udiv X, Y) * Y is always NUW

Motivated by the removal done in D109782. This implements the correct flag part generically.

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

3 years ago[mlir] Fix printing of EmitC attrs/types with escape characters
Simon Camphausen [Wed, 15 Sep 2021 17:54:57 +0000 (19:54 +0200)]
[mlir] Fix printing of EmitC attrs/types with escape characters

Attributes and types were not escaped when printing.

Reviewed By: jpienaar, marbre

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

3 years ago[mlir][Linalg] Revisit insertion points in comprehensive bufferization.
Nicolas Vasilache [Wed, 15 Sep 2021 14:55:30 +0000 (14:55 +0000)]
[mlir][Linalg] Revisit insertion points in comprehensive bufferization.

This revision fixes a corner case that could appear due to incorrect insertion point behavior in comprehensive bufferization.

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

3 years agoautogen a test for ease of update
Philip Reames [Wed, 15 Sep 2021 18:05:22 +0000 (11:05 -0700)]
autogen a test for ease of update

3 years agoswitch a couple of SCEV tests to autogen for ease of update
Philip Reames [Wed, 15 Sep 2021 17:53:27 +0000 (10:53 -0700)]
switch a couple of SCEV tests to autogen for ease of update

3 years ago[MemorySSA] Add verification levels to MemorySSA. [NFC]
Alina Sbirlea [Wed, 15 Sep 2021 17:53:35 +0000 (10:53 -0700)]
[MemorySSA] Add verification levels to MemorySSA. [NFC]

Add two levels of verification for MemorySSA: Fast and Full.
The defaults are kept the same. Full verification always occurs under
EXPENSIVE_CHECKS, but now it can also be requested in a specific pass for
debugging purposes.

3 years agoAdd llvm_unreachable after fully covered switch (NFC)
Mehdi Amini [Wed, 15 Sep 2021 17:52:39 +0000 (17:52 +0000)]
Add llvm_unreachable after fully covered switch (NFC)

This fixes a compiler warning for some version of GCC.

3 years ago[OpenMP] Add support for GOMP depobj
Peyton, Jonathan L [Thu, 26 Aug 2021 19:10:15 +0000 (14:10 -0500)]
[OpenMP] Add support for GOMP depobj

GOMP depobjs are represented as a two intptr_t array. The first
element is the base address of the dependency and the second element
is the flag indicating the type the depobj represents.

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

3 years ago[MLIR] Tighten type constraint on memref.global op def
Uday Bondhugula [Wed, 15 Sep 2021 11:28:19 +0000 (16:58 +0530)]
[MLIR] Tighten type constraint on memref.global op def

Tighten the def of memref.global op to use the right kind of TypeAttr
(of MemRefType).

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

3 years ago[HIP] Diagnose -fopenmp-targets for HIP programs
Yaxun (Sam) Liu [Mon, 13 Sep 2021 19:54:20 +0000 (15:54 -0400)]
[HIP] Diagnose -fopenmp-targets for HIP programs

Diagnose -fopenmp-targets for HIP programs since
dual HIP and OpenMP offloading in the same compilation
is currently not supported by HIP toolchain.

Reviewed by: Artem Belevich

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

3 years ago[CMake] Enable LLVM_ENABLE_PER_TARGET_RUNTIME_DIR by default on Linux
Fangrui Song [Wed, 15 Sep 2021 16:32:59 +0000 (09:32 -0700)]
[CMake] Enable LLVM_ENABLE_PER_TARGET_RUNTIME_DIR by default on Linux

This makes the default build closer to a -DLLVM_ENABLE_RUNTIMES=all build.
The layout is arguably superior because different libraries of target triples
are in different directories, similar to GCC/Debian multiarch.

When LLVM_DEFAULT_TARGET_TRIPLE is x86_64-unknown-linux-gnu,
`lib/clang/14.0.0/lib/libclang_rt.asan-x86_64.a`
is moved to
`lib/clang/14.0.0/lib/x86_64-unknown-linux-gnu/libclang_rt.asan.a`.

In addition, if the host compiler supports -m32 (multilib),
`lib/clang/14.0.0/lib/libclang_rt.asan-i386.a`
is moved to
`lib/clang/14.0.0/lib/i386-unknown-linux-gnu/libclang_rt.asan.a`.

Clang has been detecting both paths for lib/Driver/ToolChains/Gnu.cpp since 2018 (D50547).

---

Note: Darwin needs to be disabled. The hierarchy needs to be sorted out.
The current -DLLVM_DEFAULT_TARGET_TRIPLE=off state is like:
```
lib/clang/14.0.0/lib/darwin/libclang_rt.profile_ios.a
lib/clang/14.0.0/lib/darwin/libclang_rt.profile_iossim.a
lib/clang/14.0.0/lib/darwin/libclang_rt.profile_osx.a
```

Windows needs to be disabled: https://reviews.llvm.org/D107799?id=368557#2963311

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

3 years ago[compiler-rt] Move -fno-omit-frame-pointer check to common config-ix
Michał Górny [Wed, 15 Sep 2021 08:24:37 +0000 (10:24 +0200)]
[compiler-rt] Move -fno-omit-frame-pointer check to common config-ix

9ee64c374605683ae80b9641d5312a72c2a67336 has started using
COMPILER_RT_HAS_OMIT_FRAME_POINTER_FLAG inside scudo.  However,
the relevant CMake check was performed in builtin-config-ix.cmake,
so the definition was missing when builtins were not built.  Move
the check to config-ix.cmake, so that it runs unconditionally of
the components being built.

Fixes PR#51847

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

3 years ago[InstCombine] Update test checks through autogeneration, add more tests. NFC
Anna Thomas [Wed, 15 Sep 2021 16:16:57 +0000 (16:16 +0000)]
[InstCombine] Update test checks through autogeneration, add more tests. NFC

Updated check lines.
Tests precommitted from D109700.

3 years ago[test] Fix asan/scudo -shared-libsan tests with -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=on
Fangrui Song [Wed, 15 Sep 2021 16:07:47 +0000 (09:07 -0700)]
[test] Fix asan/scudo -shared-libsan tests with -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=on

On x86_64-unknown-linux-gnu, `-m32` tests set LD_LIBRARY_PATH to
`config.compiler_rt_libdir` (`$build/lib/clang/14.0.0/lib/x86_64-unknown-linux-gnu`)
instead of i386-unknown-linux-gnu, so `-shared-libsan` executables
cannot find their runtime (e.g. `TestCases/replaceable_new_delete.cpp`).

Detect -m32 and -m64 in config.target_cflags, and adjust `config.compiler_rt_libdir`.

Reviewed By: vitalybuka

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

3 years ago[HWASan] Add missing newlines.
Matt Morehouse [Wed, 15 Sep 2021 16:06:01 +0000 (09:06 -0700)]
[HWASan] Add missing newlines.

3 years ago[Test] Add a test showing missing opportunities in branch deletion by indvars
Max Kazantsev [Wed, 15 Sep 2021 15:00:40 +0000 (22:00 +0700)]
[Test] Add a test showing missing opportunities in branch deletion by indvars

3 years ago[mlir][Linalg] Fail comprehensive bufferization if a memref is returned.
Nicolas Vasilache [Wed, 15 Sep 2021 14:02:38 +0000 (14:02 +0000)]
[mlir][Linalg] Fail comprehensive bufferization if a memref is returned.

Summary:

Reviewers:

Subscribers:

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

3 years ago[SLP][NFC]Add a test for tiny tree with stores and with not
Alexey Bataev [Wed, 15 Sep 2021 15:06:09 +0000 (08:06 -0700)]
[SLP][NFC]Add a test for tiny tree with stores and with not
same/alternate instructions.

3 years ago[HWASan] Catch cases where libc populated jmp_buf.
Matt Morehouse [Wed, 15 Sep 2021 14:53:25 +0000 (07:53 -0700)]
[HWASan] Catch cases where libc populated jmp_buf.

Some setjmp calls within libc cannot be intercepted while their matching
longjmp calls can be.  This causes problems if our setjmp/longjmp
interceptors don't use the exact same format as libc for populating and
reading the jmp_buf.

We add a magic field to our jmp_buf and populate it in setjmp.  This
allows our longjmp interceptor to notice when a libc jmp_buf is passed
to it.

See discussion on https://reviews.llvm.org/D109699 and
https://reviews.llvm.org/D69045.

Fixes https://github.com/google/sanitizers/issues/1244.

Reviewed By: eugenis

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

3 years ago[clang][driver][AIX] Add system libc++ header paths to driver
David Tenty [Tue, 14 Sep 2021 22:05:31 +0000 (18:05 -0400)]
[clang][driver][AIX] Add system libc++ header paths to driver

This change adds the system libc++ header location to the driver. As well we define
the `__LIBC_NO_CPP_MATH_OVERLOADS__` macro when using those headers, in order to suppress
conflicting C++ overloads in the system libc headers that were used by XL C++.

Reviewed By: ZarkoCA

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

3 years ago[RISCV][compiler-rt] Fix an incorrect comment for RV64 __riscv_restore_12
Jessica Clarke [Wed, 15 Sep 2021 14:25:59 +0000 (15:25 +0100)]
[RISCV][compiler-rt] Fix an incorrect comment for RV64 __riscv_restore_12

This was presumably copied from the RV32 implementation and not updated
like the rest.

3 years agoImplement delimited escape sequences.
Corentin Jabot [Wed, 15 Sep 2021 13:52:25 +0000 (09:52 -0400)]
Implement delimited escape sequences.

\x{XXXX} \u{XXXX} and \o{OOOO} are accepted in all languages mode
in characters and string literals.

This is a feature proposed for both C++ (P2290R1) and C (N2785). The
papers have been seen by both committees but are not yet adopted into
either standard. However, they do have support from both committees.

3 years ago[RISCV][compiler-rt] Move RV64 __riscv_restore_1/0 directives next to labels
Jessica Clarke [Wed, 15 Sep 2021 13:42:22 +0000 (14:42 +0100)]
[RISCV][compiler-rt] Move RV64 __riscv_restore_1/0 directives next to labels

This looks like it was copied from the RV32 version and not properly
updated. This has no functional effect but is not good style.

3 years ago[RISCV][compiler-rt] Add missing __riscv_save_1/0 labels for RV64
Jessica Clarke [Wed, 15 Sep 2021 13:42:16 +0000 (14:42 +0100)]
[RISCV][compiler-rt] Add missing __riscv_save_1/0 labels for RV64

These got missed in D91717.

3 years ago[InstCombine] Transform X == 0 ? 0 : X * Y --> X * freeze(Y)
Filipp Zhinkin [Wed, 15 Sep 2021 13:04:06 +0000 (09:04 -0400)]
[InstCombine] Transform X == 0 ? 0 : X * Y --> X * freeze(Y)

Enabled mul folding optimization that was previously disabled
by being incorrect.
To preserve correctness, mul's operand that is not compared
with zero in select's condition is now frozen.

Related bug: https://bugs.llvm.org/show_bug.cgi?id=51286

Correctness:
https://alive2.llvm.org/ce/z/bHef7J
https://alive2.llvm.org/ce/z/QcR7sf
https://alive2.llvm.org/ce/z/vvBLzt
https://alive2.llvm.org/ce/z/jGDXgq
https://alive2.llvm.org/ce/z/3Pe8Z4
https://alive2.llvm.org/ce/z/LGga8M
https://alive2.llvm.org/ce/z/CTG5fs

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

3 years ago[PhaseOrdering] add tests for PR47023; NFC
Sanjay Patel [Wed, 15 Sep 2021 12:17:45 +0000 (08:17 -0400)]
[PhaseOrdering] add tests for PR47023; NFC

3 years ago[CostModel][X86] Adjust bitreverse/ctpop/ctlz/cttz AVX2+ costs based on llvm-mca...
Simon Pilgrim [Wed, 15 Sep 2021 12:02:13 +0000 (13:02 +0100)]
[CostModel][X86] Adjust bitreverse/ctpop/ctlz/cttz AVX2+ costs based on llvm-mca reports

Based off the worse case numbers generated by D103695, the AVX2/512 bit reversing/counting costs were higher than necessary (based off instruction counts instead of actual throughput).

3 years ago[lldb] [Windows] Fix an incorrect assert in NativeRegisterContextWindows_arm
Martin Storsjö [Tue, 14 Sep 2021 18:39:02 +0000 (21:39 +0300)]
[lldb] [Windows] Fix an incorrect assert in NativeRegisterContextWindows_arm

This codepath hadn't been exercised in a build with asserts before.

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

3 years ago[ARM] Move fetching of ARMSubtarget into the scopes that need it. NFC.
Martin Storsjö [Wed, 1 Sep 2021 07:45:11 +0000 (10:45 +0300)]
[ARM] Move fetching of ARMSubtarget into the scopes that need it. NFC.

This was requested in D38253, but missed back then.

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

3 years ago[gn build] (manually) port 2c42a73d6c39
Nico Weber [Wed, 15 Sep 2021 12:01:02 +0000 (08:01 -0400)]
[gn build] (manually) port 2c42a73d6c39

3 years ago[mlir][Linalg] Make codegen strategy late transformations opt-in
Nicolas Vasilache [Wed, 15 Sep 2021 11:00:06 +0000 (11:00 +0000)]
[mlir][Linalg] Make codegen strategy late transformations opt-in

Summary: Making the late transformations opt-in results in less surprising behavior when composing multiple calls to the codegen strategy.

Reviewers:

Subscribers:

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

3 years ago[mlir][Linalg] Replace DenseSet by UnionFind in ComprehensiveBufferize - NFC
Nicolas Vasilache [Wed, 15 Sep 2021 10:09:37 +0000 (10:09 +0000)]
[mlir][Linalg] Replace DenseSet by UnionFind in ComprehensiveBufferize - NFC

AliasInfo can now use union-find for a much more efficient implementation.
This brings no functional changes but large performance gains on more complex examples.

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

3 years ago[ARM] Prevent continuous folding of SUBC
David Green [Wed, 15 Sep 2021 10:23:32 +0000 (11:23 +0100)]
[ARM] Prevent continuous folding of SUBC

Under some situations under Thumb1, we could be stuck in an infinite
loop recombining the same instruction. This puts a limit on that, not
combining SUBC with SUBE repeatedly.

3 years ago[DSE] Add capture-before test cases with loads.
Florian Hahn [Tue, 14 Sep 2021 16:16:32 +0000 (17:16 +0100)]
[DSE] Add capture-before test cases with loads.

Add a set of test cases where redundant stores may be removable,
depending on whether a local allocation gets captured before performing
a load.

3 years ago[LV] Recognize intrinsic min/max reductions
David Green [Wed, 15 Sep 2021 09:45:50 +0000 (10:45 +0100)]
[LV] Recognize intrinsic min/max reductions

This extends the reduction logic in the vectorizer to handle intrinsic
versions of min and max, both the floating point variants already
created by instcombine under fastmath and the integer variants from
D98152.

As a bonus this allows us to match a chain of min or max operations into
a single reduction, similar to how add/mul/etc work.

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

3 years ago[X86] combineX86ShuffleChain - ensure we only peek through bitcasts to vectors (PR51858)
Simon Pilgrim [Wed, 15 Sep 2021 09:20:54 +0000 (10:20 +0100)]
[X86] combineX86ShuffleChain - ensure we only peek through bitcasts to vectors (PR51858)

When searching for hidden identity shuffles (added at rG41146bfe82aecc79961c3de898cda02998172e4b), only peek through bitcasts to the source operand if it is a vector type as well.

3 years ago[MIPS] Remove unused tblgen template args. NFC
Simon Atanasyan [Wed, 15 Sep 2021 05:45:46 +0000 (08:45 +0300)]
[MIPS] Remove unused tblgen template args. NFC

Identified in D109359.

3 years ago[OpenCL] Supports optional image types in C++ for OpenCL 2021
Justas Janickas [Tue, 31 Aug 2021 13:19:27 +0000 (14:19 +0100)]
[OpenCL] Supports optional image types in C++ for OpenCL 2021

Adds support for a feature macro `__opencl_c_images` in C++ for
OpenCL 2021 enabling a respective optional core feature from
OpenCL 3.0.

This change aims to achieve compatibility between C++ for OpenCL
2021 and OpenCL 3.0.

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

3 years ago[NVPTX] NFC: Remove unused imm type intrinsic arg
Cullen Rhodes [Wed, 15 Sep 2021 07:56:27 +0000 (07:56 +0000)]
[NVPTX] NFC: Remove unused imm type intrinsic arg

Identified in D109359.

Reviewed By: tra

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

3 years ago[LV] Min/max intrinsic reduction test cases.
David Green [Wed, 15 Sep 2021 08:56:19 +0000 (09:56 +0100)]
[LV] Min/max intrinsic reduction test cases.

3 years ago[mlir][linalg] ComprehensiveBufferize: Do not copy InitTensorOp results
Matthias Springer [Wed, 15 Sep 2021 08:26:29 +0000 (17:26 +0900)]
[mlir][linalg] ComprehensiveBufferize: Do not copy InitTensorOp results

E.g.:

```
%2 = memref.alloc() {alignment = 128 : i64} : memref<256x256xf32>
%3 = memref.alloc() {alignment = 128 : i64} : memref<256x256xf32>

// ... (%3 is not written to)

linalg.copy(%3, %2) : memref<256x256xf32>, memref<256x256xf32>
vector.transfer_write %11, %2[%c0, %c0] {in_bounds = [true, true]} : vector<256x256xf32>, memref<256x256xf32>
```

Avoid copies of %3 if %3 came directly from an InitTensorOp.

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

3 years ago[VPlan] Support sinking recipes with uniform users outside sink target.
Florian Hahn [Wed, 15 Sep 2021 07:33:24 +0000 (08:33 +0100)]
[VPlan] Support sinking recipes with uniform users outside sink target.

This is a first step towards addressing the last remaining limitation of
the VPlan version of sinkScalarOperands: the legacy version can
partially sink operands. For example, if a GEP has uniform users outside
the sink target block, then the legacy version will sink all scalar
GEPs, other than the one for lane 0.

This patch works towards addressing this case in the VPlan version by
detecting such cases and duplicating the sink candidate. All users
outside of the sink target will be updated to use the uniform clone.

Note that this highlights an issue with VPValue naming. If we duplicate
a replicate recipe, they will share the same underlying IR value and
both VPValues will have the same name ir<%gep>.

Reviewed By: Ayal

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

3 years ago[X86][InlineAsm] Use mem size information (*word ptr) for "global variable + register...
Xiang1 Zhang [Tue, 14 Sep 2021 05:19:22 +0000 (13:19 +0800)]
[X86][InlineAsm] Use mem size information (*word ptr) for "global variable + registers" memory expression in inline asm.

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

3 years ago[mlir] Update docs on conversion and translation to LLVM
Alex Zinenko [Fri, 10 Sep 2021 13:47:57 +0000 (15:47 +0200)]
[mlir] Update docs on conversion and translation to LLVM

Create a new document that explain both stages of the process in a single
place, merge and deduplicate the content from the two previous documents. Also
extend the documentation to account for the recent changes in pass structure
due to standard dialect splitting and translation being more flexible.

Reviewed By: aartbik

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

3 years ago[mlir][linalg] Update OpDSL doc (NFC).
Tobias Gysi [Wed, 15 Sep 2021 07:35:57 +0000 (07:35 +0000)]
[mlir][linalg] Update OpDSL doc (NFC).

Update the doc due to recent path changes an point to a helper script.

3 years ago[AArch64][GlobalISel] Add a new reassociation for G_PTR_ADDs.
Amara Emerson [Thu, 9 Sep 2021 17:14:17 +0000 (10:14 -0700)]
[AArch64][GlobalISel] Add a new reassociation for G_PTR_ADDs.

G_PTR_ADD (G_PTR_ADD X, C), Y) -> (G_PTR_ADD (G_PTR_ADD(X, Y), C)

Improves CTMark -Os on AArch64:

Program            before after  diff
           sqlite3 286932 287024  0.0%
                kc 432512 432508 -0.0%
             SPASS 412788 412764 -0.0%
    pairlocalalign 249460 249416 -0.0%
            bullet 475740 475512 -0.0%
    7zip-benchmark 568864 568356 -0.1%
  consumer-typeset 419088 418648 -0.1%
        tramp3d-v4 367628 367224 -0.1%
          clamscan 383184 382732 -0.1%
            lencod 430028 429284 -0.2%
Geomean difference               -0.1%

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

3 years ago[NPM] Added -print-pipeline-passes print params for a few passes.
Markus Lavin [Wed, 15 Sep 2021 06:22:12 +0000 (08:22 +0200)]
[NPM] Added -print-pipeline-passes print params for a few passes.

Added '-print-pipeline-passes' printing of parameters for those passes
declared with *_WITH_PARAMS macro in PassRegistry.def.

Note that it only prints the parameters declared inside *_WITH_PARAMS as
in a few cases there appear to be additional parameters not parsable.

The following passes are now covered (i.e. all of those with *_WITH_PARAMS in
PassRegistry.def).

LoopExtractorPass - loop-extract
HWAddressSanitizerPass - hwsan
EarlyCSEPass - early-cse
EntryExitInstrumenterPass - ee-instrument
LowerMatrixIntrinsicsPass - lower-matrix-intrinsics
LoopUnrollPass - loop-unroll
AddressSanitizerPass - asan
MemorySanitizerPass - msan
SimplifyCFGPass - simplifycfg
LoopVectorizePass - loop-vectorize
MergedLoadStoreMotionPass - mldst-motion
GVN - gvn
StackLifetimePrinterPass - print<stack-lifetime>
SimpleLoopUnswitchPass - simple-loop-unswitch

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