platform/upstream/llvm.git
3 years ago[DebugInfo] Correctly update debug users of SSA values in tail duplication
Stephen Tozer [Mon, 26 Jul 2021 08:59:20 +0000 (09:59 +0100)]
[DebugInfo] Correctly update debug users of SSA values in tail duplication

During tail duplication, SSA values may be updated and have their uses
replaced with a virtual register, and any debug instructions that use
that value are deleted. This patch fixes the implementation of the debug
instruction deletion to work correctly for debug instructions that use
the SSA value multiple times, by batching deletions so that we don't
attempt to delete the same instruction twice.

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

3 years ago[PowerPC] Change altivec indexed load/store builtins argument type
Qiu Chaofan [Mon, 26 Jul 2021 16:20:56 +0000 (00:20 +0800)]
[PowerPC] Change altivec indexed load/store builtins argument type

This patch changes the index argument of lvxl?/lve[bhw]x and
stvxl?/stve[bhw]x builtins from int to long. Because on 64-bit
subtargets, an extra extsw will always been generated, which is
incorrect.

Reviewed By: nemanjai

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

3 years ago[libc++] Add range_size_t
Louis Dionne [Fri, 23 Jul 2021 20:46:31 +0000 (16:46 -0400)]
[libc++] Add range_size_t

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

3 years ago[Analysis] Fix getOrderedReductionCost to call target's getArithmeticInstrCost implem...
Simon Pilgrim [Mon, 26 Jul 2021 16:15:15 +0000 (17:15 +0100)]
[Analysis] Fix getOrderedReductionCost to call target's getArithmeticInstrCost implementation

The getOrderedReductionCost implementation introduced in D105432 calls the CRTP base version getArithmeticInstrCost instead of the redirecting to the target version.

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

3 years ago[LV] Remove assert that VF cannot be scalable in setCostBasedWideningDecision.
Sander de Smalen [Mon, 26 Jul 2021 15:04:25 +0000 (16:04 +0100)]
[LV] Remove assert that VF cannot be scalable in setCostBasedWideningDecision.

Scalarization for scalable vectors is not (yet) supported, so the
LV discards a VF when scalarization is chosen as the widening
decision. It should therefore not assert that the VF is not scalable
when it computes the decision to scalarize.

The code can get here when both the interleave-cost, gather/scatter cost
and scalarization-cost are all illegal. This may e.g. happen for SVE
when the VF=1, to avoid generating `<vscale x 1 x eltty>` types that
the code-generator cannot yet handle.

Reviewed By: david-arm

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

3 years ago[clang][pp] adds '#pragma include_instead'
Christopher Di Bella [Thu, 22 Jul 2021 20:30:43 +0000 (20:30 +0000)]
[clang][pp] adds '#pragma include_instead'

`#pragma clang include_instead(<header>)` is a pragma that can be used
by system headers (and only system headers) to indicate to a tool that
the file containing said pragma is an implementation-detail header and
should not be directly included by user code.

The library alternative is very messy code that can be seen in the first
diff of D106124, and we'd rather avoid that with something more
universal.

This patch takes the first step by warning a user when they include a
detail header in their code, and suggests alternative headers that the
user should include instead. Future work will involve adding a fixit to
automate the process, as well as cleaning up modules diagnostics to not
suggest said detail headers. Other tools, such as clangd can also take
advantage of this pragma to add the correct user headers.

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

3 years ago[MergeICmps] Collect block instructions once (NFC)
Nikita Popov [Mon, 26 Jul 2021 16:05:47 +0000 (18:05 +0200)]
[MergeICmps] Collect block instructions once (NFC)

Collect the relevant instructions for a given BCECmpBlock once
on construction, rather than repeating this logic in multiple
places.

3 years ago[llvm-objcopy] Drop GRP_COMDAT if the group signature is localized
Fangrui Song [Mon, 26 Jul 2021 16:05:18 +0000 (09:05 -0700)]
[llvm-objcopy] Drop GRP_COMDAT if the group signature is localized

See [GRP_COMDAT group with STB_LOCAL signature](https://groups.google.com/g/generic-abi/c/2X6mR-s2zoc)
objcopy PR: https://sourceware.org/bugzilla/show_bug.cgi?id=27931

GRP_COMDAT deduplication is purely based on the signature symbol name in
ld.lld/GNU ld/gold. The local/global status is not part of the equation.

If the signature symbol is localized by --localize-hidden or
--keep-global-symbol, the intention is likely to make the group fully
localized. Drop GRP_COMDAT to suppress deduplication.

Reviewed By: jhenderson

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

3 years ago[yaml2obj][MachO] Rename PayloadString to Content
Fangrui Song [Mon, 26 Jul 2021 16:04:51 +0000 (09:04 -0700)]
[yaml2obj][MachO] Rename PayloadString to Content

The new name is conciser and matches yaml2obj ELF & DWARF.

Reviewed By: #lld-macho, thakis

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

3 years ago[MergeICmps] Try to fix MSVC build failure
Nikita Popov [Mon, 26 Jul 2021 15:29:07 +0000 (17:29 +0200)]
[MergeICmps] Try to fix MSVC build failure

Apparently this fails to line up the types -- try to sidestep the
issue entirely by writing the code in a more reasonable way: Walk
over the operands and perform a set lookup, rather than walking
over the set and performing an operand scan.

3 years ago[AsmParser] Remove MDRef (NFC)
Kazu Hirata [Mon, 26 Jul 2021 15:29:32 +0000 (08:29 -0700)]
[AsmParser] Remove MDRef (NFC)

The last use was removed on Jan 12, 2015 in commit
ab617d597708fcf3c4b829bf595e9d990ca66c07.

3 years ago[SVE] Use reg+reg addressing mode for immediate offsets.
Paul Walker [Thu, 22 Jul 2021 16:16:20 +0000 (17:16 +0100)]
[SVE] Use reg+reg addressing mode for immediate offsets.

For reg+imm SVE addressing mode imm is implictly scaled by VL,
making them impractical for truely immediate offsets.  However, if
the offset can be unscaled based on the storage element type we
can use the reg+reg SVE addressing mode and thus either reduce the
number of generate add instructions or replace them with a mov
instruction that can be hoisted from the hot code path.

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

3 years ago[libc++][NFC] Change a few instances of > > to >> in C++20 code
Louis Dionne [Mon, 26 Jul 2021 15:22:34 +0000 (11:22 -0400)]
[libc++][NFC] Change a few instances of > > to >> in C++20 code

3 years ago[SimplifyLibCalls] avoid crash on pointer math
Sanjay Patel [Mon, 26 Jul 2021 14:52:43 +0000 (10:52 -0400)]
[SimplifyLibCalls] avoid crash on pointer math

We could try harder to screen out libcalls by
function signature (and that would be a much larger
change than for sprintf alone), but that might make
the transition to type-less pointers more difficult.

https://llvm.org/PR51200

3 years ago[SimplifyLibCalls] reduce code duplication; NFC
Sanjay Patel [Mon, 26 Jul 2021 14:28:43 +0000 (10:28 -0400)]
[SimplifyLibCalls] reduce code duplication; NFC

3 years ago[MergeICmps] Separate out BCECmp and use Optional (NFC)
Nikita Popov [Mon, 26 Jul 2021 12:40:12 +0000 (14:40 +0200)]
[MergeICmps] Separate out BCECmp and use Optional (NFC)

Separate out the BCECmp part from BCECmpBlock, which just stores
the comparison atoms without the branch instruction. At the same
time switch the code to return Optional<> rather than objects in
invalid state and partially constructed objects.

3 years ago[LV] Don't assume isScalarAfterVectorization if one of the uses needs widening.
Sander de Smalen [Mon, 26 Jul 2021 14:22:01 +0000 (15:22 +0100)]
[LV] Don't assume isScalarAfterVectorization if one of the uses needs widening.

This fixes an issue that was found in D105199, where a GEP instruction
is used both as the address of a store, as well as the value of a store.
For the former, the value is scalar after vectorization, but the latter
(as value) requires widening.

Other code in that function seems to prevent similar cases from happening,
but it seems this case was missed.

Reviewed By: david-arm

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

3 years ago[AArch64][SVE] Break false dependencies for inactive lanes of unary operations
Bradley Smith [Thu, 8 Jul 2021 16:12:54 +0000 (16:12 +0000)]
[AArch64][SVE] Break false dependencies for inactive lanes of unary operations

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

3 years ago[Clang][OpenMP] Remove the mandatory flush for capture for OpenMP 5.1
Shilei Tian [Mon, 26 Jul 2021 15:00:32 +0000 (11:00 -0400)]
[Clang][OpenMP] Remove the mandatory flush for capture for OpenMP 5.1

In OpenMP 5.1:
> If the `write` or `update` clause is specifieded, the atomic operation is not an atomic conditional update for which the comparison fails, and the effective memory ordering is `release`, `acq_rel`, or `seq_cst`, the strong flush on entry to the atomic operation is also a release flush. If the `read` or `update` clause is specified and the effective memory ordering is `acquire`, `acq_rel`, or `seq_cst` then the strong flush on exit from the atomic operation is also an acquire flush.

In OpenMP 5.0:
> If the `write`, `update`, or **`capture`** clause is specified and the `release`, `acq_rel`, or `seq_cst` clause is specified then the strong flush on entry to the atomic operation is also a release flush. If the `read` or `capture` clause is specified and the `acquire`, `acq_rel`, or `seq_cst` clause is specified then the strong flush on exit from the atomic operation is also an acquire flush.

From my understanding, in OpenMP 5.1, `capture` is removed from the requirement for flush, therefore we don't have to enforce it.

Reviewed By: ABataev

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

3 years ago[SystemZ] Add support for new cpu architecture - arch14
Ulrich Weigand [Tue, 20 Jul 2021 16:14:38 +0000 (18:14 +0200)]
[SystemZ] Add support for new cpu architecture - arch14

This patch adds support for the next-generation arch14
CPU architecture to the SystemZ backend.

This includes:
- Basic support for the new processor and its features.
- Detection of arch14 as host processor.
- Assembler/disassembler support for new instructions.
- New LLVM intrinsics for certain new instructions.
- Support for low-level builtins mapped to new LLVM intrinsics.
- New high-level intrinsics in vecintrin.h.
- Indicate support by defining  __VEC__ == 10304.

Note: No currently available Z system supports the arch14
architecture.  Once new systems become available, the
official system name will be added as supported -march name.

3 years agoRecommit "[VPlan] Add recipe for first-order rec phis, make splicing explicit."
Florian Hahn [Mon, 26 Jul 2021 14:21:16 +0000 (15:21 +0100)]
Recommit "[VPlan] Add recipe for first-order rec phis, make splicing explicit."

This reverts the revert commit b1777b04dc4b1a9fee0e7effa7e177892ab32ef0.

The patch originally got reverted due to a crash:
https://bugs.chromium.org/p/chromium/issues/detail?id=1232798#c2

The underlying issue was that we were not using the stored values from
the modified memory recipes, but the out-of-date values directly from
the IR (accessed via the VPlan). This should be fixed in d995d6376. A
reduced version of the reproducer has been added in 93664503be6b.

3 years ago[libc++][ci] Detect not committed generated files.
Mark de Wever [Thu, 22 Jul 2021 09:17:53 +0000 (11:17 +0200)]
[libc++][ci] Detect not committed generated files.

The Generated output CI job only tests for modified files. This job
should also fail the generated output contains new files.

It would be possible to test modified and untracked files in one
execution of `git ls-files`. However the diff is stored as an artifact
so the execution of `git diff` would still be required.

Discussion: Would it be better to do `git ls-files -om` and remove the
excution of
`! grep -q '^--- a' ${BUILD_DIR}/generated_output.patch || false` ?
(Obviously then the name `generated_output.untracked` should change to
something like `generated_output.status`)

Reviewed By: #libc, ldionne

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

3 years ago[IR] Consider non-willreturn as side effect (PR50511)
Nikita Popov [Wed, 21 Jul 2021 19:23:38 +0000 (21:23 +0200)]
[IR] Consider non-willreturn as side effect (PR50511)

This adjusts mayHaveSideEffect() to return true for !willReturn()
instructions. Just like other side-effects, non-willreturn calls
(aka "divergence") cannot be removed and cannot be reordered relative
to other side effects. This fixes a number of bugs where
non-willreturn calls are either incorrectly dropped or moved. In
particular, it also fixes the last open problem in
https://bugs.llvm.org/show_bug.cgi?id=50511.

I performed a cursory review of all current mayHaveSideEffect()
uses, which convinced me that these are indeed the desired default
semantics. Places that do not want to consider non-willreturn as a
sideeffect generally do not want mayHaveSideEffect() semantics at
all. I identified two such cases, which are addressed by D106591
and D106742. Finally, there is a use in SCEV for which we don't
really have an appropriate API right now -- what it wants is
basically "would this be considered forward progress". I've just
spelled out the previous semantics there.

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

3 years agoSimplify away some SmallVector copies. NFCI.
Benjamin Kramer [Mon, 26 Jul 2021 14:32:22 +0000 (16:32 +0200)]
Simplify away some SmallVector copies. NFCI.

The lifetime of the initializer list is the full expression, so we can
skip storing it in a temporary vector.

3 years ago[Analyzer][solver][NFC] print constraints deterministically (ordered by their string...
Gabor Marton [Tue, 20 Jul 2021 14:46:15 +0000 (16:46 +0200)]
[Analyzer][solver][NFC] print constraints deterministically (ordered by their string representation)

This change is an extension to D103967 where I added dump methods for
(dis)equality classes of the State. There, the (dis)equality classes and their
contents are dumped in an ordered fashion, they are ordered based on their
string representation. This is very useful once we start to use FileCheck to
test the State dump in certain tests.

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

3 years ago[InstrRef][AArch64][1/4] Accept constant physreg variable locations
Jeremy Morse [Mon, 26 Jul 2021 14:00:08 +0000 (15:00 +0100)]
[InstrRef][AArch64][1/4] Accept constant physreg variable locations

Late in SelectionDAG we join up instruction numbers with their defining
instructions, if it couldn't be done during the main part of SelectionDAG.
One exception is function arguments, where we have to point a DBG_PHI
instruction at the incoming live register, as they don't have a defining
instruction. This patch adds another exception, for constant physregs, like
aarch64 has.

It may seem wasteful to use two instructions where we could use a single
DBG_VALUE, however the whole point of instruction referencing is to
decouple the identification of values from the specification of where
variable location ranges start.

(Part of my aarch64 work to ease adoption of  instruction referencing, as
in the meta comment on D104520)

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

3 years ago[LV] Add test to store a first-order rec via interleave group.
Florian Hahn [Mon, 26 Jul 2021 13:47:00 +0000 (14:47 +0100)]
[LV] Add test to store a first-order rec via interleave group.

This is a reduced version of the reproducer from
https://bugs.chromium.org/p/chromium/issues/detail?id=1232798#c2

3 years ago[SLP]Fix costs calculations.
Alexey Bataev [Mon, 26 Jul 2021 12:43:53 +0000 (05:43 -0700)]
[SLP]Fix costs calculations.

Need to fix several cost-related problems. The final type may be defined
incorrectly because of to early definition (we may end up with the wider
type), the CommonCost should not be redefined in ExtractElements
cost related calculations and the shuffle of the final insertelements
vectors should be calculated as a cost of single vector permutations
+ costs of two vector permutations for other n-1 incoming vectors.

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

3 years ago[OpenCL] Change default standard version to CL1.2
Anastasia Stulova [Mon, 26 Jul 2021 13:59:47 +0000 (14:59 +0100)]
[OpenCL] Change default standard version to CL1.2

Set default version for OpenCL C to 1.2. This means that the
absence of any standard flag will be equivalent to passing
'-cl-std=CL1.2'.

Note that this patch also fixes incorrect version check for
the pointer to pointer kernel arguments diagnostic and
atomic test.

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

3 years ago[llvm-readobj] Display multiple function names for stack size entries
gbreynoo [Mon, 26 Jul 2021 13:49:53 +0000 (14:49 +0100)]
[llvm-readobj] Display multiple function names for stack size entries

The current implementation of displaying .stack_size information
presumes that each entry represents a single function but this is not
always the case. For example with the use of ICF multiple functions can
be represented with the same code, meaning that the address found in a
.stack_size entry corresponds to multiple function symbols.
This change allows multiple function names to be displayed when
appropriate.

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

3 years ago[AMDGPU][GISel] Fix MMO for raw/struct buffer access with non-constant offset
Jay Foad [Wed, 21 Jul 2021 14:53:59 +0000 (15:53 +0100)]
[AMDGPU][GISel] Fix MMO for raw/struct buffer access with non-constant offset

Codegen for the raw/struct buffer access intrinsics would update the
offset in the MMO to reflect the combined offset, if it was known to be
constant. If the combined offset was not known to be constant, or if
there was an index, it would set the offset in the MMO to 0. This is
unsafe because it makes it look like the access does not alias with
another access with a fixed non-zero offset.

Fix these cases by setting the pointer in the MMO to null, to reflect
the fact that we do not have any known IR value pointer + constant
offset for the access.

D106284 did this for SelectionDAG. This is the corresponding fix for
GlobalISel.

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

3 years ago[AMDGPU] Pre-commit global-isel test case for D106451
Jay Foad [Wed, 21 Jul 2021 10:29:04 +0000 (11:29 +0100)]
[AMDGPU] Pre-commit global-isel test case for D106451

This test case shows the scheduler wrongly reordering two buffer
accesses that might alias.

3 years ago[AMDGPU] Fix MMO for raw/struct buffer access with non-constant offset
Jay Foad [Mon, 19 Jul 2021 15:29:39 +0000 (16:29 +0100)]
[AMDGPU] Fix MMO for raw/struct buffer access with non-constant offset

Codegen for the raw/struct buffer access intrinsics would update the
offset in the MMO to reflect the combined offset, if it was known to be
constant. If the combined offset was not known to be constant, or if
there was an index, it would set the offset in the MMO to 0. This is
unsafe because it makes it look like the access does not alias with
another access with a fixed non-zero offset.

Fix these cases by setting the pointer in the MMO to null, to reflect
the fact that we do not have any known IR value pointer + constant
offset for the access.

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

3 years ago[ARM] Ensure correct regclass in distributing postinc
David Green [Mon, 26 Jul 2021 13:26:38 +0000 (14:26 +0100)]
[ARM] Ensure correct regclass in distributing postinc

The register class required for some MVE loads/stores is more
constrained than the register we use when creating postinc. Make sure we
constrain the register class to keep the code correct.

3 years agoAArch64: support i128 (& larger) returns in GlobalISel
Tim Northover [Mon, 26 Jul 2021 12:53:34 +0000 (13:53 +0100)]
AArch64: support i128 (& larger) returns in GlobalISel

3 years ago[SimplifyCFG] Improve store speculation check
Nikita Popov [Wed, 21 Jul 2021 20:34:28 +0000 (22:34 +0200)]
[SimplifyCFG] Improve store speculation check

isSafeToSpeculateStore() looks for a preceding store to the same
location to make sure that introducing a new store of the same
value is safe. It currently bails on intervening mayHaveSideEffect()
instructions. However, I believe just checking mayWriteToMemory()
is sufficient there -- we just need to make sure that we know which
value was stored, we don't care if we can unwind in the meantime.

While looking into this, I started having some doubts about the
correctness of the transform with regard to thread safety. While
we don't try to hoist non-simple stores, I believe we also need
to make sure that the preceding store is simple as well. Otherwise
we could introduce a spurious non-atomic write after an atomic write
-- under our memory model this would result in a subsequent undef
atomic read, even if the second write stores the same value as the
first.

Example: https://alive2.llvm.org/ce/z/q_3YAL

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

3 years ago[SVE] Fix casts to <FixedVectorType> in truncateToMinimalBitwidths
Kerry McLaughlin [Mon, 26 Jul 2021 09:55:15 +0000 (10:55 +0100)]
[SVE] Fix casts to <FixedVectorType> in truncateToMinimalBitwidths

Fixes more casts to `<FixedVectorType>` for the cases where the
instruction is a Insert/ExtractElementInst.

For fixed-width, this part of truncateToMinimalBitWidths is tested by
AArch64/type-shrinkage-insertelt.ll. I attempted to write a test case for this part
of truncateToMinimalBitWidths which uses scalable vectors, but was unable to add
one. The tests in type-shrinkage-insertelt.ll rely on scalarization to create extract
element instructions for instance, which is not possible for scalable vectors.

Reviewed By: david-arm

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

3 years agoRevert "[SLP]Fix costs calculations."
Alexey Bataev [Mon, 26 Jul 2021 12:42:11 +0000 (05:42 -0700)]
Revert "[SLP]Fix costs calculations."

This reverts commit a053afed49897aa34e08287f91c5255efa4e5131 to fix
buildbots.

3 years ago[AArch65][SVE] Remove vector_splice from AddedComplexity pattern
Caroline Concatto [Mon, 26 Jul 2021 12:08:33 +0000 (13:08 +0100)]
[AArch65][SVE] Remove vector_splice from AddedComplexity pattern

The pattern for vector_splice with Index equal or bigger than
zero was misplaced in the AddedComplexity = 1 pattern in the AArch64
tablegen file. This patch fixes it by removing vector_splice pattern
from inside AddedComplexity = 1.

3 years ago[mlir] split type conversion to two lines for GCC's sake
Tres Popp [Mon, 26 Jul 2021 12:15:37 +0000 (14:15 +0200)]
[mlir] split type conversion to two lines for GCC's sake

3 years ago[SLP]Fix costs calculations.
Alexey Bataev [Thu, 22 Jul 2021 17:48:36 +0000 (10:48 -0700)]
[SLP]Fix costs calculations.

Need to fix several cost-related problems. The final type may be defined
incorrectly because of to early definition (we may end up with the wider
type), the CommonCost should not be redefined in ExtractElements
cost related calculations and the shuffle of the final insertelements
vectors should be calculated as a cost of single vector permutations
+ costs of two vector permutations for other n-1 incoming vectors.

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

3 years ago[NFC] Change VFShape so it contains an ElementCount rather than seperate VF and IsSca...
Paul Walker [Sat, 24 Jul 2021 15:34:20 +0000 (16:34 +0100)]
[NFC] Change VFShape so it contains an ElementCount rather than seperate VF and IsScalable properties.

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

3 years ago[Inliner] Make the CallPenalty configurable
Philipp Krones [Wed, 14 Jul 2021 11:21:40 +0000 (12:21 +0100)]
[Inliner] Make the CallPenalty configurable

Tests with multiple benchmarks, like Embench [1], showed that the
CallPenalty magic number has the most influence on inlining decisions
when optimizing for size.

On the other hand, there was no good default value for this parameter.
Some benchmarks profited strongly from a reduced call penalty. On
example is the picojpeg benchmark compiled for RISC-V, which got 6%
smaller with a CallPenalty of 10 instead of 12. Other benchmarks
increased in size, like matmult.

This commit makes the compromise of turning the magic number constant of
CallPenalty into a configurable value. This introduces the flag
`--inline-call-penalty`. With that flag users can fine tune the inliner
to their needs.

The CallPenalty constant was also used for loops. This commit replaces
the CallPenalty constant with a new LoopPenalty constant that is now
used instead.

This is a slimmed down version of https://reviews.llvm.org/D30899

[1]: https://github.com/embench/embench-iot

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

3 years ago[VPlan] Use stored value from recipes for interleave groups.
Florian Hahn [Mon, 26 Jul 2021 10:38:39 +0000 (11:38 +0100)]
[VPlan] Use stored value from recipes for interleave groups.

Instead of getting the VPValue for the stored IR values through the
current plan, use the stored value of the recipes directly.

This way, the correct VPValues are used if the store recipes have been
modified in the VPlan and the IR value is not correct any longer. This
can happen, e.g. due to D105008.

3 years ago[SVE] Add support for folding for select + masked loads
Dylan Fleming [Mon, 26 Jul 2021 10:26:28 +0000 (11:26 +0100)]
[SVE] Add support for folding for select + masked loads

Add folds to instcombine to support the removal of select instruction when the masked_load is guaranteed to zero the same lanes, i.e. select(mask, mload(,,mask,0), 0) -> mload(,,mask,0).

Patch originally authored by @paulwalker-arm

Reviewed By: david-arm

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

3 years ago[SVE][AArch64] Improve code generation for vector_splice for Imm > 0
Caroline Concatto [Mon, 19 Jul 2021 10:14:20 +0000 (11:14 +0100)]
[SVE][AArch64] Improve code generation for vector_splice for Imm > 0

This patch implements vector_splice in tablegen for all cases when the
Immediate is positive and lower than the known minimum value of
a scalable vector.
Vector_splice can be implemented using SVE instruction EXT.
For instance :
    @llvm.experimental.vector.splice(Vector_1, Vector_2, Imm)
    @llvm.experimental.vector.splice(<A,B,C,D>, <E,F,G,H>, 1) ==> <B, C, D, E>
        EXT  Vector_1, Vector_2, Imm              // Vector_1 = B, C, D + Vector_2 = E

Depends on D105633

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

3 years agoFix test failures caused by 0aff1798b5721d5f95d16f465b99d357012bb8d1
David Sherwood [Mon, 26 Jul 2021 10:38:49 +0000 (11:38 +0100)]
Fix test failures caused by 0aff1798b5721d5f95d16f465b99d357012bb8d1

3 years ago[AArch64][SVE] Improve code generation for vector_splice for Imm == -1
Caroline Concatto [Tue, 6 Jul 2021 08:19:16 +0000 (09:19 +0100)]
[AArch64][SVE] Improve code generation for vector_splice for Imm == -1

This patch implements vector_splice in tablegen for:
  a) when the immediate is equal to -1 (Imm==1) and uses:
       INSR  +  LASTB
For instance :
@llvm.experimental.vector.splice(Vector_1, Vector_2, -1)
@llvm.experimental.vector.splice(<A,B,C,D>, <E,F,G,H>, 1) ==> <D, E, F, G>
    LAST   RegLast, Vector_1                 // RegLast = D
    INSR   Res, (Vector_1 >> 1), RegLast     // Res = D + E, F, G

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

3 years ago[X86][AVX] Prefer vinsertf128 to vperm2f128 on AVX1 targets
Simon Pilgrim [Mon, 26 Jul 2021 10:11:56 +0000 (11:11 +0100)]
[X86][AVX] Prefer vinsertf128 to vperm2f128 on AVX1 targets

Splatting the lower xmm with vinsertf128 is at least as quick as vperm2f128, and a lot faster on some AMD targets.

First step towards PR50053

3 years ago[X86][SSE] Don't scrub address math from interleaved shuffle tests
Simon Pilgrim [Mon, 26 Jul 2021 10:03:31 +0000 (11:03 +0100)]
[X86][SSE] Don't scrub address math from interleaved shuffle tests

3 years agoRevert "[clangd] Avoid range-loop init-list lifetime subtleties."
Sam McCall [Mon, 26 Jul 2021 08:42:03 +0000 (10:42 +0200)]
Revert "[clangd] Avoid range-loop init-list lifetime subtleties."

This reverts commit 253b8145dedbe8d10792f44b4af7f52dbecd527f.

This doesn't actually fix anything - I should stop guessing.
See https://github.com/clangd/clangd/issues/800 for update

3 years ago[AArch64][AsmParser] NFC: Parser.getTok().getLoc() -> getLoc()
Cullen Rhodes [Mon, 26 Jul 2021 09:23:59 +0000 (09:23 +0000)]
[AArch64][AsmParser] NFC: Parser.getTok().getLoc() -> getLoc()

Reviewed By: tmatheson

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

3 years ago[Analysis] Add simple cost model for strict (in-order) reductions
David Sherwood [Wed, 7 Jul 2021 12:18:20 +0000 (13:18 +0100)]
[Analysis] Add simple cost model for strict (in-order) reductions

I have added a new FastMathFlags parameter to getArithmeticReductionCost
to indicate what type of reduction we are performing:

  1. Tree-wise. This is the typical fast-math reduction that involves
  continually splitting a vector up into halves and adding each
  half together until we get a scalar result. This is the default
  behaviour for integers, whereas for floating point we only do this
  if reassociation is allowed.
  2. Ordered. This now allows us to estimate the cost of performing
  a strict vector reduction by treating it as a series of scalar
  operations in lane order. This is the case when FP reassociation
  is not permitted. For scalable vectors this is more difficult
  because at compile time we do not know how many lanes there are,
  and so we use the worst case maximum vscale value.

I have also fixed getTypeBasedIntrinsicInstrCost to pass in the
FastMathFlags, which meant fixing up some X86 tests where we always
assumed the vector.reduce.fadd/mul intrinsics were 'fast'.

New tests have been added here:

  Analysis/CostModel/AArch64/reduce-fadd.ll
  Analysis/CostModel/AArch64/sve-intrinsics.ll
  Transforms/LoopVectorize/AArch64/strict-fadd-cost.ll
  Transforms/LoopVectorize/AArch64/sve-strict-fadd-cost.ll

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

3 years ago[SelectionDAG] Support scalable-vector splats in yet more cases
Fraser Cormack [Thu, 22 Jul 2021 17:03:40 +0000 (18:03 +0100)]
[SelectionDAG] Support scalable-vector splats in yet more cases

This patch extends support for (scalable-vector) splats in the
DAGCombiner via the `ISD::matchBinaryPredicate` function, which enable a
variety of simple combines of constants.

Users of this function may now have to distinguish between
`BUILD_VECTOR` and `SPLAT_VECTOR` vector operands. The way of dealing
with this in-tree follows the approach added for
`ISD::matchUnaryPredicate` implemented in D94501.

Reviewed By: craig.topper

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

3 years agoRevert "Revert D106562 "[clangd] Get rid of arg adjusters in CommandMangler""
Kadir Cetinkaya [Sat, 24 Jul 2021 17:44:15 +0000 (19:44 +0200)]
Revert "Revert D106562 "[clangd] Get rid of arg adjusters in CommandMangler""

This reverts commit 2aa0cf19e7fe17c9eb5eb2555e10184061b933f1.
Get rid of reference to the temporary.

3 years ago[libomptarget] Build amdgpu plugin without hsa
Jon Chesterfield [Mon, 26 Jul 2021 08:54:50 +0000 (09:54 +0100)]
[libomptarget] Build amdgpu plugin without hsa

Default to building the amdgpu plugin to use dlopen when hsa is
not found instead of disabling it.

Reviewed By: jdoerfert

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

3 years ago[libomptarget][nfc] Squash unused variable warning
Jon Chesterfield [Mon, 26 Jul 2021 08:54:30 +0000 (09:54 +0100)]
[libomptarget][nfc] Squash unused variable warning

Suppress only current warning on openmp-clang-x86_64-linux-debian

Reviewed By: jdoerfert

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

3 years ago[mlir] Fix RankedTensorType::walkImmediateSubElements method
Vladislav Vinogradov [Wed, 7 Jul 2021 15:07:51 +0000 (18:07 +0300)]
[mlir] Fix RankedTensorType::walkImmediateSubElements method

Add 'enconding' attribute visitor.
Without it ASM printer doesn't use attribute aliases for 'enconding'.

Reviewed By: rriddle

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

3 years ago[libc] fix LibcUnitTestMain when building with shared libraries
Guillaume Chatelet [Mon, 26 Jul 2021 08:43:45 +0000 (08:43 +0000)]
[libc] fix LibcUnitTestMain when building with shared libraries

3 years ago[ORC][ORC-RT] Add initial Objective-C and Swift support to MachOPlatform.
Lang Hames [Mon, 26 Jul 2021 07:49:05 +0000 (17:49 +1000)]
[ORC][ORC-RT] Add initial Objective-C and Swift support to MachOPlatform.

This allows ORC to execute code containing Objective-C and Swift classes and
methods (provided that the language runtime is loaded into the executor).

3 years ago[mlir] Added new RegionBranchTerminatorOpInterface and adapted uses of hasTrait<Retur...
Marcel Koester [Fri, 23 Jul 2021 09:59:21 +0000 (11:59 +0200)]
[mlir] Added new RegionBranchTerminatorOpInterface and adapted uses of hasTrait<ReturnLike>.

This CL adds a new RegionBranchTerminatorOpInterface to query information about operands that can be
passed to successor regions. Similar to the BranchOpInterface, it allows to freely define the
involved operands. However, in contrast to the BranchOpInterface, it expects an additional region
number to distinguish between various use cases which might require different operands passed to
different regions.

Moreover, we added new utility functions (namely getMutableRegionBranchSuccessorOperands and
getRegionBranchSuccessorOperands) to query (mutable) operand ranges for operations equiped with the
ReturnLike trait and/or implementing the newly added interface.  This simplifies reasoning about
terminators in the scope of the nested regions.

We also adjusted the SCF.ConditionOp to benefit from the newly added capabilities.

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

3 years ago[Preprocessor] Implement -fminimize-whitespace.
Michael Kruse [Mon, 26 Jul 2021 02:39:08 +0000 (21:39 -0500)]
[Preprocessor] Implement -fminimize-whitespace.

This patch adds the -fminimize-whitespace with the following effects:

 * If combined with -E, remove as much non-line-breaking whitespace as
   possible.

 * If combined with -E -P, removes as much whitespace as possible,
   including line-breaks.

The motivation is to reduce the amount of insignificant changes in the
preprocessed output with source files where only whitespace has been
changed (add/remove comments, clang-format, etc.) which is in particular
useful with ccache.

A patch for ccache for using this flag has been proposed to ccache as well:
https://github.com/ccache/ccache/pull/815, which will use
-fnormalize-whitespace when clang-13 has been detected, and additionally
uses -P in "unify_mode". ccache already had a unify_mode in an older
version which was removed because of problems that using the
preprocessor itself does not have (such that the custom tokenizer did
not recognize C++11 raw strings).

This patch slightly reorganizes which part is responsible for adding
newlines that are required for semantics. It is now either
startNewLineIfNeeded() or MoveToLine() but never both; this avoids the
ShouldUpdateCurrentLine workaround and avoids redundant lines being
inserted in some cases. It also fixes a mandatory newline not inserted
after a _Pragma("...") that is expanded into a #pragma.

Reviewed By: aaron.ballman

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

3 years ago[Object] make SourceMgr available to MCContext during inline asm symbols
Yuanfang Chen [Mon, 26 Jul 2021 04:12:28 +0000 (21:12 -0700)]
[Object] make SourceMgr available to MCContext during inline asm symbols
collection

Fixes PR51210.

3 years ago[Debug-Info][llvm-dwarfdump] Don't use DW_FORM_data4/8
Esme-Yi [Mon, 26 Jul 2021 03:47:02 +0000 (03:47 +0000)]
[Debug-Info][llvm-dwarfdump] Don't use DW_FORM_data4/8
to encode the constants for DW_AT_data_member_location.

Summary: In DWARF v3, DW_FORM_data4/8 in
DW_AT_data_member_location are interpreted as location
list pointers. Interpreting constants as pointers is
not expected, so we use DW_FORM_udata to encode the
constants.

Reviewed By: probinson

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

3 years agoRevert "Build libSupport with -Werror=global-constructors (NFC)"
Mehdi Amini [Mon, 26 Jul 2021 03:08:26 +0000 (03:08 +0000)]
Revert "Build libSupport with -Werror=global-constructors (NFC)"

This reverts commit 579cc9ad2e2db6c3f1670b9f42c2cfe67bc5722c.
This breaks on Windows.

3 years agoBuild libSupport with -Werror=global-constructors (NFC)
Mehdi Amini [Fri, 16 Jul 2021 03:32:59 +0000 (03:32 +0000)]
Build libSupport with -Werror=global-constructors (NFC)

Ensure that libSupport does not carry any static global initializer.
libSupport can be embedded in use cases where we don't want to load all
cl::opt unless we want to parse the command line.
ManagedStatic can be used to enable lazy-initialization of globals.

3 years ago[yaml2obj] Do not write the string table if there is no string entry.
Esme-Yi [Mon, 26 Jul 2021 02:37:49 +0000 (02:37 +0000)]
[yaml2obj] Do not write the string table if there is no string entry.

Summary: yaml2obj shouldn't create the string table that isn't needed
         - doing so wastes time and disk space.

Reviewed By: jhenderson

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

3 years ago[OPENCL] opencl-c.h: add initial CL 3.0 conditionals for atomic operations.
Dave Airlie [Mon, 26 Jul 2021 01:04:25 +0000 (11:04 +1000)]
[OPENCL] opencl-c.h: add initial CL 3.0 conditionals for atomic operations.

This adds the optional wrappers around things, however this isn't sufficient yet for CL 3.0 without generic address space, I've got one more additional patch to add all those APIs, but this is an easier to review precursor.

Reviewed By: Anastasia

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

3 years agoRevert "Build libSupport with -Werror=global-constructors (NFC)"
Mehdi Amini [Mon, 26 Jul 2021 00:55:36 +0000 (00:55 +0000)]
Revert "Build libSupport with -Werror=global-constructors (NFC)"

This reverts commit 5eb2e9aa64b7be7cd8ed7f36de19c2c9bdf1977c.
This broke MacOS builds, needs to have a safer check guarding the flag
addition.

3 years agoBuild libSupport with -Werror=global-constructors (NFC)
Mehdi Amini [Fri, 16 Jul 2021 03:32:59 +0000 (03:32 +0000)]
Build libSupport with -Werror=global-constructors (NFC)

Ensure that libSupport does not carry any static global initializer.
libSupport can be embedded in use cases where we don't want to load all
cl::opt unless we want to parse the command line.
ManagedStatic can be used to enable lazy-initialization of globals.

3 years agoRemove the NotUnderValgrind caching flag
Mehdi Amini [Mon, 26 Jul 2021 00:20:24 +0000 (00:20 +0000)]
Remove the NotUnderValgrind caching flag

The motivation for this caching wasn't clear, remove it in an effort to
simplify the code and make libSupport free of global dynamic constructor.

Reviewed By: dexonsmith

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

3 years ago[SimplifyCFG] Fold branch to common dest: if branch is unpredictable, prefer to speculate
Roman Lebedev [Sun, 25 Jul 2021 23:57:19 +0000 (02:57 +0300)]
[SimplifyCFG] Fold branch to common dest: if branch is unpredictable, prefer to speculate

This is consistent with the two other usages of prof md in this pass.

3 years ago[SimplifyCFG] Don't speculatively execute BB[s] if they are predictably not taken
Roman Lebedev [Sun, 25 Jul 2021 23:38:40 +0000 (02:38 +0300)]
[SimplifyCFG] Don't speculatively execute BB[s] if they are predictably not taken

Same as D106650, but for `FoldTwoEntryPHINode()`

Reviewed By: spatel

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

3 years ago[SimplifyCFG] Don't speculatively execute BB if it's predictably not taken
Roman Lebedev [Sun, 25 Jul 2021 23:30:31 +0000 (02:30 +0300)]
[SimplifyCFG] Don't speculatively execute BB if it's predictably not taken

If the branch isn't `unpredictable`, and it is predicted to *not* branch
to the block we are considering speculatively executing,
then it seems counter-productive to execute the code that is predicted not to be executed.

Reviewed By: spatel

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

3 years ago[NFC][SimplifyCFG] Add more negative tests for profmd-induced speculation avoidance
Roman Lebedev [Sun, 25 Jul 2021 23:30:12 +0000 (02:30 +0300)]
[NFC][SimplifyCFG] Add more negative tests for profmd-induced speculation avoidance

3 years ago[ELF] Support quoted symbols in symbol assignments
Fangrui Song [Sun, 25 Jul 2021 23:26:37 +0000 (16:26 -0700)]
[ELF] Support quoted symbols in symbol assignments

glibc/elf/tst-absolute-zero-lib.lds uses `"absolute" = 0;`

3 years ago[lld/mac] Make comment style uniform in start-end.s test
Nico Weber [Sun, 25 Jul 2021 22:37:49 +0000 (18:37 -0400)]
[lld/mac] Make comment style uniform in start-end.s test

3 years ago[lld/mac] Add support for segment$start$ and segment$end$ symbols
Nico Weber [Fri, 23 Jul 2021 14:12:55 +0000 (10:12 -0400)]
[lld/mac] Add support for segment$start$ and segment$end$ symbols

These symbols are somewhat interesting in that they create non-existing
segments, which as far as I know is the only way to create segments
that don't contain any sections.

Final part of part of PR50760. Like D106629, but for segments instead
of sections. I'm not aware of anything that needs this in practice.

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

3 years ago[lld/mac] Move output segment rename logic into OutputSegment
Nico Weber [Sun, 25 Jul 2021 14:09:37 +0000 (10:09 -0400)]
[lld/mac] Move output segment rename logic into OutputSegment

Fixes the output segment name if both -rename_section and
-rename_segment are used and the post-section-rename segment
name is the same as the pre-segment-rename segment name to
match ld64's behavior.

The motivation is that segment$start$ can create section-less segments,
and this makes a corner case in the interaction between segment$start and
-rename_segment in the upcoming segment$start patch.

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

3 years ago[lld/mac] Reland: Add tests for the interaction between -rename_section and -rename_s...
Nico Weber [Sun, 25 Jul 2021 14:05:58 +0000 (10:05 -0400)]
[lld/mac] Reland: Add tests for the interaction between -rename_section and -rename_segment

No behavior change.

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

3 years ago[libomptarget][amdgpu] More robust handling of failure to init HSA
Jon Chesterfield [Sun, 25 Jul 2021 22:14:42 +0000 (23:14 +0100)]
[libomptarget][amdgpu] More robust handling of failure to init HSA

If hsa_init fails, subsequent calls into hsa are not safe. Except for
hsa_init, but we don't retry on failure.

This patch:
- deletes a print that called into hsa to ask why it can't call into hsa
- drops a merge conflict block next to that print
- reliably initializes number of devices to zero
- skips the plugin destructor contents if the constructor failed to init hsa

Tested by making hsa_init return error, and by forcing the dynamic library
use which was then deleted from disk. Before this patch, both segv. After it,
friendly message about offloading being unavailable.

Reviewed By: jdoerfert

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

3 years agoRevert "[lld/mac] Add tests for the interaction between -rename_section and -rename_s...
Nico Weber [Sun, 25 Jul 2021 22:11:36 +0000 (18:11 -0400)]
Revert "[lld/mac] Add tests for the interaction between -rename_section and -rename_segment"

This reverts commit a6eb34624dcfa5a33caa0211f4a16710b22079c2.
The test fails, I screwed something up.

3 years ago[lld/mac] Add tests for the interaction between -rename_section and -rename_segment
Nico Weber [Sun, 25 Jul 2021 14:05:58 +0000 (10:05 -0400)]
[lld/mac] Add tests for the interaction between -rename_section and -rename_segment

No behavior change.

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

3 years ago[docs] Update release notes to mention lli JIT engine switch
Stefan Gränitz [Sun, 25 Jul 2021 21:58:43 +0000 (23:58 +0200)]
[docs] Update release notes to mention lli JIT engine switch

3 years agoRevert "[VPlan] Add recipe for first-order rec phis, make splicing explicit."
Nico Weber [Sun, 25 Jul 2021 21:31:02 +0000 (17:31 -0400)]
Revert "[VPlan] Add recipe for first-order rec phis, make splicing explicit."

Makes clang crash: https://reviews.llvm.org/D105008#2903350
This reverts commit d2a73fb44ea0b8c981e4b923f811f18793fc4770.

Also revert a minor formatting follow-up:
This reverts commit 82834a673246f27a541ffcc57e0eb65b008102ef.

3 years agoRevert "[libomptarget] Build amdgpu plugin without hsa"
Jon Chesterfield [Sun, 25 Jul 2021 20:03:51 +0000 (21:03 +0100)]
Revert "[libomptarget] Build amdgpu plugin without hsa"

Inaccurate error handling around hsa_init

This reverts commit e30b3b23a4eddbc08b5648e643f0a0b456a57832.

3 years ago[LangRef] Reorder two paragraphs for comdat
Fangrui Song [Sun, 25 Jul 2021 19:53:14 +0000 (12:53 -0700)]
[LangRef] Reorder two paragraphs for comdat

so that IMAGE_COMDAT_SELECT_LARGEST refers to the correct example.

3 years ago[X86][AVX] Add getBROADCAST_LOAD helper function. NFCI.
Simon Pilgrim [Sun, 25 Jul 2021 19:37:42 +0000 (20:37 +0100)]
[X86][AVX] Add getBROADCAST_LOAD helper function. NFCI.

Begin replacing individual getMemIntrinsicNode calls and setup (for X86ISD::VBROADCAST_LOAD + X86ISD::SUBV_BROADCAST_LOAD opcodes) with this getBROADCAST_LOAD helper.

3 years ago[libomptarget] Build amdgpu plugin without hsa
Jon Chesterfield [Sun, 25 Jul 2021 18:33:35 +0000 (19:33 +0100)]
[libomptarget] Build amdgpu plugin without hsa

Default to building the amdgpu plugin to use dlopen when hsa is
not found instead of disabling it.

Reviewed By: jdoerfert

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

3 years ago[OpenMP] Introduce RAII to protect certain RTL calls from DCE
Joseph Huber [Fri, 23 Jul 2021 20:32:47 +0000 (16:32 -0400)]
[OpenMP] Introduce RAII to protect certain RTL calls from DCE

This patch introduces a new RAII struct that will temporarily make an OpenMP
RTL function have external linkage. This is done before the attributor is
invoked to prevent it from incorrectly removing some function definitions that
we will use later. For example, if we determine all calls to one function are
dead, because it has internal linkage it can safely be removed. Later when we
try to get an instance to that function to modify the source using
`getOrCreateRuntimeFunction` we will then get an empty declaration for that
function that won't be defined anywhere. This patch prevents this from
occurring.

Reviewed By: jdoerfert

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

3 years ago[NFC][Codegen][X86] Improve test coverage for insertions into XMM vector
Roman Lebedev [Sun, 25 Jul 2021 14:36:51 +0000 (17:36 +0300)]
[NFC][Codegen][X86] Improve test coverage for insertions into XMM vector

3 years ago[AArch64] Fix Local Deallocation for Homogeneous Prolog/Epilog
Kyungwoo Lee [Sun, 25 Jul 2021 17:50:39 +0000 (10:50 -0700)]
[AArch64] Fix Local Deallocation for Homogeneous Prolog/Epilog

The stack adjustment for local deallocation was incorrectly ported.

Reviewed By: MaskRay

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

3 years ago[OpenMP][tests][NFC] Update test status for gcc 11 and 12
Joachim Protze [Sun, 25 Jul 2021 16:27:40 +0000 (18:27 +0200)]
[OpenMP][tests][NFC] Update test status for gcc 11 and 12

gcc 11 introduced support for depend clause, but the gomp interface of libomp
does not yet handle the information.
Also remove -fopenmp-version=50, which is no longer needed for clang, but not
supported by gcc.

3 years ago[X86][SSE] LowerRotate - perform modulo on the amount splat source directly.
Simon Pilgrim [Sun, 25 Jul 2021 16:30:17 +0000 (17:30 +0100)]
[X86][SSE] LowerRotate - perform modulo on the amount splat source directly.

If the rotation amount is a known splat, perform the modulo on the splat source, and then perform the splat. That way the amount-extension performed later by LowerScalarVariableShift can fold the splats away without any multiple-use issues.

Fixes one of the concerns raised on D104156

3 years ago[Attributes] Clean up handling of UB implying attributes (NFC)
Nikita Popov [Sun, 25 Jul 2021 16:21:13 +0000 (18:21 +0200)]
[Attributes] Clean up handling of UB implying attributes (NFC)

Rather than adding methods for dropping these attributes in
various places, add a function that returns an AttrBuilder with
these attributes, which can then be used with existing methods
for dropping attributes. This is with an eye on D104641, which
also needs to drop them from returns, not just parameters.

Also be more explicit about the semantics of the method in the
documentation. Refer to UB rather than Undef, which is what this
is actually about.

3 years ago[Attributes] Remove nonnull from UB-implying attributes
Nikita Popov [Sun, 25 Jul 2021 16:04:50 +0000 (18:04 +0200)]
[Attributes] Remove nonnull from UB-implying attributes

From LangRef:

> if the parameter or return pointer is null, poison value is
> returned or passed instead. The nonnull attribute should be
> combined with the noundef attribute to ensure a pointer is not
> null or otherwise the behavior is undefined.

Dropping noundef is sufficient to prevent UB. Including nonnull
in this method just muddies the semantics.

3 years agoRevert rG939291041bb35b8088e3b61be2b8b3bc950f64a7 "[AMDGPU] Regenerate wave32.ll...
Simon Pilgrim [Sun, 25 Jul 2021 14:59:26 +0000 (15:59 +0100)]
Revert rG939291041bb35b8088e3b61be2b8b3bc950f64a7 "[AMDGPU] Regenerate wave32.ll test checks"

This still breaks buildbots

3 years ago[JITLink][RISCV] Run new test from 0ad562b48 only if the RISCV backend is enabled
Nico Weber [Sun, 25 Jul 2021 14:45:46 +0000 (10:45 -0400)]
[JITLink][RISCV] Run new test from 0ad562b48 only if the RISCV backend is enabled

3 years ago[InstCombine] Fix PR47960 - Incorrect transformation of fabs with nnan flag
Krishna Kariya [Sun, 25 Jul 2021 14:36:25 +0000 (10:36 -0400)]
[InstCombine] Fix PR47960 - Incorrect transformation of fabs with nnan flag

Bug Fix for PR: https://llvm.org/PR47960

This patch makes sure that the fast math flag used in the 'select'
instruction is the same as the 'fabs' instruction after the transformation.

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

3 years ago[OpenMP][NVPTX] Disable OpenMPOpt when building deviceRTLs
Shilei Tian [Sun, 25 Jul 2021 14:38:15 +0000 (10:38 -0400)]
[OpenMP][NVPTX] Disable OpenMPOpt when building deviceRTLs

We build `deviceRTLs` with `-O1` by default, which also triggers OpenMPOpt. When
the info cache is created, some attributes are removed. As a result, although we
mark a few functions `noinline`, they are still inlined when the bitcode library
is generated. This can cause an issue in middle end optimization.

Reviewed By: jdoerfert

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