platform/upstream/llvm.git
3 years ago[BasicAA] Retain shl nowrap flags in GetLinearExpression()
Nikita Popov [Sat, 27 Mar 2021 11:11:25 +0000 (12:11 +0100)]
[BasicAA] Retain shl nowrap flags in GetLinearExpression()

Nowrap flags between mul and shl differ in that mul nsw allows
multiplication of 1 * INT_MIN, while shl nsw does not. This means
that it is always fine to transfer shl nowrap flags to muls, but
not necessarily the other way around. In this case the NUW/NSW
results refer to mul/add operations, so it's fine to retain the
flags from the shl.

3 years ago[X86][SSE] combineX86ShuffleChain - attempt to recognise 'hidden' identity shuffles
Simon Pilgrim [Sat, 27 Mar 2021 11:09:30 +0000 (11:09 +0000)]
[X86][SSE] combineX86ShuffleChain - attempt to recognise 'hidden' identity shuffles

See if the combined shuffle mask is equivalent to an identity shuffle, typically this is due to repeated LHS/RHS ops in horiz-ops, but isTargetShuffleEquivalent might see other patterns as well.

This is another small step towards getting rid of foldShuffleOfHorizOp and relying on canonicalizeShuffleMaskWithHorizOp and generic shuffle combining.

3 years agoMake FoldBranchToCommonDest poison-safe by default
Juneyoung Lee [Sat, 27 Mar 2021 08:12:20 +0000 (17:12 +0900)]
Make FoldBranchToCommonDest poison-safe by default

This is a small patch to make FoldBranchToCommonDest poison-safe by default.
After fc3f0c9c, only two syntactic changes are needed to fix unit tests.
This does not cause any assembly difference in testsuite as well (-O3, X86-64 Manjaro).

Reviewed By: nikic

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

3 years ago[x86] prevent crashing while matching pmaddwd
Sanjay Patel [Sat, 27 Mar 2021 09:24:52 +0000 (05:24 -0400)]
[x86] prevent crashing while matching pmaddwd

This could crash in 2 ways: either one or both of
the input vectors could be a different size than
the math ops.

https://llvm.org/PR49716

3 years ago[mlir] Register Linalg passes in C API and Python Bindings
Alex Zinenko [Fri, 26 Mar 2021 18:04:36 +0000 (19:04 +0100)]
[mlir] Register Linalg passes in C API and Python Bindings

Provide a registration mechanism for Linalg dialect-specific passes in C
API and Python bindings. These are being built into the dialect library
but exposed in separate headers (C) or modules (Python).

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

3 years ago[IRCE] Use m_LogicalAnd
Juneyoung Lee [Sat, 27 Mar 2021 06:22:17 +0000 (15:22 +0900)]
[IRCE] Use m_LogicalAnd

This is a minor fix to use m_LogicalAnd.
This allows IRCE to recognize select form of and conditions as well.

3 years ago[sanitizer] Temporarily switch ppc64 to the _dl_get_tls_static_info implementation
Fangrui Song [Sat, 27 Mar 2021 06:21:47 +0000 (23:21 -0700)]
[sanitizer] Temporarily switch ppc64 to the _dl_get_tls_static_info implementation

sanitizer-ppc64le-linux is good while clang-ppc64le-linux has test
failures due to GetStaticTlsRange(addr, size) set *addr is 0.

3 years ago[lldb] Fix TestAppleSimulatorOSType for older watchOS SDKs
Jonas Devlieghere [Sat, 27 Mar 2021 03:27:14 +0000 (20:27 -0700)]
[lldb] Fix TestAppleSimulatorOSType for older watchOS SDKs

Older watchOS SDKs *only* support i386 so we can't use x86_64/arm64
unconditionally.

3 years agodocs: Adding Google representative to the security group
George Burgess IV [Wed, 24 Mar 2021 00:34:42 +0000 (17:34 -0700)]
docs: Adding Google representative to the security group

This adds me as a Google representative for the LLVM security group.

This was proposed, discussed, and voted on in the differential revision
linked below; please see it for more information.

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

3 years ago[lldb] Stop using i386 for the watchOS simulator
Jonas Devlieghere [Sat, 27 Mar 2021 00:08:29 +0000 (17:08 -0700)]
[lldb] Stop using i386 for the watchOS simulator

This keeps breaking on my machine. It's time to move on.

3 years ago[RISCV] Merge FMulAdd and FMulSub scheduler classes to a single FMA scheduler class...
Craig Topper [Fri, 26 Mar 2021 23:37:15 +0000 (16:37 -0700)]
[RISCV] Merge FMulAdd and FMulSub scheduler classes to a single FMA scheduler class. NFC

It's unlikely that FMADD and FMSUB would have different scheduling
information so merge them.

Reviewed By: HsiangKai

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

3 years ago[CSSPGO][NFC] Fix a debug dump issue.
Hongtao Yu [Fri, 26 Mar 2021 20:18:26 +0000 (13:18 -0700)]
[CSSPGO][NFC] Fix a debug dump issue.

During context promotion, intermediate nodes that are on a call path but do not come with a profile can be promoted together with their parent nodes. Do not print sample context string for such nodes since they do not have profile.

Reviewed By: wenlei

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

3 years ago[OpenMP] Reset async stream properly upon failure
Joseph Huber [Fri, 26 Mar 2021 20:50:34 +0000 (16:50 -0400)]
[OpenMP] Reset async stream properly upon failure

Summary:
If the call to `synchronize` fails, it will currently block the stream indefinitely if execution is continued from this point. Additionally, if the program exits it will trigger an assertion on the non-null value of the async queue and prevent the runtime from printing debugging information.

Reviewers: jdoerfert

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

3 years ago[mlir] Remove unneeded ShapeFunctionLibraryTerminatorOp
Jacques Pienaar [Fri, 26 Mar 2021 23:03:51 +0000 (16:03 -0700)]
[mlir] Remove unneeded ShapeFunctionLibraryTerminatorOp

Now that NoTerminator is possible this op can be removed/it was only
needed structurally before. NFC.

3 years ago[lldb] Remove UpdateISAToDescriptorMapFromMemory
Jonas Devlieghere [Fri, 26 Mar 2021 22:27:19 +0000 (15:27 -0700)]
[lldb] Remove UpdateISAToDescriptorMapFromMemory

Remove UpdateISAToDescriptorMapFromMemory because it's dead code.

3 years agoAdd a missing file header comment, NFC.
Chris Lattner [Fri, 26 Mar 2021 22:34:04 +0000 (15:34 -0700)]
Add a missing file header comment, NFC.

3 years ago[lldb] Add consistency between reading the dynamic and shared cache class info
Jonas Devlieghere [Fri, 26 Mar 2021 21:50:46 +0000 (14:50 -0700)]
[lldb] Add consistency between reading the dynamic and shared cache class info

This adds the consistency I promised in D99315 between how we read the
class info from the Objective-C runtime and the shared cache. (NFC)

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

3 years ago[lld-macho] Add time tracing for LTO
Jez Ng [Thu, 25 Mar 2021 04:57:39 +0000 (00:57 -0400)]
[lld-macho] Add time tracing for LTO

The test is similar to the one used for LLD-ELF.

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

3 years ago[lld-macho] Fix parsing of --time-trace-{granularity,file}
Jez Ng [Thu, 25 Mar 2021 01:05:26 +0000 (21:05 -0400)]
[lld-macho] Fix parsing of --time-trace-{granularity,file}

Summary: We needed to use `Joined` instead of `Flag`. This wasn't caught
because the relevant test that was copied from LLD-ELF was still
invoking LLD-ELF instead of LLD-MachO...

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

3 years ago[lld-macho] Support -no_function_starts
Jez Ng [Mon, 22 Mar 2021 21:38:52 +0000 (17:38 -0400)]
[lld-macho] Support -no_function_starts

Pretty simple code-wise. Also threw in some refactoring:

* Put the functionStartSection under Writer instead of InStruct, since
  it doesn't need to be accessed outside of Writer
* Adjusted the test to put all files under the temp dir instead of at
  the top-level
* Added some CHECK-LABELs to make it clearer where the function starts
  data is

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

3 years ago[RISCV] Add scheduler classes for the Zba and Zbb extensions.
Craig Topper [Fri, 26 Mar 2021 21:15:27 +0000 (14:15 -0700)]
[RISCV] Add scheduler classes for the Zba and Zbb extensions.

I've used IALU for the simplest operations from Zbb:
min, minu, max, maxu, sext.b, sext.h, zext.h, andn, orn, xnor

I've put add.uw in IALU32 and slli.uw in ShiftImm32.

Remaining instructions have received new classes.
All 3 sh*add are grouped together. sh*add.uw are grouped together.
Rotate left and right are together. Everything else got their own
class containing one instruction.

I think what I have here is the minimum granularity we need. I
could be convinced that we need more classes.

Reviewed By: evandro

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

3 years ago[NFC][OCaml] Resolve a couple more compilation warnings
Josh Berdine [Fri, 26 Mar 2021 15:19:01 +0000 (15:19 +0000)]
[NFC][OCaml] Resolve a couple more compilation warnings

Followup to: 0b1dc49ca38a [NFC][OCaml] Resolve const and unsigned compilation warnings

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

3 years ago[SystemZ][z/OS] Save strings for CC_PRINT env vars
Sean Perry [Fri, 26 Mar 2021 20:37:29 +0000 (16:37 -0400)]
[SystemZ][z/OS] Save strings for CC_PRINT env vars

The contents of the string returned by getenv() is not guaranteed across calls to getenv(). The code to handle the CC_PRINT etc env vars calls getenv() and saves the results in just a char *. The string returned by getenv() needs to be copied and saved. Switching the type of the strings from char * to std::string will do this and manage the alloated memory.

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

3 years agoRevert "[ArgPromotion] Copy additional metadata for loads."
Nikita Popov [Fri, 26 Mar 2021 20:32:32 +0000 (21:32 +0100)]
Revert "[ArgPromotion] Copy additional metadata for loads."

This reverts commit 166620a4f01f10e688428caf132a147c0acc9183.

A miscompile has been reported in https://reviews.llvm.org/D93927#2653480
and following.

3 years ago[lldb] Support lazily named classes in the Objective-C classes
Jonas Devlieghere [Fri, 26 Mar 2021 19:07:46 +0000 (12:07 -0700)]
[lldb] Support lazily named classes in the Objective-C classes

Generic classes in Swift have their name instantiated on request, since
the vast majority never need it, and it just wastes time and memory.
This results in LLDB being unable to determine the dynamic type of these
Swift objects.

The main issues is that lazily named classes are not added to the
gdb_objc_realized_classes hashtable. This means the class count in the
table doesn't change when a class is realized and LLDB doesn't know it
needs to re-parse the class info. But even if it did, the classes are
not in the hash table.

The first change in this patch is that we read
objc_debug_realized_class_generation_count and re-parse the class info
when the count changes.

The second change in this patch is that we use
objc_copyRealizedClassList (if available) to get all realized classes
from the runtime.

Unfortunately, objc_copyRealizedClassList calls _dyld_objc_class_count
in its implementation. As we know, the Objective-C parsing code might
get called before dyld is fully initialized, resulting in crashes or
even a stranded lock. Therefore we only use objc_copyRealizedClassList
when we know it's safe to do so by checking libSystemInitialized in
dyld_all_image_infos.

As a result, it's possible that the first time we read the Objective-C
runtime we are forced to use gdb_objc_realized_classes. This should be
fine, as there should be no lazily named classes at this point.
Subsequent queries will detect the change in realized class generation
count and use objc_copyRealizedClassList.

This patch keeps the old behavior when objc_copyRealizedClassList or
objc_debug_realized_class_generation_count are not available.

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

3 years ago[libcxxabi] Use cxx-headers target to consume libcxx headers
Petr Hosek [Wed, 10 Mar 2021 19:21:41 +0000 (11:21 -0800)]
[libcxxabi] Use cxx-headers target to consume libcxx headers

Rather than including libc++ include dir, use the cxx-headers target.

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

3 years agoRename the 'concept' variable in SymbolInterfaces.td
Sameer Rahmani [Fri, 26 Mar 2021 20:15:06 +0000 (20:15 +0000)]
Rename the 'concept' variable in  SymbolInterfaces.td

`concept` is a reserved keyword in C++20, it can't be used as a variable name.
Here is an example of the failure:

```
      auto *concept = getInterfaceFor(op);
            ^
include/mlir/IR/SymbolInterfaces.h.inc:156:12: error: expected expression [clang-diagnostic-error]
      if (!concept)
           ^
```

Reviewed By: mehdi_amini

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

3 years ago[ConstraintElimination] Only strip casts preserving the representation.
Florian Hahn [Fri, 26 Mar 2021 17:59:32 +0000 (17:59 +0000)]
[ConstraintElimination] Only strip casts preserving the representation.

Things like addrspacecast may not be no-ops, so we should not look
through them.

3 years ago[OpenCL][Docs] Minor update about C++ for OpenCL in UsersManual.
Anastasia Stulova [Fri, 26 Mar 2021 19:23:58 +0000 (19:23 +0000)]
[OpenCL][Docs] Minor update about C++ for OpenCL in UsersManual.

3 years ago[ValueTracking] Handle shl pair in isKnownNonEqual()
Nikita Popov [Fri, 26 Mar 2021 19:16:57 +0000 (20:16 +0100)]
[ValueTracking] Handle shl pair in isKnownNonEqual()

Handle (x << s) != (y << s) where x != y and the shifts are
non-wrapping. Once again, this establishes parity with the
corresponing mul fold that already exists. The shift case is
more powerful because we don't need to guard against multiplies
by zero.

3 years ago[ValueTracking] Handle shl in isKnownNonEqual()
Nikita Popov [Fri, 26 Mar 2021 19:12:55 +0000 (20:12 +0100)]
[ValueTracking] Handle shl in isKnownNonEqual()

This handles the pattern X != X << C for non-zero X and C and a
non-overflowing shift. This establishes parity with the corresponing
fold for multiplies.

3 years ago[ValueTracking] Add tests for non equal shifts (NFC)
Nikita Popov [Fri, 26 Mar 2021 19:06:51 +0000 (20:06 +0100)]
[ValueTracking] Add tests for non equal shifts (NFC)

3 years ago[Utils] Add prefix parameter in update test checks to avoid FileCheck conflicts
Giorgis Georgakoudis [Fri, 26 Mar 2021 12:58:05 +0000 (05:58 -0700)]
[Utils] Add prefix parameter in update test checks to avoid FileCheck conflicts

IR values convert to check prefix FileCheck variables for IR checks. For example, nameless values, e.g., %0, convert to check prefix TMP FileCheck variables, e.g., [[TMP0:%.*]]. This check prefix may clash with named values that have the same name and that causes auto-generated tests to fail. Currently a warning is emitted to change the names of the IR values but this is not always possible, if for example they are generated by clang. Manual intervention to fix the FileCheck variable names is too tedious. This patch add a parameter to prefix conflicting FileCheck variable names with a user-provided string to automate the process.

Reviewed By: jdoerfert

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

3 years ago[mlir] fix -Wsign-compare in memref unit tests
Alex Zinenko [Fri, 26 Mar 2021 18:37:05 +0000 (19:37 +0100)]
[mlir] fix -Wsign-compare in memref unit tests

3 years ago[lsan][test] Enable many_tls_keys_pthread.cpp and disable swapcontext.cpp/fork_and_le...
Fangrui Song [Fri, 26 Mar 2021 18:26:08 +0000 (11:26 -0700)]
[lsan][test] Enable many_tls_keys_pthread.cpp and disable swapcontext.cpp/fork_and_leak.cpp

With D98926, many_tls_keys_pthread.cpp appears to be working.

On glibc 2.30-0ubuntu2, swapcontext.cpp and Linux/fork_and_leak.cpp work fine
but they strangely fail on clang-cmake-aarch64-full
(https://lab.llvm.org/buildbot/#/builders/7/builds/2240).
Disable them for now.

Note: check-lsan was recently enabled on AArch64 in D98985. A test takes
10+ seconds. We should figure out the bottleneck.

3 years ago[ConstraintElimination] Add additional pointercast tests.
Florian Hahn [Fri, 26 Mar 2021 17:47:54 +0000 (17:47 +0000)]
[ConstraintElimination] Add additional pointercast tests.

Add coverage for pointercasts other than bitcast. addrspacecast are not
handled properly at the moment.

3 years ago[SLP] use dyn_cast instead of isa + cast; NFC
Sanjay Patel [Fri, 26 Mar 2021 17:52:01 +0000 (13:52 -0400)]
[SLP] use dyn_cast instead of isa + cast; NFC

3 years ago[Orc][examples] Factor out make_error from parseExampleModule (NFC)
Stefan Gränitz [Fri, 26 Mar 2021 17:43:29 +0000 (18:43 +0100)]
[Orc][examples] Factor out make_error from parseExampleModule (NFC)

3 years ago[Orc][examples] Fix copy/paste issues in comments and inclue guards (NFC)
Stefan Gränitz [Wed, 17 Mar 2021 13:22:41 +0000 (14:22 +0100)]
[Orc][examples] Fix copy/paste issues in comments and inclue guards (NFC)

3 years ago[ValueTracking] Handle non-zero shl recurrence
Nikita Popov [Fri, 26 Mar 2021 17:39:06 +0000 (18:39 +0100)]
[ValueTracking] Handle non-zero shl recurrence

In this case we don't care about the step at all, and only require
that the starting value is non-zero.

3 years ago[ValueTracking] Add tests for non-zero shl recurrences (NFC)
Nikita Popov [Fri, 26 Mar 2021 17:35:38 +0000 (18:35 +0100)]
[ValueTracking] Add tests for non-zero shl recurrences (NFC)

3 years ago[ValueTracking] Handle non-zero add/mul recurrences more precisely
Nikita Popov [Fri, 26 Mar 2021 17:14:30 +0000 (18:14 +0100)]
[ValueTracking] Handle non-zero add/mul recurrences more precisely

This is mainly for clarity: It doesn't make sense to do any
negative/positive checks when dealing with a nuw add/mul. These
only make sense to nsw add/mul.

3 years ago[ValueTracking] Add more non-zero add/mul recurrence tests (NFC)
Nikita Popov [Fri, 26 Mar 2021 17:10:56 +0000 (18:10 +0100)]
[ValueTracking] Add more non-zero add/mul recurrence tests (NFC)

3 years ago[OCaml][DebugInfo][Test] Disable debuginfo tests as they fail on some machines
Vaivaswatha Nagaraj [Fri, 26 Mar 2021 17:25:31 +0000 (22:55 +0530)]
[OCaml][DebugInfo][Test] Disable debuginfo tests as they fail on some machines

3 years ago[X86][AVX] combineHorizOpWithShuffle - improve SHUFFLE(HOP(LOSUBVECTOR(X),HISUBVECTOR...
Simon Pilgrim [Fri, 26 Mar 2021 16:15:19 +0000 (16:15 +0000)]
[X86][AVX] combineHorizOpWithShuffle - improve SHUFFLE(HOP(LOSUBVECTOR(X),HISUBVECTOR(X))) folding

Peek through bitcasts to find subvector splits and use getTargetShuffleInputs to decode target shuffles as well as ShuffleVectorSDNode

3 years ago[OCaml][Test] Do not use Option, expand using match
Vaivaswatha Nagaraj [Fri, 26 Mar 2021 17:09:58 +0000 (22:39 +0530)]
[OCaml][Test] Do not use Option, expand using match

Option seems to be unsupported on the buildbot version
of OCaml. So expand the statements using a match.

Fixes buildbot failure due to
https://github.com/llvm/llvm-project/commit/c244cd72172ca8941f9f67fc183ade8afcd61c17

3 years ago[BasicAA] Add a few more interesting modulo tests.
Florian Hahn [Fri, 26 Mar 2021 15:37:07 +0000 (15:37 +0000)]
[BasicAA] Add a few more interesting modulo tests.

3 years ago[OCaml][DebugInfo] Add tests for debug info API
Vaivaswatha Nagaraj [Fri, 26 Mar 2021 16:36:48 +0000 (22:06 +0530)]
[OCaml][DebugInfo] Add tests for debug info API

In the process of adding the tests, several bugs were
found in the implementation and interface of the API
and they were fixed.

Some utilities from the core tests (core.ml) were moved
into a separate file for reuse.

The following new functions have been added:
`dibuild_create_global_variable_expression`,
`dibuild_create_constant_value_expression` and
`llmetadata_null`. The third one already existed but
is now exposed publicly.

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

3 years ago[CMake][gRPC] Fix a typo in protobuf version variable name
Aleksandr Platonov [Fri, 26 Mar 2021 16:31:38 +0000 (19:31 +0300)]
[CMake][gRPC] Fix a typo in protobuf version variable name

Without this patch CMake log contains `Using protobuf` instead of `Using protobuf <version>`.

Reviewed By: kbobyrev

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

3 years ago[lldb] Skip TestVSCode_launch.test_progress_events on linux
Pavel Labath [Fri, 26 Mar 2021 16:23:50 +0000 (17:23 +0100)]
[lldb] Skip TestVSCode_launch.test_progress_events on linux

It's flaky everywhere, not just arm.

3 years ago[lldb] XFAIL TestGdbRemote_vContThreads on macos
Pavel Labath [Fri, 26 Mar 2021 16:23:22 +0000 (17:23 +0100)]
[lldb] XFAIL TestGdbRemote_vContThreads on macos

It seems debugserver does not implement these packets.

3 years ago[lldb] Really fix dwarf5-debug_line-file-index.s
Pavel Labath [Fri, 26 Mar 2021 16:16:53 +0000 (17:16 +0100)]
[lldb] Really fix dwarf5-debug_line-file-index.s

It's not enough the change the comment -- one has to actually change the
constant before it. :/

3 years ago[AMDGPU] Use reductions instead of scans in the atomic optimizer
Jay Foad [Fri, 19 Mar 2021 12:34:37 +0000 (12:34 +0000)]
[AMDGPU] Use reductions instead of scans in the atomic optimizer

If the result of an atomic operation is not used then it can be more
efficient to build a reduction across all lanes instead of a scan. Do
this for GFX10, where the permlanex16 instruction makes it viable. For
wave64 this saves a couple of dpp operations. For wave32 it saves one
readlane (which are generally bad for performance) and one dpp
operation.

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

3 years ago[mlir][python] NFC - Fix stale path in doc
Nicolas Vasilache [Thu, 25 Mar 2021 15:08:09 +0000 (15:08 +0000)]
[mlir][python] NFC - Fix stale path in doc

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

3 years ago[SystemZ][z/OS] exclude nasty_macros.h from check-cxx
Zbigniew Sarbinowski [Fri, 26 Mar 2021 15:02:40 +0000 (15:02 +0000)]
[SystemZ][z/OS] exclude nasty_macros.h from check-cxx

Need to exclude nasty_macros.h from check-cxx on z/OS due to conflicts within system headers.

Sample failure in `random_shuffle.depr_in_cxx14.verify.cpp` libcxx test.
```
error: 'error' diagnostics seen but not expected:
Line 1268: expected ')'
Line 1268: unknown type name 'This'
Line 1268: expected ')'
```

caused by the following  macros in `nasty_macros.h`
```
#define NASTY_MACRO This should not be expanded!!!
#define _E NASTY_MACRO
```
The name collision is observed in the following code snippet whre `_E` is being used as parameter name:
```
inline int iswalnum(wint_t _E) {return __iswalnum(_E);}
```

It is reasonable to exclude `nasty_macros.h` on z/OS similarly as it was done on Windows.

Reviewed By: #libc, ldionne

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

3 years ago[BasicAA] Add a few cases with overflows in index computations.
Florian Hahn [Fri, 26 Mar 2021 14:44:13 +0000 (14:44 +0000)]
[BasicAA] Add a few cases with overflows in index computations.

This patch adds a few test cases where currently NoAlias is returned,
but the pointers can alias if the multiply overflows while computing
a GEP index value.

3 years ago[SLP] move test for min/max crashing; NFC
Sanjay Patel [Fri, 26 Mar 2021 14:26:24 +0000 (10:26 -0400)]
[SLP] move test for min/max crashing; NFC

This was originally just an XFAIL test, but I modified it
to check output. To make that bot-friendly, I'm moving it
to the x86 dir since it specified an x86 target.

3 years ago[OpenCL] Fix AST check in address-space-templates test
Anastasia Stulova [Fri, 26 Mar 2021 14:21:23 +0000 (14:21 +0000)]
[OpenCL] Fix AST check in address-space-templates test

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

3 years ago[RISCV] Add constraint for RVV indexed loads.
Zakk Chen [Mon, 15 Mar 2021 14:22:12 +0000 (07:22 -0700)]
[RISCV] Add constraint for RVV indexed loads.

Add the constraint when destination EEW not equals the source EEW for
correctness.

The RVV spec has three register overlap rules and I implement the first
stricter constraint because the others are difficult to enforce.

Reviewed By: frasercrmck, craig.topper

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

3 years ago[SystemZ][z/OS] Ignore leading zero width bitfield alignment on z/OS target
Fanbo Meng [Fri, 26 Mar 2021 14:09:57 +0000 (10:09 -0400)]
[SystemZ][z/OS] Ignore leading zero width bitfield alignment on z/OS target

Zero length bitfield alignment is not respected if they are leading members on z/OS target.

Reviewed By: abhina.sreeskantharajan

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

3 years agoRevert "[SLP] allow matching integer min/max intrinsics as reduction ops"
Sanjay Patel [Fri, 26 Mar 2021 13:09:00 +0000 (09:09 -0400)]
Revert "[SLP] allow matching integer min/max intrinsics as reduction ops"

This reverts commit 3c8473ba534daa3 and includes test diffs to
maintain testing status.

There's at least 1 place that was not updated with 7202f47508 ,
so we can crash mismatching select and intrinsics as shown in
PR49730.

3 years ago[OpenCL][Docs] Update status of OpenCL 3.0 development
Anastasia Stulova [Fri, 26 Mar 2021 13:06:26 +0000 (13:06 +0000)]
[OpenCL][Docs] Update status of OpenCL 3.0 development

3 years ago[InstCombine]Generalise regression tests for sve
Nashe Mncube [Tue, 23 Mar 2021 13:26:37 +0000 (13:26 +0000)]
[InstCombine]Generalise regression tests for sve

The tests, test/Transforms/InstCombine/AArch64/sve-*,
have been shown to not be AArch64 specific. These tests
have been renamed and moved to reflect this.

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

3 years ago[OCaml] Fix a possible crash in llvm_struct_name
Josh Berdine [Thu, 25 Mar 2021 23:34:04 +0000 (23:34 +0000)]
[OCaml] Fix a possible crash in llvm_struct_name

The implementation of `llvm_struct_name` before this diff calls
`caml_copy_string`, which allocates, while the `result` local variable
points to a block allocated by `caml_alloc_small` that has not yet
been initialized. If the allocation in `caml_copy_string` triggers a
garbage collection, then the GC root `result` contains a pointer to
uninitialized data, which may crash the GC or lead to a memory
corruption.

This diff fixes this by allocating and initializing the string first
and then allocating and initializing the option, thereby leaving no
dangling pointers when allocations are made.

The conversion from a C string to an OCaml string option is refactored
into a function, `cstr_to_string_option`. This function is also used
to simplify the definitions of `llvm_get_mdstring` and
`llvm_string_of_const`.

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

3 years ago[NFC][OCaml] Resolve const and unsigned compilation warnings
Josh Berdine [Thu, 25 Mar 2021 23:24:16 +0000 (23:24 +0000)]
[NFC][OCaml] Resolve const and unsigned compilation warnings

There are a number of compilation warnings regarding disregarding
const qualifiers, and casting between pointers to integer types with
different sign.

The incompatible sign warnings are due to treating the result of
`LLVMGetModuleIdentifier` as `const unsigned char *`, but it is
declared as `const char *`.

The dropped const qualifiers are due to the code pattern
`memcpy(String_val(_),_,_)` which ought to be (following the
implementation of the OCaml runtime)
`memcpy((char *)String_val(_),_,_)`. The issue is that `String_val` is
usually used to get the value of an immutable string. But in the
context of the `memcpy` calls, the string is in the process of being
initialized, so is not yet constant.

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

3 years ago[NFC][OCaml] Simplify llvm_global_initializer using ptr_to_option
Josh Berdine [Thu, 25 Mar 2021 23:07:46 +0000 (23:07 +0000)]
[NFC][OCaml] Simplify llvm_global_initializer using ptr_to_option

This diff uses ptr_to_option to convert a nullable C pointer to an
OCaml option instead of the redundant implementation in
llvm_global_initializer.

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

3 years agoRevert "[LoopVectorize] Simplify scalar cost calculation in getInstructionCost"
David Sherwood [Fri, 26 Mar 2021 11:36:53 +0000 (11:36 +0000)]
Revert "[LoopVectorize] Simplify scalar cost calculation in getInstructionCost"

This reverts commit 240aa96cf25d880dde7a0db5d96918cfaa4b8891.

3 years ago[LoopVectorize] Simplify scalar cost calculation in getInstructionCost
David Sherwood [Wed, 10 Mar 2021 08:34:19 +0000 (08:34 +0000)]
[LoopVectorize] Simplify scalar cost calculation in getInstructionCost

This patch simplifies the calculation of certain costs in
getInstructionCost when isScalarAfterVectorization() returns a true value.
There are a few places where we multiply a cost by a number N, i.e.

  unsigned N = isScalarAfterVectorization(I, VF) ? VF.getKnownMinValue() : 1;
  return N * TTI.getArithmeticInstrCost(...

After some investigation it seems that there are only these cases that occur
in practice:

1. VF is a scalar, in which case N = 1.
2. VF is a vector. We can only get here if: a) the instruction is a
GEP/bitcast with scalar uses, or b) this is an update to an induction variable
that remains scalar.

I have changed the code so that N is assumed to always be 1. For GEPs
the cost is always 0, since this is calculated later on as part of the
load/store cost. For all other cases I have added an assert that none of the
users needs scalarising, which didn't fire in any unit tests.

Only one test required fixing and I believe the original cost for the scalar
add instruction to have been wrong, since only one copy remains after
vectorisation.

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

3 years ago[mlir][ODS] Fix `VariadicRegion` code generation for `NoTerminator` Ops
Vladislav Vinogradov [Thu, 25 Mar 2021 12:02:41 +0000 (15:02 +0300)]
[mlir][ODS] Fix `VariadicRegion` code generation for `NoTerminator` Ops

The issue was introduced in D98468.

The `{0}Regions` is an array of `std::unique_ptr<Region>` objects,
so it should be processed accordingly.

Reviewed By: mehdi_amini

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

3 years ago[Windows] Turn off text mode in TableGen and Rewriter to stop CRLF translation
Abhina Sreeskantharajan [Fri, 26 Mar 2021 11:12:28 +0000 (07:12 -0400)]
[Windows] Turn off text mode in TableGen and Rewriter to stop CRLF translation

This patch should fix the errors shown on the Windows bots by turning off text mode. I plan to investigate a better fix but this should unblock the buildbots for now.

Reviewed By: rnk

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

3 years ago[Test] Add failing test for pr49730
Max Kazantsev [Fri, 26 Mar 2021 11:02:31 +0000 (18:02 +0700)]
[Test] Add failing test for pr49730

3 years ago[LLDB] Skip TestVSCode_disconnect.test_launch arm/linux
Muhammad Omair Javaid [Fri, 26 Mar 2021 10:54:39 +0000 (15:54 +0500)]
[LLDB] Skip TestVSCode_disconnect.test_launch arm/linux

TestVSCode_disconnect.test_launch hangs in tear down and times out
Arm linux. I am marking it skipped for the buildbot while looking
into failure.

3 years ago[AMDGPU] Inline FSHRPattern into its only use. NFC.
Jay Foad [Fri, 26 Mar 2021 09:31:42 +0000 (09:31 +0000)]
[AMDGPU] Inline FSHRPattern into its only use. NFC.

3 years ago[memprof][test] Make test_terse.cpp robust (sched_getcpu may happens to change)
Fangrui Song [Fri, 26 Mar 2021 07:45:58 +0000 (00:45 -0700)]
[memprof][test] Make test_terse.cpp robust (sched_getcpu may happens to change)

```
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/memprof/TestCases/test_terse.cpp:11:11: error: CHECK: expected string not found in input
// CHECK: MIB:[[STACKID:[0-9]+]]/1/40.00/40/40/20.00/20/20/[[AVELIFETIME:[0-9]+]].00/[[AVELIFETIME]]/[[AVELIFETIME]]/0/0/0/0
          ^
<stdin>:1:1: note: scanning from here
MIB:StackID/AllocCount/AveSize/MinSize/MaxSize/AveAccessCount/MinAccessCount/MaxAccessCount/AveLifetime/MinLifetime/MaxLifetime/NumMigratedCpu/NumLifetimeOverlaps/NumSameAllocCpu/NumSameDeallocCpu
^
<stdin>:4:1: note: possible intended match here
MIB:134217729/1/40.00/40/40/20.00/20/20/7.00/7/7/1/0/0/0
```

3 years ago[RISCV] Optimize (and (shl GPR:, uimm5:), 0xffffffff) to use 2 shifts instead of 3.
Craig Topper [Fri, 26 Mar 2021 06:29:34 +0000 (23:29 -0700)]
[RISCV] Optimize (and (shl GPR:, uimm5:), 0xffffffff) to use 2 shifts instead of 3.

The and would normally become SLLI+SRLI, giving us 2 SLLI+SRLI. We
can detect this and combine the 2 SLLIs into 1.

3 years ago[RISCV] Don't call CheckAndMask from selectZExti32.
Craig Topper [Fri, 26 Mar 2021 05:04:24 +0000 (22:04 -0700)]
[RISCV] Don't call CheckAndMask from selectZExti32.

Now that targetShrinkDemandedConstant preserves 0xffffffff masks we
shouldn't need to call computeKnownBits here.

3 years ago[sanitizer] Simplify GetTls with dl_iterate_phdr
Fangrui Song [Fri, 26 Mar 2021 04:55:27 +0000 (21:55 -0700)]
[sanitizer] Simplify GetTls with dl_iterate_phdr

GetTls is the range of

* thread control block and optional TLS_PRE_TCB_SIZE
* static TLS blocks plus static TLS surplus

On glibc, lsan requires the range to include
`pthread::{specific_1stblock,specific}` so that allocations only referenced by
`pthread_setspecific` can be scanned.

This patch uses `dl_iterate_phdr` to collect TLS ranges. Find the one
with `dlpi_tls_modid==1` as one of the initially loaded module, then find
consecutive ranges. The boundaries give us addr and size.

This allows us to drop the glibc internal `_dl_get_tls_static_info` and
`InitTlsSize` entirely. Use the simplified method with non-Android Linux for
now, but in theory this can be used with *BSD and potentially other ELF OSes.

In the future, we can move `ThreadDescriptorSize` code to lsan (and consider
intercepting `pthread_setspecific`) to avoid hacks in generic code.

See https://reviews.llvm.org/D93972#2480556 for analysis on GetTls usage
across various sanitizers.

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

3 years agoReapply [InlineCost] Enable the cost benefit analysis on FDO
Kazu Hirata [Fri, 26 Mar 2021 04:51:38 +0000 (21:51 -0700)]
Reapply [InlineCost] Enable the cost benefit analysis on FDO

This patch enables the cost-benefit-analysis-based inliner by default
if we have instrumentation profile.

- SPEC CPU 2017 shows a 0.4% improvement.

- An internal large benchmark shows a 0.9% reduction in the cycle
  count along with 14.6% reduction in the number of call instructions
  executed.

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

3 years ago[InlineCost] Reject a zero entry count
Kazu Hirata [Fri, 26 Mar 2021 04:51:36 +0000 (21:51 -0700)]
[InlineCost] Reject a zero entry count

This patch teaches the cost-benefit-analysis-based inliner to reject a
zero entry count so that we don't trigger a divide-by-zero.

3 years ago[mlir][tosa] TOSA MLIR dialect update to v0.22, part 1
Suraj Sudhir [Fri, 26 Mar 2021 04:22:33 +0000 (21:22 -0700)]
[mlir][tosa] TOSA MLIR dialect update to v0.22, part 1

Incremental set of updates to align to TOSA v0.22 spec

    - modify gather, resize
    - add scatter
    - remove aint8 type

Reviewed By: rsuderman

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

3 years ago[CSSPGO] Minor tweak for inline candidate priority tie breaker
Wenlei He [Thu, 25 Mar 2021 18:15:35 +0000 (11:15 -0700)]
[CSSPGO] Minor tweak for inline candidate priority tie breaker

When prioritize call site to consider for inlining in sample loader, use number of samples as a first tier breaker before using name/guid comparison. This would favor smaller functions when hotness is the same (from the same block). We could try to retrieve accurate function size if this turns out to be more important.

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

3 years ago[NFC][AMDGPU] Corrections to AMD GPU initial kernel launch documentation
Tony [Tue, 23 Mar 2021 22:38:10 +0000 (22:38 +0000)]
[NFC][AMDGPU] Corrections to AMD GPU initial kernel launch documentation

Reviewed By: rampitec

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

3 years ago[JITLink][MachO] Use full <segment>,<section> names for MachO jitlink::Sections.
Lang Hames [Fri, 26 Mar 2021 00:52:27 +0000 (17:52 -0700)]
[JITLink][MachO] Use full <segment>,<section> names for MachO jitlink::Sections.

JITLink now requires section names to be unique. In MachO section names are only
guaranteed to be unique within their containing segment (e.g. a '__const' section
in the '__DATA' segment does not clash with a '__const' section in the '__TEXT'
segment), so we need to use the fully qualified <segment>,<section> section
names (e.g. '__DATA,__const' or '__TEXT,__const') when constructing
jitlink::Sections for MachO objects.

3 years ago[mlir][python] Add docs for op class extension mechanism.
Stella Laurenzo [Thu, 25 Mar 2021 22:52:18 +0000 (15:52 -0700)]
[mlir][python] Add docs for op class extension mechanism.

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

3 years agoStop this test from dropping a .s file in the current directory.
Richard Smith [Fri, 26 Mar 2021 01:22:18 +0000 (18:22 -0700)]
Stop this test from dropping a .s file in the current directory.

3 years agoExplicitly enable the new pass manager in this test.
Richard Smith [Fri, 26 Mar 2021 01:09:40 +0000 (18:09 -0700)]
Explicitly enable the new pass manager in this test.

Otherwise it fails under -DENABLE_EXPERIMENTAL_NEW_PASS_MANAGER=OFF.

3 years ago[RISCV] Add Zbb+Zbt command lines to the signed saturing add/sub tests.
Craig Topper [Fri, 26 Mar 2021 00:15:10 +0000 (17:15 -0700)]
[RISCV] Add Zbb+Zbt command lines to the signed saturing add/sub tests.

This will enable cmov to be used for select. I improve the codegen
of select_cc in D99021, but that patch doesn't work for cmov.

3 years ago[GlobalISel] Add G_ROTR and G_ROTL opcodes for rotates.
Amara Emerson [Thu, 25 Mar 2021 06:59:40 +0000 (23:59 -0700)]
[GlobalISel] Add G_ROTR and G_ROTL opcodes for rotates.

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

3 years ago[AArch64][GlobalISel] Emit bzero on Darwin
Jessica Paquette [Thu, 25 Mar 2021 06:45:36 +0000 (23:45 -0700)]
[AArch64][GlobalISel] Emit bzero on Darwin

Darwin platforms for both AArch64 and X86 can provide optimized `bzero()`
routines. In this case, it may be preferable to use `bzero` in place of a
memset of 0.

This adds a G_BZERO generic opcode, similar to G_MEMSET et al. This opcode can
be generated by platforms which may want to use bzero.

To emit the G_BZERO, this adds a pre-legalize combine for AArch64. The
conditions for this are largely a port of the bzero case in
`AArch64SelectionDAGInfo::EmitTargetCodeForMemset`.

The only difference in comparison to the SelectionDAG code is that, when
compiling for minsize, this will fire for all memsets of 0. The original code
notes that it's not beneficial to do this for small memsets; however, using
bzero here will save a mov from wzr. For minsize, I think that it's preferable
to prioritise omitting the mov.

This also fixes a bug in the libcall legalization code which would delete
instructions which could not be legalized. It also adds a check to make sure
that we actually get a libcall name.

Code size improvements (Darwin):

- CTMark -Os: -0.0% geomean (-0.1% on pairlocalalign)
- CTMark -Oz: -0.2% geomean (-0.5% on bullet)

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

3 years agoAdd a target triple to fix test failure on targets that don't support
Richard Smith [Fri, 26 Mar 2021 00:05:36 +0000 (17:05 -0700)]
Add a target triple to fix test failure on targets that don't support
__int128.

3 years agoFix a miscompile introduced by 99203f2.
Richard Smith [Thu, 25 Mar 2021 23:51:56 +0000 (16:51 -0700)]
Fix a miscompile introduced by 99203f2.

getPointersDiff would previously round down the difference between two
pointers to a multiple of the element size of the pointee, which could
result in a pointer value being decreased a little.

Alexey Bataev has graciously agreed to add a testcase for this;
submitting the bugfix now to unblock.

3 years agoAdd missing 'CHECK' prefix to basic block labels test.
Rahman Lavaee [Thu, 25 Mar 2021 23:36:54 +0000 (16:36 -0700)]
Add missing 'CHECK' prefix to basic block labels test.

The `CHECK` prefix was dropped in e0bf2349303f. This lead to all CHECK
lines having no effect.

Reviewed By: tmsriram

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

3 years ago[LLDB] Skip TestVSCode_launch.test_progress_events arm/linux
Muhammad Omair Javaid [Thu, 25 Mar 2021 23:37:49 +0000 (04:37 +0500)]
[LLDB] Skip TestVSCode_launch.test_progress_events arm/linux

TestVSCode_launch.test_progress_events is mysteriously failing on arm
linux. I am marking it skipped for the buildbot while looking into
failure.

3 years ago[Triple][Driver] Add muslx32 environment and use /lib/ld-musl-x32.so.1 for -dynamic...
Fangrui Song [Thu, 25 Mar 2021 23:25:47 +0000 (16:25 -0700)]
[Triple][Driver] Add muslx32 environment and use /lib/ld-musl-x32.so.1 for -dynamic-linker

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

3 years agoBPF: add extern func to data sections if specified
Yonghong Song [Thu, 25 Mar 2021 21:09:19 +0000 (14:09 -0700)]
BPF: add extern func to data sections if specified

This permits extern function (BTF_KIND_FUNC) be added
to BTF_KIND_DATASEC if a section name is specified.
For example,

-bash-4.4$ cat t.c
void foo(int) __attribute__((section(".kernel.funcs")));
int test(void) {
  foo(5);
  return 0;
}

The extern function foo (BTF_KIND_FUNC) will be put into
BTF_KIND_DATASEC with name ".kernel.funcs".

This will help to differentiate two kinds of external functions,
functions in kernel and functions defined in other bpf programs.

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

3 years ago[ValueTracking] Handle two PHIs in isKnownNonEqual()
Jingu Kang [Thu, 11 Mar 2021 13:07:36 +0000 (13:07 +0000)]
[ValueTracking] Handle two PHIs in isKnownNonEqual()

loop:
  %cmp.0 = phi i32 [ 3, %entry ], [ %inc, %loop ]
  %pos.0 = phi i32 [ 1, %entry ], [ %cmp.0, %loop ]
  ...
  %inc = add i32 %cmp.0, 1
  br label %loop

On above example, %pos.0 uses previous iteration's %cmp.0 with backedge
according to PHI's instruction's defintion. If the %inc is not same among
iterations, we can say the two PHIs are not same.

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

3 years ago[lldb] Add IsFullyInitialized to DynamicLoader
Jonas Devlieghere [Wed, 24 Mar 2021 16:57:00 +0000 (09:57 -0700)]
[lldb] Add IsFullyInitialized to DynamicLoader

On Darwin based systems, lldb will get notified by dyld before it itself
finished initializing, at which point it's not safe to call certain APIs
or SPIs. Add a method to the DynamicLoader to query that.

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

3 years ago[llvm][hwasan] Add Fuchsia shadow mapping configuration
Leonard Chan [Thu, 25 Mar 2021 21:26:00 +0000 (14:26 -0700)]
[llvm][hwasan] Add Fuchsia shadow mapping configuration

Ensure that Fuchsia shadow memory starts at zero.

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

3 years ago[mlir][linalg] Add an InitTensorOp python builder.
Stella Laurenzo [Sat, 20 Mar 2021 01:16:45 +0000 (18:16 -0700)]
[mlir][linalg] Add an InitTensorOp python builder.

* This has the API I want but I am not thrilled with the implementation. There are various things that could be improved both about the way that Python builders are mapped and the way the Linalg ops are factored to increase code sharing between C++/Python.
* Landing this as-is since it at least makes the InitTensorOp usable with the right API. Will refactor underneath in follow-ons.

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

3 years ago[DAE] Adjust param/arg attributes when changing parameter to undef
Guozhi Wei [Thu, 25 Mar 2021 21:50:18 +0000 (14:50 -0700)]
[DAE] Adjust param/arg attributes when changing parameter to undef

In DeadArgumentElimination pass, if a function's argument is never used, corresponding caller's parameter can be changed to undef. If the param/arg has attribute noundef or other related attributes, LLVM LangRef(https://llvm.org/docs/LangRef.html#parameter-attributes) says its behavior is undefined. SimplifyCFG(D97244) takes advantage of this behavior and does bad transformation on valid code.

To avoid this undefined behavior when change caller's parameter to undef, this patch removes noundef attribute and other attributes imply noundef on param/arg.

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