platform/upstream/llvm.git
3 years ago[CVP] @llvm.[us]{min,max}() intrinsics handling
Roman Lebedev [Sat, 10 Apr 2021 21:23:27 +0000 (00:23 +0300)]
[CVP] @llvm.[us]{min,max}() intrinsics handling

If we can tell that either one of the arguments is taken,
bypass the intrinsic.

Notably, we are indeed fine with non-strict predicate:
* UL: https://alive2.llvm.org/ce/z/69qVW9 https://alive2.llvm.org/ce/z/kNFTKf
      https://alive2.llvm.org/ce/z/AvaPw2 https://alive2.llvm.org/ce/z/oxo53i
* UG: https://alive2.llvm.org/ce/z/wxHeGH https://alive2.llvm.org/ce/z/Lf76qx
* SL: https://alive2.llvm.org/ce/z/hkeTGS https://alive2.llvm.org/ce/z/eR_b-W
* SG: https://alive2.llvm.org/ce/z/wEqRm7 https://alive2.llvm.org/ce/z/FpAsVr

Much like with all other comparison handling in CVP,
while we could sort-of handle two Value's,
at least for plain ICmpInst it does not appear to be worthwhile.

This only fires 78 times on test-suite + dt + rs,
but we don't canonicalize to these yet. (only SCEV produces them)

3 years ago[NFC][CVP] Add tests for @llvm.[us]{min,max}() intrinsics
Roman Lebedev [Sat, 10 Apr 2021 21:10:47 +0000 (00:10 +0300)]
[NFC][CVP] Add tests for @llvm.[us]{min,max}() intrinsics

3 years ago[IVUsers] Check LoopSimplify cache earlier (NFC)
Nikita Popov [Sat, 10 Apr 2021 20:17:35 +0000 (22:17 +0200)]
[IVUsers] Check LoopSimplify cache earlier (NFC)

Check the cache before calling isLoopSimplifyForm(). Otherwise we'd
always perform the check for the innermost loop and only skip it
for dominating loops.

3 years ago[CSSPGO] Fix dangling context strings and improve profile order consistency and error...
Wenlei He [Thu, 8 Apr 2021 06:06:39 +0000 (23:06 -0700)]
[CSSPGO] Fix dangling context strings and improve profile order consistency and error handling

This patch fixed the following issues along side with some refactoring:

1. Fix bugs where StringRef for context string out live the underlying std::string. We now keep string table in profile generator to hold std::strings. We also do the same for bracketed context strings in profile writer.
2. Make sure profile output strictly follow (total sample, name) order. Previously, there's inconsistency between ProfileMap's key and FunctionSamples's name, leading to inconsistent ordering. This is now fixed by introducing context profile canonicalization. Assertions are also added to make sure ProfileMap's key and FunctionSamples's name are always consistent.
3. Enhanced error handling for profile writing to make sure we bubble up errors properly for both llvm-profgen and llvm-profdata when string table is not populated correctly for extended binary profile.
4. Keep all internal context representation bracket free. This avoids creating new strings for context trimming, merging and preinline. getNameWithContext API is now simplied accordingly.
5. Factor out the code for context trimming and merging into SampleContextTrimmer in SampleProf.cpp. This enables llvm-profdata to use the trimmer when merging profiles. Changes in llvm-profgen will be in separate patch.

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

3 years ago[NFC][JumpThreading] Increment 'NumFolds' statistic all places terminator becomes...
Roman Lebedev [Sat, 10 Apr 2021 18:24:29 +0000 (21:24 +0300)]
[NFC][JumpThreading] Increment 'NumFolds' statistic all places terminator becomes uncond

3 years ago[NFC][CVP] Add statistic for function pointer argument non-null-ness deduction
Roman Lebedev [Sat, 10 Apr 2021 18:23:20 +0000 (21:23 +0300)]
[NFC][CVP] Add statistic for function pointer argument non-null-ness deduction

3 years ago[CVP] LVI: Use in-block values when checking value signedness domain
Roman Lebedev [Sat, 10 Apr 2021 18:05:17 +0000 (21:05 +0300)]
[CVP] LVI: Use in-block values when checking value signedness domain

This has a huge positive impact on all the folds that use these helpers,
as it can be seen on vanilla test-suite + rawspeed + darktable:
correlated-value-propagation.NumSRems             +75.68% (+ 28)
correlated-value-propagation.NumAShrs             +63.87% (+198)
correlated-value-propagation.NumSDivs             +49.42% (+127)
correlated-value-propagation.NumSExt              + 8.85% (+593)
correlated-value-propagation.NumUDivURemsNarrowed + 8.65% (+34)

... while having pretty minimal compile-time impact:
https://llvm-compile-time-tracker.com/compare.php?from=e8c7f43e2c2c6f3581ec1c6489ec21ad9f98958a&to=4cd197711e58ee1b2faeee0c35eea54540185569&stat=instructions

3 years ago[NFC][LVI] getPredicateAt(): drop default value for UseBlockValue
Roman Lebedev [Sat, 10 Apr 2021 17:45:37 +0000 (20:45 +0300)]
[NFC][LVI] getPredicateAt(): drop default value for UseBlockValue

The default is likely wrong.
Out of all the callees, only a single one needs to pass-in false (JumpThread),
everything else either already passes true, or should pass true.

Until the default is flipped, at least make it harder to unintentionally
add new callees with UseBlockValue=false.

3 years ago[NFC] Rename LimitingIntrinsic into MinMaxIntrinsic
Roman Lebedev [Sat, 10 Apr 2021 17:34:27 +0000 (20:34 +0300)]
[NFC] Rename LimitingIntrinsic into MinMaxIntrinsic

As requested in post-commit review

3 years ago[flang] Accept & fold IEEE_SELECTED_REAL_KIND
peter klausler [Wed, 7 Apr 2021 20:21:10 +0000 (13:21 -0700)]
[flang] Accept & fold IEEE_SELECTED_REAL_KIND

F18 supports the standard intrinsic function SELECTED_REAL_KIND
but not its synonym in the standard module IEEE_ARITHMETIC
named IEEE_SELECTED_REAL_KIND until this patch.

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

3 years ago[libtooling][clang-tidy] Fix off-by-one rendering issue with SourceRanges
Whisperity [Sat, 10 Apr 2021 16:48:22 +0000 (18:48 +0200)]
[libtooling][clang-tidy] Fix off-by-one rendering issue with SourceRanges

There was an off-by-one issue with calculating the *exact* end location
of token ranges (as given by SomeDecl->getSourceRange()) which resulted in:

  xxx(something)
      ^~~~~~~~   // Note the missing ~ under the last character.

In addition, a test is added to keep the behaviour in check in the future.

This patch hotfixes commit 3b677b81cec7b3c5132aee8fccc30252d87deb69.

3 years ago[NFC][ConstantRange] Add 'icmp' helper method
Roman Lebedev [Sat, 10 Apr 2021 16:37:59 +0000 (19:37 +0300)]
[NFC][ConstantRange] Add 'icmp' helper method

"Does the predicate hold between two ranges?"

Not very surprisingly, some places were already doing this check,
without explicitly naming the algorithm, cleanup them all.

3 years agoRevert "[NFC][ConstantRange] Add 'icmp' helper method"
Roman Lebedev [Sat, 10 Apr 2021 16:37:53 +0000 (19:37 +0300)]
Revert "[NFC][ConstantRange] Add 'icmp' helper method"

This reverts commit 17cf2c94230bc107e7294ef84fad3b47f4cd1b73.

3 years agoRevert "zz"
Roman Lebedev [Sat, 10 Apr 2021 16:37:16 +0000 (19:37 +0300)]
Revert "zz"

It wasn't meant to be committed, two commits should have been squashed.

This reverts commit 0c184154969c020db416bd7066af80ffd2a27ac4.

3 years ago[NFC][ConstantRange] Add 'icmp' helper method
Roman Lebedev [Sat, 10 Apr 2021 14:58:47 +0000 (17:58 +0300)]
[NFC][ConstantRange] Add 'icmp' helper method

"Does the predicate hold between two ranges?"

Not very surprisingly, some places were already doing this check,
without explicitly naming the algorithm, cleanup them all.

3 years agozz
Roman Lebedev [Sat, 10 Apr 2021 14:10:51 +0000 (17:10 +0300)]
zz

3 years ago[libtooling][clang-tidy] Fix diagnostics not highlighting fed SourceRanges
Whisperity [Mon, 15 Mar 2021 16:06:03 +0000 (17:06 +0100)]
[libtooling][clang-tidy] Fix diagnostics not highlighting fed SourceRanges

Fixes bug http://bugs.llvm.org/show_bug.cgi?id=49000.

This patch allows Clang-Tidy checks to do

    diag(X->getLocation(), "text") << Y->getSourceRange();

and get the highlight of `Y` as expected:

    warning: text [blah-blah]
        xxx(something)
        ^   ~~~~~~~~~

Reviewed-By: aaron.ballman, njames93
Differential Revision: http://reviews.llvm.org/D98635

3 years ago[CVP] @llvm.abs() handling
Roman Lebedev [Sat, 10 Apr 2021 12:52:28 +0000 (15:52 +0300)]
[CVP] @llvm.abs() handling

Iff we know the sigdness domain of the argument,
we can either skip @llvm.abs, or do negation directly.

Notably, INT_MIN can belong to either domain:
* X u<= INT_MIN --> X  is always fine
  https://alive2.llvm.org/ce/z/QB8j-C https://alive2.llvm.org/ce/z/7sFKpS
* X s<= 0 --> -X  is always fine
  https://alive2.llvm.org/ce/z/QbGSyq https://alive2.llvm.org/ce/z/APsN84

If all else fails, try to inferr NSW flag:
https://alive2.llvm.org/ce/z/qCJfYm

3 years ago[NFC][CVP] Add `@llvm.abs` test cases
Roman Lebedev [Sat, 10 Apr 2021 12:41:43 +0000 (15:41 +0300)]
[NFC][CVP] Add `@llvm.abs` test cases

3 years ago[Matrix] Implement C-style explicit type conversions for matrix types.
Saurabh Jha [Sat, 10 Apr 2021 09:25:34 +0000 (10:25 +0100)]
[Matrix] Implement C-style explicit type conversions for matrix types.

This implements C-style type conversions for matrix types, as specified
in clang/docs/MatrixTypes.rst.

Fixes PR47141.

Reviewed By: fhahn

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

3 years ago[RISCV][Clang] Add RVV vleff intrinsic functions.
Hsiangkai Wang [Fri, 9 Apr 2021 23:02:08 +0000 (07:02 +0800)]
[RISCV][Clang] Add RVV vleff intrinsic functions.

Reviewed By: craig.topper, liaolucy, jrtc27, khchen

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

3 years agoTemporairly revert "[CGCall] Annotate `this` argument with alignment"
Roman Lebedev [Sat, 10 Apr 2021 07:41:16 +0000 (10:41 +0300)]
Temporairly revert "[CGCall] Annotate `this` argument with alignment"

As per @jyknight, "It seems like there's a bug with vtable thunks getting the wrong information."
See https://reviews.llvm.org/D99790#2680857, https://godbolt.org/z/MxhYMe1q7

This reverts commit 0aa0458f1429372038ca6a4edc7e94c96cd9a753.

3 years ago[AMDGPU][CostModel] Refine cost model for control-flow instructions.
dfukalov [Tue, 16 Feb 2021 19:20:06 +0000 (22:20 +0300)]
[AMDGPU][CostModel] Refine cost model for control-flow instructions.

Added cost estimation for switch instruction, updated costs of branches, fixed
phi cost.
Had to increase `-amdgpu-unroll-threshold-if` default value since conditional
branch cost (size) was corrected to higher value.
Test renamed to "control-flow.ll".

Removed redundant code in `X86TTIImpl::getCFInstrCost()` and
`PPCTTIImpl::getCFInstrCost()`.

Reviewed By: rampitec

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

3 years ago[clang][AVR] Support variable decorator '__flash'
Ben Shi [Sat, 10 Apr 2021 03:23:55 +0000 (11:23 +0800)]
[clang][AVR] Support variable decorator '__flash'

Reviewed By: Anastasia

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

3 years agoSupport: Add move semantics to mapped_file_region
Duncan P. N. Exon Smith [Fri, 9 Apr 2021 01:43:21 +0000 (18:43 -0700)]
Support: Add move semantics to mapped_file_region

Update llvm::sys::fs::mapped_file_region to have a move constructor and
a move assignment operator, allowing it to be used as an Optional. Also,
update FileOutputBuffer's OnDiskBuffer to take advantage of this,
avoiding an extra allocation from the unique_ptr.

A nice follow-up would be to make the mapped_file_region constructor
private and replace its use with a factory function, such as
mapped_file_region::create(), that returns an Expected (or ErrorOr). I
don't plan on doing that immediately, but I might swing back later.

No functionality change, besides the saved allocation in OnDiskBuffer.

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

3 years ago[flang] RANDOM_NUMBER, RANDOM_SEED, RANDOM_INIT in runtime
peter klausler [Wed, 7 Apr 2021 20:14:14 +0000 (13:14 -0700)]
[flang] RANDOM_NUMBER, RANDOM_SEED, RANDOM_INIT in runtime

Add APIs, initial non-coarray implementations, and unit
tests for the intrinsic subroutines for pseudo-random
number generation.

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

3 years ago[lld-macho][nfc] Remove DYSYM8 reloc attribute
Jez Ng [Fri, 9 Apr 2021 23:47:10 +0000 (19:47 -0400)]
[lld-macho][nfc] Remove DYSYM8 reloc attribute

It's likely redundant, per discussion with @gkm. The BYTE8
attribute covers the bit width requirement already.

Reviewed By: #lld-macho, gkm

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

3 years ago[flang] Enforce a limit on recursive PDT instantiations
peter klausler [Wed, 7 Apr 2021 20:17:39 +0000 (13:17 -0700)]
[flang] Enforce a limit on recursive PDT instantiations

For pernicious test cases with explicit non-constant actual
type parameter expressions in components, e.g.:

  type :: t(k)
    integer, kind :: k
    type(t(k+1)), pointer :: p
  end type

we should detect the infinite recursion and complain rather
than looping until the stack overflows.

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

3 years agoRevert "[AMDGPU] Remove MachineDCE after SIFoldOperands"
Mitch Phillips [Fri, 9 Apr 2021 22:36:11 +0000 (15:36 -0700)]
Revert "[AMDGPU] Remove MachineDCE after SIFoldOperands"

This reverts commit 5a0117b2d0eaedffeeb393bd9915f11cccfe241b.

Reason: Dependent change d19a42eba98fe853dd52f7dc89d8cd2727c7fc1c broke
the ASan buildbots.

3 years agoRevert "[AMDGPU] SIFoldOperands: eagerly erase dead REG_SEQUENCEs"
Mitch Phillips [Fri, 9 Apr 2021 22:02:33 +0000 (15:02 -0700)]
Revert "[AMDGPU] SIFoldOperands: eagerly erase dead REG_SEQUENCEs"

This reverts commit d19a42eba98fe853dd52f7dc89d8cd2727c7fc1c.

Reason: Broke the ASan buildbots. See the original phabricator review
for more details: https://reviews.llvm.org/D100188

3 years ago[AArch64][GlobalISel] Swap compare operands when it may be profitable
Jessica Paquette [Mon, 9 Nov 2020 21:35:41 +0000 (13:35 -0800)]
[AArch64][GlobalISel] Swap compare operands when it may be profitable

This adds support for swapping comparison operands when it may introduce new
folding opportunities.

This is roughly the same as the code added to AArch64ISelLowering in
162435e7b5e026b9f988c730bb6527683f6aa853.

For an example of a testcase which exercises this, see
llvm/test/CodeGen/AArch64/swap-compare-operands.ll

(Godbolt for that testcase: https://godbolt.org/z/43WEMb)

The idea behind this is that sometimes, we may be able to fold away, say, a
shift or extend in a compare by swapping its operands.

e.g. in the case of this compare:

```
lsl x8, x0, #1
cmp x8, x1
cset w0, lt
```

The following is equivalent:

```
cmp x1, x0, lsl #1
cset w0, gt
```

Most of the code here is just a reimplementation of what already exists in
AArch64ISelLowering.

(See `getCmpOperandFoldingProfit` and `getAArch64Cmp` for the equivalent code.)

Note that most of the AND code in the testcase doesn't actually fold. It seems
like we're missing selection support for that sort of fold right now, since SDAG
happily folds these away (e.g testSwapCmpWithShiftedZeroExtend8_32 in the
original .ll testcase)

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

3 years ago[flang] Check for conflicting BIND(C) names
peter klausler [Wed, 7 Apr 2021 20:23:45 +0000 (13:23 -0700)]
[flang] Check for conflicting BIND(C) names

Check for two or more symbols that define a data object or entry point
with the same interoperable BIND(C) name.

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

3 years ago[Analysis] isDereferenceableAndAlignedPointer(): recurse into select's hands
Roman Lebedev [Fri, 9 Apr 2021 21:31:56 +0000 (00:31 +0300)]
[Analysis] isDereferenceableAndAlignedPointer(): recurse into select's hands

By doing this within the method itself,
we support traversing multiple levels of selects (TODO: PHI's),
fixing the SROA `std::clamp()` testcase.

Fixes https://bugs.llvm.org/show_bug.cgi?id=47271
Mostly fixes https://bugs.llvm.org/show_bug.cgi?id=49909

3 years ago[NFC][SROA] Add C++'s `std::clamp()` testcase from PR47271/PR49909
Roman Lebedev [Fri, 9 Apr 2021 21:26:18 +0000 (00:26 +0300)]
[NFC][SROA] Add C++'s `std::clamp()` testcase from PR47271/PR49909

3 years ago[ASan] Allow new/delete replacement by making interceptors weak
Mitch Phillips [Fri, 9 Apr 2021 20:46:24 +0000 (13:46 -0700)]
[ASan] Allow new/delete replacement by making interceptors weak

ASan declares these functions as strongly-defined, which results in
'duplicate symbol' errors when trying to replace them in user code when
linking the runtimes statically.

Reviewed By: eugenis

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

3 years ago[scudo][standalone] Use BatchClassId in drain rather than 0
Kostya Kortchinsky [Wed, 7 Apr 2021 19:39:24 +0000 (12:39 -0700)]
[scudo][standalone] Use BatchClassId in drain rather than 0

D99763 fixed `SizeClassAllocatorLocalCache::drain` but with the
assumption that `BatchClassId` is 0 - which is currently true. I would
rather not make the assumption so that if we ever change the ID of
the batch class, the loop would still work. Since `BatchClassId` is
used more often in `local_cache.h`, introduce a constant so that we
don't have to specify `SizeClassMap::` every time.

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

3 years agoRevert "[PowerPC] Add ROP Protection Instructions for PowerPC"
Mitch Phillips [Fri, 9 Apr 2021 20:32:12 +0000 (13:32 -0700)]
Revert "[PowerPC] Add ROP Protection Instructions for PowerPC"

This reverts commit 16fe741c69429235210c03c46420f8fa6aece4a1.

Reason: Broke the UBSan buildbots. More information available in the
phabricator review: https://reviews.llvm.org/D99375

3 years ago[mlir] NFC - Add help functions to scf.ForOp
Nicolas Vasilache [Fri, 9 Apr 2021 10:37:44 +0000 (10:37 +0000)]
[mlir] NFC - Add help functions to scf.ForOp

This revision adds 2 helperr functions that help tie OpOperands and
BlockArguments in scf.ForOp without having to use the internal implementation
details.

3 years ago[OpenMP51][DOCS] Claimed masked construct and report current patch, NFC.
cchen [Fri, 9 Apr 2021 20:21:13 +0000 (15:21 -0500)]
[OpenMP51][DOCS] Claimed masked construct and report current patch, NFC.

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

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

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

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

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

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

3 years ago[MSSA] Rename uses in IDF regardless of new def position in basic block.
Alina Sbirlea [Fri, 9 Apr 2021 06:56:34 +0000 (23:56 -0700)]
[MSSA] Rename uses in IDF regardless of new def position in basic block.

When inserting a new def and renaming of uses is asked, always compute
IDF and do the renaming for the blocks with Phis in that IDF.
Resolves PR49859.

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

3 years ago[libc++] NFC: Move unused include of <limits> to allocator_traits.h
Louis Dionne [Fri, 9 Apr 2021 19:19:42 +0000 (15:19 -0400)]
[libc++] NFC: Move unused include of <limits> to allocator_traits.h

The include should have been moved when I split allocator_traits.h out
of memory.

3 years ago[AMDGPU] Added udot2 op_sel test. NFC.
Stanislav Mekhanoshin [Fri, 9 Apr 2021 19:19:42 +0000 (12:19 -0700)]
[AMDGPU] Added udot2 op_sel test. NFC.

3 years agoAdd correct types to the xxsplti32dx pattern.
Stefan Pintilie [Fri, 9 Apr 2021 19:07:13 +0000 (14:07 -0500)]
Add correct types to the xxsplti32dx pattern.

Regiser types for xxsplti32dx for two td file patterns was incorrect.
Fixed the two types and added a test case that was reduced from a larger
failing test.

Reviewed By: nemanjai, #powerpc

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

3 years ago[LLDB][NFC] Add clarifying comments for AddCXXSummary and AddCXXSynthetic
Shafik Yaghmour [Fri, 9 Apr 2021 19:05:36 +0000 (12:05 -0700)]
[LLDB][NFC] Add clarifying comments for AddCXXSummary and AddCXXSynthetic

Adding comments to AddCXXSynthetic and AddCXXSummary to better explain what they are doing.

3 years ago[OpenMP51] Initial support for masked directive and filter clause
cchen [Fri, 9 Apr 2021 19:00:36 +0000 (14:00 -0500)]
[OpenMP51] Initial support for masked directive and filter clause

Adds basic parsing/sema/serialization support for the #pragma omp masked
directive.

Reviewed By: ABataev

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

3 years agoSupport: Remove code duplication for mapped_file_region accessors, NFC
Duncan P. N. Exon Smith [Fri, 9 Apr 2021 18:48:40 +0000 (11:48 -0700)]
Support: Remove code duplication for mapped_file_region accessors, NFC

3 years ago[libcxx] [test] Add more tests for renaming directories in fs.op.rename
Martin Storsjö [Tue, 23 Mar 2021 12:33:11 +0000 (14:33 +0200)]
[libcxx] [test] Add more tests for renaming directories in fs.op.rename

This was requested during the review of D98640.

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

3 years ago[libcxx] [test] Use GetWindowsInaccessibleDir() in a couple more tests
Martin Storsjö [Thu, 11 Mar 2021 13:01:58 +0000 (15:01 +0200)]
[libcxx] [test] Use GetWindowsInaccessibleDir() in a couple more tests

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

3 years ago[libcxx] [test] Use GetWindowsInaccessibleDir() instead of dirs with perms::none...
Martin Storsjö [Thu, 11 Mar 2021 19:42:13 +0000 (21:42 +0200)]
[libcxx] [test] Use GetWindowsInaccessibleDir() instead of dirs with perms::none in fs.op.is_*

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

3 years ago[WebAssembly] Add shuffles as an option for lowering BUILD_VECTOR
Thomas Lively [Fri, 9 Apr 2021 18:21:49 +0000 (11:21 -0700)]
[WebAssembly] Add shuffles as an option for lowering BUILD_VECTOR

When lowering a BUILD_VECTOR SDNode, we choose among various possible vector
creation instructions in an attempt to minimize the total number of instructions
used. We previously considered using swizzles, consts, and splats, and this
patch adds shuffles as well. A common pattern that now lowers to shuffles is
when two 64-bit vectors are concatenated. Previously, concatenations generally
lowered to sequences of extract_lane and replace_lane instructions when they
could have been a single shuffle.

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

3 years agoHandle alloc_size attribute on function pointers
Alex Richardson [Thu, 6 Dec 2018 12:22:08 +0000 (12:22 +0000)]
Handle alloc_size attribute on function pointers

I have been trying to statically find and analyze all calls to heap
allocation functions to determine how many of them use sizes known at
compile time vs only at runtime. While doing so I saw that quite a few
projects use replaceable function pointers for heap allocation and noticed
that clang was not able to annotate functions pointers with alloc_size.
I have changed the Sema checks to allow alloc_size on all function pointers
and typedefs for function pointers now and added checks that these
attributes are propagated to the LLVM IR correctly.

With this patch we can also compute __builtin_object_size() for calls to
allocation function pointers with the alloc_size attribute.

Reviewed By: aaron.ballman, erik.pilkington
Differential Revision: https://reviews.llvm.org/D55212

3 years ago[builtins] Avoid enum name conflicts with fenv.h
Alex Richardson [Fri, 9 Apr 2021 15:58:58 +0000 (16:58 +0100)]
[builtins] Avoid enum name conflicts with fenv.h

After a follow-up change (D98332) this header can be included the same time
as fenv.h when running the tests. To avoid enum members conflicting with
the macros/enums defined in the host fenv.h, prefix them with CRT_.

Reviewed By: peter.smith

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

3 years ago[TableGen] Report an error message on a missing comma
Alex Richardson [Fri, 9 Apr 2021 15:58:16 +0000 (16:58 +0100)]
[TableGen] Report an error message on a missing comma

I recently forgot a comma in a defm argument list and tablegen just
failed with exit code 1 without printing an error message. I believe
this issue was introduced in a9fc44c5573208859c2550382755098d750fc47d.

This change prints the following instead:
.../clang/include/clang/Driver/Options.td:569:3: error: Expected comma before next argument

Reviewed By: Paul-C-Anagnostopoulos

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

3 years ago[AArch64][GlobalISel] Fix incorrect codegen for <16 x s8> G_ASHR.
Amara Emerson [Fri, 9 Apr 2021 17:39:59 +0000 (10:39 -0700)]
[AArch64][GlobalISel] Fix incorrect codegen for <16 x s8> G_ASHR.

Fixes PR49904

3 years ago[PowerPC] Add ROP Protection Instructions for PowerPC
Stefan Pintilie [Fri, 9 Apr 2021 17:05:52 +0000 (12:05 -0500)]
[PowerPC] Add ROP Protection Instructions for PowerPC

There are four new PowerPC instructions that are introduced in
Power 10. They are hashst, hashchk, hashstp, hashchkp.

These instructions will be used for ROP Protection.
This patch adds the four instructions.

Reviewed By: nemanjai, amyk, #powerpc

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

3 years ago[RGT] Disable some tests on Windows at compile-time, not runtime
Paul Robinson [Fri, 9 Apr 2021 16:40:00 +0000 (09:40 -0700)]
[RGT] Disable some tests on Windows at compile-time, not runtime

These show up as un-executed on non-Windows hosts.

Found by the Rotten Green Tests project.

3 years agoUpdate the linkage name of coro-split functions in the debug info.
Adrian Prantl [Fri, 9 Apr 2021 16:48:33 +0000 (09:48 -0700)]
Update the linkage name of coro-split functions in the debug info.

This patch updates the linkage name in the DISubprogram of coro-split
functions, which is particularly important for Swift, where the
funclets have a special name mangling. This patch does not affect C++
coroutines, since the DW_AT_specification is expected to hold the
(original) linkage name. I believe this is mostly due to limitations
in AsmPrinter, so we might be able to relax this restriction in the
future.

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

3 years ago[PhaseOrdering] add test for llvm.expect; NFC
Sanjay Patel [Fri, 9 Apr 2021 15:52:47 +0000 (11:52 -0400)]
[PhaseOrdering] add test for llvm.expect; NFC

3 years ago[Flang] Changes to mangling code
Eric Schweitz [Mon, 5 Apr 2021 16:09:10 +0000 (17:09 +0100)]
[Flang] Changes to mangling code

Call static functions using the class name (fir::NameUniquer).
Add function for mangling derivedTypes.

All the name mangling functions that are ultimately called are
tested in unittests/Optimizer/InternalNamesTest.cpp.

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

3 years ago[InstCombine] Regenerate 2010-11-23-Distributed.ll tests
Simon Pilgrim [Fri, 9 Apr 2021 15:38:57 +0000 (16:38 +0100)]
[InstCombine] Regenerate 2010-11-23-Distributed.ll tests

3 years ago[clang] tests: cleanup, update and add some new ones
Matheus Izvekov [Tue, 23 Mar 2021 20:20:07 +0000 (21:20 +0100)]
[clang] tests: cleanup, update and add some new ones

This reworks a small set of tests, as preparatory work for implementing
P2266.
* Run for more standard versions, including c++2b.
* Normalize file names and run commands.
* Adds some extra tests.

New Coroutine tests taken from Aaron Puchert's D68845.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
Reviewed By: thakis

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

3 years ago[X86] Fold cmpeq/ne(or(X,Y),X) --> cmpeq/ne(and(~X,Y),0) on non-BMI targets (PR44136)
Simon Pilgrim [Fri, 9 Apr 2021 15:10:57 +0000 (16:10 +0100)]
[X86] Fold cmpeq/ne(or(X,Y),X) --> cmpeq/ne(and(~X,Y),0) on non-BMI targets (PR44136)

Followup to D100177, enable the fold for non-BMI targets as well.

3 years ago[RGT] Tweak test so assertion is always executed
Paul Robinson [Fri, 9 Apr 2021 15:03:44 +0000 (08:03 -0700)]
[RGT] Tweak test so assertion is always executed

Any given Windows system will have only one "system" encoding for
UTF-16 (BE or LE), so the assert for the other one would always
show up as rotten.  Use a common assertion for both paths to avoid
this.

3 years ago[MLIR][Shape] Combine `cstr_eq` only if they share shape operands
Frederik Gossen [Fri, 9 Apr 2021 14:51:34 +0000 (16:51 +0200)]
[MLIR][Shape] Combine `cstr_eq` only if they share shape operands

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

3 years ago[X86][BMI] Fold cmpeq/ne(or(X,Y),X) --> cmpeq/ne(and(~X,Y),0) (PR44136)
Simon Pilgrim [Fri, 9 Apr 2021 14:51:53 +0000 (15:51 +0100)]
[X86][BMI] Fold cmpeq/ne(or(X,Y),X) --> cmpeq/ne(and(~X,Y),0) (PR44136)

I've initially just enabled this for BMI which has the ANDN instruction for i32/i64 - the i16/i8 cases give an idea of what'd we get when we enable it in all cases (I'll do this as a later commit).

Additionally, the i16/i8 cases could be freely promoted to i32 (as the args are already zeroext) and we could then make use of ANDN + the free cmp0 there as well - this has come up in PR48768 and PR49028 so I'm going to look at this soon.

https://alive2.llvm.org/ce/z/QVWHP_
https://alive2.llvm.org/ce/z/pLngT-

Vector cases do not appear to benefit from this as we end up with having to generate the zero vector as well - this is one of the reasons I didn't try to tie this into hasAndNot/hasAndNotCompare.

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

3 years ago[libc++] Fix abs and div overload issue for compilers on AIX
jasonliu [Thu, 8 Apr 2021 21:48:42 +0000 (21:48 +0000)]
[libc++] Fix abs and div overload issue for compilers on AIX

Summary:
AIX system's stdlib.h provide different overload of abs and div
depending on compiler versions.

For example, std::div(long, long) and std::abs(long) are not available
from OS's stdlib.h when building with clang, but they are available
when building with xlclang compiler.

Therefore, we need to provide those extra overloads in libc++'s stdlib.h
when OS's stdlib.h does not.

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

3 years ago[HIP] Workaround ICE compiling SemaChecking.cpp with gcc 5
Yaxun (Sam) Liu [Fri, 9 Apr 2021 14:39:23 +0000 (10:39 -0400)]
[HIP] Workaround ICE compiling SemaChecking.cpp with gcc 5

Change-Id: I6c6213bc6b90365bfb78636ce7fb0700a58807cf

3 years ago[InstCombine] try to eliminate an instruction in min/max -> abs fold
Sanjay Patel [Fri, 9 Apr 2021 13:58:16 +0000 (09:58 -0400)]
[InstCombine] try to eliminate an instruction in min/max -> abs fold

As suggested in the review thread for 5094e12 and seen in the
motivating example from https://llvm.org/PR49885, it's not
clear if we have a way to create the optimal code without
this heuristic.

3 years ago[InstCombine] add test with multiple uses of min/max negated operand; NFC
Sanjay Patel [Fri, 9 Apr 2021 13:47:00 +0000 (09:47 -0400)]
[InstCombine] add test with multiple uses of min/max negated operand; NFC

3 years agoRISCVABIInfo::classifyArgumentType: Fix static analyzer warnings with uninitialized...
Soumi Manna [Fri, 9 Apr 2021 14:23:32 +0000 (15:23 +0100)]
RISCVABIInfo::classifyArgumentType: Fix static analyzer warnings with uninitialized variables warnings - NFCI

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

3 years ago[X86] Add zeroext attributes to i8/i16 and/or/xor overflow tests
Simon Pilgrim [Fri, 9 Apr 2021 14:00:56 +0000 (15:00 +0100)]
[X86] Add zeroext attributes to i8/i16 and/or/xor overflow tests

Matches original c/c++ test cases

3 years ago[clangd] Log a message when gRPC support is off, but remote-index is configured
Kadir Cetinkaya [Thu, 8 Apr 2021 13:37:32 +0000 (15:37 +0200)]
[clangd] Log a message when gRPC support is off, but remote-index is configured

Before this change clangd would emit a diagnostic whenever remote-index
was configured but binary didn't have grpc support.

This can be annoying when projects are configuring remote-index through their
configs but developers have a clangd binary without the support.

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

3 years ago[TableGen] [docs] Change title of tblgen.rst to fix man page filename
Paul C. Anagnostopoulos [Fri, 9 Apr 2021 13:35:52 +0000 (09:35 -0400)]
[TableGen] [docs] Change title of tblgen.rst to fix man page filename

3 years ago[AMDGPU] Allow relaxed/consume memory order for atomic inc/dec
Yaxun (Sam) Liu [Thu, 8 Apr 2021 21:44:29 +0000 (17:44 -0400)]
[AMDGPU] Allow relaxed/consume memory order for atomic inc/dec

Reviewed by: Jon Chesterfield

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

3 years agoFor non-null pointer checks, do not descend through out-of-bounds GEPs
Momchil Velikov [Fri, 9 Apr 2021 12:54:39 +0000 (13:54 +0100)]
For non-null pointer checks, do not descend through out-of-bounds GEPs

In LazyValueInfoImpl::isNonNullAtEndOfBlock we populate a set of
pointers, known to be non-null at the end of a block (e.g. because we
did a load through them). We then infer that any pointer, based on an
element of this set is non-null as well ("based" here meaning a
non-null pointer is the underlying object). This is incorrect, even if
the base pointer was non-null, the value of a GEP, that lacks the
inbounds` attribute, may be null.

This issue appeared as miscompilation of the following test case:

int puts(const char *);

typedef struct iter {
  int *val;
} iter_t;

static long distance(iter_t first, iter_t last) {
  long r = 0;
  for (; first.val != last.val; first.val++)
    ++r;
  return r;
}

int main() {
  int arr[2] = {0};
  iter_t i, j;
  i.val = arr;
  j.val = arr + 1;
  if (distance(i, j) >= 2)
    puts("failed");
  else
    puts("passed");
}

This fixes PR49662.

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

3 years ago[AMDGPU] SIFoldOperands: eagerly delete dead copies
Jay Foad [Thu, 8 Apr 2021 15:07:49 +0000 (16:07 +0100)]
[AMDGPU] SIFoldOperands: eagerly delete dead copies

This is cheap to implement, means less work for future passes like
MachineDCE, and slightly improves the folding in some cases.

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

3 years ago[X86] Adjust PR44136 tests to add cmpne coverage as well
Simon Pilgrim [Fri, 9 Apr 2021 12:42:18 +0000 (13:42 +0100)]
[X86] Adjust PR44136 tests to add cmpne coverage as well

Alive2: https://alive2.llvm.org/ce/z/pLngT-

3 years ago[clang] Tiny format fix
Nathan Sidwell [Thu, 8 Apr 2021 17:17:14 +0000 (10:17 -0700)]
[clang] Tiny format fix

Misindented close brace.

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

3 years ago[PowerPC, test] Fix use of undef FileCheck var
Thomas Preud'homme [Mon, 5 Apr 2021 10:28:35 +0000 (11:28 +0100)]
[PowerPC, test] Fix use of undef FileCheck var

LLVM test CodeGen/PowerPC/ctrloops-softfloat.ll tries to check for the
absence of sequences of instructions with several CHECK-NOT with one of
those directives using a variable defined in another. However CHECK-NOT
are checked independently so that is using a variable defined in a
pattern that should not occur in the input.

This commit changes occurence of the variable for the regex used in its
definition, thereby making each CHECK-NOT independent.

Reviewed By: nemanjai

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

3 years ago[PowerPC, test] Fix use of undef FileCheck var
Thomas Preud'homme [Sun, 4 Apr 2021 23:07:35 +0000 (00:07 +0100)]
[PowerPC, test] Fix use of undef FileCheck var

Commit 6ad3d05b681b36f6ecc98523257d154053e4116d disables the definition
of CSR that a follow-up CHECK-NOT directive depends on. This commit
replaces the undefined CSR variable use by the regex used to define it.

Reviewed By: nemanjai

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

3 years ago[clangd] Add --check-lines to restrict --check to specific lines
Adam Czachorowski [Thu, 18 Mar 2021 20:14:02 +0000 (21:14 +0100)]
[clangd] Add --check-lines to restrict --check to specific lines

This will allow us to add code completion, which is too expensive at
every token, to --check too.

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

3 years ago[PowerPC, test] Fix use of undef FileCheck var
Thomas Preud'homme [Sun, 4 Apr 2021 22:58:18 +0000 (23:58 +0100)]
[PowerPC, test] Fix use of undef FileCheck var

Commit 6646033e6e759657b6122fde64844fd28a2c9635 removed the definition
of variable RESULT used in two CHECK-NOT directives in LLVM test
CodeGen/PowerPC/ppc64-i128-abi.ll. This commit replaces the uses by the
regex that was used to define that variable.

Reviewed By: nemanjai

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

3 years ago[OpenCL] Simplify InsertOCLBuiltinDeclarationsFromTable
Sven van Haastregt [Fri, 9 Apr 2021 10:54:15 +0000 (11:54 +0100)]
[OpenCL] Simplify InsertOCLBuiltinDeclarationsFromTable

 - Use a range-based for loop.  This will help a later patch to skip
   prototypes that use an unavailable return type or argument type.

 - Replace a dyn_cast with a cast, as we are only dealing with
   FunctionProtoType Types here.

3 years ago[X86] Add PR44136 test coverage
Simon Pilgrim [Fri, 9 Apr 2021 10:31:29 +0000 (11:31 +0100)]
[X86] Add PR44136 test coverage

3 years ago[AMDGPU] Use SIInstrFlags for flat variants. NFC
Sebastian Neubauer [Tue, 30 Mar 2021 12:38:07 +0000 (14:38 +0200)]
[AMDGPU] Use SIInstrFlags for flat variants. NFC

Use SIInstrFlags to differentiate between the different
variants of flat instructions (flat, global and scratch).
This should make it easier to bundle the immediate offset logic in a
single place and implement restrictions and bug workarounds.

Fixed version of D99587, which does not rely on the address space.

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

3 years ago[AA][NFC] Convert AliasResult to class containing offset for PartialAlias case.
dfukalov [Tue, 16 Mar 2021 13:36:17 +0000 (16:36 +0300)]
[AA][NFC] Convert AliasResult to class containing offset for PartialAlias case.

Add an ability to store `Offset` between partially aliased location. Use this
storage within returned `ResultAlias` instead of caching it in `AAQueryInfo`.

Reviewed By: asbirlea

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

3 years ago[MLIR][Shape] Add convenience builder for `shape.assuming_all`
Frederik Gossen [Fri, 9 Apr 2021 10:13:10 +0000 (12:13 +0200)]
[MLIR][Shape] Add convenience builder for `shape.assuming_all`

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

3 years ago[NFC][AA] Prepare to convert AliasResult to class with PartialAlias offset.
dfukalov [Fri, 5 Mar 2021 10:58:13 +0000 (13:58 +0300)]
[NFC][AA] Prepare to convert AliasResult to class with PartialAlias offset.

Main reason is preparation to transform AliasResult to class that contains
offset for PartialAlias case.

Reviewed By: asbirlea

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

3 years ago[X86] combineHorizOpWithShuffle - peek through one use bitcasts when decoding shuffles.
Simon Pilgrim [Thu, 8 Apr 2021 13:49:31 +0000 (14:49 +0100)]
[X86] combineHorizOpWithShuffle - peek through one use bitcasts when decoding shuffles.

Checking for one use, peek through bitcasts of the horizop args to allows us to merge shuffles of different widths through the horizop.

3 years ago[MLIR][Shape] Canonicalize `assuming_all` when all operands are `cstr_eq` ops
Frederik Gossen [Fri, 9 Apr 2021 09:00:01 +0000 (11:00 +0200)]
[MLIR][Shape] Canonicalize `assuming_all` when all operands are `cstr_eq` ops

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

3 years ago[FunctionAttrs] Force old pm in test so it doens't behave differently depending on...
Benjamin Kramer [Fri, 9 Apr 2021 09:46:19 +0000 (11:46 +0200)]
[FunctionAttrs] Force old pm in test so it doens't behave differently depending on the configuration setting for this flag

3 years ago[NFC] Move statictic increment out of helper
Max Kazantsev [Fri, 9 Apr 2021 09:32:01 +0000 (16:32 +0700)]
[NFC] Move statictic increment out of helper

3 years ago[RegisterScavenging] Add asserts for better errors
Sebastian Neubauer [Thu, 8 Apr 2021 14:27:46 +0000 (16:27 +0200)]
[RegisterScavenging] Add asserts for better errors

These cases were failing before, but with cryptic asserts.
Add asserts in the RegScavenger that fail earlier with better
messages. NFC

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

3 years ago[AMDGPU] IsFlatScratch/Global -> FlatScratch/Global
Sebastian Neubauer [Fri, 9 Apr 2021 09:20:15 +0000 (11:20 +0200)]
[AMDGPU] IsFlatScratch/Global -> FlatScratch/Global

Remove 'Is' from IsFlatScratch/Global. NFC

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

3 years ago[GVN][NFC] Factor out load elimination logic via PRE for reuse
Max Kazantsev [Fri, 9 Apr 2021 08:22:47 +0000 (15:22 +0700)]
[GVN][NFC] Factor out load elimination logic via PRE for reuse

3 years ago[MLIR] Do not yield values from an assuming op that are never used
Frederik Gossen [Thu, 8 Apr 2021 09:21:50 +0000 (11:21 +0200)]
[MLIR] Do not yield values from an assuming op that are never used

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

3 years ago[RISCV][NFC] Replace explicit type i64 with riscv customized SDTypeProfile.
Jim Lin [Fri, 9 Apr 2021 09:01:48 +0000 (17:01 +0800)]
[RISCV][NFC] Replace explicit type i64 with riscv customized SDTypeProfile.

New SDTypeProfile can be reused for other word operation patterns without explicit i64 type in the future.

Reviewed By: craig.topper

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

3 years ago[test, LoopVectorize] Fix use of var defined in CHECK-NOT
Thomas Preud'homme [Sun, 28 Mar 2021 00:03:37 +0000 (00:03 +0000)]
[test, LoopVectorize] Fix use of var defined in CHECK-NOT

LLVM test Transforms/LoopVectorize/pr34681.ll tries to check for the
absence of a sequence of instructions with several CHECK-NOT with one of
those directives using a variable defined in another. However CHECK-NOT
are checked independently so that is using a variable defined in a
pattern that should not occur in the input.

This commit only checks for the absence of icmp ne 1 which rules out the
presence of the whole sequence and does not involve an undefined
variable.

Reviewed By: fhahn

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