platform/upstream/llvm.git
2 years ago[SimplifyCFG] 'merge compatible invokes': support normal destination w/ PHIs but...
Roman Lebedev [Tue, 8 Feb 2022 13:34:34 +0000 (16:34 +0300)]
[SimplifyCFG] 'merge compatible invokes': support normal destination w/ PHIs but no uses

As long as the incoming values for all the invokes in the set
are identical, we can merge the invokes.

2 years ago[SimplifyCFG] 'merge compatible invokes': support normal destination w/ no uses,...
Roman Lebedev [Tue, 8 Feb 2022 12:42:03 +0000 (15:42 +0300)]
[SimplifyCFG] 'merge compatible invokes': support normal destination w/ no uses, no PHI's

Even if the invokes have normal destination, iff it's the same block,
we can merge them. For now, require that there are no PHI nodes,
and the returned values of invokes aren't used.

2 years ago[NFC][SimplifyCFG] 'merge compatible invokes': more tests for various edge-cases
Roman Lebedev [Tue, 8 Feb 2022 12:13:16 +0000 (15:13 +0300)]
[NFC][SimplifyCFG] 'merge compatible invokes': more tests for various edge-cases

2 years agoRevert rG6c174ab2ad0676b295f11f6c3913eff9289fa6b9 "[X86] Remove __builtin_ia32_padd...
Simon Pilgrim [Tue, 8 Feb 2022 14:45:28 +0000 (14:45 +0000)]
Revert rG6c174ab2ad0676b295f11f6c3913eff9289fa6b9 "[X86] Remove __builtin_ia32_padd/psub saturated intrinsics and use generic __builtin_elementwise_add/sub_sat"

Missed some legacy builtin tests that need cleaning up first

2 years ago[GlobalISel] Add big endian support in CallLowering
Sheng [Tue, 8 Feb 2022 14:32:48 +0000 (14:32 +0000)]
[GlobalISel] Add big endian support in CallLowering

When splitting values, CallLowering assumes Lo part goes first. But in big endian ISA such as M68k, Hi part goes first.

This patch fixes this.

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

2 years ago[demangler] Improve ->* & .* demangling
Nathan Sidwell [Fri, 28 Jan 2022 17:27:28 +0000 (09:27 -0800)]
[demangler] Improve ->* & .* demangling

The demangler treats ->* as a BinaryExpr, but .* as a MemberExpr.
That's inconsistent.  This makes the former a MemberExpr too.
However, in order to not regress the paren output, MemberExpr::print
is modified to parenthesize the MemberExpr if the operator ends with
'*'.  Printing is affected thusly:

Before:
    obj.member
    obj->member
    obj.*member
    (obj) ->* (member)

After:
   obj.member   # Unchanged
   obj->member  # Unchanged
   obj.*(member)  # Added paren member operand
   obj->*(member) # Removed paren on object operand, less whitespace

The right solution to the paren problem is to add some notion of
precedence (and associativity) to Nodes, but that's a larger change
that would become simpler once the refactoring I'm doing is completed.

FWIW, binutils' demangler's paren algorithm has a small idea of
precedence, and will generally not emit parens when the operand is
unary.

Reviewed By: bruno

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

2 years ago[X86] Remove __builtin_ia32_padd/psub saturated intrinsics and use generic __builtin_...
Simon Pilgrim [Tue, 8 Feb 2022 14:21:11 +0000 (14:21 +0000)]
[X86] Remove __builtin_ia32_padd/psub saturated intrinsics and use generic __builtin_elementwise_add/sub_sat

D117898 added the generic __builtin_elementwise_add_sat and __builtin_elementwise_sub_sat with the same integer behaviour as the SSE/AVX instructions

This patch removes the __builtin_ia32_padd/psub saturated intrinsics and just uses the generics - the existing tests see no changes:

__m256i test_mm256_adds_epi8(__m256i a, __m256i b) {
  // CHECK-LABEL: test_mm256_adds_epi8
  // CHECK: call <32 x i8> @llvm.sadd.sat.v32i8(<32 x i8> %{{.*}}, <32 x i8> %{{.*}})
  return _mm256_adds_epi8(a, b);
}

2 years ago[AArch64TargetTransformInfo] Avoid pointer element type access
Nikita Popov [Tue, 8 Feb 2022 14:16:16 +0000 (15:16 +0100)]
[AArch64TargetTransformInfo] Avoid pointer element type access

Use the element type of the gathered/scattered vector instead.

2 years agoFix signed/unsigned comparison warnings on ppc buildbots
Simon Pilgrim [Tue, 8 Feb 2022 14:13:36 +0000 (14:13 +0000)]
Fix signed/unsigned comparison warnings on ppc buildbots

2 years agoAdd core papers adopted at the february plenary.
Corentin Jabot [Tue, 8 Feb 2022 14:13:04 +0000 (09:13 -0500)]
Add core papers adopted at the february plenary.

2 papers are added to the status page, one targeting
C++23, the other added to the batch of C++20 concept papers.

2 years ago[AsmPrinter] Avoid pointer element type access
Nikita Popov [Tue, 8 Feb 2022 14:04:23 +0000 (15:04 +0100)]
[AsmPrinter] Avoid pointer element type access

Instead of checking for a bitcast from a function type, check
whether the aliasee is a function after stripping bitcasts. This
is not strictly equivalent, but serves the same purpose.

2 years agoFix signed/unsigned comparison warnings on ppc buildbots
Simon Pilgrim [Tue, 8 Feb 2022 13:55:01 +0000 (13:55 +0000)]
Fix signed/unsigned comparison warnings on ppc buildbots

2 years ago[OpenCL] opencl-c.h: remove arg names from arm_dot; NFC
Sven van Haastregt [Tue, 8 Feb 2022 13:42:24 +0000 (13:42 +0000)]
[OpenCL] opencl-c.h: remove arg names from arm_dot; NFC

This simplifies completeness comparisons against OpenCLBuiltins.td.

2 years agoEnable inoutset dependency-type in depend clause.
David Pagan [Tue, 8 Feb 2022 13:33:52 +0000 (08:33 -0500)]
Enable inoutset dependency-type in depend clause.

Done in manner similar to mutexinoutset
(see https://reviews.llvm.org/D57576)

Runtime support already exists in LLVM OpenMP runtime (see
https://reviews.llvm.org/D97085).

The value used to identify an inoutset dependency type in the LLVM
OpenMP runtime is 8.

Some tests updated due to change in dependency type error messages that
now include new dependency type. Also updated
test/OpenMP/task_codegen.cpp to verify we emit the right code.

2 years ago[MLIR][Presburger] factor out duplicated function `parsePoly` into a Utils.h
Arjun P [Tue, 8 Feb 2022 12:25:40 +0000 (17:55 +0530)]
[MLIR][Presburger] factor out duplicated function `parsePoly` into a Utils.h

Reviewed By: Groverkss

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

2 years ago[ValueTracking] Add support for X*X self-multiplication
Simon Pilgrim [Tue, 8 Feb 2022 13:33:18 +0000 (13:33 +0000)]
[ValueTracking] Add support for X*X self-multiplication

D108992 added KnownBits handling for 'Quadratic Reciprocity' self-multiplication patterns (bit[1] == 0), which can be used for non-undef values (poison is OK).

This patch adds noundef selfmultiply handling to value tracking so demanded bits patterns can make use of it.

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

2 years ago[ValueTracking] Replace dyn_cast with dyn_cast_or_null to account for getTerminator...
Simon Pilgrim [Tue, 8 Feb 2022 13:29:49 +0000 (13:29 +0000)]
[ValueTracking] Replace dyn_cast with dyn_cast_or_null to account for getTerminator returning null

Noticed while running checks on D117995 - a hexagon regression test was managing to return a block without a terminator

2 years agoMake run-clang-tidy.py print the configured checks correctly
Jesko Appelfeller [Tue, 8 Feb 2022 13:30:59 +0000 (08:30 -0500)]
Make run-clang-tidy.py print the configured checks correctly

The test invocation at the start of run-clang-tidy.py (line 257) prints
all enabled checks - meaning either the default set or anything
configured via the -checks option. If any checks were (un-)configured
via the -config option, these are not printed. This is confusing to the
user, since the list of checks that are printed may be different from
the list of checks that are used by the non-testing calls to clang-tidy,
where the -config option is passed correctly.

This patch adds the -config option to the test invocation of clang-tidy
at the start of the script. This means that checks (un-)configured via
the -config option (rather than the -checks option) are applied
correctly, when printing the list of enabled checks.

2 years ago[AMDGPU] Regenerate test checks (NFC)
Nikita Popov [Tue, 8 Feb 2022 13:21:40 +0000 (14:21 +0100)]
[AMDGPU] Regenerate test checks (NFC)

Use --include-generated-funcs checks. Unfortunately this places
all the functions at the end of the file rather than interleaving
them, but at least makes it feasible to update these tests.

2 years ago[VE] v256.32|64 setcc isel and tests
Simon Moll [Tue, 8 Feb 2022 12:20:45 +0000 (13:20 +0100)]
[VE] v256.32|64 setcc isel and tests

Reviewed By: kaz7

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

2 years ago[ADT] Add APInt/MathExtras isShiftedMask variant returning mask offset/length
Simon Pilgrim [Tue, 8 Feb 2022 11:57:05 +0000 (11:57 +0000)]
[ADT] Add APInt/MathExtras isShiftedMask variant returning mask offset/length

In many cases, calls to isShiftedMask are immediately followed with checks to determine the size and position of the bitmask.

This patch adds variants of APInt::isShiftedMask, isShiftedMask_32 and isShiftedMask_64 that return these values as additional arguments.

I've updated a number of cases that were either performing seperate size/position calculations or had created their own local wrapper versions of these.

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

2 years ago[libc] Optimized version of memmove
Guillaume Chatelet [Fri, 26 Nov 2021 14:00:17 +0000 (14:00 +0000)]
[libc] Optimized version of memmove

This implementation relies on storing data in registers for sizes up to 128B.
Then depending on whether `dst` is less (resp. greater) than `src` we move data forward (resp. backward) by chunks of 32B.
We first make sure one of the pointers is aligned to increase performance on large move sizes.

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

2 years agoAttempt to fix sphinx 'Malformed table' warning.
Simon Pilgrim [Tue, 8 Feb 2022 11:47:50 +0000 (11:47 +0000)]
Attempt to fix sphinx 'Malformed table' warning.

2 years ago[AArch64] Attempt to emitConjunction from brcond
David Green [Tue, 8 Feb 2022 11:27:10 +0000 (11:27 +0000)]
[AArch64] Attempt to emitConjunction from brcond

We currently use emitConjunction to create CCMP conjunctions from the
conditions of selects, helping turning and/ors into more optimal ccmp
sequences that don't need to go through csels. This extends that to also
be used whilst lowering brcond, giving more opportunity for better
condition generation.

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

2 years ago[Clang] Add elementwise saturated add/sub builtins
Simon Pilgrim [Tue, 8 Feb 2022 11:21:46 +0000 (11:21 +0000)]
[Clang] Add elementwise saturated add/sub builtins

This patch implements `__builtin_elementwise_add_sat` and `__builtin_elementwise_sub_sat` builtins.

These map to the add/sub saturated math intrinsics described here:
https://llvm.org/docs/LangRef.html#saturation-arithmetic-intrinsics

With this in place we should then be able to replace the x86 SSE adds/subs intrinsics with these generic variants - it looks like other targets should be able to use these as well (arm/aarch64/webassembly all have similar examples in cgbuiltin).

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

2 years ago[AArch64] FeaturePerfMon Added to CPUs
Mubashar Ahmad [Thu, 27 Jan 2022 12:42:58 +0000 (12:42 +0000)]
[AArch64] FeaturePerfMon Added to CPUs

FeaturePerfMon has been enabled for CPUs in AArch64.

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

2 years ago[NVPTXISelLowering] Remove unnecessary context parameter (NFCI)
Nikita Popov [Tue, 8 Feb 2022 11:18:15 +0000 (12:18 +0100)]
[NVPTXISelLowering] Remove unnecessary context parameter (NFCI)

The module context shouldn't be relevant here, and should never
be null either.

2 years ago[NVPTXISelLowering] Use byval IndirectType
Nikita Popov [Tue, 8 Feb 2022 11:08:23 +0000 (12:08 +0100)]
[NVPTXISelLowering] Use byval IndirectType

Instead of the pointer element type.

2 years ago[NVPTXISelLowering] Use getByValSize()
Nikita Popov [Tue, 8 Feb 2022 11:03:38 +0000 (12:03 +0100)]
[NVPTXISelLowering] Use getByValSize()

Instead of computing the size of the pointer element type.

2 years ago[libc] Don't use Clang flags on other compilers
Guillaume Chatelet [Mon, 7 Feb 2022 15:23:42 +0000 (15:23 +0000)]
[libc] Don't use Clang flags on other compilers

This is necessary to get llvm-libc compile with GCC.
This patch is extracted from D119002.

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

2 years ago[NVPTXAsmPrinter] Use byval type
Nikita Popov [Tue, 8 Feb 2022 10:57:18 +0000 (11:57 +0100)]
[NVPTXAsmPrinter] Use byval type

Instead of pointer element type.

2 years ago[flang][nfc] Add an assert to guard against `nullptr` dereferencing
Andrzej Warzynski [Mon, 7 Feb 2022 14:03:49 +0000 (14:03 +0000)]
[flang][nfc] Add an assert to guard against `nullptr` dereferencing

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

2 years ago[libc] Disable rtti/expections
Guillaume Chatelet [Thu, 3 Feb 2022 12:36:05 +0000 (12:36 +0000)]
[libc] Disable rtti/expections

llvm-libc exhibits a C interface but its source is C++.
This patch explicitly disables the use of exceptions and RTTI when compiling the entrypoints.

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

2 years ago[RISCV] Optimize splats of extracted vector elements
Fraser Cormack [Fri, 28 Jan 2022 12:33:37 +0000 (12:33 +0000)]
[RISCV] Optimize splats of extracted vector elements

This patch adds an optimization to splat-like operations where the
splatted value is extracted from a identically-sized vector. On RVV we
can splat that via vrgather.vx/vrgather.vi without dropping to scalar
beforehand.

We do have a similar VECTOR_SHUFFLE-specific optimization but that only
works on fixed-length vector types and for those with a constant splat
lane. This patch extends this optimization to make it work on
scalable-vector types and on unknown extract indices.

It is performed during fixed-vector BUILD_VECTOR lowering and during a
new DAGCombine on SPLAT_VECTOR for scalable vectors.

Reviewed By: craig.topper, khchen

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

2 years ago[NVPTXLowerArgs] Use byval type
Nikita Popov [Tue, 8 Feb 2022 10:41:45 +0000 (11:41 +0100)]
[NVPTXLowerArgs] Use byval type

Instead of pointer element type.

2 years ago[OpenMPIRBuilderTest] Remove getPointerElementType() uses (NFC)
Nikita Popov [Tue, 8 Feb 2022 10:37:42 +0000 (11:37 +0100)]
[OpenMPIRBuilderTest] Remove getPointerElementType() uses (NFC)

Use the type of the stored value instead.

2 years ago[libc][NFC] moving template specialization outside class declaration
Guillaume Chatelet [Mon, 7 Feb 2022 15:18:11 +0000 (15:18 +0000)]
[libc][NFC] moving template specialization outside class declaration

This is necessary to get llvm-libc compile with GCC.
This patch is extracted from D119002.

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

2 years ago[AArch64] Add some additional tests for conditions of branches. NFC
David Green [Tue, 8 Feb 2022 10:28:33 +0000 (10:28 +0000)]
[AArch64] Add some additional tests for conditions of branches. NFC

2 years agoRemove restriction on static dimensions in Shape method
Tres Popp [Tue, 8 Feb 2022 10:15:04 +0000 (11:15 +0100)]
Remove restriction on static dimensions in Shape method

mlir::shape::ToExtentTensorOp::areCastCompatible didn't allow the input
to have a static dimension, but that is allowed.

2 years ago[mlir][Affine][Vector] NFC: fix examples in comments
Cullen Rhodes [Tue, 8 Feb 2022 10:03:32 +0000 (10:03 +0000)]
[mlir][Affine][Vector] NFC: fix examples in comments

s/-affine-vectorize/-affine-super-vectorize/g

Reviewed By: aartbik

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

2 years ago[ArgPromotion] Check dereferenceability on argument as well
Nikita Popov [Tue, 8 Feb 2022 09:29:51 +0000 (10:29 +0100)]
[ArgPromotion] Check dereferenceability on argument as well

Before walking all the callers, check whether we have a
dereferenceable attribute directly on the argument.

Also make it clearer that the code currently does not treat
alignment correctly.

2 years ago[ArgPromotion] Test dereferenceable annotation on callee (NFC)
Nikita Popov [Tue, 8 Feb 2022 09:27:17 +0000 (10:27 +0100)]
[ArgPromotion] Test dereferenceable annotation on callee (NFC)

While we check dereferenceability of all callers, we don't check
dereferenceability annotations on the callee.

2 years ago[Bitstream] Make MaxChunkSize word-size independent
Nikita Popov [Tue, 8 Feb 2022 09:12:46 +0000 (10:12 +0100)]
[Bitstream] Make MaxChunkSize word-size independent

We only support chunks <= 32 bits regardless of whether we're
running on a 64-bit platform or not. Chunk size > 32 <= 64 would
cause UB in the reading code.

2 years ago[Bitcode] Prevent OOB read for invalid name size
Nikita Popov [Tue, 8 Feb 2022 08:48:43 +0000 (09:48 +0100)]
[Bitcode] Prevent OOB read for invalid name size

2 years ago[Bitstream] Check for unterminated VBR
Nikita Popov [Tue, 8 Feb 2022 08:40:57 +0000 (09:40 +0100)]
[Bitstream] Check for unterminated VBR

This avoid shift larger than bitwidth UB.

2 years ago[Bitcode] Add missing includes in llvm-dis-fuzzer
Nikita Popov [Tue, 8 Feb 2022 08:33:55 +0000 (09:33 +0100)]
[Bitcode] Add missing includes in llvm-dis-fuzzer

Probably missed as part of some recent header cleanup.

2 years ago[NFC] Fix comment.
Clement Courbet [Tue, 8 Feb 2022 08:42:44 +0000 (09:42 +0100)]
[NFC] Fix comment.

The extra space causes the table to render incorrectly in doxygen.

2 years ago[clang-format] Comment unused parameters. NFC.
Marek Kurdej [Tue, 8 Feb 2022 08:21:12 +0000 (09:21 +0100)]
[clang-format] Comment unused parameters. NFC.

2 years ago[clang-format] Fix typo. NFC.
Marek Kurdej [Tue, 8 Feb 2022 08:18:28 +0000 (09:18 +0100)]
[clang-format] Fix typo. NFC.

2 years ago[mlir] Move constBuidlerCall from to ArrayAttrBase
Alex Zinenko [Mon, 7 Feb 2022 09:28:09 +0000 (10:28 +0100)]
[mlir] Move constBuidlerCall from to ArrayAttrBase

This makes it applicable to both ArrayAttr and its typed subclasses instead of
only the latter. There is no good reason why ArrayAttr shouldn't be
const-buildable while its typed subclasses are, this was likely just an
omission.

Depends On D119113

Reviewed By: rriddle, nicolasvasilache

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

2 years ago[mlir] ODS: require DefaultValuedAttr to be const-buildable
Alex Zinenko [Mon, 7 Feb 2022 09:27:07 +0000 (10:27 +0100)]
[mlir] ODS: require DefaultValuedAttr to be const-buildable

ODS provides a mechanism for defalut-valued attributes based on a wrapper
TableGen class that is recognized by mlir-tblgen. Such attributes, if not set
on the operaiton, can be construted on-the-fly in their getter given a constant
value. In order for this construction to work, the attribute specificaiton in
ODS must set the constBuilderCall field correctly. This has not been verified,
which could lead to invalid C++ code being generated by mlir-tblgen.

Closes #53588.

Reviewed By: rriddle, mehdi_amini

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

2 years ago[CSKY] Add CSKYDisassembler.cpp to construct objdump
Zi Xuan Wu [Tue, 8 Feb 2022 07:18:59 +0000 (15:18 +0800)]
[CSKY] Add CSKYDisassembler.cpp to construct objdump

CSKYDisassembler tries to disassemble register MC operand from register num for different register class, and
also handles immediate num and carry flag operand which is not encoded in instruction binary.

Also enhance the printer of instruction to accept sub-option to control the print format. Sometimes, it prefers to
print number in hex, especially when immediate number represents symbol address.

2 years ago[CSKY] Add CK800 series ProcessorModel and complete related SubtargetFeatures
Zi Xuan Wu [Tue, 8 Feb 2022 03:52:50 +0000 (11:52 +0800)]
[CSKY] Add CK800 series ProcessorModel and complete related SubtargetFeatures

Now we only support CSKY 800 series cpus and newer cpus in the future undering CSKYv2 ABI specification.
There are 11 processor family enums for CK series cpus such as CK801, CK802, CK803, CK803S, CK804, CK805,
CK807, CK810, CK810V, CK860, CK860V.

The SchedMachineModels are not ready for different cpus, so only NoSchedModel is used.

2 years agoAdd missing BUILD dependency to ShapeOps
Tres Popp [Tue, 8 Feb 2022 08:00:03 +0000 (09:00 +0100)]
Add missing BUILD dependency to ShapeOps

2 years ago[CodeGen][test] XFAIL CodeGen/Generic/ForceStackAlign.ll on SPARC
Rainer Orth [Tue, 8 Feb 2022 07:57:59 +0000 (08:57 +0100)]
[CodeGen][test] XFAIL CodeGen/Generic/ForceStackAlign.ll on SPARC

`CodeGen/Generic/ForceStackAlign.ll` `FAIL`s on SPARC like this:

  LLVM ERROR: Function "g" required stack re-alignment, but LLVM couldn't
handle it (probably because it has a dynamic alloca).

According to the comments in `llvm/lib/Target/Sparc/SparcFrameLowering.cpp`
(`SparcFrameLowering::emitPrologue`) and `SparcRegisterInfo.cpp`
(`SparcRegisterInfo::canRealignStack`) this isn't going to change any time
soon, so this patch `XFAIL`s the test.

Tested on `sparcv9-sun-solaris2.11`.

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

2 years agoPlatform gdb RSP packet doc fixes based on implementation behavior
Jason Molenda [Tue, 8 Feb 2022 07:51:46 +0000 (23:51 -0800)]
Platform gdb RSP packet doc fixes based on implementation behavior

Reviewing some recent fixes to the platform packet implementations
in lldb, I saw the docs were out of sync in a few spots.  Updated them.

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

2 years ago[lldb][CMake] Fix linking of gdb-remote when LLVM_ENABLE_ZLIB is ON
Mariusz Ceier [Tue, 8 Feb 2022 07:26:22 +0000 (23:26 -0800)]
[lldb][CMake] Fix linking of gdb-remote when LLVM_ENABLE_ZLIB is ON

When LLVM_ENABLE_ZLIB is ON gdb-remote should link against ZLIB::ZLIB.

This fixes
```
/mnt/b/yoe/master/build/tmp/hosttools/ld: lib/liblldbPluginProcessGDBRemote.a(GDBRemoteCommunication.cpp.o): in function `lldb_private::process_gdb_remote::GDBRemoteCommunication::DecompressPacket() [clone .localalias]':
GDBRemoteCommunication.cpp:(.text._ZN12lldb_private18process_gdb_remote22GDBRemoteCommunication16DecompressPacketEv+0x59a): undefined reference to `inflateInit2_'
/mnt/b/yoe/master/build/tmp/hosttools/ld: GDBRemoteCommunication.cpp:(.text._ZN12lldb_private18process_gdb_remote22GDBRemoteCommunication16DecompressPacketEv+0x5af): undefined reference to `inflate'
```

Reviewed By: JDevlieghere, MaskRay

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

2 years ago[MachineLICM] Add shouldHoist method to TargetInstrInfo
Carl Ritson [Tue, 8 Feb 2022 06:01:07 +0000 (15:01 +0900)]
[MachineLICM] Add shouldHoist method to TargetInstrInfo

Add a shouldHoist method to TargetInstrInfo which is queried by
MachineLICM to override hoisting decisions for a given target.
This mirrors functionality provided by shouldSink.

Reviewed By: foad

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

2 years ago[ORC-RT] Fix missing #include from f9aef477ebc.
Lang Hames [Tue, 8 Feb 2022 06:41:53 +0000 (17:41 +1100)]
[ORC-RT] Fix missing #include from f9aef477ebc.

2 years ago[ORC][ORC-RT] Rewrite the MachO platform to use allocation actions.
Lang Hames [Tue, 8 Feb 2022 05:31:17 +0000 (16:31 +1100)]
[ORC][ORC-RT] Rewrite the MachO platform to use allocation actions.

This patch updates the MachO platform (both the ORC MachOPlatform class and the
ORC-Runtime macho_platform.* files) to use allocation actions, rather than EPC
calls, to transfer the initializer information scraped from each linked object.
Interactions between the ORC and ORC-Runtime sides of the platform are
substantially redesigned to accomodate the change.

The high-level changes in this patch are:

1. The MachOPlatform::setupJITDylib method now calls into the runtime to set up
   a dylib name <-> header mapping, and a dylib state object (JITDylibState).

2. The MachOPlatformPlugin builds an allocation action that calls the
   __orc_rt_macho_register_object_platform_sections and
   __orc_rt_macho_deregister_object_platform_sections functions in the runtime
   to register the address ranges for all "interesting" sections in the object
   being allocated (TLS data sections, initializers, language runtime metadata
   sections, etc.).

3. The MachOPlatform::rt_getInitializers method (the entry point in the
   controller for requests from the runtime for initializer information) is
   replaced by MachOPlatform::rt_pushInitializers. The former returned a data
   structure containing the "interesting" section address ranges, but these are
   now handled by __orc_rt_macho_register_object_platform_sections. The new
   rt_pushInitializers method first issues a lookup to trigger materialization
   of the "interesting" sections, then returns the dylib dependence tree rooted
   at the requested dylib for dlopen to consume. (The dylib dependence tree is
   returned by rt_pushInitializers, rather than being handled by some dedicated
   call, because rt_pushInitializers can alter the dependence tree).

The advantage of these changes (beyond the performance advantages of using
allocation actions) is that it moves more information about the materialized
portions of the JITDylib into the executor. This tends to make the runtime
easier to reason about, e.g. the implementation of dlopen in the runtime is now
recursive, rather than relying on recursive calls in the controller to build a
linear data structure for consumption by the runtime. This change can also make
some operations more efficient, e.g. JITDylibs can be dlclosed and then
re-dlopened without having to pull all initializers over from the controller
again.

In addition to the high-level changes, there are some low-level changes to ORC
and the runtime:

* In ORC, at ExecutionSession teardown time JITDylibs are now destroyed in
reverse creation order. This is on the assumption that the ORC runtime will be
loaded into an earlier dylib that will be used by later JITDylibs. This is a
short-term solution to crashes that arose during testing when the runtime was
torn down before its users. Longer term we will likely destroy dylibs in
dependence order.

* toSPSSerializable(Expected<T> E) is updated to explicitly initialize the T
value, allowing it to be used by Ts that have explicit constructors.

* The ORC runtime now (1) attempts to track ref-counts, and (2) distinguishes
not-yet-processed "interesting" sections from previously processed ones. (1)
is necessary for standard dlopen/dlclose emulation. (2) is intended as a step
towards better REPL support -- it should enable future runtime calls that
run only newly registered initializers ("dlopen_more", "dlopen_additions",
...?).

2 years ago[ELF] AArch64ErrataFix: replace std::map with DenseMap. NFC
Fangrui Song [Tue, 8 Feb 2022 06:02:25 +0000 (22:02 -0800)]
[ELF] AArch64ErrataFix: replace std::map with DenseMap. NFC

There is now no <map> in lld/ELF.

2 years ago[ELF] Clean up headers. NFC
Fangrui Song [Tue, 8 Feb 2022 05:53:34 +0000 (21:53 -0800)]
[ELF] Clean up headers. NFC

2 years ago[RISCV] Split f64 undef into two i32 undefs
wangpc [Tue, 8 Feb 2022 05:42:15 +0000 (13:42 +0800)]
[RISCV] Split f64 undef into two i32 undefs

So that no store instruction will be generated.

Reviewed By: asb

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

2 years ago[llvm-jitlink] Don't add process symbols to every JITDylib.
Lang Hames [Tue, 8 Feb 2022 05:18:43 +0000 (16:18 +1100)]
[llvm-jitlink] Don't add process symbols to every JITDylib.

The addProcessSymbols function added a generator for process symbols to every
JITDylib in the session, but this is unhelpful default behavior (e.g. it will
cause the ORC runtime's definition of __cxa_atexit to be shadowed by the
process's definition for all JITDylibs except main).

Since the loadProcessSymbols function already added a generator to main we only
need to drop this function. Other JITDylibs wishing to resolve process symbols
can link against the main JITDylib by passing `-lmain`.

2 years ago[ORC-RT] Make ExecutorAddr hashable.
Lang Hames [Tue, 8 Feb 2022 05:10:10 +0000 (16:10 +1100)]
[ORC-RT] Make ExecutorAddr hashable.

This will be used in an upcoming macho_platform patch.

2 years ago[BOLT][CMAKE][NFC] Update runtime/CMakeLists.txt
Amir Ayupov [Mon, 7 Feb 2022 19:03:20 +0000 (11:03 -0800)]
[BOLT][CMAKE][NFC] Update runtime/CMakeLists.txt

Summary:
- Specify compiler flags for runtime libraries as BOLT_RT_FLAGS,
- Remove redundant CMake definitions.

Reviewers: maksfb

FBD34048561

2 years ago[BOLT] Add ld.lld substitution
Amir Ayupov [Thu, 3 Feb 2022 03:08:27 +0000 (19:08 -0800)]
[BOLT] Add ld.lld substitution

Register ld.lld substition (tests were failing)

Reviewed By: yota9

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

2 years ago[RISCV] Pre-commit test for D118222
wangpc [Tue, 8 Feb 2022 04:52:13 +0000 (12:52 +0800)]
[RISCV] Pre-commit test for D118222

Reviewed By: craig.topper

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

2 years ago[ORC-RT] Add more string_view operations and tests.
Lang Hames [Tue, 8 Feb 2022 04:12:00 +0000 (15:12 +1100)]
[ORC-RT] Add more string_view operations and tests.

Adds construction from std::string, an ostream &operator<< and std::hash
specialization. Also adds unit tests for each of these operations, as well as
tests for copy construction and assignment.

These new operations will be used in upcoming macho_platform patches.

2 years ago[ORC-RT] Fix typos in testcase.
Lang Hames [Tue, 8 Feb 2022 03:23:02 +0000 (14:23 +1100)]
[ORC-RT] Fix typos in testcase.

Replace references to 'span' in string_view tests that were originally copied
from span tests.

2 years ago[test][llvm-objcopy/mac] Fix invalid strip tests
Keith Smiley [Mon, 7 Feb 2022 23:08:24 +0000 (15:08 -0800)]
[test][llvm-objcopy/mac] Fix invalid strip tests

I discovered some of these tests had `cmp` statements that weren't
actually being run. I had also recently copied this broken setup for a
new test around chained fixups. Fixing this revealed that the binaries
did differ because of their code signature so I regenerated the fixture
here with this source:

```c
int main() {
   return 0;
}
```

Passing `-Wl,-no_adhoc_codesign` on my M1 machine to make sure it didn't
get any signature.

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

2 years ago[test][llvm-objcopy/mac] Move test to new file
Keith Smiley [Mon, 7 Feb 2022 17:01:14 +0000 (09:01 -0800)]
[test][llvm-objcopy/mac] Move test to new file

Follow up from https://reviews.llvm.org/D118526

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

2 years ago[C++20] [Modules] Don't create multiple global module fragment
Chuanqi Xu [Tue, 8 Feb 2022 03:50:57 +0000 (11:50 +0800)]
[C++20] [Modules] Don't create multiple global module fragment

Since the serialization code would recognize modules by names and the
name of all global module fragment is <global>, so that the
serialization code would complain for the same module.

This patch fixes this by using a unique global module fragment in Sema.
Before this patch, the compiler would fail on an assertion complaining
the duplicated modules.

Reviewed By: urnathan, rsmith

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

2 years ago[C++20] [Coroutines] Warning for always_inline coroutine
Chuanqi Xu [Tue, 8 Feb 2022 03:42:38 +0000 (11:42 +0800)]
[C++20] [Coroutines] Warning for always_inline coroutine

See the discussion in https://reviews.llvm.org/D100282. The coroutine
marked always inline might not be inlined properly in current compiler
support. Since the coroutine would be splitted into pieces. And the call
to resume() and destroy() functions might be indirect call. Also the
ramp function wouldn't get inlined under O0 due to pipeline ordering
problems. It might be different to what users expects to. Emit a warning
to tell it.

This is what GCC does too: https://godbolt.org/z/7eajb1Gf8

Reviewed By: Quuxplusone

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

2 years ago[mlir] Finish removing FunctionPass
River Riddle [Tue, 1 Feb 2022 21:27:46 +0000 (13:27 -0800)]
[mlir] Finish removing FunctionPass

FunctionPass has been deprecated in favor of OperationPass<FuncOp>
for a few weeks, and this commit finished the deprecation with deletion.
The only difference between the two is that FunctionPass filters out function
declarations. When updating references to FunctionPass, ensure that
the pass either can handle declarations or explicitly add in filtering.

See https://llvm.discourse.group/t/functionpass-deprecated-in-favor-of-operationpass-funcop

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

2 years ago[mlir] Update uses of `parser`/`printer` ODS op field to `hasCustomAssemblyFormat`
River Riddle [Tue, 8 Feb 2022 01:54:04 +0000 (17:54 -0800)]
[mlir] Update uses of `parser`/`printer` ODS op field to `hasCustomAssemblyFormat`

The parser/printer fields are deprecated and in the process of being removed.

2 years ago[mlir] Update Toy operations to use the `hasCustomAssemblyFormat` field
River Riddle [Sat, 5 Feb 2022 21:59:43 +0000 (13:59 -0800)]
[mlir] Update Toy operations to use the `hasCustomAssemblyFormat` field

The parser/printer fields are deprecated and in the process of being removed.

2 years ago[mlir][NFC] Remove deprecated/old build/fold/parser utilities from OpDefinition
River Riddle [Sun, 6 Feb 2022 20:33:08 +0000 (12:33 -0800)]
[mlir][NFC] Remove deprecated/old build/fold/parser utilities from OpDefinition

These have generally been replaced by better ODS functionality, and do not
need to be explicitly provided anymore.

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

2 years ago[mlir][NFC] Remove a few op builders that simply swap parameter order
River Riddle [Sun, 6 Feb 2022 20:32:47 +0000 (12:32 -0800)]
[mlir][NFC] Remove a few op builders that simply swap parameter order

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

2 years ago[mlir:ODS] Deprecate Op parser/printer fields in favor of a new hasCustomAssemblyForm...
River Riddle [Sat, 5 Feb 2022 04:47:01 +0000 (20:47 -0800)]
[mlir:ODS] Deprecate Op parser/printer fields in favor of a new hasCustomAssemblyFormat field

Currently if an operation wants a C++ implemented parser/printer, it specifies inline
code blocks. This is quite problematic for various reasons, e.g. it requires defining
C++ inside of Tablegen which is discouraged when possible, but mainly because
nearly all usages simply forward to static functions (e.g. `static void parseSomeOp(...)`)
with users devising their own standards for how these are defined.

This commit adds support for a `hasCustomAssemblyFormat` bit field that specifies if
a C++ parser/printer is needed, and when set to 1 declares the parse/print methods for
operations to override. For migration purposes, the existing behavior is untouched. Upstream
usages will be replaced in a followup to keep this patch focused on the new implementation.

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

2 years ago[clang] Fix some clang->llvm type cache invalidation issues
Arthur Eubanks [Wed, 2 Feb 2022 00:47:29 +0000 (16:47 -0800)]
[clang] Fix some clang->llvm type cache invalidation issues

Take the following as an example

  struct z {
    z (*p)();
  };

  z f();

When we attempt to get the LLVM type of f, we recurse into z. z itself
has a function pointer with the same type as f. Given the recursion,
Clang simply treats z::p as a pointer to an empty struct `{}*`. The
LLVM type of f is as expected. So we have two different potential
LLVM types for a given Clang type. If we store one of those into the
cache, when we access the cache with a different context (e.g. we
are/aren't recursing on z) we may get an incorrect result. There is some
attempt to clear the cache in these cases, but it doesn't seem to handle
all cases.

This change makes it so we only use the cache when we are not in any
sort of function context, i.e. `noRecordsBeingLaidOut() &&
FunctionsBeingProcessed.empty()`, which are the cases where we may
decide to choose a different LLVM type for a given Clang type. LLVM
types for builtin types are never recursive so they're always ok.

This allows us to clear the type cache less often (as seen with the
removal of one of the calls to `TypeCache.clear()`). We
still need to clear it when we use a placeholder type then replace it
later with the final type and other dependent types need to be
recalculated.

I've added a check that the cached type matches what we compute. It
triggered in this test case without the fix. It's currently not
check-clang clean so it's not on by default for something like expensive
checks builds.

This change uncovered another issue where the LLVM types for an argument
and its local temporary don't match. For example in type-cache-3, when
expanding z::dc's argument into a temporary alloca, we ConvertType() the
type of z::p which is `void ({}*)*`, which doesn't match the alloca GEP
type of `{}*`.

No noticeable compile time changes:
https://llvm-compile-time-tracker.com/compare.php?from=3918dd6b8acf8c5886b9921138312d1c638b2937&to=50bdec9836ed40e38ece0657f3058e730adffc4c&stat=instructions

Fixes #53465.

Reviewed By: rnk

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

2 years ago[AMDGPU] [NFC] refactor the AMDGPU attributor
Sameer Sahasrabuddhe [Tue, 8 Feb 2022 02:45:32 +0000 (21:45 -0500)]
[AMDGPU] [NFC] refactor the AMDGPU attributor

Reviewed By: arsenm

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

2 years ago[AMDGPU] Allow hoisting of some VALU compare instructions
Carl Ritson [Tue, 8 Feb 2022 02:27:23 +0000 (11:27 +0900)]
[AMDGPU] Allow hoisting of some VALU compare instructions

Conversatively allow hoisting/sinking of VALU comparisons.
If the result of a comparison is masked with exec, narrowing the
set of active lanes, then it is safe to hoist it as the masking
instruction will never by hoisted.

Heuristically this is also true for sinking, as we do not expect
the result of a sunk comparison that is masked with exec to be
used outside of the loop.

Reviewed By: rampitec

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

2 years ago[Attributor][FIX] Do not use assumed information for UB detection
Johannes Doerfert [Tue, 8 Feb 2022 01:39:19 +0000 (19:39 -0600)]
[Attributor][FIX] Do not use assumed information for UB detection

The helper `Attributor::checkForAllReturnedValuesAndReturnInsts`
simplifies the returned value optimistically. In `AAUndefinedBehavior`
we cannot use such optimistic values when deducing UB. As a result, we
assumed UB for the return value of a function because we initially
(=optimistically) thought the function return is `undef`. While we later
adjusted this properly, the `AAUndefinedBehavior` was under the
impression the return value is "known" (=fix) and could never change.

To correct this we use `Attributor::checkForAllInstructions` and then
manually to perform simplification of the return value, only allowing
known values to be used. This actually matches the other UB deductions.

Fixes #53647

2 years ago[MemoryBuiltins][FIX] Adjust index type size properly wrt. AS casts
Johannes Doerfert [Tue, 1 Feb 2022 20:32:33 +0000 (14:32 -0600)]
[MemoryBuiltins][FIX] Adjust index type size properly wrt. AS casts

Use existing functionality to strip constant offsets that works well
with AS casts and avoids the code duplication.

Since we strip AS casts during the computation of the offset we also
need to adjust the APInt properly to avoid mismatches in the bit width.
This code ensures the caller of `compute` sees APInts that match the
index type size of the value passed to `compute`, not the value result
of the strip pointer cast.

Fixes #53559.

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

2 years ago[M68k][GlobalISel] Implement lowerCall based on M68k calling convention
Sheng [Tue, 8 Feb 2022 02:08:21 +0000 (21:08 -0500)]
[M68k][GlobalISel] Implement lowerCall based on M68k calling convention

This patch implements CallLowering::lowerCall based on M68k calling
convention and adds M68kOutgoingValueHandler and CallReturnHandler to
handle argument passing and returned value.

2 years ago[libc] Return a float NaN for log1pf instead of double NaN.
Tue Ly [Tue, 8 Feb 2022 02:04:12 +0000 (21:04 -0500)]
[libc] Return a float NaN for log1pf instead of double NaN.

2 years ago[lld-macho] Include address offsets in error messages
Jez Ng [Tue, 8 Feb 2022 02:06:02 +0000 (21:06 -0500)]
[lld-macho] Include address offsets in error messages

This makes it easier to pinpoint the source of the problem.

TODO: Have more relocation error messages make use of this
functionality.

Reviewed By: #lld-macho, oontvoo

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

2 years ago[SystemZ] Remove a superfluous semicolon to fix a gcc warning. NFC
Craig Topper [Tue, 8 Feb 2022 01:52:08 +0000 (17:52 -0800)]
[SystemZ] Remove a superfluous semicolon to fix a gcc warning. NFC

2 years ago[AMDGPU][NFC] AMDGPUUsage.rst: fix wording.
Lancelot Six [Tue, 8 Feb 2022 00:06:13 +0000 (19:06 -0500)]
[AMDGPU][NFC] AMDGPUUsage.rst: fix wording.

2 years ago[GlobalISel][Legalizer] Support reducing load/store width in big endian order
Sheng [Tue, 8 Feb 2022 00:04:27 +0000 (19:04 -0500)]
[GlobalISel][Legalizer] Support reducing load/store width in big endian order

2 years agoM68K: Pre-commit test of D116931
Sheng [Tue, 8 Feb 2022 00:03:26 +0000 (19:03 -0500)]
M68K: Pre-commit test of D116931

2 years ago[clang][driver] update the darwin driver to point to correct macho_embedded path
Alex Lorenz [Tue, 8 Feb 2022 00:49:47 +0000 (16:49 -0800)]
[clang][driver] update the darwin driver to point to correct macho_embedded path

Compiler-rt started emitting the macho_embedded libraries in
`<resource_dir>/lib/darwin/macho_embedded` after
https://reviews.llvm.org/D105765 / 1e03c37b97b6176a60404d84665c40321f4e33a4,
so update the clang's driver to reflect that.

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

2 years ago[BOLT] Fix runtime osx cross-compile build
Vladislav Khmelevsky [Fri, 4 Feb 2022 22:33:11 +0000 (01:33 +0300)]
[BOLT] Fix runtime osx cross-compile build

Place include elf.h under !apple condition

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

2 years ago[libc++][CI] Put runs into groups
Nikolas Klauser [Mon, 7 Feb 2022 20:06:03 +0000 (21:06 +0100)]
[libc++][CI] Put runs into groups

Many CI runs are very similar in nature. Let's put them into groups for a better overview

Reviewed By: ldionne, #libc

Spies: libcxx-commits, arichardson, mstorsjo

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

2 years ago[BOLT] Add aarch64 support for peephole passes
Vladislav Khmelevsky [Tue, 1 Feb 2022 20:41:07 +0000 (23:41 +0300)]
[BOLT] Add aarch64 support for peephole passes

Enable peephole optimizations for aarch64.
Also small code refactoring - add PeepholeOpts under Peepholes class.

Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

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

2 years ago[RISCV] Use splat_vector instead of SplatPat in widening FP instruction patterns...
Craig Topper [Mon, 7 Feb 2022 23:52:13 +0000 (15:52 -0800)]
[RISCV] Use splat_vector instead of SplatPat in widening FP instruction patterns. NFCI

We use splat_vector for FP nodes without VL, not SplatPat which handles
splat_vector and integer VMV_V_X_VL.

Reduces isel table size by a few hundred bytes.

2 years ago[VP] llvm.vp.fma intrinsic and LangRef
Craig Topper [Mon, 7 Feb 2022 21:24:36 +0000 (13:24 -0800)]
[VP] llvm.vp.fma intrinsic and LangRef

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

2 years ago[gn build] (manually) port 157bbe6aea22e
Nico Weber [Mon, 7 Feb 2022 23:45:04 +0000 (18:45 -0500)]
[gn build] (manually) port 157bbe6aea22e

2 years ago[libc++] Mark some members private in experimental/functional
Joe Loser [Mon, 7 Feb 2022 00:47:45 +0000 (19:47 -0500)]
[libc++] Mark some members private in experimental/functional

Some members are public but should be private. Nothing requires they are public
right now, so make them private.

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