platform/upstream/llvm.git
4 years ago[X86][SSE] combineTargetShuffle - use scaleShuffleMask helper to widen shuffle mask...
Simon Pilgrim [Sat, 8 Aug 2020 18:35:57 +0000 (19:35 +0100)]
[X86][SSE] combineTargetShuffle - use scaleShuffleMask helper to widen shuffle mask. NFCI.

Use scaleShuffleMask helper for the shuffle(hadd,hadd) canonicalization.

4 years ago[X86] Increase the number of instructions searched for isSafeToClobberEFLAGS in a...
Craig Topper [Sat, 8 Aug 2020 18:03:16 +0000 (11:03 -0700)]
[X86] Increase the number of instructions searched for isSafeToClobberEFLAGS in a couple places

Previously this function searched 4 instructions forwards or
backwards to determine if it was ok to clobber eflags.

This is called in 3 places: rematerialization, turning 2 operand
leas into adds or splitting 3 ops leas into an lea and add on some
CPU targets.

This patch increases the search limit to 10 instructions for
rematerialization and 2 operand lea to add. I've left the old
treshold for 3 ops lea spliting as that increases code size.

Fixes PR47024 and PR43014

4 years ago[InstCombine] Use CreateVectorSplat(ElementCount) variant directly
Simon Pilgrim [Sat, 8 Aug 2020 18:26:02 +0000 (19:26 +0100)]
[InstCombine] Use CreateVectorSplat(ElementCount) variant directly

This was introduced at rGe20223672100, and the CreateVectorSplat(unsigned NumElements) variant calls it internally

4 years agoFix MSVC "not all control paths return a value" warning. NFC.
Simon Pilgrim [Sat, 8 Aug 2020 18:12:11 +0000 (19:12 +0100)]
Fix MSVC "not all control paths return a value" warning. NFC.

4 years agoChange the default target CPU for OpenBSD/i386 to i586
Brad Smith [Sat, 8 Aug 2020 17:49:45 +0000 (13:49 -0400)]
Change the default target CPU for OpenBSD/i386 to i586

4 years ago[Clang] Fixed buildboit failure; bot defaults to older C++ standard
Dávid Bolvanský [Sat, 8 Aug 2020 17:37:50 +0000 (19:37 +0200)]
[Clang] Fixed buildboit failure; bot defaults to older C++ standard

4 years ago[Clang] Avoid whitespace in fixit note
Dávid Bolvanský [Sat, 8 Aug 2020 17:34:07 +0000 (19:34 +0200)]
[Clang] Avoid whitespace in fixit note

4 years ago[Diagnostics] Diagnose missing comma in string array initialization
Dávid Bolvanský [Sat, 8 Aug 2020 17:22:44 +0000 (19:22 +0200)]
[Diagnostics] Diagnose missing comma in string array initialization

Motivation (from PR37674):

const char *ss[] = {
  "foo", "bar",
  "baz", "qux"  // <-- Missing comma!
  "abc", "xyz"
  };

This kind of bug was recently also found in LLVM codebase (see PR47030).

Solves PR47038, PR37674

Reviewed By: aaron.ballman

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

4 years ago[SimplifyCFG] Fix invoke->call fold w/ multiple invokes in presence of lifetime intri...
Roman Lebedev [Sat, 8 Aug 2020 14:57:32 +0000 (17:57 +0300)]
[SimplifyCFG] Fix invoke->call fold w/ multiple invokes in presence of lifetime intrinsics

SimplifyCFG has two main folds for resumes - one when resume is directly
using the landingpad, and the other one where resume is using a PHI node.

While for the first case, we were already correctly ignoring all the
PHI nodes, and both the debug info intrinsics and lifetime intrinsics,
in the PHI-based-one, we weren't ignoring PHI's in the resume block,
and weren't ignoring lifetime intrinsics. That is clearly a bug.

On RawSpeed library, this results in +9.34% (+81) more invoke->call folds,
-0.19% (-39) landing pads, -0.24% (-81) invoke instructions
but +51 call instructions and -132 basic blocks.

Though, the run-time performance impact appears to be within the noise.

4 years ago[NFC][SimplifyCFG] Rewrite isCleanupBlockEmpty() to be iterator_range-based
Roman Lebedev [Sat, 8 Aug 2020 14:20:36 +0000 (17:20 +0300)]
[NFC][SimplifyCFG] Rewrite isCleanupBlockEmpty() to be iterator_range-based

4 years ago[NFC][SimplifyCFG] Add a test showing invoke->call simplification failure
Roman Lebedev [Sat, 8 Aug 2020 13:53:30 +0000 (16:53 +0300)]
[NFC][SimplifyCFG] Add a test showing invoke->call simplification failure

4 years ago[NFC][SimplifyCFG] Count the number of invokes turned into calls due to empty cleanup...
Roman Lebedev [Sat, 8 Aug 2020 13:46:31 +0000 (16:46 +0300)]
[NFC][SimplifyCFG] Count the number of invokes turned into calls due to empty cleanup blocks

4 years ago[ELF] --wrap: set isUsedInRegularObj of __wrap_ if it is defined or shared
Fangrui Song [Sat, 8 Aug 2020 16:24:08 +0000 (09:24 -0700)]
[ELF] --wrap: set isUsedInRegularObj of __wrap_ if it is defined or shared

Fixes PR47017 (a regression when fixing PR46169): if __wrap_ is shared,
it is not exported.

4 years ago[DAGCombiner] reassociate reciprocal sqrt expression to eliminate FP division, part 2
Sanjay Patel [Fri, 7 Aug 2020 20:57:27 +0000 (16:57 -0400)]
[DAGCombiner] reassociate reciprocal sqrt expression to eliminate FP division, part 2

Follow-up to D82716 / rGea71ba11ab11
We do not have the fabs removal fold in IR yet for the case
where the sqrt operand is repeated, so that's another potential
improvement.

4 years ago[x86] add tests for another reciprocal sqrt pattern; NFC
Sanjay Patel [Fri, 7 Aug 2020 16:27:55 +0000 (12:27 -0400)]
[x86] add tests for another reciprocal sqrt pattern; NFC

4 years agolib/CodeGen doesn't depend on lib/Passes.
Benjamin Kramer [Sat, 8 Aug 2020 11:40:24 +0000 (13:40 +0200)]
lib/CodeGen doesn't depend on lib/Passes.

4 years ago[test][DebugInfo] Adapt two tests for Sun assembler syntax on Sparc
Rainer Orth [Sat, 8 Aug 2020 07:13:47 +0000 (09:13 +0200)]
[test][DebugInfo] Adapt two tests for Sun assembler syntax on Sparc

Two DebugInfo tests currently `FAIL` on Sparc:

  LLVM :: DebugInfo/Generic/2010-06-29-InlinedFnLocalVar.ll
  LLVM :: DebugInfo/Generic/array.ll

both in a similar way.  E.g.

  : 'RUN: at line 1';   /var/llvm/local-sparcv9-A/bin/llc -O2 /vol/llvm/src/llvm-project/local/llvm/test/DebugInfo/Generic/2010-06-29-InlinedFnLocalVar.ll -o - | /var/llvm/local-sparcv9-A/bin/FileCheck /vol/llvm/src/llvm-project/local/llvm/test/DebugInfo/Generic/2010-06-29-InlinedFnLocalVar.ll

  /vol/llvm/src/llvm-project/local/llvm/test/DebugInfo/Generic/2010-06-29-InlinedFnLocalVar.ll:4:10: error: CHECK: expected string not found in input
  ; CHECK: debug_info,
           ^

On `amd64-pc-solaris2.11`, the corresponding line is

  .section        .debug_info,"",@progbits

while on `sparcv9-sun-solaris2.11` we have only

  .section        .debug_info

This happens because Sparc currently emits `.section` directives using the
style of the Solaris/SPARC assembler (controlled by `SunStyleELFSectionSwitchSyntax`).

This patch takes the easy way out and allows both forms while tightening the
check to only match the `.section` directive.

Tested on `sparcv9-sun-solaris2.11`, `amd64-pc-solaris2.11`,
`x86_64-pc-linux-gnu`, and `x86_64-apple-darwin20.0.0`.

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

4 years ago[libc][NFC] Disable a loader test as ld.gold fails to link.
Siva Chandra Reddy [Sat, 8 Aug 2020 06:45:18 +0000 (23:45 -0700)]
[libc][NFC] Disable a loader test as ld.gold fails to link.

Will be reenabled after investigating and fixing the problem.

4 years ago[libc][NFC] Add library of floating point test matchers.
Siva Chandra Reddy [Thu, 6 Aug 2020 07:19:08 +0000 (00:19 -0700)]
[libc][NFC] Add library of floating point test matchers.

This eliminates UnitTest's dependency on FPUtil and hence prevents
non-math tests from depending indirectly on FPUtil. The patch
essentially moves some of the existing pieces into a library of its own.

Along the way, renamed add_math_unittest to add_fp_unittest.

Reviewed By: lntue

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

4 years agoAdd the inline interface to the shape dialect
Feng Liu [Sat, 8 Aug 2020 06:23:06 +0000 (23:23 -0700)]
Add the inline interface to the shape dialect

This patch also fixes a minor issue that shape.rank should allow
returning !shape.size. The dialect doc has such an example for
shape.rank.

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

4 years ago[InstCombine] Optimize select(freeze(icmp eq/ne x, y), x, y)
Juneyoung Lee [Fri, 7 Aug 2020 12:12:52 +0000 (21:12 +0900)]
[InstCombine] Optimize select(freeze(icmp eq/ne x, y), x, y)

This patch adds an optimization that folds select(freeze(icmp eq/ne x, y), x, y)
to x or y.
This was needed to resolve slowdown after D84940 is applied.

I tried to bake this logic into foldSelectInstWithICmp, but it wasn't clear.
This patch conservatively writes the pattern in a separate function,
foldSelectWithFrozenICmp.

The output does not need freeze; https://alive2.llvm.org/ce/z/X49hNE (from @nikic)

Reviewed By: nikic

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

4 years ago[libc] Setup TLS in x86_64 loader.
Siva Chandra Reddy [Wed, 24 Jun 2020 21:12:46 +0000 (14:12 -0700)]
[libc] Setup TLS in x86_64 loader.

The new code added is still very x86_64 specific. AArch64 support will
be added very soon and refactoring of the loader code will be done as
part of the patches adding it.

Reviewed By: asteinhauser

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

4 years ago[InstCombine] Add tests for select(freeze(icmp x, y), x, y); NFC
Juneyoung Lee [Fri, 7 Aug 2020 12:11:58 +0000 (21:11 +0900)]
[InstCombine] Add tests for select(freeze(icmp x, y), x, y); NFC

4 years ago[X86] Limit the scope of the min/max canonicalization in combineSelect
Craig Topper [Sat, 8 Aug 2020 05:51:49 +0000 (22:51 -0700)]
[X86] Limit the scope of the min/max canonicalization in combineSelect

Previously the transform was doing these two canonicalizations
(x > y) ? x : y -> (x >= y) ? x : y
(x < y) ? x : y -> (x <= y) ? x : y

But those don't seem to be useful generally. And they actively
pessimize the cases in PR47049.

This patch limits it to
(x > 0) ? x : 0 -> (x >= 0) ? x : 0
(x < -1) ? x : -1 -> (x <= -1) ? x : -1

These are the cases mentioned in the comments as the motivation
for the canonicalization. These allow the CMOV to use the S
flag from the compare thus improving opportunities to use a TEST
or the flags from an arithmetic instruction.

4 years agoRemove unused static helper getMemRefTypeFromTensorType() (NFC)
Mehdi Amini [Sat, 8 Aug 2020 05:37:42 +0000 (05:37 +0000)]
Remove unused static helper getMemRefTypeFromTensorType() (NFC)

4 years agoRemove unused class member (NFC)
Mehdi Amini [Sat, 8 Aug 2020 05:36:41 +0000 (05:36 +0000)]
Remove unused class member (NFC)

Fix include/mlir/Reducer/ReductionNode.h:79:18: warning: private field 'parent' is not used [-Wunused-private-field]

4 years agoRevert "[mlir] Add a utility class, ThreadLocalCache, for storing non static thread...
Mehdi Amini [Sat, 8 Aug 2020 05:31:25 +0000 (05:31 +0000)]
Revert "[mlir] Add a utility class, ThreadLocalCache, for storing non static thread local objects."

This reverts commit 9f24640b7e6e61b0f293c724155a90a5e446dd7a.

We hit some dead-locks on thread exit in some configurations: TLS exit handler is taking a lock.
Temporarily reverting this change as we're debugging what is going on.

4 years ago[ELF] Support .cfi_signal_frame
Fangrui Song [Sat, 8 Aug 2020 05:08:00 +0000 (22:08 -0700)]
[ELF] Support .cfi_signal_frame

glibc/sysdeps/unix/sysv/linux/x86_64/sigaction.c libc.a(sigaction.o) has a CIE
with the augmentation string "zRS". Support 'S' to allow --icf={safe,all}.

4 years ago[MLIR] Add tiling validity check to loop tiling pass
Vincent Zhao [Thu, 6 Aug 2020 20:25:49 +0000 (01:55 +0530)]
[MLIR] Add tiling validity check to loop tiling pass

This revision aims to provide a new API, `checkTilingLegality`, to
verify that the loop tiling result still satisifes the dependence
constraints of the original loop nest.

Previously, there was no check for the validity of tiling. For instance:

```
func @diagonal_dependence() {
  %A = alloc() : memref<64x64xf32>

  affine.for %i = 0 to 64 {
    affine.for %j = 0 to 64 {
      %0 = affine.load %A[%j, %i] : memref<64x64xf32>
      %1 = affine.load %A[%i, %j - 1] : memref<64x64xf32>
      %2 = addf %0, %1 : f32
      affine.store %2, %A[%i, %j] : memref<64x64xf32>
    }
  }

  return
}
```

You can find more information about this example from the Section 3.11
of [1].

In general, there are three types of dependences here: two flow
dependences, one in direction `(i, j) = (0, 1)` (notation that depicts a
vector in the 2D iteration space), one in `(i, j) = (1, -1)`; and one
anti dependence in the direction `(-1, 1)`.

Since two of them are along the diagonal in opposite directions, the
default tiling method in `affine`, which tiles the iteration space into
rectangles, will violate the legality condition proposed by Irigoin and
Triolet [2]. [2] implies two tiles cannot depend on each other, while in
the `affine` tiling case, two rectangles along the same diagonal are
indeed dependent, which simply violates the rule.

This diff attempts to put together a validator that checks whether the
rule from [2] is violated or not when applying the default tiling method
in `affine`.

The canonical way to perform such validation is by examining the effect
from adding the constraint from Irigoin and Triolet to the existing
dependence constraints.

Since we already have the prior knowlegde that `affine` tiles in a
hyper-rectangular way, and the resulting tiles will be scheduled in the
same order as their respective loop indices, we can simplify the
solution to just checking whether all dependence components are
non-negative along the tiling dimensions.

We put this algorithm into a new API called `checkTilingLegality` under
`LoopTiling.cpp`. This function iterates every `load`/`store` pair, and
if there is any dependence between them, we get the dependence component
  and check whether it has any negative component. This function returns
  `failure` if the legality condition is violated.

[1]. Bondhugula, Uday. Effective Automatic parallelization and locality optimization using the Polyhedral model. https://dl.acm.org/doi/book/10.5555/1559029
[2]. Irigoin, F. and Triolet, R. Supernode Partitioning. https://dl.acm.org/doi/10.1145/73560.73588

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

4 years agoPR47025, PR47043: Diagnose unexpanded parameter packs in concept
Richard Smith [Sat, 8 Aug 2020 01:17:24 +0000 (18:17 -0700)]
PR47025, PR47043: Diagnose unexpanded parameter packs in concept
declarations and requires-expressions.

4 years ago[X86] Don't produce bad x86andp nodes for i1 vectors
Keno Fischer [Fri, 7 Aug 2020 20:38:15 +0000 (16:38 -0400)]
[X86] Don't produce bad x86andp nodes for i1 vectors

In D85499, I attempted to fix this same issue by canonicalizing
andnp for i1 vectors, but since there was some opposition to such
a change, this commit just fixes the bug by using two different
forms depending on which kind of vector type is in use. We can
then always decide to switch the canonical forms later.

Description of the original bug:
We have a DAG combine that tries to fold (vselect cond, 0000..., X) -> (andnp cond, x).
However, it does so by attempting to create an i64 vector with the number
of elements obtained by truncating division by 64 from the bitwidth. This is
bad for mask vectors like v8i1, since that division is just zero. Besides,
we don't want i64 vectors anyway. For i1 vectors, switch the pattern
to (andnp (not cond), x), which is the canonical form for `kandn`
on mask registers.

Fixes https://github.com/JuliaLang/julia/issues/36955.

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

4 years ago[gn build] Port f5b5ccf2a68
LLVM GN Syncbot [Fri, 7 Aug 2020 23:43:14 +0000 (23:43 +0000)]
[gn build] Port f5b5ccf2a68

4 years agoReland "Revert "[NewPM][CodeGen] Introduce machine pass and machine pass manager""
Yuanfang Chen [Fri, 7 Aug 2020 19:57:38 +0000 (12:57 -0700)]
Reland "Revert "[NewPM][CodeGen] Introduce machine pass and machine pass manager""

This relands commit 320eab2d558fde0b61437e9b9075bfd301c2c474.

The test failed because it was looking for x86-linux target
unconditionally. Now it gets the default target.

4 years ago[flang] Handle DATA initialization of EQUIVALENCE'd objects
peter klausler [Fri, 7 Aug 2020 20:25:11 +0000 (13:25 -0700)]
[flang] Handle DATA initialization of EQUIVALENCE'd objects

Objects that are storage associated by EQUIVALENCE and
initialized with DATA are initialized by creating a
compiler temporary data object in the same scope,
assigning it an offset, type, and size that covers the
transitive closure of the associated initialized original
symbols, and combining their initializers into one common
initializer for the temporary.

Some problems with offset assignment of EQUIVALENCE'd objects
in COMMON were exposed and corrected, and some more error
cases are checked.

Remove obsolete function.
Small bugfix (nested implied dos).
Add a test.
Fix struct/class warning.

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

4 years agoAMDGPU: Avoid explicitly listing all the memory nodes
Matt Arsenault [Thu, 6 Aug 2020 23:59:25 +0000 (19:59 -0400)]
AMDGPU: Avoid explicitly listing all the memory nodes

4 years ago[NFC][StackSafety] Fix statistics
Vitaly Buka [Fri, 7 Aug 2020 23:18:10 +0000 (16:18 -0700)]
[NFC][StackSafety] Fix statistics

4 years ago[sanitizer] Fix comment (NFC)
Teresa Johnson [Fri, 7 Aug 2020 22:52:50 +0000 (15:52 -0700)]
[sanitizer] Fix comment (NFC)

As pointed out in D85387, part of the comment for MapDynamicShadow
refactored to sanitizer_common in D83247 was incorrect for non-Linux
versions. Update the comment to reflect that.

4 years agoCreate Reduction Tree Pass
Mauricio Sifontes [Fri, 7 Aug 2020 23:17:27 +0000 (23:17 +0000)]
Create Reduction Tree Pass

Implement the Reduction Tree Pass framework as part of the MLIR Reduce tool. This is a parametarizable pass that allows for the implementation of custom reductions passes in the tool.
Implement the FunctionReducer class as an example of a Reducer class parameter for the instantiation of a Reduction Tree Pass.
Create a pass pipeline with a Reduction Tree Pass with the FunctionReducer class specified as parameter.

Reviewed By: jpienaar

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

4 years agoRevert "[Clang] implement -fno-eliminate-unused-debug-types"
Nick Desaulniers [Fri, 7 Aug 2020 23:11:41 +0000 (16:11 -0700)]
Revert "[Clang] implement -fno-eliminate-unused-debug-types"

This reverts commit e486921fd6cf96ae9114adac455f7c0b5c1088a7.

Breaks windows builds and osx builds.

4 years agoRevert "fix windows build for D80242"
Nick Desaulniers [Fri, 7 Aug 2020 23:11:26 +0000 (16:11 -0700)]
Revert "fix windows build for D80242"

This reverts commit cbd8ec93709376fbf404c99f4eee399790e26db7.

4 years ago[OpenMP 5.0] Fix PR-45212: Shouldn't error out while using overloaded operator for...
cchen [Fri, 7 Aug 2020 23:04:56 +0000 (18:04 -0500)]
[OpenMP 5.0] Fix PR-45212: Shouldn't error out while using overloaded operator for map clause

LValue map checker should handle CXXOperatorCallExpr

Reviewed By: jdoerfert

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

4 years ago[mlir] Centralize handling of memref element types.
Sean Silva [Fri, 7 Aug 2020 18:40:58 +0000 (11:40 -0700)]
[mlir] Centralize handling of memref element types.

This also beefs up the test coverage:
- Make unranked memref testing consistent with ranked memrefs.
- Add testing for the invalid element type cases.

This is not quite NFC: index types are now allowed in unranked memrefs.

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

4 years ago[lldb] Assert the process has exited before we gets its output.
Jonas Devlieghere [Fri, 7 Aug 2020 22:06:14 +0000 (15:06 -0700)]
[lldb] Assert the process has exited before we gets its output.

4 years ago[NewPM] Print 'Skipping pass' as pass instrumentation
Arthur Eubanks [Fri, 7 Aug 2020 02:03:09 +0000 (19:03 -0700)]
[NewPM] Print 'Skipping pass' as pass instrumentation

If OptNoneInstrumentation prints it instead, 'Skipping pass' will print for even required passes.

Reviewed By: ychen

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

4 years agofix windows build for D80242
Nick Desaulniers [Fri, 7 Aug 2020 21:59:35 +0000 (14:59 -0700)]
fix windows build for D80242

4 years ago[NFC][MLInliner] Refactor logging implementation
Mircea Trofin [Fri, 7 Aug 2020 21:56:31 +0000 (14:56 -0700)]
[NFC][MLInliner] Refactor logging implementation

This prepares it for logging externally-specified outputs.

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

4 years agoAdd a setting to force stepping to always run all threads.
Jim Ingham [Fri, 7 Aug 2020 21:44:01 +0000 (14:44 -0700)]
Add a setting to force stepping to always run all threads.
Also allow ScriptedThreadPlans to set & get their StopOthers
state.

<rdar://problem/64229484>

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

4 years ago[llvm-libtool-darwin] Add support for -D and -U options
Sameer Arora [Mon, 20 Jul 2020 23:10:07 +0000 (16:10 -0700)]
[llvm-libtool-darwin] Add support for -D and -U options

Add support for `-D` and `-U` options for llvm-libtool-darwin. `-D`
allows for using zero for timestamps and UIDs/GIDs. `-U` allows for
using actual timestamps and UIDs/GIDs.

Reviewed by jhenderson, smeenai

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

4 years ago[llvm-libtool-darwin] Add support for -filelist option
Sameer Arora [Mon, 20 Jul 2020 21:27:48 +0000 (14:27 -0700)]
[llvm-libtool-darwin] Add support for -filelist option

Add support for `-filelist` option for llvm-libtool-darwin. `-filelist`
option allows for passing in a file containing a list of filenames.

Reviewed by jhenderson, smeenai

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

4 years agoFactor out reference-counting code from PlatformApple*
Adrian Prantl [Fri, 7 Aug 2020 21:24:03 +0000 (14:24 -0700)]
Factor out reference-counting code from PlatformApple*

into PlatformAppleSimulator. This is legal because that is the only
entry point for the Terminate/Initialize functions.

4 years ago[Clang] implement -fno-eliminate-unused-debug-types
Nick Desaulniers [Fri, 7 Aug 2020 21:10:04 +0000 (14:10 -0700)]
[Clang] implement -fno-eliminate-unused-debug-types

Fixes pr/11710.
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed By: dblaikie

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

4 years ago[llvm-libtool-darwin] Add constant CPU_SUBTYPE_ARM64_V8
Sameer Arora [Fri, 31 Jul 2020 18:52:47 +0000 (11:52 -0700)]
[llvm-libtool-darwin] Add constant CPU_SUBTYPE_ARM64_V8

Add support for constant MachO::CPU_SUBTYPE_ARM64_V8. This constant is
needed so as to match `llvm-libtool-darwin`'s behavior to that of
cctools' libtool when `-arch_only` flag is passed in on command line.

Reviewed by jhenderson, alexshap, smeenai

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

4 years agoRevert "[StackSafety] Skip ambiguous lifetime analysis"
Vitaly Buka [Fri, 7 Aug 2020 20:59:22 +0000 (13:59 -0700)]
Revert "[StackSafety] Skip ambiguous lifetime analysis"

This reverts commit 0b2616a8045cb776ea1514c3401d0a8577de1060.

Crashes with safe-stack.

4 years ago[StackSafety,NFC] Add Stats counters
Vitaly Buka [Fri, 7 Aug 2020 20:58:10 +0000 (13:58 -0700)]
[StackSafety,NFC] Add Stats counters

4 years ago[OpenMP,MLIR] Translation of parallel operation: num_threads, if clauses 3/n
Kiran Chandramohan [Fri, 7 Aug 2020 18:33:46 +0000 (18:33 +0000)]
[OpenMP,MLIR] Translation of parallel operation: num_threads, if clauses 3/n

This simple patch translates the num_threads and if clauses of the parallel
operation. Also includes test cases.
A minor change was made to parsing of the if clause to parse AnyType and
return the parsed type. Updates to test cases also.

Reviewed by: SouraVX
Differential Revision: https://reviews.llvm.org/D84798

4 years ago[OpenMP] Split OpenMP/target_map_codegen test [NFC]
Artem Belevich [Fri, 7 Aug 2020 19:59:49 +0000 (12:59 -0700)]
[OpenMP] Split OpenMP/target_map_codegen test [NFC]

The test file is the single longest test among clang's tests and ends up about
doubling the wall time of clang tests on machines with high number of cores.

The test appears to consist of multiple independent subtests and does not have
to be in one file. Splitting it into smaller parts reduces test time on my
machine from ~80s down to ~45.

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

4 years agoAdd symlinks for `libtool` and `install_name_tool`
Sameer Arora [Fri, 31 Jul 2020 22:22:16 +0000 (15:22 -0700)]
Add symlinks for `libtool` and `install_name_tool`

Add symlinks for `llvm-libtool-darwin` and
`llvm-install-name-tool`.

Reviewed by jhenderson, smeenai

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

4 years ago[flang] Update FirOpsDialect constructor to pass its TypeID
River Riddle [Fri, 7 Aug 2020 20:41:42 +0000 (13:41 -0700)]
[flang] Update FirOpsDialect constructor to pass its TypeID

4 years ago[mlir][Type] Remove usages of Type::getKind
River Riddle [Fri, 7 Aug 2020 20:30:43 +0000 (13:30 -0700)]
[mlir][Type] Remove usages of Type::getKind

This is in preparation for removing the use of "kinds" within attributes and types in MLIR.

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

4 years ago[mlir][Attribute] Remove usages of Attribute::getKind
River Riddle [Fri, 7 Aug 2020 20:30:29 +0000 (13:30 -0700)]
[mlir][Attribute] Remove usages of Attribute::getKind

This is in preparation for removing the use of "kinds" within attributes and types in MLIR.

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

4 years ago[mlir] Remove the need to define `kindof` on attribute and type classes.
River Riddle [Fri, 7 Aug 2020 20:30:17 +0000 (13:30 -0700)]
[mlir] Remove the need to define `kindof` on attribute and type classes.

This revision refactors the default definition of the attribute and type `classof` methods to use the TypeID of the concrete class instead of invoking the `kindof` method. The TypeID is already used as part of uniquing, and this allows for removing the need for users to define any of the type casting utilities themselves.

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

4 years ago[mlir][Types] Remove the subclass data from Type
River Riddle [Fri, 7 Aug 2020 20:29:55 +0000 (13:29 -0700)]
[mlir][Types] Remove the subclass data from Type

Subclass data is useful when a certain amount of memory is allocated, but not all of it is used. In the case of Type, that hasn't been the case for a while and the subclass is just taking up a full `unsigned`. Removing this frees up ~8 bytes for almost every type instance.

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

4 years ago[mlir] Add a utility class, ThreadLocalCache, for storing non static thread local...
River Riddle [Fri, 7 Aug 2020 20:29:36 +0000 (13:29 -0700)]
[mlir] Add a utility class, ThreadLocalCache, for storing non static thread local objects.

This class allows for defining thread local objects that have a set non-static lifetime. This internals of the cache use a static thread_local map between the various different non-static objects and the desired value type. When a non-static object destructs, it simply nulls out the entry in the static map. This will leave an entry in the map, but erase any of the data for the associated value. The current use cases for this are in the MLIRContext, meaning that the number of items in the static map is ~1-2 which aren't particularly costly enough to warrant the complexity of pruning. If a use case arises that requires pruning of the map, the functionality can be added.

This is especially useful in the context of MLIR for implementing thread-local caching of context level objects that would otherwise have very high lock contention. This revision adds a thread local cache in the MLIRContext for attributes, identifiers, and types to reduce some of the locking burden. This led to a speedup of several hundred miliseconds when compiling a conversion pass on a very large mlir module(>300K operations).

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

4 years ago[mlir] Refactor StorageUniquer to require registration of possible storage types
River Riddle [Fri, 7 Aug 2020 20:29:11 +0000 (13:29 -0700)]
[mlir] Refactor StorageUniquer to require registration of possible storage types

This allows for bucketing the different possible storage types, with each bucket having its own allocator/mutex/instance map. This greatly reduces the amount of lock contention when multi-threading is enabled. On some non-trivial .mlir modules (>300K operations), this led to a compile time decrease of a single conversion pass by around half a second(>25%).

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

4 years ago[ELF]: --icf: don't fold sections referencing sections with LCDA after D84610
Fangrui Song [Fri, 7 Aug 2020 20:42:09 +0000 (13:42 -0700)]
[ELF]: --icf: don't fold sections referencing sections with LCDA after D84610

4 years agoGlobalISel: Handle zext(sext x) in artifact combiner
Matt Arsenault [Fri, 7 Aug 2020 13:08:00 +0000 (09:08 -0400)]
GlobalISel: Handle zext(sext x) in artifact combiner

This eliminates the illegal intermediate s8 value in the added test.

4 years agolldbutil: add a retry mechanism for the ios simulator
Adrian Prantl [Fri, 7 Aug 2020 20:28:05 +0000 (13:28 -0700)]
lldbutil: add a retry mechanism for the ios simulator

We've been seeing this failure on green dragon when the system is
under high load. Unfortunately this is outside of LLDB's control.

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

4 years ago[FileCheck] Add docs for --allow-empty
Sameer Arora [Mon, 13 Jul 2020 14:39:29 +0000 (07:39 -0700)]
[FileCheck] Add docs for --allow-empty

This diff adds documentation for `allow-empty` flag under FileCheck
docs.

Reviewed by jhenderson, smeenai, thopre

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

4 years ago[flang] Support DATA statement initialization of numeric with Hollerith/CHARACTER
peter klausler [Fri, 7 Aug 2020 00:58:40 +0000 (17:58 -0700)]
[flang] Support DATA statement initialization of numeric with Hollerith/CHARACTER

This is a common Fortran language extension.

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

4 years ago[libc] Add strcpsn and strpbrk implementation.
cgyurgyik [Fri, 7 Aug 2020 20:13:48 +0000 (16:13 -0400)]
[libc] Add strcpsn and strpbrk implementation.

Reviewed By: sivachandra

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

4 years ago[flang] Descriptor-based I/O data item transfers
peter klausler [Fri, 7 Aug 2020 00:30:01 +0000 (17:30 -0700)]
[flang] Descriptor-based I/O data item transfers

Add support for OutputDescriptor() and InputDescriptor()
in the I/O runtime.  Change existing scalar formatted I/O
functions to drive descriptor-based I/O routines internally.

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

4 years ago[lldb] Only check for --apple-sdk argument on Darwin
Jonas Devlieghere [Fri, 7 Aug 2020 20:04:16 +0000 (13:04 -0700)]
[lldb] Only check for --apple-sdk argument on Darwin

4 years ago[llvm-install-name-tool] Adds docs for llvm-install-name-tool
Sameer Arora [Fri, 12 Jun 2020 14:39:46 +0000 (07:39 -0700)]
[llvm-install-name-tool] Adds docs for llvm-install-name-tool

Adding documentation for llvm-install-name-tool.

Reviewed by smeenai, Ktwu

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

4 years agoRevert "[MSAN] Instrument libatomic load/store calls"
Gui Andrade [Fri, 7 Aug 2020 19:30:15 +0000 (19:30 +0000)]
Revert "[MSAN] Instrument libatomic load/store calls"

Problems with instrumenting atomic_load when the call has no successor,
blocking compiler roll

This reverts commit 33d239513c881d8c11c60d5710c55cf56cc309a5.

4 years ago[MLIR] Add getSizeInBits() for tensor of complex
Tim Shen [Thu, 6 Aug 2020 00:26:32 +0000 (17:26 -0700)]
[MLIR] Add getSizeInBits() for tensor of complex

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

4 years ago[mlir][spirv] Add correct handling of Kernel and Addresses capabilities
Konrad Dobros [Fri, 7 Aug 2020 17:40:21 +0000 (10:40 -0700)]
[mlir][spirv] Add correct handling of Kernel and Addresses capabilities

This change adds initial support needed to generate OpenCL compliant SPIRV.
If Kernel capability is declared then memory model becomes OpenCL.
If Addresses capability is declared then addressing model becomes Physical64.
Additionally for Kernel capability interface variable ABI attributes are not
generated as entry point function is expected to have normal arguments.

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

4 years ago[flang][NFC] Reformat files with current clang-format
peter klausler [Thu, 6 Aug 2020 23:56:14 +0000 (16:56 -0700)]
[flang][NFC] Reformat files with current clang-format

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

4 years ago[gn build] Port 320eab2d558
LLVM GN Syncbot [Fri, 7 Aug 2020 19:01:40 +0000 (19:01 +0000)]
[gn build] Port 320eab2d558

4 years agoRevert "[NewPM][CodeGen] Introduce machine pass and machine pass manager"
Yuanfang Chen [Fri, 7 Aug 2020 18:59:58 +0000 (11:59 -0700)]
Revert "[NewPM][CodeGen] Introduce machine pass and machine pass manager"

This reverts commit 911565d1085d9447363fe8ad041817436c4998fe.

Broke some non-Linux bots.

4 years ago[mlir][SCF] Add utility to outline the then and else branches of an scf.IfOp
Nicolas Vasilache [Fri, 7 Aug 2020 18:35:33 +0000 (14:35 -0400)]
[mlir][SCF] Add utility to outline the then and else branches of an scf.IfOp

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

4 years agoReduce dropTriviallyDeadConstantArrays cumulative time percentage from 17% to 4%
Jianzhou Zhao [Fri, 7 Aug 2020 16:30:26 +0000 (09:30 -0700)]
Reduce dropTriviallyDeadConstantArrays cumulative time percentage from 17% to 4%

The history of dropTriviallyDeadConstantArrays is like this. Because the appending linkage uses too much memory (http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20150105/251381.html), dropTriviallyDeadConstantArrays was introduced (https://reviews.llvm.org/rG81f385b0c6ea37dd7195a65be162c75bbdef29d2) to release unused constant arrays. Recently, dropTriviallyDeadConstantArrays was improved (https://reviews.llvm.org/rG81f385b0c6ea37dd7195a65be162c75bbdef29d2) to reduce its quadratic cost.

Our recent LTO profiling shows that when a target is large, 15-20% of time cost is from the SetVector::insert called by dropTriviallyDeadConstantArrays.

A large application has hundreds or thousands of modules; each module calls dropTriviallyDeadConstantArrays once for cleaning up tens of thousands of ConstantArrays a module has. In those ConstantArrays, usually around 5 can be deleted; a very very few deleted ConstantArrays reference other ConstantArrays: less than 10 out of millions.

Given this, the cost of SetVector::insert is mainly from the construction of WorkList from ArrayConstants. This motivated the fix that iterates ArrayConstants directly, and uses WorkList only when necessary.

Our evaluation shows that
1) The cumulative time percentage of dropTriviallyDeadConstantArrays is reduced from 15-17% to 4-6%.
2) For targets with LTO time > 20min, the time reduction is about 20%.
3) No observable performance impact for build without using LTO.

{F12506218}
{F12506221}

Reviewed By: mehdi_amini, tejohnson, jdoerfert

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

4 years ago[mlir] Introduce AffineMinSCF folding as a pattern
Nicolas Vasilache [Fri, 7 Aug 2020 18:28:40 +0000 (14:28 -0400)]
[mlir] Introduce AffineMinSCF folding as a pattern

This revision adds a folding pattern to replace affine.min ops by the actual min value, when it can be determined statically from the strides and bounds of enclosing scf loop .

This matches the type of expressions that Linalg produces during tiling and simplifies boundary checks. For now Linalg depends both on Affine and SCF but they do not depend on each other, so the pattern is added there.
In the future this will move to a more appropriate place when it is determined.

The canonicalization of AffineMinOp operations in the context of enclosing scf.for and scf.parallel proceeds by:
  1. building an affine map where uses of the induction variable of a loop
  are replaced by `%lb + %step * floordiv(%iv - %lb, %step)` expressions.
  2. checking if any of the results of this affine map divides all the other
  results (in which case it is also guaranteed to be the min).
  3. replacing the AffineMinOp by the result of (2).

The algorithm is functional in simple parametric tiling cases by using semi-affine maps. However simplifications of such semi-affine maps are not yet available and the canonicalization does not succeed yet.

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

4 years ago[PPC] Rename bool-ret-to-int -> ppc-bool-ret-to-int
Arthur Eubanks [Thu, 6 Aug 2020 03:02:22 +0000 (20:02 -0700)]
[PPC] Rename bool-ret-to-int -> ppc-bool-ret-to-int

Reviewed By: #powerpc, nemanjai

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

4 years ago[gn build] Port 911565d1085
LLVM GN Syncbot [Fri, 7 Aug 2020 18:22:24 +0000 (18:22 +0000)]
[gn build] Port 911565d1085

4 years ago[NFC] Use value initializer for OVERLAPPED
Arthur Eubanks [Thu, 6 Aug 2020 22:33:33 +0000 (15:33 -0700)]
[NFC] Use value initializer for OVERLAPPED

To fix
../llvm/lib/Support/Windows/Path.inc(1265,21): warning: missing field
'InternalHigh' initializer [-Wmissing-field-initializers]
  OVERLAPPED OV = {0};

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

4 years ago[AMDGPU] Fix not rescheduling without clustering
Vang Thao [Fri, 7 Aug 2020 03:46:27 +0000 (20:46 -0700)]
[AMDGPU] Fix not rescheduling without clustering

Regions are sometimes skipped which should be rescheduled without memory op
clustering. RegionIdx is not incremented when iterating over regions that
are flagged to be skipped, causing the index to be incorrect.

Thanks to Vang Thao for discovering this bug!

Reviewed By: rampitec

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

4 years ago[lldb] Store the Apple SDK in dotest's configuration.
Jonas Devlieghere [Fri, 7 Aug 2020 17:06:38 +0000 (10:06 -0700)]
[lldb] Store the Apple SDK in dotest's configuration.

This patch stores the --apple-sdk argument in the dotest configuration.
When it's set, use it instead of the triple to determine the current
platform.

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

4 years ago[Clang] Add note for bad conversion when expression is pointer to forward-declared...
Zequan Wu [Wed, 5 Aug 2020 18:48:36 +0000 (11:48 -0700)]
[Clang] Add note for bad conversion when expression is pointer to forward-declared type

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

4 years ago[SyntaxTree] Use simplified grammar rule for `NestedNameSpecifier` grammar nodes
Eduardo Caldas [Tue, 4 Aug 2020 17:33:36 +0000 (17:33 +0000)]
[SyntaxTree] Use simplified grammar rule for `NestedNameSpecifier` grammar nodes

This is our grammar rule for nested-name-specifiers:
globalbal-specifier:
  /*empty*/
simple-template-specifier:
  template_opt simple-template-id
name-specifier:
  global-specifier
  decltype-specifier
  identifier
  simple-template-specifier
nested-name-specifier:
  list(name-specifier, ::, non-empty, terminated)

It is a relaxed version of C++ [expr.prim.id] and quite simpler to map to our API.

TODO: refine name specifiers, `simple-template-name-specifier` and
decltype-name-specifier` are token soup for now.

4 years ago[lld-macho] Add .tbd support for frameworks
Jez Ng [Fri, 7 Aug 2020 18:04:54 +0000 (11:04 -0700)]
[lld-macho] Add .tbd support for frameworks

Required for e.g. linking iOS apps since they don't have a platform-native
SDK

Reviewed By: #lld-macho, compnerd, smeenai

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

4 years ago[lld-macho] Support static linking of thread-locals
Jez Ng [Fri, 7 Aug 2020 18:04:52 +0000 (11:04 -0700)]
[lld-macho] Support static linking of thread-locals

Note: What ELF refers to as "TLS", Mach-O seems to refer to as "TLV", i.e.
thread-local variables.

This diff implements support for TLV relocations that reference defined
symbols. On x86_64, TLV relocations are always used with movq opcodes, so for
defined TLVs, we don't need to create a synthetic section to store the
addresses of the symbols -- we can just convert the `movq` to a `leaq`.

One notable quirk of Mach-O's TLVs is that absolute-address relocations
inside TLV-defining sections behave differently -- their addresses are
no longer absolute, but relative to the start of the target section.
(AFAICT, RIP-relative relocations are not allowed in these sections.)

Reviewed By: #lld-macho, compnerd, smeenai

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

4 years ago[lld-macho] Ensure .tbss sections are also considered as ZeroFilled
Jez Ng [Fri, 7 Aug 2020 18:04:41 +0000 (11:04 -0700)]
[lld-macho] Ensure .tbss sections are also considered as ZeroFilled

This diff makes the behavior in {D80859} and {D81888} apply to
thread-local ZeroFill sections too. I realized this was necessary whie
trying to implement thread-local variables.

Reviewed By: #lld-macho, compnerd, MaskRay

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

4 years ago[NewPM][CodeGen] Introduce machine pass and machine pass manager
Yuanfang Chen [Fri, 7 Aug 2020 16:24:52 +0000 (09:24 -0700)]
[NewPM][CodeGen] Introduce machine pass and machine pass manager

machine pass could define four methods:
- `PreservedAnalyses run(MachineFunction &, MachineFunctionAnalysisManager &)`
- `Error doInitialization(Module &, MachineFunctionAnalysisManager &)`
- `Error doFinalization(Module &, MachineFunctionAnalysisManager &)`
- `Error run(Module &, MachineFunctionAnalysisManager &)`

machine pass manger:
- MachineFunctionAnalysisManager:
  Basically an AnalysisManager<MachineFunction> augmented with the ability to
  register and query IR analyses
- MachineFunctionPassManager: support only two methods, `addPass` and `run`

Reviewed By: arsenm, asbirlea, aeubanks

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

4 years ago[NewPM] Only verify loop for nonskipped user loop pass
Yuanfang Chen [Fri, 7 Aug 2020 16:22:51 +0000 (09:22 -0700)]
[NewPM] Only verify loop for nonskipped user loop pass

No verification for pass mangers since it is not needed.
No verification for skipped loop pass since the asserted condition is not used.

Add a BeforeNonSkippedPass callback for this. The callback needs more
inputs than its parameters to work so the callback is added on-the-fly.

Reviewed By: aeubanks, asbirlea

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

4 years agoRevert "Reland D64327 [MC][ELF] Allow STT_SECTION referencing SHF_MERGE on REL targets"
Mitch Phillips [Fri, 7 Aug 2020 17:56:33 +0000 (10:56 -0700)]
Revert "Reland D64327 [MC][ELF] Allow STT_SECTION referencing SHF_MERGE on REL targets"

This reverts commit b497665d98ad5026b1d3d67d5793a28fefe27bea.

Spent some time trying to reproduce this locally, reverting in a
desparate attempt to fix the sanitizer buildbot:
 - http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/28828

I don't know exactly why or how this patch breaks the bots, but it seems
pretty concrete that it's the culprit.

4 years agoMake clang HIP headers compatible with C++98
Yaxun (Sam) Liu [Fri, 7 Aug 2020 17:50:22 +0000 (13:50 -0400)]
Make clang HIP headers compatible with C++98

Automation to detect compiler features, such as CMake's target_compile_features,
would attempt to detect compiler features by explicitly using langugage flags.
This change ensures that the HIP headers would still work with C++98.

Patch by Siu Chi Chan

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

Change-Id: I304e964b18a525b0fde55efd841da74b6c4dc8ed

4 years ago[analyzer] pr47030: MoveChecker: Unforget a comma in the suppression list.
Artem Dergachev [Fri, 7 Aug 2020 17:17:27 +0000 (10:17 -0700)]
[analyzer] pr47030: MoveChecker: Unforget a comma in the suppression list.

4 years ago[flang] Remove extra CMAKE_CXX_FLAGS in Lower and Optimizer
Tim Keith [Fri, 7 Aug 2020 17:21:52 +0000 (10:21 -0700)]
[flang] Remove extra CMAKE_CXX_FLAGS in Lower and Optimizer

`-Wno-error` and `-Wno-unused-parameter` appear to no longer be needed
for Lower and Optimizer.

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

4 years ago[NFC] Add utility to sum/merge stats files
Tyker [Fri, 7 Aug 2020 17:02:25 +0000 (19:02 +0200)]
[NFC] Add utility to sum/merge stats files

Add a small script to sum *.stats file given as input and output the totals
usage example:
    merge-stats.py $(find ./builddir/ -name "*.stats") > total.stats

Reviewed By: lebedev.ri

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

4 years ago[mlir] [VectorOps] Improve lowering of extract_strided_slice (and friends like shape_...
aartbik [Thu, 6 Aug 2020 22:34:47 +0000 (15:34 -0700)]
[mlir] [VectorOps] Improve lowering of extract_strided_slice (and friends like shape_cast)

Using a shuffle for the last recursive step in progressive lowering not only
results in much more compact IR, but also more efficient code (since the
backend is no longer confused on subvector aliasing for longer vectors).

E.g. the following

  %f = vector.shape_cast %v0: vector<1024xf32> to vector<32x32xf32>

yields much better x86-64 code that runs 3x faster than the original.

Reviewed By: bkramer, nicolasvasilache

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