platform/upstream/llvm.git
2 years ago[SLP] Add additional memory versioning tests.
Florian Hahn [Thu, 16 Sep 2021 12:28:32 +0000 (13:28 +0100)]
[SLP] Add additional memory versioning tests.

2 years ago[hwasan] print globals in symbolizer-friendly format.
Florian Mayer [Mon, 13 Sep 2021 15:37:44 +0000 (16:37 +0100)]
[hwasan] print globals in symbolizer-friendly format.

Reviewed By: eugenis

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

2 years ago[ARM] Mitigate the cve-2021-35465 security vulnurability.
Alexandros Lamprineas [Thu, 2 Sep 2021 14:01:18 +0000 (15:01 +0100)]
[ARM] Mitigate the cve-2021-35465 security vulnurability.

Recently a vulnerability issue is found in the implementation of VLLDM
instruction in the Arm Cortex-M33, Cortex-M35P and Cortex-M55. If the
VLLDM instruction is abandoned due to an exception when it is partially
completed, it is possible for subsequent non-secure handler to access
and modify the partial restored register values. This vulnerability is
identified as CVE-2021-35465.

The mitigation sequence varies between v8-m and v8.1-m as follows:

v8-m.main
---------
mrs        r5, control
tst        r5, #8       /* CONTROL_S.SFPA */
it         ne
.inst.w    0xeeb00a40   /* vmovne s0, s0 */
1:
vlldm      sp           /* Lazy restore of d0-d16 and FPSCR. */

v8.1-m.main
-----------
vscclrm    {vpr}        /* Clear VPR. */
vlldm      sp           /* Lazy restore of d0-d16 and FPSCR. */

More details on
developer.arm.com/support/arm-security-updates/vlldm-instruction-security-vulnerability

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

2 years ago[ARM][CMSE] Clear the secure fp-registers when using softfp abi.
Alexandros Lamprineas [Thu, 2 Sep 2021 11:48:07 +0000 (12:48 +0100)]
[ARM][CMSE] Clear the secure fp-registers when using softfp abi.

When expanding the non-secure call instruction we are emiting code
to clear the secure floating-point registers only if the targeted
architecture has floating-point support. The potential problem is
when the source code containing non-secure calls are built with
-mfloat-abi=soft but some other part of the system has been built
with -mfloat-abi=softfp (soft and softfp are compatible as they use
the same procedure calling standard). In this case floating-point
registers could leak to non-secure state as the non-secure won't
have cleared them assuming no floating point has been used.

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

2 years ago[OpenCL] Supports optional program scope global variables in C++ for OpenCL 2021
Justas Janickas [Wed, 1 Sep 2021 16:14:22 +0000 (17:14 +0100)]
[OpenCL] Supports optional program scope global variables in C++ for OpenCL 2021

Adds support for macro `__opencl_c_program_scope_global_variables`
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/D109305

2 years ago[clang-cl] Add a /diasdkdir flag and make /winsysroot imply it
Nico Weber [Thu, 16 Sep 2021 11:42:32 +0000 (07:42 -0400)]
[clang-cl] Add a /diasdkdir flag and make /winsysroot imply it

D109708 added "DIA SDK" to our win sysroot for hermetic builds
that use LLVM_ENABLE_DIA_SDK. But the build system still has to
manually pass flags pointing to it.

Since we have a /winsysroot flag, make it look at DIA SDK in
the sysroot.

With this, the following is enough to compile the DIA2Dump example:

out\gn\bin\clang-cl ^
  "sysroot\DIA SDK\Samples\DIA2Dump\DIA2Dump.cpp" ^
  "sysroot\DIA SDK\Samples\DIA2Dump\PrintSymbol.cpp" ^
  "sysroot\DIA SDK\Samples\DIA2Dump\regs.cpp" ^
  /diasdkdir "sysroot\DIA SDK" ^
  ole32.lib oleaut32.lib diaguids.lib

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

2 years ago[lldb/win] Fix TestIRMemoryMapWindows.test when running tests in git bash
Nico Weber [Thu, 16 Sep 2021 11:40:54 +0000 (07:40 -0400)]
[lldb/win] Fix TestIRMemoryMapWindows.test when running tests in git bash

lit.util.which('link') picks up the wrong link.exe in git bash, leading
to this error:

  # command stderr:
  /usr/bin/link: extra operand '/LIBPATH:C:\\Progra....'
  Try '/usr/bin/link --help' for more information.

Instead, assume that link.exe is next to cl.exe.

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

2 years ago[AArch64][SVE] NFC: Remove unnecessary if
Cullen Rhodes [Thu, 16 Sep 2021 11:15:15 +0000 (11:15 +0000)]
[AArch64][SVE] NFC: Remove unnecessary if

2 years ago[lldb] [Process/gdb-remote] Alias sp to x31 on AArch64 for gdbserver
Michał Górny [Thu, 16 Sep 2021 09:03:00 +0000 (11:03 +0200)]
[lldb] [Process/gdb-remote] Alias sp to x31 on AArch64 for gdbserver

Alias the "sp" register to "x31" on AArch64 if one is present and does
not have the alt_name.  This is the case when connecting to gdbserver.

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

2 years ago[X86] SimplifyDemandedVectorEltsForTargetNode - add PSADBW handling
Simon Pilgrim [Thu, 16 Sep 2021 10:28:17 +0000 (11:28 +0100)]
[X86] SimplifyDemandedVectorEltsForTargetNode - add PSADBW handling

Peek through PSADBW operands to handle non demanded elements.

2 years ago[PGO] Change ThinLTO test for targets with loop unrolling disabled
Sherwin da Cruz [Thu, 16 Sep 2021 10:07:21 +0000 (11:07 +0100)]
[PGO] Change ThinLTO test for targets with loop unrolling disabled

I am working on a target in a downstream LLVM repo, and it seems that if a target backend chooses to disable loop unrolling this test would fail. A solution would be to modify the test to search for a different string instead.

The specific test checks for `if.true.direct_targ` which appears in the output when thinlto is not used (ie samplepgo). The same is true for `if.false.orig_indirect`.

However, if a target disables loop unrolling in the backend, the test fails as  `if.true.direct_targ` no longer appears, though `if.false.orig_indirect` still does. This can be seen by using a clang pragma to disable loop unrolling in the `unroll()` function.

For reference, the following files are the outputs of the last 2 test functions being compiled as the test case does, with and without thinlto, and with and without loop unrolling on the latest x86 clang build. The loop unrolling pragma was used to simulate the loop unrolling being disabled in a backend.
```
// RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o out.ll
// RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -flto=thin -o out.ll
```

Reviewed By: tejohnson

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

2 years ago[lldb] [DynamicRegisterInfo] Pass name/alt_name via RegisterInfo
Michał Górny [Thu, 16 Sep 2021 09:43:56 +0000 (11:43 +0200)]
[lldb] [DynamicRegisterInfo] Pass name/alt_name via RegisterInfo

Remove the name and alt_name parameters from AddRegister() and instead
pass them via RegisterInfo.name and .alt_name fields.  This makes
the API simpler and removes some duplication.

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

2 years ago[Analyzer] ConversionChecker: track back the cast expression
Gabor Marton [Wed, 15 Sep 2021 16:32:19 +0000 (18:32 +0200)]
[Analyzer] ConversionChecker: track back the cast expression

Adding trackExpressionValue to the checker so it tracks the value of the
implicit cast's DeclRefExpression up to initialization/assignment. This
way the report becomes cleaner.

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

2 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.

2 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.

2 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

2 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

2 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.

2 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

2 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

2 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

2 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

2 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

2 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.

2 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

2 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

2 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.

2 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

2 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

2 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

2 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));
}

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

2 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

2 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)

2 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

2 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.

2 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.

2 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.

2 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

2 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

2 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.

2 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

2 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

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

2 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.

2 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

2 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.

2 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

2 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

2 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.

2 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.

2 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

2 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

2 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

2 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.

2 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

2 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

2 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.

2 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

2 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

2 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]".

2 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

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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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.

2 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.

2 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

2 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

2 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

2 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

2 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

2 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.

2 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

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

2 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

2 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

2 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.

2 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

2 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

2 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.

2 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.

2 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.

2 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.

2 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

2 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

2 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).

2 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

2 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

2 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

2 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

2 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

2 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.

2 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.