platform/upstream/llvm.git
3 years ago[BasicAA] Add test for single arg phi in loop (NFC)
Nikita Popov [Sun, 14 Feb 2021 17:44:38 +0000 (18:44 +0100)]
[BasicAA] Add test for single arg phi in loop (NFC)

3 years ago[ARM] A couple of small MVE reduction tests from intrinsics. NFC
David Green [Sun, 14 Feb 2021 18:26:22 +0000 (18:26 +0000)]
[ARM] A couple of small MVE reduction tests from intrinsics. NFC

Also added a PhaseOrdering test, to make sure they are not broken by
VectorCombine cost changes.

3 years ago[AMDGPU] Limit memory scope for scratch, LDS and GDS
Tony Tye [Sat, 13 Feb 2021 08:43:48 +0000 (08:43 +0000)]
[AMDGPU] Limit memory scope for scratch, LDS and GDS

Changes for AMD GPU SIMemoryLegalizer:

- Limit the memory scope to maximum supported by the scratch, LDS and
  GDS address spaces.

- Improve assertion checking.

- Correct toSIAtomicScope argument name.

Reviewed By: rampitec

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

3 years ago[AMDGPU] Fix build breakage
Kazu Hirata [Sun, 14 Feb 2021 17:02:54 +0000 (09:02 -0800)]
[AMDGPU] Fix build breakage

3 years ago[ARM] Add some tests for MVE lane interleaving. NFC
David Green [Sun, 14 Feb 2021 16:51:18 +0000 (16:51 +0000)]
[ARM] Add some tests for MVE lane interleaving. NFC

3 years ago[llvm] Use llvm::is_contained (NFC)
Kazu Hirata [Sun, 14 Feb 2021 16:36:20 +0000 (08:36 -0800)]
[llvm] Use llvm::is_contained (NFC)

3 years ago[llvm] Fix header guards (NFC)
Kazu Hirata [Sun, 14 Feb 2021 16:36:16 +0000 (08:36 -0800)]
[llvm] Fix header guards (NFC)

Identified with llvm-header-guard.

3 years ago[Analysis] Use ListSeparator (NFC)
Kazu Hirata [Sun, 14 Feb 2021 16:36:14 +0000 (08:36 -0800)]
[Analysis] Use ListSeparator (NFC)

3 years ago[BasicAA] Avoid duplicate query for GEPs with identical offsets (NFCI)
Nikita Popov [Sat, 13 Feb 2021 22:43:57 +0000 (23:43 +0100)]
[BasicAA] Avoid duplicate query for GEPs with identical offsets (NFCI)

For two GEPs with identical offsets, we currently first perform
a base address query without size information, and then if it is
MayAlias, perform another with size information. This is pointless,
as the latter query should produce strictly better results.

This was not quite true historically due to the way that NoAlias
assumptions were handled, but that issue has since been resolved.

3 years ago[BasicAA] Use index difference to detect GEPs with identical indexes
Nikita Popov [Sun, 14 Feb 2021 14:55:53 +0000 (15:55 +0100)]
[BasicAA] Use index difference to detect GEPs with identical indexes

We currently detect GEPs that have exactly the same indexes by
comparing the Offsets and VarIndices. However, the latter implicitly
performs equality comparisons between two values, which is not
generally legal inside BasicAA, due to the possibility of comparisons
across phi cycles.

I believe that in this particular instance this actually ends up being
unproblematic, at least I wasn't able to come up with any cases that
could result in an incorrect root query result.

In the interest of being defensive, compute GetIndexDifference earlier
(which knows how to handle phi cycles properly) and use the result of
that to determine whether the offsets are identical.

3 years ago[mlir][Linalg] Fix constant detection in linalg.pad_tensor vectorization.
Nicolas Vasilache [Sun, 14 Feb 2021 15:53:13 +0000 (15:53 +0000)]
[mlir][Linalg] Fix constant detection in linalg.pad_tensor vectorization.

3 years ago[ValueTracking] Dereferenced pointers are noundef
aqjune [Sat, 13 Feb 2021 07:22:25 +0000 (16:22 +0900)]
[ValueTracking] Dereferenced pointers are noundef

This is a follow-up of D95238's LangRef update.
This patch updates `programUndefinedIfUndefOrPoison(V)` to return true if
`V` is used by any memory-accessing instruction.
Interestingly, this affected many tests in Attributors, mainly about adding noundefs.
The tests are updated using llvm/utils/update_test_checks.py. I checked that the diffs
are about updating noundefs.

Reviewed By: nikic

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

3 years ago[ASTMatchers] Clarify example in docs
Stephen Kelly [Sun, 14 Feb 2021 13:45:56 +0000 (13:45 +0000)]
[ASTMatchers] Clarify example in docs

3 years ago[InstCombine] fold fdiv with pow divisor (PR49147)
Sanjay Patel [Sun, 14 Feb 2021 13:06:15 +0000 (08:06 -0500)]
[InstCombine] fold fdiv with pow divisor (PR49147)

This is unusual in the general (non-reciprocal) case because we need
an extra instruction, but that should be better for general FP
reassociation and codegen. We conservatively check for "arcp" FMF
here as we do with existing fdiv folds, but it is not strictly
necessary to have that.

This is part of solving:
https://llvm.org/PR49147
(The powi variant potentially has a different constraint.)

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

3 years ago[InstCombine] Add nonnull(select c, null, p) tests (NFC)
Juneyoung Lee [Sun, 14 Feb 2021 13:03:15 +0000 (22:03 +0900)]
[InstCombine] Add nonnull(select c, null, p) tests (NFC)

3 years ago[LoopVectorize] Fix VPRecipeBuilder::createEdgeMask to correctly generate the mask
Juneyoung Lee [Tue, 9 Feb 2021 05:06:17 +0000 (14:06 +0900)]
[LoopVectorize] Fix VPRecipeBuilder::createEdgeMask to correctly generate the mask

This patch fixes pr48832 by correctly generating the mask when a poison value is involved.

Consider this CFG (which is a part of the input):

```
for.body:                                         ; preds = %for.cond
  br i1 true, label %cond.false, label %land.rhs

land.rhs:                                         ; preds = %for.body
  br i1 poison, label %cond.end, label %cond.false

cond.false:                                       ; preds = %for.body, %land.rhs
  br label %cond.end

cond.end:                                         ; preds = %land.rhs, %cond.false
  %cond = phi i32 [ 0, %cond.false ], [ 1, %land.rhs ]

```

The path for.body -> land.rhs -> cond.end should be taken when 'select i1 false, i1 poison, i1 false' holds (which means it's never taken); but VPRecipeBuilder::createEdgeMask was emitting 'and i1 false, poison' instead.
The former one successfully blocks poison propagation whereas the latter one doesn't, making the condition poison and thus causing the miscompilation.

SimplifyCFG has a similar bug (which didn't expose a real-world bug yet), and a patch for this is also ongoing (see https://reviews.llvm.org/D95026).

Reviewed By: bjope

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

3 years ago[Polly] Test all optimization levels.
Michael Kruse [Sun, 14 Feb 2021 06:31:10 +0000 (00:31 -0600)]
[Polly] Test all optimization levels.

3 years ago[CodeGen] Use range-based for loops (NFC)
Kazu Hirata [Sun, 14 Feb 2021 04:41:39 +0000 (20:41 -0800)]
[CodeGen] Use range-based for loops (NFC)

3 years ago[Analysis] Drop unnecessary const from return types (NFC)
Kazu Hirata [Sun, 14 Feb 2021 04:41:38 +0000 (20:41 -0800)]
[Analysis] Drop unnecessary const from return types (NFC)

Identified with readability-const-return-type.

3 years ago[TableGen] Use ListSeparator (NFC)
Kazu Hirata [Sun, 14 Feb 2021 04:41:36 +0000 (20:41 -0800)]
[TableGen] Use ListSeparator (NFC)

3 years ago[AVR] Fix a bug in 16-bit shifts
Ben Shi [Sun, 14 Feb 2021 03:54:55 +0000 (11:54 +0800)]
[AVR] Fix a bug in 16-bit shifts

Reviewed By: aykevl

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

3 years ago[gold] Add case being tested by equivalent lld test
Teresa Johnson [Sun, 14 Feb 2021 01:09:56 +0000 (17:09 -0800)]
[gold] Add case being tested by equivalent lld test

The new tests added by 1487747e990ce9f8851f3d92c3006a74134d7518 for lld
and gold plugin were largely equivalent, but the gold one was missing
one of the cases added to lld. Add that test to the gold plugin version.

3 years ago[lld] Reorder cases in test to match comments (NFC)
Teresa Johnson [Sun, 14 Feb 2021 00:32:39 +0000 (16:32 -0800)]
[lld] Reorder cases in test to match comments (NFC)

The test added in 1487747e990ce9f8851f3d92c3006a74134d7518 had a few
cases that were out of order compared to the comments. Reordered to
match.

3 years ago[LTT] Address post-review comments (NFC)
Teresa Johnson [Thu, 11 Feb 2021 03:07:51 +0000 (19:07 -0800)]
[LTT] Address post-review comments (NFC)

Implement some post-review cleanup suggestions for D96083.

3 years ago[Clang] Ensure vector predication loop metadata is always emitted when pragma is...
Malhar [Sat, 13 Feb 2021 21:57:21 +0000 (15:57 -0600)]
[Clang] Ensure vector predication loop metadata is always emitted when pragma is specified.

This patch ensures that vector predication and vectorization width
pragmas work together correctly/as expected. Specifically, this patch
fixes the issue that when vectorization_width > 1, the vector
predication behaviour (this would matter if it has NOT been disabled
explicitly by a pragma) was getting ignored, which was incorrect.

The fix here removes the dependence of vector predication on the
vectorization width. The loop metadata corresponding to clang loop
pragma vectorize_predicate is always emitted, if the pragma is
specified, even if vectorization is disabled by vectorize_width(1)
or vectorize(disable) since the option is also used for interleaving
by the LoopVectorize pass.

Reviewed By: dmgreen, Meinersbur

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

3 years agoELFObjectWriter: Simplify
Fangrui Song [Sat, 13 Feb 2021 22:52:30 +0000 (14:52 -0800)]
ELFObjectWriter: Simplify

* Delete unused ELFSymbolData::operator<
* Inline createStringTable
* Fix a comment
* Change align to return uint64_t

3 years ago[CMake][mlir] Fix mlir-linalg-ods-gen/CMakeLists.txt after D96645
Fangrui Song [Sat, 13 Feb 2021 22:16:38 +0000 (14:16 -0800)]
[CMake][mlir] Fix mlir-linalg-ods-gen/CMakeLists.txt after D96645

3 years ago[RISCV] Rename the RVVBaseAddr ComplexPattern to just BaseAddr and use it to merge...
Craig Topper [Sat, 13 Feb 2021 08:42:25 +0000 (00:42 -0800)]
[RISCV] Rename the RVVBaseAddr ComplexPattern to just BaseAddr and use it to merge some scalar load/store patterns too.

3 years agoELFObjectWriter: Delete redundant registerSymbol
Fangrui Song [Sat, 13 Feb 2021 20:01:37 +0000 (12:01 -0800)]
ELFObjectWriter: Delete redundant registerSymbol

MCELFStreamer::changeSection has registered the group signature symbol.

3 years agofix linalg ods gen cross compiling like other gen executables
daquexian [Sat, 13 Feb 2021 17:15:47 +0000 (17:15 +0000)]
fix linalg ods gen cross compiling like other gen executables

Signed-off-by: daquexian <daquexian566@gmail.com>
Reviewed By: vinograd47

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

3 years ago[lldb][test] Fix Shell/SymbolFile/symbol-binding.test
Fangrui Song [Sat, 13 Feb 2021 19:10:29 +0000 (11:10 -0800)]
[lldb][test] Fix Shell/SymbolFile/symbol-binding.test

3 years agoELFObjectWriter: Don't sort non-local symbols
Fangrui Song [Sat, 13 Feb 2021 18:32:27 +0000 (10:32 -0800)]
ELFObjectWriter: Don't sort non-local symbols

As we don't sort local symbols, don't sort non-local symbols.  This makes
non-local symbols appear in their register order, which matches GNU as. The
register order is nice in that you can write tests with interleaved CHECK
prefixes, e.g.

```
// CHECK: something about foo
.globl foo
foo:
// CHECK: something about bar
.globl bar
bar:
```

With the lexicographical order, the user needs to place lexicographical smallest
symbol first or keep CHECK prefixes in one place.

3 years ago[InstCombine] add tests for pow() divisor; NFC
Sanjay Patel [Sat, 13 Feb 2021 16:00:55 +0000 (11:00 -0500)]
[InstCombine] add tests for pow() divisor; NFC

3 years ago[pstl] Iterator types renaming: ForwardIterator -> RandomAccessIterator; for parallel...
Mikhail Dvorskiy [Sat, 13 Feb 2021 17:28:50 +0000 (20:28 +0300)]
[pstl] Iterator types renaming: ForwardIterator -> RandomAccessIterator; for parallel patterns/bricks

https://reviews.llvm.org/D96266

3 years ago[IRBuilder] Remove Align-related deprecated APIs
Nikita Popov [Sat, 13 Feb 2021 15:39:44 +0000 (16:39 +0100)]
[IRBuilder] Remove Align-related deprecated APIs

This removes IRBuilder methods accepting unsigned alignments
in favor of their Align/MaybeAlign variants. These methods have
been deprecated for more than a year at this point, so they
should be safe to remove.

3 years ago[ARM] Fix duplicate fdiv tests, changing them to frem. NFC
David Green [Sat, 13 Feb 2021 15:16:11 +0000 (15:16 +0000)]
[ARM] Fix duplicate fdiv tests, changing them to frem. NFC

3 years ago[ARM] Extra vector shuffle tests of various kinds. NFC
David Green [Sat, 13 Feb 2021 14:16:50 +0000 (14:16 +0000)]
[ARM] Extra vector shuffle tests of various kinds. NFC

3 years ago[DAG] Fold i1/vXi1 saddsat/uaddsat(x,y) -> or(x,y)
Simon Pilgrim [Sat, 13 Feb 2021 15:01:48 +0000 (15:01 +0000)]
[DAG] Fold i1/vXi1 saddsat/uaddsat(x,y) -> or(x,y)

Alive2: https://alive2.llvm.org/ce/z/FzcrpH

3 years ago[NFC][Docs] Fix RAVFrontendAction doc's CMakeLists.txt for shared build
Shivam Gupta [Sat, 13 Feb 2021 14:18:49 +0000 (19:48 +0530)]
[NFC][Docs] Fix RAVFrontendAction doc's CMakeLists.txt for shared build

It should fix following error:

  Undefined symbols for architecture x86_64:
    "llvm::outs()", referenced from:
        FindNamedClassVisitor::VisitCXXRecordDecl(clang::CXXRecordDecl*) in FindClassDecls.cpp.o

3 years ago[clangd] Retire clang-tidy-checks flag.
Nathan James [Sat, 13 Feb 2021 14:14:21 +0000 (14:14 +0000)]
[clangd] Retire clang-tidy-checks flag.

In clangd-12 the ability to override what clang tidy checks should run was moved into config.
For the 13 release its a wise progression to remove the command line option for this.

Reviewed By: sammccall

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

3 years ago[clang-tidy] Simplify inaccurate erase check
Stephen Kelly [Sun, 3 Jan 2021 16:43:54 +0000 (16:43 +0000)]
[clang-tidy] Simplify inaccurate erase check

The normalization of matchers means that this now works in all language
modes.

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

3 years ago[clang-tidy] Simplify static assert check
Stephen Kelly [Mon, 28 Dec 2020 01:18:54 +0000 (01:18 +0000)]
[clang-tidy] Simplify static assert check

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

3 years ago[DAG] Fold i1/vXi1 ssubsat/usubsat(x,y) -> and(x,~y)
Simon Pilgrim [Sat, 13 Feb 2021 13:21:15 +0000 (13:21 +0000)]
[DAG] Fold i1/vXi1 ssubsat/usubsat(x,y) -> and(x,~y)

Alive2: https://alive2.llvm.org/ce/z/4nkNGh

3 years ago[DAG] PromoteIntRes_ADDSUBSHLSAT - use promoted ISD::USUBSAT directly
Simon Pilgrim [Sat, 13 Feb 2021 12:34:56 +0000 (12:34 +0000)]
[DAG] PromoteIntRes_ADDSUBSHLSAT - use promoted ISD::USUBSAT directly

As discussed on D96413, as long as the promoted bits of the args are zero we can use the basic ISD::USUBSAT pattern directly, without the shifting like we do for other ops.

I think something similar should be possible for ISD::UADDSAT as well, which I'll look at later.

Also, create a ISD::USUBSAT node directly - this will be expanded back by the legalizer later on if necessary.

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

3 years ago[clangd] Fix unsued private field warning
Kadir Cetinkaya [Sat, 13 Feb 2021 12:20:15 +0000 (13:20 +0100)]
[clangd] Fix unsued private field warning

3 years agoreland [InstCombine] convert assumes to operand bundles
Tyker [Tue, 9 Feb 2021 18:20:50 +0000 (19:20 +0100)]
reland [InstCombine] convert assumes to operand bundles

Instcombine will convert the nonnull and alignment assumption that use the boolean condtion
to an assumption that uses the operand bundles when knowledge retention is enabled.

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

3 years ago[DAG] Fix shift amount limit in SimplifyDemandedBits trunc(shift(x,c)) to truncated...
Simon Pilgrim [Sat, 13 Feb 2021 11:59:52 +0000 (11:59 +0000)]
[DAG] Fix shift amount limit in SimplifyDemandedBits trunc(shift(x,c)) to truncated bitwidth

We lost this in D56387/rG69bc0990a9181e6eb86228276d2f59435a7fae67 - where I got the src/dst bitwidths mixed up and assumed getValidShiftAmountConstant would catch it.

Patch by @craig.topper - confirmed by @Carrot that it fixes PR49162

3 years ago[WebAssemblly] Fix rethrow's argument computation
Heejin Ahn [Thu, 11 Feb 2021 19:05:41 +0000 (11:05 -0800)]
[WebAssemblly] Fix rethrow's argument computation

Previously we assumed `rethrow`'s argument was always 0, but it turned
out `rethrow` follows the same rule with `br` or `delegate`:
https://github.com/WebAssembly/exception-handling/pull/137
https://github.com/WebAssembly/exception-handling/issues/146#issuecomment-777349038

Currently `rethrow`s generated by our backend always rethrow the
exception caught by the innermost enclosing catch, so this adds a
function to compute that and replaces `rethrow`'s argument with its
computed result.

This also renames `EHPadStack` in `InstPrinter` to `TryStack`, because
in CFGStackify we use `EHPadStack` to mean the range between
`catch`~`end`, while in `InstPrinter` we used it to mean the range
between `try`~`catch`, so choosing different names would look clearer.
Doesn't contain any functional changes in `InstPrinter`.

Reviewed By: dschuff

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

3 years ago[X86] Add reduced test case for PR49162
Simon Pilgrim [Sat, 13 Feb 2021 11:33:14 +0000 (11:33 +0000)]
[X86] Add reduced test case for PR49162

3 years ago[ARM] MVE min/max cost tests. NFC
David Green [Sat, 13 Feb 2021 11:12:12 +0000 (11:12 +0000)]
[ARM] MVE min/max cost tests. NFC

3 years ago[analyzer][tests] Fix issue comparison script
Valeriy Savchenko [Fri, 12 Feb 2021 16:47:24 +0000 (19:47 +0300)]
[analyzer][tests] Fix issue comparison script

When newer build has duplicate issues the script tried to
remove it from the list more than once.  The new approach
changes the way we filter out matching issues.

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

3 years ago[libunwind][cmake] Add an option to enable/disable tests
Kristina Bessonova [Sat, 13 Feb 2021 10:49:47 +0000 (12:49 +0200)]
[libunwind][cmake] Add an option to enable/disable tests

Reviewed By: ldionne, compnerd

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

3 years ago[Polly] Preserve DetectionContext references.
Michael Kruse [Sat, 13 Feb 2021 06:36:19 +0000 (00:36 -0600)]
[Polly] Preserve DetectionContext references.

DetectionContext objects are stored as values in a DenseMap. When the
DenseMap reaches its maximum load factor, it is resized and all its
objects moved to a new memory allocation. Unfortunately Scop object have
a reference to its DetectionContext. When the DenseMap resizes, all the
DetectionContexts reference now point to invalid memory, even if caused
by an unrelated DetectionContext.

Even worse, NewPM's ScopPassManager called isMaxRegionInScop with the
Verify=true parameter before each pass. This caused the old
DetectionContext to be removed an a new on created and re-verified.
Of course, the Scop object was already created pointing to the old
DetectionContext. Because the new DetectionContext would
usually be stored at the same position in the DenseMap, the reference
would usually reference the new DetectionContext of the same Region.
Usually.
If not, the old position still points to memory in the DenseMap
allocation (unless also a resizing occurs) such that tools like Valgrind
and AddressSanitizer would not be able to diagnose this.

Instead of storing the DetectionContext inside the DenseMap, use a
std::unique_ptr to a DetectionContext allocation, i.e. it will not move
around anymore. This also allows use to remove the very strange

    DetectionContext(const DetectionContext &&)

copy/move(?) constructor. DetectionContext objects now are neither
copied nor moved.

As a result, every re-verification of a DetectionContext will use a new
allocation. Therefore, once a Scop object has been created using a
DetectionContext, it must not be re-verified (the Scop data structure
requires its underlying Region to not change before code generation
anyway). The NewPM may call isMaxRegionInScop only with
Validate=false parameter.

3 years ago[test] Make ELF tests less reliant on the lexicographical order of non-local symbols
Fangrui Song [Sat, 13 Feb 2021 09:01:06 +0000 (01:01 -0800)]
[test] Make ELF tests less reliant on the lexicographical order of non-local symbols

3 years ago[CodeGen] Use range-based for loops (NFC)
Kazu Hirata [Sat, 13 Feb 2021 07:44:33 +0000 (23:44 -0800)]
[CodeGen] Use range-based for loops (NFC)

3 years ago[AMDGPU] Drop unnecessary const from a return type (NFC)
Kazu Hirata [Sat, 13 Feb 2021 07:44:31 +0000 (23:44 -0800)]
[AMDGPU] Drop unnecessary const from a return type (NFC)

Identified with readability-const-return-type.

3 years ago[TableGen] Use ListSeparator (NFC)
Kazu Hirata [Sat, 13 Feb 2021 07:44:30 +0000 (23:44 -0800)]
[TableGen] Use ListSeparator (NFC)

3 years ago[InstSimplify] add tests that look into pointer operands of instructions
Juneyoung Lee [Sat, 13 Feb 2021 07:25:27 +0000 (16:25 +0900)]
[InstSimplify] add tests that look into pointer operands of instructions

3 years ago[LTO] Perform DSOLocal propagation in combined index
Wei Wang [Wed, 10 Feb 2021 05:14:43 +0000 (21:14 -0800)]
[LTO] Perform DSOLocal propagation in combined index

Perform DSOLocal propagation within summary list of every GV. This
avoids the repeated query of this information during function
importing.

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

3 years ago[LangRef] Update memory access ops to raise UB if ptrs are not well defined
Juneyoung Lee [Sat, 13 Feb 2021 05:12:33 +0000 (14:12 +0900)]
[LangRef] Update memory access ops to raise UB if ptrs are not well defined

In the past, it was stated in D87994 that it is allowed to dereference a pointer that is partially undefined
if all of its possible representations fit into a dereferenceable range.
The motivation of the direction was to make a range analysis helpful for assuring dereferenceability.
Even if a range analysis concludes that its offset is within bounds, the offset could still be partially undefined; to utilize the range analysis, this relaxation was necessary.
https://groups.google.com/g/llvm-dev/c/2Qk4fOHUoAE/m/KcvYMEgOAgAJ has more context about this.

However, this is currently blocking another optimization, which is annotating the noundef attribute for library functions' arguments. D95122 is the patch.
Currently, there are quite a few library functions which cannot have noundef attached to its pointer argument because it can be transformed from load/store.
For example, MemCpyOpt can convert stores into memset:

```
store p, i32 0
store (p+1), i32 0 // Since currently it is allowed for store to have partially undefined pointer..
->
memset(p, 0, 8)    // memset cannot guarantee that its ptr argument is noundef.
```

A bigger problem is that this makes unclear which library functions are allowed to have 'noundef' and which functions aren't (e.g., strlen).
This makes annotating noundef almost impossible for this kind of functions.

This patch proposes that all memory operations should have well-defined pointers.
For memset/memcpy, it is semantically equivalent to running a loop until the size is met (and branching on undef is UB), so the size is also updated to be well-defined.

Strictly speaking, this again violates the implication of dereferenceability from range analysis result.
However, I think this is okay for the following reasons:

1. It seems the existing analyses in the LLVM main repo does not have conflicting implementation with the new proposal.
`isDereferenceableAndAlignedPointer` works only when the GEP offset is constant, and `isDereferenceableAndAlignedInLoop` is also fine.

2. A possible miscompilation happens only when the source has a pointer with a *partially* undefined offset (it's okay with poison because there is no 'partially poison' value).
But, at least I'm not aware of a language using LLVM as backend that has a well-defined program while allowing partially undefined pointers.
There might be such a language that I'm not aware of, but improving the performance of the mainstream languages like C and Rust is more important IMHO.

Reviewed By: jdoerfert

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

3 years ago[test] Make ELF tests amenable to the order of non-local symbols
Fangrui Song [Sat, 13 Feb 2021 05:00:42 +0000 (21:00 -0800)]
[test] Make ELF tests amenable to the order of non-local symbols

3 years ago[FPEnv][ARM] Implement lowering of llvm.set.rounding
Serge Pavlov [Thu, 11 Feb 2021 13:06:28 +0000 (20:06 +0700)]
[FPEnv][ARM] Implement lowering of llvm.set.rounding

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

3 years agoRevert "[flang][fir] Add fir-opt tool"
clementval [Sat, 13 Feb 2021 03:27:48 +0000 (22:27 -0500)]
Revert "[flang][fir] Add fir-opt tool"

This reverts commit df1eeaa7b404f7c5a96a812479f0ee2ce8354f6a.

Buildbot failure.

3 years ago[flang][fir][NFC] Move FieldType to TableGen type definition
Valentin Clement [Sat, 13 Feb 2021 03:22:56 +0000 (22:22 -0500)]
[flang][fir][NFC] Move FieldType to TableGen type definition

This patch is a follow up of D96422 and move ComplexType to TableGen.

Reviewed By: schweitz, mehdi_amini

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

3 years ago[flang][fir] Add fir-opt tool
Valentin Clement [Sat, 13 Feb 2021 03:20:15 +0000 (22:20 -0500)]
[flang][fir] Add fir-opt tool

This patch introduce the fir-opt tool. Similar to mlir-opt for FIR.
It will be used in following patches to test fir opt and round-trip.

Reviewed By: schweitz, mehdi_amini

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

3 years ago[llvm-objcopy] preserve file ownership when overwritten by root
Jian Cai [Wed, 3 Feb 2021 02:47:03 +0000 (18:47 -0800)]
[llvm-objcopy] preserve file ownership when overwritten by root

As of binutils 2.36, GNU strip calls chown(2) for "sudo strip foo" and
"sudo strip foo -o foo", but no "sudo strip foo -o bar" or "sudo strip
foo -o ./foo". In other words, while "sudo strip foo -o bar" creates a
new file bar with root access, "sudo strip foo" will keep the owner and
group of foo unchanged. Currently llvm-objcopy and llvm-strip behave
differently, always changing the owner and gropu to root. The
discrepancy prevents Chrome OS from migrating to llvm-objcopy and
llvm-strip as they change file ownership and cause intended users/groups
to lose access when invoked by sudo with the following sequence
(recommended in man page of GNU strip).

1.<Link the executable as normal.>
1.<Copy "foo" to "foo.full">
1.<Run "strip --strip-debug foo">
1.<Run "objcopy --add-gnu-debuglink=foo.full foo">

This patch makes llvm-objcopy and llvm-strip follow GNU's behavior.

Link: crbug.com/1108880

3 years ago[OpenMP] NFC: fix test removing the target construct
AndreyChurbanov [Sat, 13 Feb 2021 01:49:52 +0000 (04:49 +0300)]
[OpenMP] NFC: fix test removing the target construct

3 years ago[OpenMP] fix test adding mapping of shared variables
AndreyChurbanov [Sat, 13 Feb 2021 01:13:54 +0000 (04:13 +0300)]
[OpenMP] fix test adding mapping of shared variables

3 years ago[SYCL] Ignore file-scope asm during device-side SYCL compilation.
Artur Gainullin [Thu, 11 Feb 2021 20:54:59 +0000 (12:54 -0800)]
[SYCL] Ignore file-scope asm during device-side SYCL compilation.

Reviewed By: bader, eandrews

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

3 years agoStore the LocationKind of an entry value buffer independently from the main LocationK...
Adrian Prantl [Thu, 11 Feb 2021 23:38:49 +0000 (15:38 -0800)]
Store the LocationKind of an entry value buffer independently from the main LocationKind (NFC)

This patch hides the logic for setting the location kind of an entry
value inside the begin/finalize/cancel functions. This way we get rid
the strange workaround that is currently in setLocation().

In the future, this will allow us to set the location kind of the
entry value independently from the location kind of the main
expression.

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

3 years ago[CSSPGO][llvm-profgen] Filter out the instructions without location info for symbolizer
wlei [Wed, 10 Feb 2021 18:04:39 +0000 (10:04 -0800)]
[CSSPGO][llvm-profgen] Filter out the instructions without location info for symbolizer

It appears some instructions doesn't have the debug location info and the symbolizer will return an empty call stack for them which will cause some crash later in profile unwinding. Actually we do not record the sample info for them, so this change just filter out those instruction.

As those instruction would appears at the begin and end of the instruction list, without them we need to add the boundary check for IP `advance` and `backward`.

Also for pseudo probe based profile, we actually don't need the symbolized location info, so here just change to use an empty stack for it. This could save half of the binary loading time.

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

3 years ago[NFC] Combine runNewPMPasses() and runNewPMCustomPasses()
Arthur Eubanks [Thu, 11 Feb 2021 22:37:29 +0000 (14:37 -0800)]
[NFC] Combine runNewPMPasses() and runNewPMCustomPasses()

I've already witnessed two separate changes missing runNewPMPasses()
because runNewPMCustomPasses() is so similar.

This cleans up some duplicated code.

Reviewed By: tejohnson

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

3 years ago[lldb] Fix up SysV ABI implementations after 057efa9916cdc354ef4653bcd128a578cc43125e
Benjamin Kramer [Sat, 13 Feb 2021 00:33:22 +0000 (01:33 +0100)]
[lldb] Fix up SysV ABI implementations after 057efa9916cdc354ef4653bcd128a578cc43125e

3 years ago[SystemZ] Fix vecintrin.h to not emit alignment hints in vec_xl/vec_xst.
Jonas Paulsson [Wed, 10 Feb 2021 00:30:05 +0000 (18:30 -0600)]
[SystemZ] Fix vecintrin.h to not emit alignment hints in vec_xl/vec_xst.

vec_xl() and vec_xst() should not emit alignment hints since they take a
scalar pointer and also add a byte offset if passed.

This patch uses memcpy to achieve the desired result.

Review: Ulrich Weigand

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

3 years agoSupport dereferencing a DWARF scalar stack value
Adrian Prantl [Thu, 11 Feb 2021 23:04:10 +0000 (15:04 -0800)]
Support dereferencing a DWARF scalar stack value

Swift async functions receive function arguments inside a
heap-allocated data structure, similar to how ObjC block captures or
C++ coroutine arguments are implement. In DWARF they are described
relative to an entry value that produces a pointer into that heap
object. At typical location looks like

DW_OP_entry_value [ DW_OP_reg14 ] DW_OP_deref DW_OP_plus_uconst 32 DW_OP_deref

This allows the unwinder (which has special ABI knowledge to restore
the contents of r14) to push the base address onto the stack thus
allowing the deref/offset operations to continue. The result of the
entry value is a scalar, because DW_OP_reg14 is a register location —
as it should be since we want to restore the pointer value contained
in r14 at the beginning of the function and not the historical memory
contents it was pointing to. The entry value should restore the
address, which is still valid, not the contents at function entry.

To make this work, we need to allow LLDB to dereference Scalar stack
results like load addresses, which is what this patch
does. Unfortunately it is difficult to test this in isolation, since
the DWARFExpression unit test doesn't have a process.

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

3 years agoMake the error condition in Value::ValueType explicit (NFC)
Adrian Prantl [Thu, 11 Feb 2021 20:57:04 +0000 (12:57 -0800)]
Make the error condition in Value::ValueType explicit (NFC)

The comment for ValueType claims that all values <1 are errors, but
not all switch statements take this into account. This patch
introduces an explicit Error case and deletes all default: cases, so
we get warned about incomplete switch coverage.

https://reviews.llvm.org/D96537

3 years ago[RISCV] Move riscv_vfmv_v_f_vl patterns to RISCVInstrInfoVVLPatterns.td for consisten...
Craig Topper [Sat, 13 Feb 2021 00:08:22 +0000 (16:08 -0800)]
[RISCV] Move riscv_vfmv_v_f_vl patterns to RISCVInstrInfoVVLPatterns.td for consistency with riscv_vmv_v_x_vl. NFC

3 years ago[RISCV] Add support for fixed vector fabs
Craig Topper [Fri, 12 Feb 2021 23:33:21 +0000 (15:33 -0800)]
[RISCV] Add support for fixed vector fabs

3 years ago[RISCV] Add support for fixed vector sqrt.
Craig Topper [Fri, 12 Feb 2021 23:10:18 +0000 (15:10 -0800)]
[RISCV] Add support for fixed vector sqrt.

3 years agoLLVM-C: Allow LLVM{Get/Set}Alignment on an atomicrmw/cmpxchg instruction.
James Y Knight [Fri, 12 Feb 2021 22:09:18 +0000 (17:09 -0500)]
LLVM-C: Allow LLVM{Get/Set}Alignment on an atomicrmw/cmpxchg instruction.

(Now that these can have alignment specified.)

3 years ago[flang][fir][NFC] Minor format changes to FIROps.td.
Eric Schweitz [Fri, 12 Feb 2021 21:51:37 +0000 (13:51 -0800)]
[flang][fir][NFC] Minor format changes to FIROps.td.

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

3 years ago[CSSPGO][llvm-profgen] Renovate perfscript check and command line input validation
wlei [Wed, 10 Feb 2021 00:41:44 +0000 (16:41 -0800)]
[CSSPGO][llvm-profgen] Renovate perfscript check and command line input validation

This include some changes related with PerfReader's the input check and command line change:

1) It appears there might be thousands of leading MMAP-Event line in the perfscript for large workload. For this case, the 4k threshold is not eligible to determine it's a hybrid sample. This change renovated the `isHybridPerfScript` by going through the script without threshold limitation checking whether there is a non-empty call stack immediately followed by a LBR sample. It will stop once it find a valid one.

2) Added several input validations for the command line switches in PerfReader.

3) Changed the command line `show-disassembly` to `show-disassembly-only`, it will print to stdout and exit early which leave an empty output profile.

Reviewed By: hoy, wenlei

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

3 years ago[flang][fir][NFC] Move code from FIRDialect.h into a new header.
Eric Schweitz [Fri, 12 Feb 2021 21:09:10 +0000 (13:09 -0800)]
[flang][fir][NFC] Move code from FIRDialect.h into a new header.

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

3 years ago[AArch64][GlobalISel] Fold constants into G_GLOBAL_VALUE
Jessica Paquette [Fri, 12 Feb 2021 01:00:00 +0000 (17:00 -0800)]
[AArch64][GlobalISel] Fold constants into G_GLOBAL_VALUE

This is pretty much just ports `performGlobalAddressCombine` from
AArch64ISelLowering. (AArch64 doesn't use the generic DAG combine for this.)

This adds a pre-legalize combine which looks for this pattern:

```
  %g = G_GLOBAL_VALUE @x
  %ptr1 = G_PTR_ADD %g, cst1
  %ptr2 = G_PTR_ADD %g, cst2
  ...
  %ptrN = G_PTR_ADD %g, cstN
```

And then, if possible, transforms it like so:

```
  %g = G_GLOBAL_VALUE @x
  %offset_g = G_PTR_ADD %g, -min(cst)
  %ptr1 = G_PTR_ADD %offset_g, cst1
  %ptr2 = G_PTR_ADD %offset_g, cst2
  ...
  %ptrN = G_PTR_ADD %offset_g, cstN
```

Where min(cst) is the smallest out of the G_PTR_ADD constants.

This means we should save at least one G_PTR_ADD.

This also updates code in the legalizer + selector which assumes that
G_GLOBAL_VALUE will never have an offset and adds/updates relevant tests.

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

3 years agoFix test in external_symbolizer_path.cpp, by adding a REQUIRES: static-lib.
Amy Huang [Fri, 12 Feb 2021 21:58:50 +0000 (13:58 -0800)]
Fix test in external_symbolizer_path.cpp, by adding a REQUIRES: static-lib.

Follow-up to https://reviews.llvm.org/D94563.

3 years ago[RISCV] Use a ComplexPattern to merge the PatFrags for removing unneeded masks on...
Craig Topper [Fri, 12 Feb 2021 22:01:28 +0000 (14:01 -0800)]
[RISCV] Use a ComplexPattern to merge the PatFrags for removing unneeded masks on shift amounts.

Rather than having patterns with and without an AND, use a
ComplexPattern to handle both cases.

Reduces the isel table by about 700 bytes.

3 years ago[libc++abi] Fix forced_unwind tests failures on ARM/EHABI targets.
Vladimir Vereschaka [Fri, 12 Feb 2021 21:58:41 +0000 (13:58 -0800)]
[libc++abi] Fix forced_unwind tests failures on ARM/EHABI targets.

Added __cxxabi_config.h includes to resolve _LIBCXXABI_ARM_EHABI and
proper building the forces_unwindX.cpp tests for the ARM/EHABI targets.

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

3 years ago[GlobalISel] Simpler verification of G_SEXT_INREG and G_ASSERT_ZEXT
Jay Foad [Fri, 12 Feb 2021 11:29:13 +0000 (11:29 +0000)]
[GlobalISel] Simpler verification of G_SEXT_INREG and G_ASSERT_ZEXT

There's no need to call verifyVectorElementMatch since we already know
that the source and destination types are identical.

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

3 years agoFix test failure for external_symbolizer_path.cpp
Amy Huang [Fri, 12 Feb 2021 20:48:06 +0000 (12:48 -0800)]
Fix test failure for external_symbolizer_path.cpp

3 years ago[gn build] Add missing llvm-profgen dependency
Arthur Eubanks [Fri, 12 Feb 2021 20:43:27 +0000 (12:43 -0800)]
[gn build] Add missing llvm-profgen dependency

Or else a clean build fails with missing Attributes.inc.

3 years ago[AA] Add option for tracing AA queries (NFC)
Nikita Popov [Fri, 12 Feb 2021 15:00:24 +0000 (16:00 +0100)]
[AA] Add option for tracing AA queries (NFC)

Add an -aa-trace debug option that can be used to print AA queries,
including any recursive queries and their results.

3 years ago[AA] Move Depth member from AAResults to AAQI (NFC)
Nikita Popov [Fri, 12 Feb 2021 14:41:22 +0000 (15:41 +0100)]
[AA] Move Depth member from AAResults to AAQI (NFC)

Rather than storing the query depth in AAResults, store it in AAQI.
This makes more sense, as it is a property of the query. This
sidesteps the issue of D94363, fixing slightly inaccurate AA
statistics. Additionally, I plan to use the Depth from BasicAA in
the future, where fetching it from AAResults would be unreliable.

This change is not quite as straightforward as it seems, because
we need to preserve the depth when creating a new AAQI for recursive
queries across phis. I'm adding a new method for this, as we may
need to preserve additional information here in the future.

3 years ago[AMDGPU] Fix Windows build
Stanislav Mekhanoshin [Fri, 12 Feb 2021 20:30:52 +0000 (12:30 -0800)]
[AMDGPU] Fix Windows build

A trivial fix, 64 bit constant is 1ull, not 1ul on Windows.
Fixed build broken by c0d7a8bc6241.

3 years agoAdd a "kind" attribute to ContractionOp and OuterProductOp.
Praveen Narayanan [Fri, 12 Feb 2021 20:14:51 +0000 (20:14 +0000)]
Add a "kind" attribute to ContractionOp and OuterProductOp.

Currently, vector.contract joins the intermediate result and the accumulator
argument (of ranks K) using summation. We desire more joining operations ---
such as max --- to help vector.contract express reductions. This change extends
Vector_ContractionOp to take an optional attribute (called "kind", of enum type
CombiningKind) specifying the joining operation to be add/mul/min/max for int/fp
, and and/or/xor for int only. By default this attribute has value "add".

To implement this we also need to extend vector.outerproduct, since
vector.contract gets transformed to vector.outerproduct (and that to
vector.fma). The extension for vector.outerproduct is also an optional kind
attribute that uses the same enum type and possible values. The default is
"add". In case of max/min we transform vector.outerproduct to a combination of
compare and select.

Reviewed By: nicolasvasilache

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

3 years ago[SystemZ][ZOS] Fix __libcpp_thrad_isnull()
Zbigniew Sarbinowski [Fri, 12 Feb 2021 19:14:41 +0000 (19:14 +0000)]
[SystemZ][ZOS] Fix __libcpp_thrad_isnull()

Previous pthread revision https://reviews.llvm.org/D91875 missed a small change for `__libcpp_thrad_isnull()` required for z/OS.

Reviewed By: zibi

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

3 years ago[clang] Remove redundant condition (NFC).
Florian Hahn [Fri, 12 Feb 2021 20:07:58 +0000 (20:07 +0000)]
[clang] Remove redundant condition (NFC).

3 years ago[GlobalISel] Combine (x + 0) -> x, G_PTR_ADD edition
Jessica Paquette [Fri, 12 Feb 2021 01:02:50 +0000 (17:02 -0800)]
[GlobalISel] Combine (x + 0) -> x, G_PTR_ADD edition

Add it to right_identity_zero.

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

3 years ago[docs/Coverage] Document -show-region-summary
Vedant Kumar [Fri, 12 Feb 2021 20:04:57 +0000 (12:04 -0800)]
[docs/Coverage] Document -show-region-summary

As a drive-by, fix the section in the clang docs about the number of
statistics visible in a report.

3 years ago[docs/Coverage] Answer FAQ about optimization
Vedant Kumar [Fri, 12 Feb 2021 20:04:27 +0000 (12:04 -0800)]
[docs/Coverage] Answer FAQ about optimization

3 years ago[OpenMP] Silence more warning flags
Martin Storsjö [Fri, 12 Feb 2021 09:38:25 +0000 (11:38 +0200)]
[OpenMP] Silence more warning flags

This silences warnings like these, in mingw builds with clang:

runtime/src/kmp_atomic.h:1021:13: warning: '__kmpc_atomic_cmplx8_rd' has C-linkage specified, but returns user-defined type 'kmp_cmplx64' (aka '__kmp_cmplx64_t') which is incompatible with C [-Wreturn-type-c-linkage]

runtime/src/z_Windows_NT_util.cpp:479:17: warning: cast from 'volatile void *' to 'type-parameter-0-0 *' drops volatile qualifier [-Wcast-qual]
    flag = (C *)th->th.th_sleep_loc;

runtime/src/z_Windows_NT_util.cpp:1321:14: warning: cast to 'void *' from smaller integer type 'DWORD' (aka 'unsigned long') [-Wint-to-void-pointer-cast]
  } else if ((void *)exit_val != (void *)th) {

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