platform/upstream/llvm.git
3 years ago[InstCombine] add/adjust tests for add+xor -> shifts; NFC
Sanjay Patel [Sat, 10 Oct 2020 13:50:34 +0000 (09:50 -0400)]
[InstCombine] add/adjust tests for add+xor -> shifts; NFC

3 years ago[VE][NFC] Clean VEISelLowering.cpp
Kazushi (Jam) Marukawa [Sun, 11 Oct 2020 10:34:12 +0000 (19:34 +0900)]
[VE][NFC] Clean VEISelLowering.cpp

Clean the order of setOperationActions and others.

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

3 years agoFix Wdocumentation warning. NFCI.
Simon Pilgrim [Sun, 11 Oct 2020 10:25:22 +0000 (11:25 +0100)]
Fix Wdocumentation warning. NFCI.

Add a space after /param names before any commas otherwise the doxygen parsers get confused.

3 years ago[X86][SSE2] Use smarter instruction patterns for lowering UMIN/UMAX with v8i16.
Simon Pilgrim [Sun, 11 Oct 2020 10:21:23 +0000 (11:21 +0100)]
[X86][SSE2] Use smarter instruction patterns for lowering UMIN/UMAX with v8i16.

This is my first LLVM patch, so please tell me if there are any process issues.

The main observation for this patch is that we can lower UMIN/UMAX with v8i16 by using unsigned saturated subtractions in a clever way. Previously this operation was lowered by turning the signbit of both inputs and the output which turns the unsigned minimum/maximum into a signed one.

We could use this trick in reverse for lowering SMIN/SMAX with v16i8 instead. In terms of latency/throughput this is the needs one large move instruction. It's just that the sign bit turning has an increased chance of being optimized further. This is particularly apparent in the "reduce" test cases. However due to the slight regression in the single use case, this patch no longer proposes this.

Unfortunately this argument also applies in reverse to the new lowering of UMIN/UMAX with v8i16 which regresses the "horizontal-reduce-umax", "horizontal-reduce-umin", "vector-reduce-umin" and "vector-reduce-umax" test cases a bit with this patch. Maybe some extra casework would be possible to avoid this. However independent of that I believe that the benefits in the common case of just 1 to 3 chained min/max instructions outweighs the downsides in that specific case.

Patch By: @TomHender (Tom Hender) ActuallyaDeviloper

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

3 years ago[InstCombine] Remove accidental unnecessary ConstantExpr qualification added in rGb75...
Simon Pilgrim [Sun, 11 Oct 2020 09:39:51 +0000 (10:39 +0100)]
[InstCombine] Remove accidental unnecessary ConstantExpr qualification added in rGb752daa26b64155

MSVC didn't complain but everything else did....

3 years ago[InstCombine] matchFunnelShift - fold or(shl(a,x),lshr(b,sub(bw,x))) -> fshl(a,b...
Simon Pilgrim [Sun, 11 Oct 2020 09:37:20 +0000 (10:37 +0100)]
[InstCombine] matchFunnelShift - fold or(shl(a,x),lshr(b,sub(bw,x))) -> fshl(a,b,x) iff x < bw

If value tracking can confirm that a shift value is less than the type bitwidth then we can more confidently fold general or(shl(a,x),lshr(b,sub(bw,x))) patterns to a funnel/rotate intrinsic pattern without causing bad codegen regressions in the backend (see D89139).

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

3 years ago[InstCombine] Replace getLogBase2 internal helper with ConstantExpr::getExactLogBase2...
Simon Pilgrim [Sun, 11 Oct 2020 09:31:17 +0000 (10:31 +0100)]
[InstCombine] Replace getLogBase2 internal helper with ConstantExpr::getExactLogBase2. NFCI.

This exposes the helper for other power-of-2 instcombine folds that I'm intending to add vector support to.

The helper only operated on power-of-2 constants so getExactLogBase2 is a more accurate name.

3 years ago[mlir] add scf.if op canonicalization pattern that removes unused results
Tobias Gysi [Sun, 11 Oct 2020 08:40:28 +0000 (10:40 +0200)]
[mlir] add scf.if op canonicalization pattern that removes unused results

The patch adds a canonicalization pattern that removes the unused results of scf.if operation. As a result, cse may remove unused computations in the then and else regions of the scf.if operation.

Reviewed By: mehdi_amini

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

3 years ago[Coroutines] Refactor/Rewrite Spill and Alloca processing
Xun Li [Sun, 11 Oct 2020 05:21:34 +0000 (22:21 -0700)]
[Coroutines] Refactor/Rewrite Spill and Alloca processing

This patch is a refactoring of how we process spills and allocas during CoroSplit.
In the previous implementation, everything that needs to go to the heap is put into Spills, including all the values defined by allocas.
And the way to identify a Spill, is to check whether there exists a use-def relationship that crosses suspension points.

This approach is fundamentally confusing, and unfortunately, incorrect.
First of all, allocas are always process differently than spills, hence it's quite confusing to put them together. It's a much cleaner to separate them and process them separately.
Doing so simplify lots of code and makes the logic more clear and easier to reason about.

Secondly, use-def relationship is insufficient to decide whether a value defined by AllocaInst needs to go to the heap.
There are many cases where a value defined by AllocaInst can implicitly be used across suspension points without a direct use-def relationship.
For example, you can store the address of an alloca into the heap, and load that address after suspension. Or you can escape the address into an object through a function call.
Or you can have a PHINode that takes two allocas, and this PHINode is used across suspension point (when this happens, the existing implementation will spill the PHINode, a.k.a a stack adddress to the heap!).
All these issues suggest that we need to separate spill and alloca in order to properly implement this.
This patch does not yet fix these bugs, however it sets up the code in a better shape so that we can start fixing them in the next patch.

The core idea of this patch is to add a new struct called FrameDataInfo, which contains all Spills, all Allocas, and a map from each definition to its layout index in the frame (FieldIndexMap).
Spills and Allocas are identified, stored and processed independently. When they are initially added to the frame, we record their field index through FieldIndexMap. When the frame layout is finalized, we update each index into their final layout index.

In doing so, I also cleaned up a few things and also discovered a few other bugs.

Cleanups:
1. Found out that PromiseFieldId is not used, delete it.
2. Previously, SpillInfo is a vector, which is strange because every def can have multiple users. This patch cleans it up by turning it into a map from def to users.
3. Previously, a frame Field struct contains a list of Spills that field corresponds to. This isn't necessary since we only need the layout index for each given definition. This patch removes that list. Instead, we connect each field and definition using the FieldIndexMap.
4. All the loops that process Spills are simplified now because we use a map instead of a vector.

Bugs:
It seems that we are only keeping llvm.dbg.declare intrinsics in the .resume part of the function. The ramp function will no longer has it. This means we are dropping some debug information in the ramp function.

The next step is to start fixing the bugs where the implementation fails to identify some allocas that should live on the frame.

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

3 years ago[X86] Redefine X86ISD::PEXTRB/W and X86ISD::PINSRB/PINSRW to use a i8 TargetConstant...
Craig Topper [Sun, 11 Oct 2020 04:34:37 +0000 (21:34 -0700)]
[X86] Redefine X86ISD::PEXTRB/W and X86ISD::PINSRB/PINSRW to use a i8 TargetConstant for the immediate instead of a ptr constant.

This is more consistent with other target specific ISD opcodes that
require immediates.

3 years ago[X86] AMX intrinsics should have ImmArg for the register numbers and use timm in...
Craig Topper [Sun, 11 Oct 2020 03:11:26 +0000 (20:11 -0700)]
[X86] AMX intrinsics should have ImmArg for the register numbers and use timm in isel patterns.

3 years ago[X86] Add a X86ISD::BEXTRI to distinquish the case where the control must be a constant.
Craig Topper [Sun, 11 Oct 2020 02:18:02 +0000 (19:18 -0700)]
[X86] Add a X86ISD::BEXTRI to distinquish the case where the control must be a constant.

The bextri intrinsic has a ImmArg attribute which will be converted
in SelectionDAG using TargetConstant. We previously converted this
to a plain Constant to allow X86ISD::BEXTR to call SimplifyDemandedBits
on it.

But while trying to decide if D89178 was safe, I realized that
this conversion of TargetConstant to Constant would be one case
where that would break.

So this patch adds a new opcode specifically for the immediate case.
And then teaches computeKnownBits and SimplifyDemandedBits to also
handle it, but not try to SimplifyDemandedBits on it. To make up
for that, I immediately masked the constant to 16 bits when
converting from the intrinsic node to the X86ISD node.

3 years ago[Hexagon] Replace HexagonISD::VSPLAT with ISD::SPLAT_VECTOR
Krzysztof Parzyszek [Sat, 10 Oct 2020 01:17:50 +0000 (20:17 -0500)]
[Hexagon] Replace HexagonISD::VSPLAT with ISD::SPLAT_VECTOR

This removes VSPLAT and VZERO. VZERO is now SPLAT_VECTOR of (i32 0).

Included is also a testcase for the previous (target-independent)
commit.

3 years ago[SDAG] Remember to set UndefElts in isSplatValue for SPLAT_VECTOR
Krzysztof Parzyszek [Sat, 10 Oct 2020 20:37:32 +0000 (15:37 -0500)]
[SDAG] Remember to set UndefElts in isSplatValue for SPLAT_VECTOR

3 years ago[X86] Delete redundant 'static' from namespace scope 'static constexpr'. NFC
Fangrui Song [Sat, 10 Oct 2020 21:05:48 +0000 (14:05 -0700)]
[X86] Delete redundant 'static' from namespace scope 'static constexpr'. NFC

This decreases 7 lines as the result of packing more bits on one line.

3 years ago[InstCombine] getLogBase2(undef) -> 0.
Simon Pilgrim [Sat, 10 Oct 2020 19:28:50 +0000 (20:28 +0100)]
[InstCombine] getLogBase2(undef) -> 0.

Move the undef element handling into the getLogBase2 helper instead of pre-empting with replaceUndefsWith.

3 years agoFix CMake configuration error when run with -Werror/-Wall
Alex Denisov [Sat, 10 Oct 2020 19:22:40 +0000 (21:22 +0200)]
Fix CMake configuration error when run with -Werror/-Wall

The following code doesn't compile

  uint64_t i = x.load(std::memory_order_relaxed);
  return 0;

when CMAKE_C_FLAGS set to -Werror -Wall, thus incorrectly
breaking the CMake configuration step:

  -- Looking for __atomic_load_8 in atomic
  -- Looking for __atomic_load_8 in atomic - not found
  CMake Error at cmake/modules/CheckAtomic.cmake:79 (message):
    Host compiler appears to require libatomic for 64-bit operations, but
    cannot find it.
  Call Stack (most recent call first):
    cmake/config-ix.cmake:360 (include)
    CMakeLists.txt:671 (include)

3 years ago[InstCombine] getLogBase2 - no need to specify Type. NFCI.
Simon Pilgrim [Sat, 10 Oct 2020 19:09:55 +0000 (20:09 +0100)]
[InstCombine] getLogBase2 - no need to specify Type. NFCI.

In all the getLogBase2 uses, the specified Type is always the same as the constant being folded.

3 years agoRemove %tmp variables from test cases to appease update_test_checks.py
Simon Pilgrim [Sat, 10 Oct 2020 18:13:01 +0000 (19:13 +0100)]
Remove %tmp variables from test cases to appease update_test_checks.py

3 years ago[PowerPC] ReplaceNodeResults - bail on funnel shifts and let generic legalizers deal...
Simon Pilgrim [Sat, 10 Oct 2020 18:09:58 +0000 (19:09 +0100)]
[PowerPC] ReplaceNodeResults - bail on funnel shifts and let generic legalizers deal with it

Fixes regression raised on D88834 for 32-bit triple + 64-bit cpu cases (which apparently is a thing).

3 years agoDefine splat_vector for ISD::SPLAT_VECTOR in TargetSelectionDAG.td
Krzysztof Parzyszek [Sat, 10 Oct 2020 01:16:09 +0000 (20:16 -0500)]
Define splat_vector for ISD::SPLAT_VECTOR in TargetSelectionDAG.td

3 years ago[lldb] [Windows] Remove unused functions. NFC.
Martin Storsjö [Sat, 10 Oct 2020 11:33:10 +0000 (14:33 +0300)]
[lldb] [Windows] Remove unused functions. NFC.

These became unused in 51117e3c51754f3732e.

3 years ago[lldb] [Windows] Add missing 'override', silencing warnings. NFC.
Martin Storsjö [Sat, 10 Oct 2020 11:26:32 +0000 (14:26 +0300)]
[lldb] [Windows] Add missing 'override', silencing warnings. NFC.

Also remove superfluous 'virtual' in overridden methods.

3 years ago[PowerPC] Add ppc32 funnel shift test coverage
Simon Pilgrim [Sat, 10 Oct 2020 17:18:57 +0000 (18:18 +0100)]
[PowerPC] Add ppc32 funnel shift test coverage

3 years ago[InstCombine] Add test case showing rotate intrinsic being split by SimplifyDemandedBits
Simon Pilgrim [Sat, 10 Oct 2020 15:28:59 +0000 (16:28 +0100)]
[InstCombine] Add test case showing rotate intrinsic being split by SimplifyDemandedBits

Noticed while triaging regression report on D88834

3 years ago[lldb] [Process/FreeBSDRemote] Fix double semicolon
Michał Górny [Sat, 10 Oct 2020 16:54:52 +0000 (18:54 +0200)]
[lldb] [Process/FreeBSDRemote] Fix double semicolon

3 years ago[lldb] [Process/FreeBSDRemote] Kill process via PT_KILL
Michał Górny [Sat, 10 Oct 2020 07:36:57 +0000 (09:36 +0200)]
[lldb] [Process/FreeBSDRemote] Kill process via PT_KILL

Use PT_KILL to kill the stopped process.  This ensures that the process
termination is reported properly and fixes delay/error on killing it.

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

3 years ago[lldb] [Process/FreeBSD] Mark methods override in RegisterContext*
Michał Górny [Sat, 10 Oct 2020 07:23:15 +0000 (09:23 +0200)]
[lldb] [Process/FreeBSD] Mark methods override in RegisterContext*

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

3 years agoStep down from security group
Philip Reames [Sat, 10 Oct 2020 16:48:02 +0000 (09:48 -0700)]
Step down from security group

Resigning from security group as Azul representative as I have left Azul.  Previously communicated via email with security group.

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

3 years ago[AMDGPU] Add gfx602, gfx705, gfx805 targets
Tim Renouf [Tue, 6 Oct 2020 17:23:59 +0000 (18:23 +0100)]
[AMDGPU] Add gfx602, gfx705, gfx805 targets

At AMD, in an internal audit of our code, we found some corner cases
where we were not quite differentiating targets enough for some old
hardware. This commit is part of fixing that by adding three new
targets:

* The "Oland" and "Hainan" variants of gfx601 are now split out into
  gfx602. LLPC (in the GPUOpen driver) and other front-ends could use
  that to avoid using the shaderZExport workaround on gfx602.

* One variant of gfx703 is now split out into gfx705. LLPC and other
  front-ends could use that to avoid using the
  shaderSpiCsRegAllocFragmentation workaround on gfx705.

* The "TongaPro" variant of gfx802 is now split out into gfx805.
  TongaPro has a faster 64-bit shift than its former friends in gfx802,
  and a subtarget feature could be set up for that to take advantage of
  it. This commit does not make that change; it just adds the target.

V2: Add clang changes. Put TargetParser list in order.
V3: AMDGCNGPUs table in TargetParser.cpp needs to be in GPUKind order,
    so fix the GPUKind order.

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

Change-Id: Ia901a7157eb2f73ccd9f25dbacec38427312377d

3 years ago[SCEV] Add test cases where the max BTC is imprecise, due to step != 1.
Florian Hahn [Sat, 10 Oct 2020 15:39:48 +0000 (16:39 +0100)]
[SCEV] Add test cases where the max BTC is imprecise, due to step != 1.

Add a test case where we fail to compute a tight max backedge taken
count, due to the step being != 1.

This is part of the issue with PR40961.

3 years ago[SCEV] Handle ULE in applyLoopGuards.
Florian Hahn [Sat, 10 Oct 2020 15:20:37 +0000 (16:20 +0100)]
[SCEV] Handle ULE in applyLoopGuards.

Handle ULE predicate in similar fashion to ULT predicate in
applyLoopGuards.

3 years ago[SCEV] Add a test case with ULE loop guard.
Florian Hahn [Sat, 10 Oct 2020 11:26:01 +0000 (12:26 +0100)]
[SCEV] Add a test case with ULE loop guard.

3 years ago[MemCpyOpt] Add test for incorrect memset DSE (NFC)
Nikita Popov [Sat, 10 Oct 2020 14:09:15 +0000 (16:09 +0200)]
[MemCpyOpt] Add test for incorrect memset DSE (NFC)

We can't shorten the memset if there's a throwing call in between
and the destination is non-local.

3 years ago[ARM] Attempt to make Tail predication / RDA more resilient to empty blocks
David Green [Sat, 10 Oct 2020 13:50:25 +0000 (14:50 +0100)]
[ARM] Attempt to make Tail predication / RDA more resilient to empty blocks

There are a number of places in RDA where we assume the block will not
be empty. This isn't necessarily true for tail predicated loops where we
have removed instructions. This attempt to make the pass more resilient
to empty blocks, not casting pointers to machine instructions where they
would be invalid.

The test contains a case that was previously failing, but recently been
hidden on trunk. It contains an empty block to begin with to show a
similar error.

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

3 years ago[DebugInfo] Support for DWARF attribute DW_AT_rank
Alok Kumar Sharma [Sat, 10 Oct 2020 12:18:35 +0000 (17:48 +0530)]
[DebugInfo] Support for DWARF attribute DW_AT_rank

This patch adds support for DWARF attribute DW_AT_rank.

  Summary:
Fortran assumed rank arrays have dynamic rank. DWARF attribute
DW_AT_rank is needed to support that.

  Testing:
unit test cases added (hand-written)
check llvm
check debug-info

Reviewed By: aprantl

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

3 years ago[clangd] Map bits/stdint-intn.h and bits/stdint-uintn.h to cstdint.
Benjamin Kramer [Sat, 10 Oct 2020 12:13:42 +0000 (14:13 +0200)]
[clangd] Map bits/stdint-intn.h and bits/stdint-uintn.h to cstdint.

These are private glibc headers containing parts of the implementation
of stdint.h.

3 years ago[AArch64][LV] Move vectorizer test to Transforms/LoopVectorize/AArch64. NFC
David Green [Sat, 10 Oct 2020 09:15:43 +0000 (10:15 +0100)]
[AArch64][LV] Move vectorizer test to Transforms/LoopVectorize/AArch64. NFC

3 years ago[TblGen][Scheduling] Fix debug output. NFC
David Green [Sat, 10 Oct 2020 09:04:28 +0000 (10:04 +0100)]
[TblGen][Scheduling] Fix debug output. NFC

This just moves some newlines to the expected places.

3 years ago[mlir][scf] Fix a bug in scf::ForOp loop unroll with an epilogue
Tatiana Shpeisman [Sat, 10 Oct 2020 08:45:05 +0000 (14:15 +0530)]
[mlir][scf] Fix a bug in scf::ForOp loop unroll with an epilogue

Fixes a bug in formation and simplification of an epilogue loop generated
during loop unroll of scf::ForOp (https://bugs.llvm.org/show_bug.cgi?id=46689)

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

3 years ago[MemCpyOpt] Don't hoist store that's not guaranteed to execute
Nikita Popov [Fri, 9 Oct 2020 19:09:16 +0000 (21:09 +0200)]
[MemCpyOpt] Don't hoist store that's not guaranteed to execute

MemCpyOpt can hoist stores while load+store pairs into memcpy.
This hoisting can currently result in stores being executed that
weren't guaranteed to execute in the original problem.

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

3 years ago[Statepoints] Allow deopt GC pointer on VReg if gc-live bundle is empty.
Denis Antrushin [Wed, 7 Oct 2020 18:32:50 +0000 (01:32 +0700)]
[Statepoints] Allow deopt GC pointer on VReg if gc-live bundle is empty.

Currently we allow passing pointers from deopt bundle on VReg only if
they were seen in list of gc-live pointers passed on VRegs.
This means that for the case of empty gc-live bundle we spill deopt
bundle's pointers. This change allows lowering deopt pointers to VRegs
in case of empty gc-live bundle. In case of non-empty gc-live bundle,
behavior does not change.

Reviewed By: skatkov

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

3 years ago[CSKY 1/n] Add basic stub or infra of csky backend
Zi Xuan Wu [Tue, 29 Sep 2020 04:31:36 +0000 (12:31 +0800)]
[CSKY 1/n] Add basic stub or infra of csky backend

This patch introduce files that just enough for lib/Target/CSKY to compile.
Notably a basic CSKYTargetMachine and CSKYTargetInfo.

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

3 years ago[PowerPC] Fix signed overflow in decomposeMulByConstant after D88201
Fangrui Song [Sat, 10 Oct 2020 01:28:31 +0000 (18:28 -0700)]
[PowerPC] Fix signed overflow in decomposeMulByConstant after D88201

Caught by multipliers LONG_MAX (after +1) and LONG_MIN (after -1) in CodeGen/PowerPC/mul-const-i64.ll

3 years ago[X86] Add CET test, NFC
Xiang1 Zhang [Sat, 10 Oct 2020 00:59:27 +0000 (08:59 +0800)]
[X86] Add CET test, NFC

3 years ago[mlir][openacc] Introduce acc.exit_data operation
Valentin Clement [Sat, 10 Oct 2020 01:02:29 +0000 (21:02 -0400)]
[mlir][openacc] Introduce acc.exit_data operation

This patch introduces the acc.exit_data operation that represents an OpenACC Exit Data directive.
Operands and attributes are derived from clauses in the spec 2.6.6.

Reviewed By: kiranchandramohan

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

3 years ago[mlir] Rename BufferPlacement.h to Bufferize.h
Sean Silva [Sat, 10 Oct 2020 00:31:42 +0000 (17:31 -0700)]
[mlir] Rename BufferPlacement.h to Bufferize.h

Context: https://llvm.discourse.group/t/what-is-the-strategy-for-tensor-memref-conversion-bufferization/1938/14

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

3 years ago[intel pt] Refactor parsing
Walter Erquinigo [Sat, 3 Oct 2020 19:23:12 +0000 (12:23 -0700)]
[intel pt] Refactor parsing

With the feedback I was getting in different diffs, I realized that splitting the parsing logic into two classes was not easy to deal with. I do see value in doing that, but I'd rather leave that as a refactor after most of the intel-pt logic is in place. Thus, I'm merging the common parser into the intel pt one, having thus only one that is fully aware of Intel PT during parsing and object creation.

Besides, based on the feedback in https://reviews.llvm.org/D88769, I'm creating a ThreadIntelPT class that will be able to orchestrate decoding of its own trace and can handle the stop events correctly.

This leaves the TraceIntelPT class as an initialization class that glues together different components. Right now it can initialize a trace session from a json file, and in the future will be able to initialize a trace session from a live process.

Besides, I'm renaming SettingsParser to SessionParser, which I think is a better name, as the json object represents a trace session of possibly many processes.

With the current set of targets, we have the following

- Trace: main interface for dealing with trace sessions
- TraceIntelPT: plugin Trace for dealing with intel pt sessions
- TraceIntelPTSessionParser: a parser of a json trace session file that can create a corresponding TraceIntelPT instance along with Targets, ProcessTraces (to be created in https://reviews.llvm.org/D88769), and ThreadIntelPT threads.
- ProcessTrace: (to be created in https://reviews.llvm.org/D88769) can handle the correct state of the traces as the user traverses the trace. I don't think there'll be a need an intel-pt specific implementation of this class.
- ThreadIntelPT: a thread implementation that can handle the decoding of its own trace file, along with keeping track of the current position the user is looking at when doing reverse debugging.

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

3 years ago[mlir] [standard] fixed typo in comment
Aart Bik [Fri, 9 Oct 2020 23:56:11 +0000 (16:56 -0700)]
[mlir] [standard] fixed typo in comment

There is an atomic_rmw and a generic_atomic_rmw operation.
The doc of the latter incorrectly referred to former though.

Reviewed By: rriddle

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

3 years ago[bugpoint] Delete -safe-llc and make -run-llc work like -run-llc -safe-run-llc
Fangrui Song [Fri, 9 Oct 2020 23:38:12 +0000 (16:38 -0700)]
[bugpoint] Delete -safe-llc and make -run-llc work like -run-llc -safe-run-llc

3 years ago[mlir, win] Mark several MLRI tests as unsupported on system-windows
Stella Stamenova [Fri, 9 Oct 2020 23:27:50 +0000 (16:27 -0700)]
[mlir, win] Mark several MLRI tests as unsupported on system-windows

They are currently marked as unsupported when windows is part of the triple, but they actually fail when they are run on Windows, so they are unsupported on system-windows

Reviewed By: rriddle

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

3 years agoSink: Handle instruction sink when a user is dead
Changpeng Fang [Fri, 9 Oct 2020 23:20:26 +0000 (16:20 -0700)]
Sink: Handle instruction sink when a user is dead

Summary:
  The current instruction sink pass uses findNearestCommonDominator of all users to find block to sink the instruction to.
However, a user may be in a dead block, which will result in unexpected behavior.

This patch handles such cases by skipping dead blocks. This patch fixes:
https://bugs.llvm.org/show_bug.cgi?id=47415

Reviewers:
  MaskRay, arsenm

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

3 years ago[X86] Check if call is indirect before emitting NT_CALL
Joao Moreira [Fri, 9 Oct 2020 22:25:24 +0000 (15:25 -0700)]
[X86] Check if call is indirect before emitting NT_CALL

The notrack prefix is a relaxation of CET policies which makes it possible to indirectly call targets which do not have an ENDBR instruction in the landing address. To emit a call with this prefix, the special attribute "nocf_check" is used. When used as a function attribute, a CallInst targeting the respective function will return true for the method "doesNoCfCheck()", no matter if it is a direct call (and such should remain like this, as the information that the to-be-called function won't perform control-flow checks is useful in other contexts). Yet, when emitting an X86ISD::NT_CALL, the respective CallInst should be verified for its indirection, allowing that the prefixed calls are only emitted in the right situations.

Update the respective testing unit to also verify for direct calls to functions with ''nocf_check'' attributes.

The bug can also be reproduced through compiling the following C code using the -fcf-protection=full flag.

int __attribute__((nocf_check)) foo(int a) {};

int main() {
  foo(42);
}

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

3 years ago[X86][test] Add a regression test for lock cmpxchg16b on a global variable with offset
Fangrui Song [Fri, 9 Oct 2020 21:51:45 +0000 (14:51 -0700)]
[X86][test] Add a regression test for lock cmpxchg16b on a global variable with offset

Add a test for a bug (uncovered by D88808) fixed by f34bb06935aa3bab353d70d515b767fdd2f5625c.
Also delete cmpxchg16b.ll which is covered by atomic128.ll

Reviewed By: craig.topper

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

3 years ago[SCCP] Reduce the number of times ResolvedUndefsIn is called for large modules.
Eli Friedman [Thu, 8 Oct 2020 23:04:28 +0000 (16:04 -0700)]
[SCCP] Reduce the number of times ResolvedUndefsIn is called for large modules.

If a module has many values that need to be resolved by
ResolvedUndefsIn, compilation takes quadratic time overall. Solve should
do a small amount of work, since not much is added to the worklists each
time markOverdefined is called. But ResolvedUndefsIn is linear over the
length of the function/module, so resolving one undef at a time is
quadratic in general.

To solve this, make ResolvedUndefsIn resolve every undef value at once,
instead of resolving them one at a time. This loses a little
optimization power, but can be a lot faster.

We still need a loop around ResolvedUndefsIn because markOverdefined
could change the set of blocks that are live. That should be uncommon,
hopefully. We could optimize it by tracking which blocks transition from
dead to live, instead of iterating over the whole module to find them.
But I'll leave that for later. (The whole function will become a lot
simpler once we start pruning branches on undef.)

The regression test changes seem minor. The specific cases in question
could probably be optimized with a bit more work, but they seem like
edge cases that don't really matter.

Fixes an "infinite" compile issue my team found on an internal workoad.

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

3 years ago[IRMover] Add missing open quote in the warning message
Steven Wu [Fri, 9 Oct 2020 22:17:16 +0000 (15:17 -0700)]
[IRMover] Add missing open quote in the warning message

Fix the missing single quotation mark in the warning message for
target triple mismatch.

3 years agoTemporarily revert "[ThinLTO] Re-order modules for optimal multi-threaded processing"
Jordan Rupprecht [Fri, 9 Oct 2020 21:36:20 +0000 (14:36 -0700)]
Temporarily revert "[ThinLTO] Re-order modules for optimal multi-threaded processing"

This reverts commit 6537004913f3009d896bc30856698e7d22199ba7. This is causing test failures internally, and while a few of the cases turned out to be bad user code (relying on a specific order of static initialization across translation units), some cases are less clear. Temporarily reverting for now, and Teresa is going to follow up with more details.

3 years ago[WebAssembly] Prototype i16x8.q15mulr_sat_s
Thomas Lively [Fri, 9 Oct 2020 21:17:53 +0000 (21:17 +0000)]
[WebAssembly] Prototype i16x8.q15mulr_sat_s

This saturating, rounding, Q-format multiplication instruction is proposed in
https://github.com/WebAssembly/simd/pull/365.

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

3 years ago[libc++] Remove code to prevent overwriting the system libc++ on Darwin
Louis Dionne [Fri, 9 Oct 2020 19:06:04 +0000 (15:06 -0400)]
[libc++] Remove code to prevent overwriting the system libc++ on Darwin

The system partition is read-only since Catalina.

3 years ago[libc++] Remove redundant if(LIBCXX_INSTALL_LIBRARY)
Louis Dionne [Fri, 9 Oct 2020 19:04:12 +0000 (15:04 -0400)]
[libc++] Remove redundant if(LIBCXX_INSTALL_LIBRARY)

The individual LIBCXX_INSTALL_(SHARED|STATIC)_LIBRARY are already
dependent on whether LIBCXX_INSTALL_LIBRARY is ON or OFF.

3 years agoDirectoryWatcher: add an implementation for Windows
Saleem Abdulrasool [Thu, 1 Oct 2020 05:42:17 +0000 (22:42 -0700)]
DirectoryWatcher: add an implementation for Windows

This implements the directory watcher on Windows.  It does the most
naive thing for simplicity.  ReadDirectoryChangesW is used to monitor
the changes.  However, in order to support interruption, we must use
overlapped IO, which allows us to use the blocking, synchronous
mechanism.  We create a thread to post the notification to the consumer
to allow the monitoring to continue.  The two threads communicate via a
locked queue.

Differential Revision: https://reviews.llvm.org/D88666
Reviewed By: Adrian McCarthy

3 years ago[NFC][Regalloc] VirtRegAuxInfo::Hint does not need to be a field
Mircea Trofin [Fri, 9 Oct 2020 20:35:56 +0000 (13:35 -0700)]
[NFC][Regalloc] VirtRegAuxInfo::Hint does not need to be a field

It is only used in weightCalcHelper, and cleared upon its finishing its
job there.

The patch further cleans up style guide discrepancies, and simplifies
CopyHint by removing duplicate 'IsPhys' information (it's what the Reg
field would report).

3 years ago[Hexagon] Remove ISD node VSPLATW, use VSPLAT instead
Krzysztof Parzyszek [Thu, 8 Oct 2020 22:20:31 +0000 (17:20 -0500)]
[Hexagon] Remove ISD node VSPLATW, use VSPLAT instead

This is a step towards improving HVX codegen for splat.

3 years ago[Hexagon] Generalize handling of SDNodes created during ISel
Krzysztof Parzyszek [Thu, 8 Oct 2020 22:12:32 +0000 (17:12 -0500)]
[Hexagon] Generalize handling of SDNodes created during ISel

The selection of HVX shuffles can produce more nodes in the DAG,
which need special handling, or otherwise they would be left
unselected by the main selection code. Make the handling of such
nodes more general.

3 years agoAdd GPU async op interface and token type.
Christian Sigg [Thu, 8 Oct 2020 11:43:18 +0000 (13:43 +0200)]
Add GPU async op interface and token type.

See https://llvm.discourse.group/t/rfc-new-dialect-for-modelling-asynchronous-execution-at-a-higher-level/1345

Reviewed By: herhut

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

3 years ago[mlir][Linalg] NFC - Cleanup explicitly instantiated paterns 2/n - Loops.cpp
Nicolas Vasilache [Fri, 9 Oct 2020 19:15:16 +0000 (19:15 +0000)]
[mlir][Linalg] NFC - Cleanup explicitly instantiated paterns 2/n - Loops.cpp

This revision belongs to a series of patches that reduce reliance of Linalg transformations on templated rewrite and conversion patterns.
Instead, this uses a MatchAnyTag pattern for the vast majority of cases and dispatches internally.

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

3 years ago[mlir][Linalg] NFC - Cleanup explicitly instantiated paterns 1/n - LinalgToStandard.cpp
Nicolas Vasilache [Fri, 9 Oct 2020 14:31:52 +0000 (14:31 +0000)]
[mlir][Linalg] NFC - Cleanup explicitly instantiated paterns 1/n - LinalgToStandard.cpp

This revision belongs to a series of patches that reduce reliance of Linalg transformations on templated rewrite and conversion patterns.
Instead, this uses a MatchAnyTag pattern for the vast majority of cases and dispatches internally.

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

3 years agoRevert "Give attributes C++ namespaces."
Nicolas Vasilache [Fri, 9 Oct 2020 10:45:59 +0000 (10:45 +0000)]
Revert "Give attributes C++ namespaces."

This reverts commit 0a34492f36d77f043d371cc91f359b2d65e86475.

This change turned out to be very intrusive wrt some internal projects.
Reverting until this can be sorted out.

3 years ago[Reg2Mem][NewPM] Pin test to legacy PM
Arthur Eubanks [Fri, 9 Oct 2020 19:35:23 +0000 (12:35 -0700)]
[Reg2Mem][NewPM] Pin test to legacy PM

This pass hasn't been touched in a long time and isn't used in tree.

3 years ago Enable LSAN for Android
Vy Nguyen [Mon, 21 Sep 2020 21:41:48 +0000 (17:41 -0400)]
Enable LSAN for Android

    Make use of the newly added thread-properties API (available since 31).

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

3 years ago[NFC][Regalloc] Fix coding style in CalcSpillWeights
Mircea Trofin [Fri, 9 Oct 2020 19:18:52 +0000 (12:18 -0700)]
[NFC][Regalloc] Fix coding style in CalcSpillWeights

3 years agoNFC: Address post-commit doc/formatting comments on TypeID.h.
Stella Laurenzo [Fri, 9 Oct 2020 19:16:45 +0000 (12:16 -0700)]
NFC: Address post-commit doc/formatting comments on TypeID.h.

3 years ago[mlir] Fix TypeID for shared libraries built with -fvisibility=hidden.
Stella Laurenzo [Fri, 9 Oct 2020 18:49:38 +0000 (11:49 -0700)]
[mlir] Fix TypeID for shared libraries built with -fvisibility=hidden.

* Isolates the visibility controlled parts of its implementation to a detail namespace.
* Applies a struct level visibility attribute which applies to the static local within the get() functions.
* The prior version was not emitting a symbol for the static local "instance" fields when the user TU was compiled with -fvisibility=hidden.

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

3 years ago[clang] Add a test for CGDebugInfo treatment of blocks
Scott Linder [Fri, 9 Oct 2020 19:02:53 +0000 (19:02 +0000)]
[clang] Add a test for CGDebugInfo treatment of blocks

There doesn't seem to be a direct test of this, and I'm planning to make
future changes which will affect it.

I'm not particularly familiar with the blocks extension, so suggestions
for better tests are welcome.

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

3 years ago[X86] When expanding LCMPXCHG16B_NO_RBX in EmitInstrWithCustomInserter, directly...
Craig Topper [Fri, 9 Oct 2020 18:48:10 +0000 (11:48 -0700)]
[X86] When expanding LCMPXCHG16B_NO_RBX in EmitInstrWithCustomInserter, directly copy address operands instead of going through X86AddressMode.

I suspect getAddressFromInstr and addFullAddress are not handling
all addresses cases properly based on a report from MaskRay.

So just copy the operands directly. This should be more efficient
anyway.

3 years ago[X86] Don't copy kill flag when expanding LCMPXCHG16B_SAVE_RBX
Craig Topper [Fri, 9 Oct 2020 17:26:50 +0000 (10:26 -0700)]
[X86] Don't copy kill flag when expanding LCMPXCHG16B_SAVE_RBX

The expansion code creates a copy to RBX before the real LCMPXCHG16B.
It's possible this copy uses a register that is also used by the
real LCMPXCHG16B. If we set the kill flag on the use in the copy,
then we'll fail the machine verifier on the use on the LCMPXCHG16B.

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

3 years ago[MemCpyOpt] Add test for incorrectly hoisted store (NFC)
Nikita Popov [Fri, 9 Oct 2020 18:52:08 +0000 (20:52 +0200)]
[MemCpyOpt] Add test for incorrectly hoisted store (NFC)

3 years ago[libc++] Fixup a missing occurrence of LIBCXX_ENABLE_DEBUG_MODE
Louis Dionne [Fri, 9 Oct 2020 18:40:47 +0000 (14:40 -0400)]
[libc++] Fixup a missing occurrence of LIBCXX_ENABLE_DEBUG_MODE

3 years ago[libc++] Rename LIBCXX_ENABLE_DEBUG_MODE to LIBCXX_ENABLE_DEBUG_MODE_SUPPORT
Louis Dionne [Fri, 9 Oct 2020 18:39:20 +0000 (14:39 -0400)]
[libc++] Rename LIBCXX_ENABLE_DEBUG_MODE to LIBCXX_ENABLE_DEBUG_MODE_SUPPORT

To make it clearer this is about whether the library supports the debug
mode at all, not whether the debug mode is enabled. Per comment by Nico
Weber on IRC.

3 years ago[libc++] NFCI: Define small methods of basic_stringstream inline
Louis Dionne [Fri, 9 Oct 2020 18:21:23 +0000 (14:21 -0400)]
[libc++] NFCI: Define small methods of basic_stringstream inline

It greatly increases readability because defining the methods out-of-line
involves a ton of boilerplate template declarations.

3 years ago[BPF] Make BPFAbstractMemberAccessPass required
Arthur Eubanks [Wed, 7 Oct 2020 03:28:43 +0000 (20:28 -0700)]
[BPF] Make BPFAbstractMemberAccessPass required

Or else on optnone functions we get the following during instruction selection:
  fatal error: error in backend: Cannot select: intrinsic %llvm.preserve.struct.access.index

Currently the -O0 pipeline doesn't properly run passes registered via
TargetMachine::registerPassBuilderCallbacks(), so don't add that RUN
line yet. That will be fixed after this.

Reviewed By: yonghong-song

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

3 years ago[ARM][MIPS] Add funnel shift test coverage
Simon Pilgrim [Fri, 9 Oct 2020 18:19:35 +0000 (19:19 +0100)]
[ARM][MIPS] Add funnel shift test coverage

Based on offline discussions regarding D89139 and D88783 - we want to make sure targets aren't doing anything particularly dumb

Tests copied from aarch64 which has a mixture of general, legalization and special case tests

3 years ago[lldb] Update docs with new buildbot URLs
Jonas Devlieghere [Fri, 9 Oct 2020 17:57:37 +0000 (10:57 -0700)]
[lldb] Update docs with new buildbot URLs

Buildbot got upgraded and now the (LLDB) builders have different URLs.

3 years ago[OpenMPOpt] Merge parallel regions
Giorgis Georgakoudis [Tue, 7 Jul 2020 21:14:47 +0000 (14:14 -0700)]
[OpenMPOpt] Merge parallel regions

There are cases that generated OpenMP code consists of multiple,
consecutive OpenMP parallel regions, either due to high-level
programming models, such as RAJA, Kokkos, lowering to OpenMP code, or
simply because the programmer parallelized code this way.  This
optimization merges consecutive parallel OpenMP regions to: (1) reduce
the runtime overhead of re-activating a team of threads; (2) enlarge the
scope for other OpenMP optimizations, e.g., runtime call deduplication
and synchronization elimination.

This implementation defensively merges parallel regions, only when they
are within the same BB and any in-between instructions are safe to
execute in parallel.

Reviewed By: jdoerfert

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

3 years ago[libc++] Clean up logic around aligned/sized allocation and deallocation
Louis Dionne [Fri, 25 Sep 2020 13:24:14 +0000 (09:24 -0400)]
[libc++] Clean up logic around aligned/sized allocation and deallocation

Due to the need to support compilers that implement builtin operator
new/delete but not their align_val_t overloaded versions, there was a
lot of complexity. By assuming that a compiler that supports the builtin
new/delete operators also supports their align_val_t overloads, the code
can be simplified quite a bit.

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

3 years ago[clang] Don't look into <sysroot> for C++ headers if they are found alongside the...
Louis Dionne [Wed, 7 Oct 2020 18:27:55 +0000 (14:27 -0400)]
[clang] Don't look into <sysroot> for C++ headers if they are found alongside the toolchain

Currently, Clang looks for libc++ headers alongside the installation
directory of Clang, and it also adds a search path for headers in the
-isysroot. This is problematic if headers are found in both the toolchain
and in the sysroot, since #include_next will end up finding the libc++
headers in the sysroot instead of the intended system headers.

This patch changes the logic such that if the toolchain contains libc++
headers, no C++ header paths are added in the sysroot. However, if the
toolchain does *not* contain libc++ headers, the sysroot is searched as
usual.

This should not be a breaking change, since any code that previously
relied on some libc++ headers being found in the sysroot suffered from
the #include_next issue described above, which renders any libc++ header
basically useless.

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

3 years ago[libc++] Remove some workarounds for C++03
Louis Dionne [Fri, 9 Oct 2020 16:33:49 +0000 (12:33 -0400)]
[libc++] Remove some workarounds for C++03

We don't support any compiler that doesn't support variadics and rvalue
references in C++03 mode, so these workarounds can be dropped. There's
still *a lot* of cruft related to these workarounds, but I try to tackle
a bit of it here and there.

3 years ago[FixIrreducible][NewPM] Port -fix-irreducible to NPM
Arthur Eubanks [Thu, 8 Oct 2020 15:53:00 +0000 (08:53 -0700)]
[FixIrreducible][NewPM] Port -fix-irreducible to NPM

In the NPM, a pass cannot depend on another non-analysis pass. So pin
the test that tests that -lowerswitch is run automatically to legacy PM.

Reviewed By: sameerds

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

3 years ago[LoopInterchange][NewPM] Port -loop-interchange to NPM
Arthur Eubanks [Thu, 17 Sep 2020 23:19:04 +0000 (16:19 -0700)]
[LoopInterchange][NewPM] Port -loop-interchange to NPM

Reviewed By: fhahn

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

3 years ago[AMDGPU] Only enable mad/mac legacy f32 patterns if denormals may be flushed
Jay Foad [Fri, 9 Oct 2020 12:28:19 +0000 (13:28 +0100)]
[AMDGPU] Only enable mad/mac legacy f32 patterns if denormals may be flushed

Following on from D88890, this makes the newly added patterns
conditional on NoFP32Denormals. mad/mac f32 instructions always flush
denormals regardless of the MODE register setting, and I believe the
legacy variants do the same.

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

3 years ago[mlir] Forward listeners when utilizing scf::IfOp::get*BodyBuilder.
Tres Popp [Fri, 9 Oct 2020 13:37:42 +0000 (15:37 +0200)]
[mlir] Forward listeners when utilizing scf::IfOp::get*BodyBuilder.

Without this PatternRewriting infrastructure does not know of modifications and
cannot properly legalize nor rollback changes.

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

3 years ago[InstCombine] Support lshr(trunc(lshr(x,c1)), c2) -> trunc(lshr(lshr(x,c1),c2)) unifo...
Simon Pilgrim [Fri, 9 Oct 2020 15:54:32 +0000 (16:54 +0100)]
[InstCombine] Support lshr(trunc(lshr(x,c1)), c2) -> trunc(lshr(lshr(x,c1),c2)) uniform vector tests

FoldShiftByConstant is hardcoded for scalar/uniform outer shift amounts atm so that needs to be fixed first to support non-uniform cases

3 years ago[InstCombine] Add lshr(trunc(lshr(x,c1)), c2) -> trunc(lshr(lshr(x,c1),c2)) vector...
Simon Pilgrim [Fri, 9 Oct 2020 15:32:07 +0000 (16:32 +0100)]
[InstCombine] Add lshr(trunc(lshr(x,c1)), c2) -> trunc(lshr(lshr(x,c1),c2)) vector tests

3 years ago[MLIR] Add async token/value arguments to async.execute op
Eugene Zhulenev [Thu, 8 Oct 2020 20:28:09 +0000 (13:28 -0700)]
[MLIR] Add async token/value arguments to async.execute op

Async execute operation can take async arguments as dependencies.

Change `async.execute` custom parser/printer format to use `%value as %unwrapped: !async.value<!type>` sytax.

Reviewed By: mehdi_amini, herhut

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

3 years ago[mlir] Fix shared libs build
Andrzej Warzynski [Fri, 9 Oct 2020 09:57:35 +0000 (10:57 +0100)]
[mlir] Fix shared libs build

Reverts one breaking change introduced in
https://reviews.llvm.org/D88846.

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

3 years ago[ARM] Add MVE vecreduce costmodel tests. NFC
David Green [Fri, 9 Oct 2020 15:25:25 +0000 (16:25 +0100)]
[ARM] Add MVE vecreduce costmodel tests. NFC

There were some existing tests that were not super useful. New ones are
added for testing MVE specific patterns.

3 years ago[NFC] Reformat MILexer.cpp:getIdentifierKind
Scott Linder [Fri, 9 Oct 2020 15:13:45 +0000 (15:13 +0000)]
[NFC] Reformat MILexer.cpp:getIdentifierKind

Reformat to avoid unrelated changes in diff of future patch.
Committed as obvious.

3 years ago[InstCombine] commonShiftTransforms - add support for pow2 nonuniform constant vector...
Simon Pilgrim [Fri, 9 Oct 2020 14:59:19 +0000 (15:59 +0100)]
[InstCombine] commonShiftTransforms - add support for pow2 nonuniform constant vectors in srem fold

Note: we already fold srem to undef if any denominator vector element is undef.

3 years ago[Hexagon] Return 1 instead of 0 from getMaxInterleaveFactor
Krzysztof Parzyszek [Fri, 9 Oct 2020 14:34:24 +0000 (09:34 -0500)]
[Hexagon] Return 1 instead of 0 from getMaxInterleaveFactor

3 years ago[InstCombine] allow vector splats for add+and with high-mask
Sanjay Patel [Fri, 9 Oct 2020 14:25:08 +0000 (10:25 -0400)]
[InstCombine] allow vector splats for add+and with high-mask

There might be a better way to specify the pre-conditions,
but this is hopefully clearer than the way it was written:
https://rise4fun.com/Alive/Jhk3

  Pre: C2 < 0 && isShiftedMask(C2) && (C1 == C1 & C2)
  %a = and %x, C2
  %r = add %a, C1
  =>
  %a2 = add %x, C1
  %r = and %a2, C2