platform/upstream/llvm.git
3 years ago[CSSPGO] Exclude pseudo probes from slot index
Hongtao Yu [Tue, 13 Apr 2021 06:51:44 +0000 (23:51 -0700)]
[CSSPGO] Exclude pseudo probes from slot index

Pseudo probe are currently given a slot index like other regular instructions. This affects register pressure and lifetime weight computation because of enlarged lifetime length with pseudo probe instructions. As a consequence, program could get different code generated w/ and w/o pseudo probes. I'm closing the gap by excluding pseudo probes from stack index and downstream register allocation related passes.

Reviewed By: wmi

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

3 years ago[CSSPGO] Flip SkipPseudoOp to true for MIR APIs.
Hongtao Yu [Mon, 19 Apr 2021 15:51:57 +0000 (08:51 -0700)]
[CSSPGO] Flip SkipPseudoOp to true for MIR APIs.

Flipping the default value of SkipPseudoOp to true for those MIR APIs to favor maximum performance. Note that certain spots like branch folding and MIR if-conversion is are disabled for better counts quality. For these two optimizations, this is a no-diff change.

The counts quality with SPEC2017 before/after this change is unchanged.

Reviewed By: wmi

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

3 years agoFix android-x86 library name in asan_device_setup.
Evgenii Stepanov [Wed, 14 Apr 2021 20:11:38 +0000 (13:11 -0700)]
Fix android-x86 library name in asan_device_setup.

https://reviews.llvm.org/D26764 removed i686 variants of compiler-rt
libraries and canonicalized the i386 name.

https://reviews.llvm.org/D37278 partially reverted the previous change
to keep i686 name on Android, but did not update asan_device_setup
script.

This changes fixes asan_device_setup.

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

3 years ago[InstCombine] Enhance deduction of alignment for aligned_alloc
Dávid Bolvanský [Tue, 20 Apr 2021 00:03:38 +0000 (02:03 +0200)]
[InstCombine] Enhance deduction of alignment for aligned_alloc

This patch improves https://reviews.llvm.org/D76971 (Deduce attributes for aligned_alloc in InstCombine) and implements "TODO" item mentioned in the review of that patch.

> The function aligned_alloc() is the same as memalign(), except for the added restriction that size should be a multiple of alignment.

Currently, we simply bail out if we see a non-constant size - change that.

Reviewed By: jdoerfert

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

3 years ago[lldb] Fix demangler leaks in the DWARF AST parser
Fangrui Song [Mon, 19 Apr 2021 23:36:54 +0000 (16:36 -0700)]
[lldb] Fix demangler leaks in the DWARF AST parser

This fixes 6 check-lldb-shell failures in a `-DLLVM_USE_SANITIZER=Leaks` build.

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

3 years ago[libc++] [C++20] [P0586] Implement safe integral comparisons
Kamlesh Kumar [Mon, 19 Apr 2021 23:18:34 +0000 (04:48 +0530)]
[libc++] [C++20] [P0586] Implement safe integral comparisons

* https://wg21.link/P0586

Reviewed By: #libc, curdeius, Quuxplusone

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

3 years agoAdd a cache of checked AttributeLists.
Nick Lewycky [Mon, 19 Apr 2021 03:51:43 +0000 (20:51 -0700)]
Add a cache of checked AttributeLists.

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

3 years ago[M68k] Put M68kDesc as the direct library dependency for disassembler
Min-Yih Hsu [Mon, 19 Apr 2021 22:53:52 +0000 (15:53 -0700)]
[M68k] Put M68kDesc as the direct library dependency for disassembler

M68kDisassembler should put M68kDesc as its direct library dependency
since it uses logics releated to code beads Otherwise the build will
fail when building LLVM libraries as shared objects (building LLVM
libraries statically won't have this problem though)

3 years agoReset NextFnNum in MachineModuleInfo::initialize
Roman Tereshin [Tue, 11 Aug 2020 06:29:39 +0000 (23:29 -0700)]
Reset NextFnNum in MachineModuleInfo::initialize

In an env that reuses compiler instances for multiple compilations, this
omission results in non-deterministic assembly output (names of the
auto-generated labels) if the order or full set of Modules compiled
varies.

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

3 years ago[libc++][gardening] Replace instances of `\x{AD}`.
zoecarver [Mon, 19 Apr 2021 21:59:32 +0000 (14:59 -0700)]
[libc++][gardening] Replace instances of `\x{AD}`.

This is a NFC.

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

3 years agoRevert "[clang-scan-deps] Add support for clang-cl"
Alexandre Ganea [Mon, 19 Apr 2021 21:43:24 +0000 (17:43 -0400)]
Revert "[clang-scan-deps] Add support for clang-cl"

This reverts commit bb26fa8c286bf524ed9235c3e293ad22ecf3e984.

3 years ago[PhaseOrdering] add test to show unintended code sinking; NFC
Sanjay Patel [Mon, 19 Apr 2021 20:41:27 +0000 (16:41 -0400)]
[PhaseOrdering] add test to show unintended code sinking; NFC

See D87479 for discussion.

3 years ago[M68k] Implement Disassembler
Ricky Taylor [Thu, 11 Mar 2021 22:12:47 +0000 (22:12 +0000)]
[M68k] Implement Disassembler

This is an implementation of a disassembler for M68k.

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

3 years ago[M68k] Change printing of absolute memory references
Ricky Taylor [Sat, 17 Apr 2021 10:03:34 +0000 (11:03 +0100)]
[M68k] Change printing of absolute memory references

This also includes PC-relative addresses since they are still
referenced as absolute addresses in assembly and converted to
relative addresses by the assembler.

This changes, for example:
- `bra #-2` -> `bra $100`
- `jsr #16` -> `jsr $10`

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

3 years agoRevert "[SLP]Add detection of shuffled/perfect matching of tree entries."
Alexey Bataev [Mon, 19 Apr 2021 21:09:40 +0000 (14:09 -0700)]
Revert "[SLP]Add detection of shuffled/perfect matching of tree entries."

This reverts commit d6fde913790db898e72e27b51defbc7442f3418a to fix
compiler crashes.

3 years ago[ThinLTO] Copy UnnamedAddr when spliting module.
Zequan Wu [Wed, 14 Apr 2021 17:42:50 +0000 (10:42 -0700)]
[ThinLTO] Copy UnnamedAddr when spliting module.

The unnamedaddr property of a function is lost when using
`-fwhole-program-vtables` and thinlto which causes size increase under linker's
safe icf mode.

The size increase of chrome on Linux when switching from all icf to safe icf
drops from 5 MB to 3 MB after this change, and from 6 MB to 4 MB on Windows.

There is a repro:
```
# a.h
struct A {
  virtual int f();
  virtual int g();
};

# a.cpp
#include "a.h"
int A::f() { return 10; }
int A::g() { return 10; }

# main.cpp
#include "a.h"

int g(A* a) {
  return a->f();
}

int main(int argv, char** args) {
  A a;
  return g(&a);
}

$ clang++ -O2 -ffunction-sections -flto=thin -fwhole-program-vtables -fsplit-lto-unit -c main.cpp -o main.o  && clang++ -Wl,--icf=safe -fuse-ld=lld  -flto=thin main.o -o a.out && llvm-readobj -t a.out | grep -A 1 -e _ZN1A1fEv -e _ZN1A1gEv
    Name: _ZN1A1fEv (480)
    Value: 0x201830
--
    Name: _ZN1A1gEv (490)
    Value: 0x201840
```

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

3 years ago[compiler-rt] assert max virtual address is <= mmap range size
Emily Shi [Sat, 10 Apr 2021 00:47:54 +0000 (17:47 -0700)]
[compiler-rt] assert max virtual address is <= mmap range size

If these sizes do not match, asan will not work as expected.

If possible, assert at compile time that the vm size is less than or equal to mmap range.
If a compile time assert is not possible, check at run time (for iOS)

rdar://76477969

Reviewed By: delcypher, yln

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

3 years ago[SLP]Add detection of shuffled/perfect matching of tree entries.
Alexey Bataev [Wed, 14 Apr 2021 16:44:01 +0000 (09:44 -0700)]
[SLP]Add detection of shuffled/perfect matching of tree entries.

SLP supports perfect diamond matching for the vectorized tree entries
but do not support it for gathered entries and does not support
non-perfect (shuffled) matching with 1 or 2 tree entries. Patch adds
support for this matching to improve cost of the vectorized tree.

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

3 years ago[CodeGen] Use ProcResGroup information in SchedBoundary
David Penry [Mon, 19 Apr 2021 20:27:45 +0000 (21:27 +0100)]
[CodeGen] Use ProcResGroup information in SchedBoundary

When the ProcResGroup has BufferSize=0,

1. if there is a subunit in the list of write resources for the
   scheduling class, do not attempt to schedule the ProcResGroup.
2. if there is not a subunit in the list of write resources for the
   scheduling class, choose a subunit to use instead of the ProcResGroup.
3. having both the ProcResGroup and any of its subunits in the resources
   implied by a InstRW is not supported.

Used to model parallel uses from a pool of resources.

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

3 years ago[ARM] Use ProcResGroup in Cortex-M7 scheduling model
David Penry [Mon, 19 Apr 2021 20:23:05 +0000 (21:23 +0100)]
[ARM] Use ProcResGroup in Cortex-M7 scheduling model

Used to model structural hazards on FP issue, where some
instructions take up 2 issue slots and others one as well
as similar structural hazards on load issue, where some
instructions take up two load lanes and others one.

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

3 years ago[funcattrs] Consistently check call site attributes
Philip Reames [Mon, 19 Apr 2021 20:19:39 +0000 (13:19 -0700)]
[funcattrs] Consistently check call site attributes

This is mostly stylistic cleanup after D100226, but not entirely. When skimming the code, I found one case where we weren't accounting for attributes on the callsite at all. I'm also suspicious we had some latent bugs related to operand bundles (which are supposed to be able to *override* attributes on declarations), but I don't have concrete test cases for those, just suspicions.

Aside: The only case left in the file which directly checks attributes on the declaration is the norecurse logic. I left that because I didn't understand it; it looks obviously wrong, so I suspect I'm misinterpreting the intended semantics of the attribute.

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

3 years ago[AST] Fix comparison to of SourceRanges in container
Stephen Kelly [Sun, 18 Apr 2021 12:15:01 +0000 (13:15 +0100)]
[AST] Fix comparison to of SourceRanges in container

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

3 years ago[rs4gc] Fix a latent bug around attribute stripping for intrinsics
Philip Reames [Mon, 19 Apr 2021 20:03:24 +0000 (13:03 -0700)]
[rs4gc] Fix a latent bug around attribute stripping for intrinsics

This change fixes a latent bug which was exposed by a change currently in review (https://reviews.llvm.org/D99802#2685032).

The story on this is a bit involved.  Without this change, what ended up happening with the pending review was that we'd strip attributes off intrinsics, and then selectiondag would fail to lower the intrinsic.  Why?  Because the lowering of the intrinsic relies on the presence of the readonly attribute.  We don't have a matcher to select the case where there's a glue node needed.

Now, on the surface, this still seems like a codegen bug.  However, here it gets fun.  I was unable to reproduce this with a standalone test at all, and was pretty much struck until skatkov provided the critical detail.  This reproduces only when RS4GC and codegen are run in the same process and context.  Why?  Because it turns out we can't roundtrip the stripped attribute through serialized IR!

We'll happily print out the missing attribute, but when we parse it back, the auto-upgrade logic has a side effect of blindly overwriting attributes on intrinsics with those specified in Intrinsics.td.  This makes it impossible to exercise SelectionDAG from a standalone test case.

At this point, I decided to treat this an RS4GC bug as a) we don't need to strip in this case, and b) I could write a test which shows the correct behavior to ensure this doesn't break again in the future.

As an aside, I'd originally set out to handle libfuncs too - since in theory they might have the same issues - but backed away quickly when I realized how the semantics of builtin, nobuiltin, and no-builtin-x all interacted.  I'm utterly convinced that no part of the optimizer handles that correctly, and decided not to open that can of worms here.

3 years ago[InstCombine] Fold multiuse shr eq zero
Nikita Popov [Mon, 19 Apr 2021 20:09:15 +0000 (22:09 +0200)]
[InstCombine] Fold multiuse shr eq zero

The single-use case is handled implicity by converting the icmp
into a mask check first. When comparing with zero in particular,
we don't need the one-use restriction, as we only produce a single
icmp.

https://alive2.llvm.org/ce/z/MSixcm
https://alive2.llvm.org/ce/z/GwpG0M

3 years ago[InstCombine] Add tests for multiuse shr eq zero (NFC)
Nikita Popov [Mon, 19 Apr 2021 19:01:13 +0000 (21:01 +0200)]
[InstCombine] Add tests for multiuse shr eq zero (NFC)

The exact case is folded, the inexact one is not.

3 years ago[AST] Update introspection API to use const-ref for copyable types
Stephen Kelly [Sun, 18 Apr 2021 10:02:41 +0000 (11:02 +0100)]
[AST] Update introspection API to use const-ref for copyable types

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

3 years ago[libcxx] [test] Ifdef out tests that rely on perms::none on directories for triggerin...
Martin Storsjö [Fri, 26 Feb 2021 10:56:41 +0000 (12:56 +0200)]
[libcxx] [test] Ifdef out tests that rely on perms::none on directories for triggering errors

On Windows, one can't use perms::none on a directory to trigger
failures to read the directory entries.

These remaining tests can't use GetWindowsInaccessibleDir() sensibly,
e.g. for tests that rely on toggling accessibility back and forth during
the test, or where the semantics of the dir provided by
GetWindowsInaccessibleDir() doesn't allow for running the ifdeffed tests
meaningfully.

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

3 years ago[WebAssembly] Use v128.const instead of splats for constants
Thomas Lively [Mon, 19 Apr 2021 19:43:58 +0000 (12:43 -0700)]
[WebAssembly] Use v128.const instead of splats for constants

We previously used splats instead of v128.const to materialize vector constants
because V8 did not support v128.const. Now that V8 supports v128.const, we can
use v128.const instead. Although this increases code size, it should also
increase performance (or at least require fewer engine-side optimizations), so
it is an appropriate change to make.

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

3 years ago[libcxx] Base MSVC autolinking on _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS
Martin Storsjö [Thu, 15 Apr 2021 08:16:28 +0000 (11:16 +0300)]
[libcxx] Base MSVC autolinking on _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS

Previously the decision of which library to try to autolink was
based on _DLL, however the _DLL define (which is set by the compiler)
is tied to whether using a dynamically linked CRT or not, and the choice
of dynamic or static CRT is entirely orthogonal to whether libc++ is
linked dynamically or statically.

If _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS isn't defined, then all
declarations are decorated with dllimport, and there's no doubt that
the DLL version of the library is what must be linked.

_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS is defined if building with
LIBCXX_ENABLE_SHARED disabled, and thus the static library is what
should be linked.

If defining _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS manually but wanting
to link against the DLL version of the library, that's not a canonical
configuration, and then it's probably reasonable to manually define
_LIBCPP_NO_AUTO_LINK too, and manually link against the desired
library.

This fixes, among other issues, running tests for the library if
built with LIBCXX_ENABLE_STATIC disabled.

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

3 years ago[mlir][python] ExecutionEngine can dump to object file
Nicolas Vasilache [Mon, 19 Apr 2021 19:30:29 +0000 (19:30 +0000)]
[mlir][python] ExecutionEngine can dump to object file

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

3 years ago[lldb] Stop unsetting LLDB_DEBUGSERVER_PATH from TestLaunchProcessPosixSpawn
Jonas Devlieghere [Mon, 19 Apr 2021 19:24:58 +0000 (12:24 -0700)]
[lldb] Stop unsetting LLDB_DEBUGSERVER_PATH from TestLaunchProcessPosixSpawn

We no longer need this after Pavel's change to automatically find debug
servers to test. (3ca7b2d)

3 years ago[PowerPC] Disable relative lookup table converter pass for AIX
Jinsong Ji [Mon, 19 Apr 2021 18:57:18 +0000 (18:57 +0000)]
[PowerPC] Disable relative lookup table converter pass for AIX

XCOFF hasn't implemented lowerRelativeReference.
So we need to disable new pass introduced by https://reviews.llvm.org/D94355 for
AIX for now.

Reviewed By: gulfem

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

3 years ago[lldb] Update breakpoint_function_callback.test for different error message
Jonas Devlieghere [Mon, 19 Apr 2021 19:22:31 +0000 (12:22 -0700)]
[lldb] Update breakpoint_function_callback.test for different error message

Adjust for the Lua error message printed by Lua 5.4.3.

3 years ago[lldb] Print the fixed address if symbolication fails in DumpDataExtractor
Jonas Devlieghere [Fri, 16 Apr 2021 21:10:26 +0000 (14:10 -0700)]
[lldb] Print the fixed address if symbolication fails in DumpDataExtractor

When formatting memory with as eFormatAddressIn and symbolication fails,
fix the code address and print the symbol it points to, if any.

3 years ago[compiler-rt][asan] use full vm range on apple silicon macs
Emily Shi [Fri, 9 Apr 2021 00:49:22 +0000 (17:49 -0700)]
[compiler-rt][asan] use full vm range on apple silicon macs

We previously shrunk the mmap range size on ios, but those settings got inherited by apple silicon macs.
Don't shrink the vm range on apple silicon Mac since we have access to the full range.

Also don't shrink vm range for iOS simulators because they have the same range as the host OS, not the simulated OS.

rdar://75302812

Reviewed By: delcypher, kubamracek, yln

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

3 years ago[AMDGPU] Remove error check for indirect calls and add missing queue-ptr
madhur13490 [Fri, 16 Apr 2021 08:42:38 +0000 (14:12 +0530)]
[AMDGPU] Remove error check for indirect calls and add missing queue-ptr

This patch removes -fixed-abi check for indirect calls
and also adds queue-ptr which is required for indirect calls to work.

Reviewed By: arsenm

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

3 years ago[AArch64] Peephole rule to remove redundant cmp after cset.
Pavel Iliin [Tue, 9 Mar 2021 00:18:27 +0000 (00:18 +0000)]
[AArch64] Peephole rule to remove redundant cmp after cset.

Comparisons to zero or one after cset instructions can be safely
removed in examples like:

cset w9, eq          cset w9, eq
cmp  w9, #1   --->   <removed>
b.ne    .L1          b.ne    .L1

cset w9, eq          cset w9, eq
cmp  w9, #0   --->   <removed>
b.ne    .L1          b.eq    .L1

Peephole optimization to detect suitable cases and get rid of that
comparisons added.

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

3 years ago[CUDA][HIP] Allow non-ODR use of host var in device
Yaxun (Sam) Liu [Mon, 8 Mar 2021 17:29:03 +0000 (12:29 -0500)]
[CUDA][HIP] Allow non-ODR use of host var in device

Reviewed by: Artem Belevich, Richard Smith

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

3 years ago[flang] Define missing & needed IEEE_ARITHMETIC symbols
peter klausler [Thu, 15 Apr 2021 21:11:47 +0000 (14:11 -0700)]
[flang] Define missing & needed IEEE_ARITHMETIC symbols

Define IEEE_IS_NAN, IEEE_IS_FINITE, & IEEE_REM.

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

3 years ago[gn build] Port e0adf7e06a9e
LLVM GN Syncbot [Mon, 19 Apr 2021 18:35:15 +0000 (18:35 +0000)]
[gn build] Port e0adf7e06a9e

3 years ago[LICM] Make capture check more precise
Nikita Popov [Sat, 17 Apr 2021 13:25:29 +0000 (15:25 +0200)]
[LICM] Make capture check more precise

During store promotion, we check whether the pointer was captured
to exclude potential reads from other threads. However, we're only
interested in captures before or inside the loop. Check this using
PointerMayBeCapturedBefore against the loop header.

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

3 years ago[libc++][NFC] Move incrementable_traits and indirectly_readable_traits into separate...
zoecarver [Mon, 19 Apr 2021 18:28:27 +0000 (14:28 -0400)]
[libc++][NFC] Move incrementable_traits and indirectly_readable_traits into separate headers.

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

3 years ago[RISCV] Fix mistake in comment. NFC
Craig Topper [Mon, 19 Apr 2021 18:06:58 +0000 (11:06 -0700)]
[RISCV] Fix mistake in comment. NFC

3 years agoUpdate a test for auto-update format change
Philip Reames [Mon, 19 Apr 2021 18:14:39 +0000 (11:14 -0700)]
Update a test for auto-update format change

3 years ago[RISCV] Pad v4i1/v2i1/v1i1 stores with 0s to make a full byte.
Craig Topper [Mon, 19 Apr 2021 17:52:22 +0000 (10:52 -0700)]
[RISCV] Pad v4i1/v2i1/v1i1 stores with 0s to make a full byte.

As noted in the FIXME there's a sort of agreement that the any
extra bits stored will be 0.

The generated code is pretty terrible. I was really hoping we
could use a tail undisturbed trick, but tail undisturbed no
longer applies to masked destinations in the current draft
spec.

Fingers crossed that it isn't common to do this. I doubt IR
from clang or the vectorizer would ever create this kind of store.

Reviewed By: frasercrmck

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

3 years ago[test] Make global in split-gep-and-gvn.ll not constant
Arthur Eubanks [Mon, 19 Apr 2021 18:03:19 +0000 (11:03 -0700)]
[test] Make global in split-gep-and-gvn.ll not constant

An upcoming change will cause loads from a constant zeroinitializer
global to be constant folded, breaking this test.

3 years ago[lld] Delete unused includes. NFC
Fangrui Song [Mon, 19 Apr 2021 17:56:48 +0000 (10:56 -0700)]
[lld] Delete unused includes. NFC

3 years ago[AArch64][GlobalISel] Implement custom legalization for s32 and s64 G_CTPOP
Jessica Paquette [Tue, 13 Apr 2021 17:11:25 +0000 (10:11 -0700)]
[AArch64][GlobalISel] Implement custom legalization for s32 and s64 G_CTPOP

This is a partial port of AArch64TargetLowering::LowerCTPOP.

This custom lowering tries to uses NEON instructions to give a more efficient
CTPOP lowering when possible.

In the non-NEON/noimplicitfloat case, this should use the generic lowering
(see: https://godbolt.org/z/GcaPvWe4x). I think that's worth implementing after
implementing the widening code for s16/s8 though.

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

3 years ago[TargetLowering] move "o" and "X" constraint handling to base class
Nick Desaulniers [Mon, 19 Apr 2021 17:36:33 +0000 (10:36 -0700)]
[TargetLowering] move "o" and "X" constraint handling to base class

These constraints are machine agnostic; there's no reason to handle
these per-arch. If arches don't support these constraints, then they
will fail elsewhere during instruction selection. We don't need virtual
calls to look these up; TargetLowering::getInlineAsmMemConstraint should
only be overridden by architectures with additional unique memory
constraints.

Reviewed By: echristo, MaskRay

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

3 years ago[AArch64][GlobalISel] Regbankselect + select @llvm.aarch64.neon.uaddlv
Jessica Paquette [Tue, 13 Apr 2021 17:03:17 +0000 (10:03 -0700)]
[AArch64][GlobalISel] Regbankselect + select @llvm.aarch64.neon.uaddlv

It turns out we actually import a bunch of selection code for intrinsics. The
imported code checks that the register banks on the G_INTRINSIC instruction
are correct. If so, it goes ahead and selects it.

This adds code to AArch64RegisterBankInfo to allow us to correctly determine
register banks on intrinsics which have known register bank constraints.

For now, this only handles @llvm.aarch64.neon.uaddlv. This is necessary for
porting AArch64TargetLowering::LowerCTPOP.

Also add a utility for getting the intrinsic ID from a G_INTRINSIC instruction.
This seems a little nicer than having to know about how intrinsic instructions
are structured.

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

3 years ago[lldb] Support "absolute memory address" images in crashlog.py
Jonas Devlieghere [Mon, 19 Apr 2021 17:20:13 +0000 (10:20 -0700)]
[lldb] Support "absolute memory address" images in crashlog.py

The binary image list contains the following entry when a frame is not
found in any know binary image:

  {
    "size" : 0,
    "source" : "A",
    "base" : 0,
    "uuid" : "00000000-0000-0000-0000-000000000000"
  }

Note that this object is missing the name and path keys. This patch
makes the JSON parser resilient against their absence.

3 years ago[LowerConstantIntrinsics] avoid crashing on alloca with unexpected operand type
Sanjay Patel [Mon, 19 Apr 2021 15:47:13 +0000 (11:47 -0400)]
[LowerConstantIntrinsics] avoid crashing on alloca with unexpected operand type

The test here is reduced from the fuzzer-generated crasher in:
https://llvm.org/PR50023
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=33395

I don't know if this is the best or complete solution, but the
zext of the i42 type appears to match the behavior if we run a
weird type example like this through the IR optimizer with -O1.

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

3 years agofix comment typo to cycle bots
Nico Weber [Mon, 19 Apr 2021 16:58:56 +0000 (12:58 -0400)]
fix comment typo to cycle bots

3 years ago[AIX] Diagnose thinLTO usage in clang on AIX.
Wael Yehia [Mon, 19 Apr 2021 16:01:19 +0000 (16:01 +0000)]
[AIX] Diagnose thinLTO usage in clang on AIX.

Reviewed By: Xiangling Liao

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

3 years ago[clang] NFC: Fix range-based for loop warnings related to decl lookup
Jan Svoboda [Mon, 19 Apr 2021 16:31:31 +0000 (18:31 +0200)]
[clang] NFC: Fix range-based for loop warnings related to decl lookup

3 years ago[polly] Fix check-polly after SCEVExpander PtrToInt fixes
Roman Lebedev [Mon, 19 Apr 2021 16:10:55 +0000 (19:10 +0300)]
[polly] Fix check-polly after SCEVExpander PtrToInt fixes

3 years ago[SCEVExpander] ReuseOrCreateCast(): use IRBuilder to actually create the cast
Roman Lebedev [Mon, 19 Apr 2021 15:30:56 +0000 (18:30 +0300)]
[SCEVExpander] ReuseOrCreateCast(): use IRBuilder to actually create the cast

In particular, this allows to create constant expressions
instead of IR Instruction's if the argumen is a constant.

3 years ago[SCEVExpander] Expand explicit PtrToInt casts just like we would implicit ones
Roman Lebedev [Mon, 19 Apr 2021 14:15:01 +0000 (17:15 +0300)]
[SCEVExpander] Expand explicit PtrToInt casts just like we would implicit ones

I.e., use GetOptimalInsertionPointForCastOf() helper to get the insertion
point, and try to reuse casts first.

3 years ago[SCEVExpander] GetOptimalInsertionPointForCastOf(): gracefully handle Constant's
Roman Lebedev [Mon, 19 Apr 2021 14:36:20 +0000 (17:36 +0300)]
[SCEVExpander] GetOptimalInsertionPointForCastOf(): gracefully handle Constant's

I guess this case hasn't come up thus far, and i'm not sure if it can
really happen for the existing usages, thus no test in *this* commit.

But, the following commit adds test coverage,
there we'd expirience a crash without this fix.

3 years ago[NFCI][SCEVExpander] Extract GetOptimalInsertionPointForCastOf() helper
Roman Lebedev [Mon, 19 Apr 2021 14:06:15 +0000 (17:06 +0300)]
[NFCI][SCEVExpander] Extract GetOptimalInsertionPointForCastOf() helper

3 years ago[SCEVExpander] generateOverflowCheck(): explicitly PtrToInt the Start
Roman Lebedev [Mon, 19 Apr 2021 13:48:02 +0000 (16:48 +0300)]
[SCEVExpander] generateOverflowCheck(): explicitly PtrToInt the Start

Currently, InsertNoopCastOfTo() would implicitly insert that cast,
but now that we have SCEVPtrToIntExpr, i'm hoping we could stop
InsertNoopCastOfTo() from doing that. But first all users must be fixed.

3 years ago[NFC][SCEVExpander][LoopDistribute] Add test for SCEVPtrToIntExpr in SCEVExpander...
Roman Lebedev [Mon, 19 Apr 2021 13:46:08 +0000 (16:46 +0300)]
[NFC][SCEVExpander][LoopDistribute] Add test for SCEVPtrToIntExpr in SCEVExpander::generateOverflowCheck()

We shouldn't end up with ptrtoint-of-getelementptr there.

3 years ago[NFC][SCEVExpander][LoopDistribute] Regenerate scev-inserted-runtime-check.ll check...
Roman Lebedev [Mon, 19 Apr 2021 13:44:13 +0000 (16:44 +0300)]
[NFC][SCEVExpander][LoopDistribute] Regenerate scev-inserted-runtime-check.ll check lines

3 years ago[NFC][SCEV] Assert that we don't try to create SCEVPtrToIntExpr of a non-integral...
Roman Lebedev [Mon, 19 Apr 2021 13:29:41 +0000 (16:29 +0300)]
[NFC][SCEV] Assert that we don't try to create SCEVPtrToIntExpr of a non-integral pointer

ptr<->int casts are only valid for integral pointes,
defensively assert that we don't try to break that here.

3 years ago[Analysis] ImportedFunctionsInliningStatistics.h - add <memory> and remove unused...
Simon Pilgrim [Mon, 19 Apr 2021 13:51:57 +0000 (14:51 +0100)]
[Analysis] ImportedFunctionsInliningStatistics.h - add <memory> and remove unused <string> include. NFCI.

Move <string> include to ImportedFunctionsInliningStatistics.cpp and add missing <memory> include as we have explicit uses of std::unique_ptr in the header.

3 years ago[gn build] (manually) merge 5f87ab336e9f4
Nico Weber [Mon, 19 Apr 2021 14:34:41 +0000 (10:34 -0400)]
[gn build] (manually) merge 5f87ab336e9f4

3 years ago[gn build] Add missing dependencies to clang/lib/Basic
Nico Weber [Mon, 19 Apr 2021 14:30:10 +0000 (10:30 -0400)]
[gn build] Add missing dependencies to clang/lib/Basic

These are needed when buildling `clang-format` in a clean build dir.
It's a bit unfortunate that clang's lib/Basic depends on these
random TableGen targets. In the CMake build, this is less visible
because I think all llvm-tblgen's complete before all compiles there
(not sure though).

3 years agoFix test/Frontend/print-header-includes.c
Hans Wennborg [Mon, 19 Apr 2021 13:38:59 +0000 (15:38 +0200)]
Fix test/Frontend/print-header-includes.c

I managed to run the wrong tests before committing D100759.

3 years ago[Support] Memory.h - remove unnecessary <string> include. NFCI.
Simon Pilgrim [Mon, 19 Apr 2021 13:07:01 +0000 (14:07 +0100)]
[Support] Memory.h - remove unnecessary <string> include. NFCI.

protectMappedMemory no longer returns an error message, so we don't need std::string - I've fixed an unnecessary doxygen entry as well (oddly I wasn't seeing a Wdocumentation warning)

3 years ago[SystemZ][z/OS] Set more text files as text
Abhina Sreeskantharajan [Mon, 19 Apr 2021 13:31:13 +0000 (09:31 -0400)]
[SystemZ][z/OS] Set more text files as text

This patch corrects more instances of text files being opened as text.

Reviewed By: Jonathan.Crowther

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

3 years agoRename -show-skipped-includes to -fshow-skipped-includes and make it a driver option
Hans Wennborg [Mon, 19 Apr 2021 13:08:49 +0000 (15:08 +0200)]
Rename -show-skipped-includes to -fshow-skipped-includes and make it a driver option

This is a user-facing option, so it doesn't make sense for it to be cc1
only.

Follow-up to D100420

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

3 years ago[AMDGPU] GCNDPPCombine: simplify API of isShrinkable. NFC.
Jay Foad [Mon, 19 Apr 2021 13:20:46 +0000 (14:20 +0100)]
[AMDGPU] GCNDPPCombine: simplify API of isShrinkable. NFC.

3 years ago[clang][deps] NFC: Remove unused FullDependencies member
Jan Svoboda [Mon, 19 Apr 2021 12:34:10 +0000 (14:34 +0200)]
[clang][deps] NFC: Remove unused FullDependencies member

This patch removes the `FullDependencies::AdditionalNonPathCommandLine` member, as it's value-initialized and never mutated.

Reviewed By: dexonsmith

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

3 years ago[TableGen] Add support for the 'assert' statement in multiclasses
Paul C. Anagnostopoulos [Thu, 1 Apr 2021 17:01:43 +0000 (13:01 -0400)]
[TableGen] Add support for the 'assert' statement in multiclasses

This is step 3 of adding the 'assert' statement.

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

3 years ago[mlir][linalg] enable library call rewrites for linalg operations with index semantics.
Tobias Gysi [Mon, 19 Apr 2021 12:23:11 +0000 (12:23 +0000)]
[mlir][linalg] enable library call rewrites for linalg operations with index semantics.

The patch enables the library call lowering for linalg operations that contain index operations.

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

3 years ago[mlir] Improve debug flag management in Python bindings
Alex Zinenko [Mon, 19 Apr 2021 11:37:01 +0000 (13:37 +0200)]
[mlir] Improve debug flag management in Python bindings

Expose the debug flag as a readable and assignable property of a
dedicated class instead of a write-only function. Actually test the fact
of setting the flag. Move test to a dedicated file, it has zero relation
to context_managers.py where it was added.

Arguably, it should be promoted from mlir.ir to mlir module, but we are
not re-exporting the latter and this functionality is purposefully
hidden so can stay in IR for now. Drop unnecessary export code.

Refactor C API and put Debug into a separate library, fix it to actually
set the flag to the given value.

Reviewed By: nicolasvasilache

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

3 years ago[clang][deps] Generate the full command-line for modules
Jan Svoboda [Tue, 30 Mar 2021 11:31:03 +0000 (13:31 +0200)]
[clang][deps] Generate the full command-line for modules

This patch uses the new `CompilerInvocation::generateCC1CommandLine` to generate the full canonical command line for modular dependencies, instead of only appending additional arguments.

Reviewed By: dexonsmith

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

3 years ago[IR] GlobalObject.h - remove unused <utility> include. NFCI.
Simon Pilgrim [Mon, 19 Apr 2021 12:25:24 +0000 (13:25 +0100)]
[IR] GlobalObject.h - remove unused <utility> include. NFCI.

In fact there's no explicit use of any std:: type or method in this header.

3 years ago[mlir][linalg] adding pass to run the interchange pattern.
Tobias Gysi [Mon, 19 Apr 2021 11:53:18 +0000 (11:53 +0000)]
[mlir][linalg] adding pass to run the interchange pattern.

Instead of interchanging loops during the loop lowering this pass performs the interchange by permuting the indexing maps. It also updates the iterator types and the index accesses in the body of the operation.

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

3 years ago[SystemZ][z/OS] Set files in FileRemapper.cpp are text
Abhina Sreeskantharajan [Mon, 19 Apr 2021 11:59:23 +0000 (07:59 -0400)]
[SystemZ][z/OS] Set files in FileRemapper.cpp are text

This patch sets files in FileRemapper to open as text.

Reviewed By: Jonathan.Crowther

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

3 years ago[IR] GlobalObject.h - remove unused <string> include. NFCI.
Simon Pilgrim [Mon, 19 Apr 2021 10:51:27 +0000 (11:51 +0100)]
[IR] GlobalObject.h - remove unused <string> include. NFCI.

All string usage is hidden behind StringRefs - so we don't need an explicit <string> include.

3 years ago[llvm-exegesis] Analysis.cpp - use for-range loop. NFCI.
Simon Pilgrim [Mon, 19 Apr 2021 10:49:35 +0000 (11:49 +0100)]
[llvm-exegesis] Analysis.cpp - use for-range loop. NFCI.

3 years ago[MCA] CodeEmitter.h - remove unused <string> include. NFCI.
Simon Pilgrim [Mon, 19 Apr 2021 10:44:12 +0000 (11:44 +0100)]
[MCA] CodeEmitter.h - remove unused <string> include. NFCI.

Add explicit SmallString.h include - which is used in the header

3 years agoTry to unbreak the compiler-rt build on s390x
Sylvestre Ledru [Mon, 19 Apr 2021 11:17:47 +0000 (13:17 +0200)]
Try to unbreak the compiler-rt build on s390x

Introduced by:
3d1d7156e9a9a794ba649b79e27fe448274fd558

3 years ago[AMDGPU] Remove MachineDCE after SIFoldOperands
Jay Foad [Thu, 8 Apr 2021 16:10:54 +0000 (17:10 +0100)]
[AMDGPU] Remove MachineDCE after SIFoldOperands

Remove the MachineDCE pass after the first SIFoldOperands pass now
that SIFoldOperands deletes its own dead instructions.

Reapply after fixing dependent change D100188.

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

3 years ago[AMDGPU] SIFoldOperands: eagerly erase dead REG_SEQUENCEs
Jay Foad [Fri, 9 Apr 2021 12:52:35 +0000 (13:52 +0100)]
[AMDGPU] SIFoldOperands: eagerly erase dead REG_SEQUENCEs

This is fairly cheap to implement and means less work for future
passes like MachineDCE.

Reapply with a fix for using InstToErase after it had been erased.

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

3 years ago[TTI] NFC: Remove unused 'OptSize' parameter from shouldMaximizeVectorBandwidth
Cullen Rhodes [Tue, 13 Apr 2021 11:46:33 +0000 (11:46 +0000)]
[TTI] NFC: Remove unused 'OptSize' parameter from shouldMaximizeVectorBandwidth

Reviewed By: sdesmalen

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

3 years ago[clang][parser] Unify rejecting (non) decl stmts with gnu attributes
Timm Bäder [Tue, 6 Apr 2021 09:54:02 +0000 (11:54 +0200)]
[clang][parser] Unify rejecting (non) decl stmts with gnu attributes

The comment here was introduced in
a3e01cf822f7415337e5424af3c6f4c94a12c1b9 and suggests that we should
handle declaration statements and non-declaration statements the same,
but don't because ProhibitAttributes() can't handle GNU attributes. That
has recently changed, so remove the comment and handle all statements
the same.

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

3 years ago[AMDGPU][MC] Corrected parsing of carry in/out operands in VOP3
Dmitry Preobrazhensky [Mon, 19 Apr 2021 10:40:00 +0000 (13:40 +0300)]
[AMDGPU][MC] Corrected parsing of carry in/out operands in VOP3

Disabled constants as carry in/out operands. See bug 48711.

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

3 years ago[clang][deps] Remove the -full-command-line flag
Jan Svoboda [Tue, 30 Mar 2021 08:45:04 +0000 (10:45 +0200)]
[clang][deps] Remove the -full-command-line flag

This patch removes the `-full-command-line` option from `clang-scan-deps`. It's only used with `-format=experimental-full`, where omitting the command lines doesn't make much sense. There are no tests without `-full-command-line`.

Depends on D100531.

Reviewed By: Bigcheese

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

3 years ago[X86][CostModel] X86TTIImpl::getShuffleCost(): subvector insertions are cheap
Roman Lebedev [Mon, 19 Apr 2021 10:23:48 +0000 (13:23 +0300)]
[X86][CostModel] X86TTIImpl::getShuffleCost(): subvector insertions are cheap

This is similar to the subvector extractions,
except that the 0'th subvector isn't free to insert,
because we generally don't know whether or not
the upper elements need to be preserved:
https://godbolt.org/z/rsxP5W4sW

This is needed to avoid regressions in D100684

Reviewed By: RKSimon

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

3 years ago[RISCV] Lower vector shuffles to vrgather operations
Fraser Cormack [Thu, 15 Apr 2021 09:06:11 +0000 (10:06 +0100)]
[RISCV] Lower vector shuffles to vrgather operations

This patch extends the lowering of RVV fixed-length vector shuffles to
avoid the default stack expansion and instead lower to vrgather
instructions.

For "permute"-style shuffles where one vector is swizzled, we can lower
to one vrgather. For shuffles involving two vector operands, we lower to
one unmasked vrgather (or splat, where appropriate) followed by a masked
vrgather which blends in the second half.

On occasion, when it's not possible to create a legal BUILD_VECTOR for
the indices, we use vrgatherei16 instructions with 16-bit index types.

For 8-bit element vectors where we may have indices over 255, we have a
fairly blunt fallback to the stack expansion to avoid custom-splitting
of the vector types.

To enable the selection of masked vrgather instructions, this patch
extends the various RISCVISD::VRGATHER nodes to take a passthru operand.

Reviewed By: craig.topper

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

3 years ago[NFC] Add tests for scalable vectorization of loops with in-order reductions
Kerry McLaughlin [Mon, 19 Apr 2021 09:47:05 +0000 (10:47 +0100)]
[NFC] Add tests for scalable vectorization of loops with in-order reductions

D98435 added support for in-order reductions and included tests for fixed-width
vectorization with the -enable-strict-reductions flag.

This patch adds similar tests to verify support for scalable vectorization of loops
with in-order reductions.

Reviewed By: david-arm

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

3 years ago[clang][deps] Simplify function discovering .pcm and .modulemap files
Jan Svoboda [Tue, 30 Mar 2021 08:45:04 +0000 (10:45 +0200)]
[clang][deps] Simplify function discovering .pcm and .modulemap files

This patch simplifies (and renames) the `appendCommonModuleArguments` function.

It no longer tries to construct the command line for explicitly building modules. Instead, it only performs the DFS traversal of modular dependencies and queries the callbacks to collect paths to `.pcm` and `.modulemap` files.

This makes it more flexible and usable in two contexts:

* Generating additional command line arguments for the main TU in modular build. The `std::vector<std::string>` output parameters can be used to manually generate appropriate command line flags.
* Generate full command line for a module. The output parameters can be the corresponding parts of `CompilerInvocation`. (In a follow-up patch.)

Reviewed By: dexonsmith

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

3 years ago[DebugInfo] Replace debug uses in replaceUsesOutsideBlock
OCHyams [Mon, 19 Apr 2021 09:31:41 +0000 (10:31 +0100)]
[DebugInfo] Replace debug uses in replaceUsesOutsideBlock

Value::replaceUsesOutsideBlock doesn't replace debug uses which leads to an
unnecessary reduction in variable location coverage. Fix this, add a unittest for
it, and add a regression test demonstrating the change through instcombine's
replacedSelectWithOperand.

Reviewed By: djtodoro

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

3 years agoAdd default DataLayout support for complex numbers
Tres Popp [Mon, 12 Apr 2021 08:27:14 +0000 (10:27 +0200)]
Add default DataLayout support for complex numbers

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

3 years ago[DebugInfo] Move the findDbg* functions into DebugInfo.cpp
OCHyams [Mon, 19 Apr 2021 08:54:22 +0000 (09:54 +0100)]
[DebugInfo] Move the findDbg* functions into DebugInfo.cpp

Move the findDbg* functions into lib/IR/DebugInfo.cpp from
lib/Transforms/Utils/Local.cpp.

D99169 adds a call to a function (findDbgUsers) that lives in
lib/Transforms/Utils/Local.cpp (LLVMTransformUtils) from lib/IR/Value.cpp
(LLVMCore). The Core lib doesn't include TransformUtils. The builtbots caught
this here: https://lab.llvm.org/buildbot/#/builders/109/builds/12664. This patch
moves the function, and the 3 similar ones for consistency, into DebugInfo.cpp
which is part of LLVMCore.

Reviewed By: dblaikie, rnk

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

3 years ago[clang][cli] NFC: Move conditional LangOptions parsing/generation
Jan Svoboda [Fri, 16 Apr 2021 15:20:04 +0000 (17:20 +0200)]
[clang][cli] NFC: Move conditional LangOptions parsing/generation

NFC, this simplifies the main parsing/generating functions by moving logic around conditional `LangOptions` where it belongs.

Reviewed By: Bigcheese

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

3 years ago[OpenCL] Change OpenCL builtin version encoding
Sven van Haastregt [Mon, 19 Apr 2021 09:23:13 +0000 (10:23 +0100)]
[OpenCL] Change OpenCL builtin version encoding

Instead of using a MinVersion and MaxVersion field, encode the version
of a builtin using a mask that aligns better with version handling in
OpenCLOptions.h.  In addition, this saves a field in the BuiltinTable.

This change allows a finer-grained control over the OpenCL versions in
which a builtin is available: instead of a range, we can now toggle
each version individually.

The fine-grained version control is not yet exposed on the TableGen
definitions side, as changes for OpenCL 3 feature optionality still
need to be defined and will affect how we want to expose these.

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

3 years ago[clang][cli] NFC: Use Diags to report parsing success/failure
Jan Svoboda [Fri, 16 Apr 2021 13:30:28 +0000 (15:30 +0200)]
[clang][cli] NFC: Use Diags to report parsing success/failure

`Success` is set to `false` whenever `Diags.Report(diag::err_)` is called. Remove the duplication and use `Diags` as the source of truth when deciding whether to report parsing success/failure.

Reviewed By: dexonsmith

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