platform/upstream/llvm.git
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

3 years agoMark gc.relocate and gc.result as readnone (try 2)
Philip Reames [Thu, 25 Mar 2021 21:50:07 +0000 (14:50 -0700)]
Mark gc.relocate and gc.result as readnone (try 2)

As noted in the LangRef, these are semantically readnone projections from the result value of the associated statepoint. However, it turned out we had a few latent bugs being covered up by the fact we were only marking them readonly (see PR49607 for context).

As of this change, all known issues are resolved. This is a deliberately minimal patch to make it easy to test downstream and revert with minimal change if that turns out to be necessary.

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

3 years ago[deref] Handle byval/byref/sret/inalloc/preallocated arguments for deref-at-point...
Philip Reames [Thu, 25 Mar 2021 21:47:31 +0000 (14:47 -0700)]
[deref] Handle byval/byref/sret/inalloc/preallocated arguments for deref-at-point semantics

All of these are scoped allocations which remain dereferenceable during the lifetime of the callee.

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

3 years agoAutogen test to account for tool output format change
Philip Reames [Thu, 25 Mar 2021 21:41:08 +0000 (14:41 -0700)]
Autogen test to account for tool output format change

3 years ago[test] Add test for hoisting to custom allocation function using allocsize
Philip Reames [Thu, 25 Mar 2021 21:08:39 +0000 (14:08 -0700)]
[test] Add test for hoisting to custom allocation function using allocsize

The first is currently demonstrating a miscompile.

3 years agoHandle 128-bits IntegerLiterals in StmtPrinter
David Stone [Thu, 25 Mar 2021 21:27:13 +0000 (17:27 -0400)]
Handle 128-bits IntegerLiterals in StmtPrinter

This fixes PR35677: "int128_t or uint128_t as non-type template
parameter causes crash when considering invalid constructor".

3 years ago[lldb/Commands] Fix spelling of target.move-to-nearest-code in helptext
Vedant Kumar [Thu, 25 Mar 2021 21:24:59 +0000 (14:24 -0700)]
[lldb/Commands] Fix spelling of target.move-to-nearest-code in helptext

3 years ago[HWASan] Mention x86_64 aliasing mode in design doc.
Matt Morehouse [Thu, 25 Mar 2021 21:20:48 +0000 (14:20 -0700)]
[HWASan] Mention x86_64 aliasing mode in design doc.

Reviewed By: eugenis

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

3 years ago[RISCV] Reorder checks in RISCVTTIImpl::getGatherScatterOpCost to avoid calling getMi...
Craig Topper [Thu, 25 Mar 2021 21:20:38 +0000 (14:20 -0700)]
[RISCV] Reorder checks in RISCVTTIImpl::getGatherScatterOpCost to avoid calling getMinRVVVectorSizeInBits() when V extension is not enabled.

getMinRVVVectorSizeInBits() asserts if the V extension isn't
enabled. So check that gather/scatter is legal first since it
already contains a check for V extension being enabled. It
also already checks getMinRVVVectorSizeInBits for fixed length
vectors so we don't need a check in getGatherScatterOpCost.

3 years ago[MCA] Support carry-over instructions for in-order processors
Andrew Savonichev [Wed, 24 Mar 2021 20:33:21 +0000 (23:33 +0300)]
[MCA] Support carry-over instructions for in-order processors

Instructions that have more uops than the processor's IssueWidth are
issued in multiple cycles.

The patch fixes PR49712.

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

3 years ago[OpenMP][InstrProfiling] Fix a missing instr profiling counter
Xun Li [Thu, 25 Mar 2021 20:52:36 +0000 (13:52 -0700)]
[OpenMP][InstrProfiling] Fix a missing instr profiling counter

When emitting a function body there needs to be a instr profiling counter emitted. Otherwise instr profiling won't work for this function.

Reviewed By: MaskRay

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

3 years agoPR49724: Fix deduction of null member pointers.
Richard Smith [Thu, 25 Mar 2021 20:46:23 +0000 (13:46 -0700)]
PR49724: Fix deduction of null member pointers.

Previously we created an implicit cast of the wrong kind, which we'd
later fail to constant-evaluate, resulting in deduction failure.

3 years agoReland [lld-macho][nfc] minor clean up, follow up to D98559
Vy Nguyen [Wed, 24 Mar 2021 01:27:58 +0000 (21:27 -0400)]
Reland [lld-macho][nfc] minor clean up, follow up to D98559

This reverts commit 77b4230ed9bea541fd3fb04707e35308c2f34347.

New change: Fixed tests on windows

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

3 years ago[Coroutine][Clang] Force emit lifetime intrinsics for Coroutines
Xun Li [Thu, 25 Mar 2021 20:46:20 +0000 (13:46 -0700)]
[Coroutine][Clang] Force emit lifetime intrinsics for Coroutines

tl;dr Correct implementation of Corouintes requires having lifetime intrinsics available.

Coroutine functions are functions that can be suspended and resumed latter. To do so, data that need to stay alive after suspension must be put on the heap (i.e. the coroutine frame).
The optimizer is responsible for analyzing each AllocaInst and figure out whether it should be put on the stack or the frame.
In most cases, for data that we are unable to accurately analyze lifetime, we can just conservatively put them on the heap.
Unfortunately, there exists a few cases where certain data MUST be put on the stack, not on the heap. Without lifetime intrinsics, we are unable to correctly analyze those data's lifetime.

To dig into more details, there exists cases where at certain code points, the current coroutine frame may have already been destroyed. Hence no frame access would be allowed beyond that point.
The following is a common code pattern called "Symmetric Transfer" in coroutine:
```
auto tmp = await_suspend();
__builtin_coro_resume(tmp.address());
return;
```
In the above code example, `await_suspend()` returns a new coroutine handle, which we will obtain the address and then resume that coroutine. This essentially "transfered" from the current coroutine to a different coroutine.
During the call to `await_suspend()`, the current coroutine may be destroyed, which should be fine because we are not accessing any data afterwards.
However when LLVM is emitting IR for the above code, it needs to emit an AllocaInst for `tmp`. It will then call the `address` function on tmp. `address` function is a member function of coroutine, and there is no way for the LLVM optimizer to know that it does not capture the `tmp` pointer. So when the optimizer looks at it, it has to conservatively assume that `tmp` may escape and hence put it on the heap. Furthermore, in some cases `address` call would be inlined, which will generate a bunch of store/load instructions that move the `tmp` pointer around. Those stores will also make the compiler to think that `tmp` might escape.
To summarize, it's really difficult for the mid-end to figure out that the `tmp` data is short-lived.
I made some attempt in D98638, but it appears to be way too complex and is basically doing the same thing as inserting lifetime intrinsics in coroutines.

Also, for reference, we already force emitting lifetime intrinsics in O0 for AlwaysInliner: https://github.com/llvm/llvm-project/blob/main/llvm/lib/Passes/PassBuilder.cpp#L1893

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

3 years agoRevert "[InlineCost] Enable the cost benefit analysis on FDO"
Nico Weber [Thu, 25 Mar 2021 20:41:32 +0000 (16:41 -0400)]
Revert "[InlineCost] Enable the cost benefit analysis on FDO"

This reverts commit ef69aa961d12dee2141a79b05c9637d8cc9c0c74.
Makes clang assert in PGO builds, see repro tgz in
https://bugs.chromium.org/p/chromium/issues/detail?id=1192783#c6

3 years ago[clang][driver] Support HWASan in the Fuchsia toolchain
Leonard Chan [Thu, 25 Mar 2021 18:30:44 +0000 (11:30 -0700)]
[clang][driver] Support HWASan in the Fuchsia toolchain

These contain clang driver changes for supporting HWASan on Fuchsia.
This includes hwasan multilibs and the dylib path change.

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

3 years ago[NFCI][SimplifyCFG] Don't pay for a Small{Map,Set}Vector when plain SmallSet will...
Roman Lebedev [Thu, 25 Mar 2021 19:58:10 +0000 (22:58 +0300)]
[NFCI][SimplifyCFG] Don't pay for a Small{Map,Set}Vector when plain SmallSet will suffice

This *only* changes the cases where we *really* don't care
about the iteration order of the underlying contained,
namely when we will use the values from it to form DTU updates.

3 years ago[IR] Lift attribute handling for assume bundles into CallBase
Nikita Popov [Wed, 24 Mar 2021 16:56:23 +0000 (17:56 +0100)]
[IR] Lift attribute handling for assume bundles into CallBase

Rather than special-casing assume in BasicAA getModRefBehavior(),
do this one level higher, in the attribute handling of CallBase.

For assumes with operand bundles, the inaccessiblememonly attribute
applies regardless of operand bundles.

3 years ago[PowerPC] auto-generate complete testchecks; NFC
Sanjay Patel [Thu, 25 Mar 2021 18:58:51 +0000 (14:58 -0400)]
[PowerPC] auto-generate complete testchecks; NFC

The full checks demonstrate a problem that comes up in:
https://llvm.org/PR49610

3 years ago[flang] fix spurious runtime crash on TRIM('')
peter klausler [Thu, 25 Mar 2021 18:03:32 +0000 (11:03 -0700)]
[flang] fix spurious runtime crash on TRIM('')

The standard interoperability routine CFI_establish() does not
accept a zero-length CHARACTER type.  Since these can be valid
results of intrinsic function references, work around the design
of CFI_establish() in the wrapper routine that calls it.

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

3 years ago[Support][Windows] Make sure only executables are found by sys::findProgramByName
Markus Böck [Thu, 25 Mar 2021 19:26:20 +0000 (20:26 +0100)]
[Support][Windows] Make sure only executables are found by sys::findProgramByName

The function utilizes Windows' SearchPathW function, which as I found out today, may also return directories. After looking at the Unix implementation of the file I found that it contains a check whether the found path is also executable. While fixing the Windows implementation, I also learned that sys::fs::access returns successfully when querying whether directories are executable, which the Unix version does not.

This patch makes both of these functions equivalent to their Unix implementation and insures that any path returned by sys::findProgramByName on Windows may only be executable, just like the Unix implementation.

The equivalent additions I have made to the Windows implementation, in the Unix implementation are here:
sys::findProgramByName: https://github.com/llvm/llvm-project/blob/39ecfe614350fa5db7b8f13f81212f8e3831a390/llvm/lib/Support/Unix/Program.inc#L90
sys::fs::access: https://github.com/llvm/llvm-project/blob/c2a84771bb63947695ea50b89160c02b36fb634d/llvm/lib/Support/Unix/Path.inc#L608

I encountered this issue when running the LLVM testsuite. Commands of the form not test ... would fail to correctly execute test.exe, which is part of GnuWin32, as it actually tried to execute a folder called test, which happened to be in a directory on my PATH.

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

3 years ago[NFC] Module::getInstructionCount() is const
Mircea Trofin [Thu, 25 Mar 2021 19:28:47 +0000 (12:28 -0700)]
[NFC] Module::getInstructionCount() is const

3 years ago[CUDA][HIP] add __builtin_get_device_side_mangled_name
Yaxun (Sam) Liu [Wed, 24 Mar 2021 21:28:56 +0000 (17:28 -0400)]
[CUDA][HIP] add __builtin_get_device_side_mangled_name

Add builtin function __builtin_get_device_side_mangled_name
to get device side manged name for functions and global
variables, which can be used to get symbol address of kernels
or variables by mangled name in dynamically loaded
bundled code objects at run time.

Reviewed by: Artem Belevich

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

3 years ago[AMDGPU] Refactoring mfma intrinsic definitions. NFC.
Stanislav Mekhanoshin [Thu, 25 Mar 2021 19:04:57 +0000 (12:04 -0700)]
[AMDGPU] Refactoring mfma intrinsic definitions. NFC.

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

3 years ago[lld-macho][nfc] Removed unnecessary static_cast
Vy Nguyen [Thu, 25 Mar 2021 18:59:54 +0000 (14:59 -0400)]
[lld-macho][nfc] Removed unnecessary static_cast

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

3 years ago[flang][driver] Fix typos and inconsistent comments (nfc)
Andrzej Warzynski [Thu, 25 Mar 2021 18:59:48 +0000 (18:59 +0000)]
[flang][driver] Fix typos and inconsistent comments (nfc)