platform/upstream/llvm.git
3 years ago[llvm-reduce] Skip updating calls where OldF isn't the called fn.
Florian Hahn [Fri, 1 Oct 2021 08:56:08 +0000 (09:56 +0100)]
[llvm-reduce] Skip updating calls where OldF isn't the called fn.

When replacing function calls, skip call instructions where the old
function is not the called function, but e.g. the old function is passed
as an argument.

This fixes a crash due to trying to construct invalid IR for the test
case.

Reviewed By: aeubanks

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

3 years agoRevert "[libcxx][test] Use python specified by build rather than system default python"
David Spickett [Fri, 1 Oct 2021 09:44:44 +0000 (09:44 +0000)]
Revert "[libcxx][test] Use python specified by build rather than system default python"

This reverts commit 9f641c96cb15c9752c976bff286bb57adf86acab.

The "python" command in gdb uses the python gdb is linked to,
not what "python" would give you if you used it directly in the shell.

3 years agoRevert "[libcxx] Run u16string tests for gdb pretty printers"
David Spickett [Fri, 1 Oct 2021 09:43:16 +0000 (09:43 +0000)]
Revert "[libcxx] Run u16string tests for gdb pretty printers"

This reverts commit e9564c3698edffc64439a8f957c7c28b19214613
due to a report of these tests failing.

3 years agoRevert "[LoopVectorize] Permit vectorisation of more select(cmp(), X, Y) reduction...
Krasimir Georgiev [Fri, 1 Oct 2021 09:37:40 +0000 (11:37 +0200)]
Revert "[LoopVectorize] Permit vectorisation of more select(cmp(), X, Y) reduction patterns"

It appears to cause stage2 clang build failures, e.g.,
https://lab.llvm.org/buildbot/#/builders/74/builds/7145.

This reverts commit 1fb37334bdb3cdb028977382fbd84cebde64ebb2.

3 years ago[clang][ASTImporter] Import ConstructorUsingShadowDecl correctly.
Balázs Kéri [Fri, 1 Oct 2021 09:04:54 +0000 (11:04 +0200)]
[clang][ASTImporter] Import ConstructorUsingShadowDecl correctly.

Fix import of ConstructorUsingShadowDecl and add tests.

Reviewed By: martong

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

3 years ago[flang][driver] Error if uuidgen is not installed
David Spickett [Wed, 29 Sep 2021 11:30:55 +0000 (12:30 +0100)]
[flang][driver] Error if uuidgen is not installed

Ubuntu Bionic installs it by default, Focal does not.

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

3 years ago[clang][ASTImporter] Import InheritedConstructor and ConstructorUsingShadowDecl.
Gabor Marton [Fri, 1 Oct 2021 07:24:41 +0000 (09:24 +0200)]
[clang][ASTImporter] Import InheritedConstructor and ConstructorUsingShadowDecl.

Reviewed By: martong

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

3 years ago[LoopVectorize] Permit vectorisation of more select(cmp(), X, Y) reduction patterns
David Sherwood [Wed, 4 Aug 2021 07:10:51 +0000 (08:10 +0100)]
[LoopVectorize] Permit vectorisation of more select(cmp(), X, Y) reduction patterns

This patch adds further support for vectorisation of loops that involve
selecting an integer value based on a previous comparison. Consider the
following C++ loop:

  int r = a;
  for (int i = 0; i < n; i++) {
    if (src[i] > 3) {
      r = b;
    }
    src[i] += 2;
  }

We should be able to vectorise this loop because all we are doing is
selecting between two states - 'a' and 'b' - both of which are loop
invariant. This just involves building a vector of values that contain
either 'a' or 'b', where the final reduced value will be 'b' if any lane
contains 'b'.

The IR generated by clang typically looks like this:

  %phi = phi i32 [ %a, %entry ], [ %phi.update, %for.body ]
  ...
  %pred = icmp ugt i32 %val, i32 3
  %phi.update = select i1 %pred, i32 %b, i32 %phi

We already detect min/max patterns, which also involve a select + cmp.
However, with the min/max patterns we are selecting loaded values (and
hence loop variant) in the loop. In addition we only support certain
cmp predicates. This patch adds a new pattern matching function
(isSelectCmpPattern) and new RecurKind enums - SelectICmp & SelectFCmp.
We only support selecting values that are integer and loop invariant,
however we can support any kind of compare - integer or float.

Tests have been added here:

  Transforms/LoopVectorize/AArch64/sve-select-cmp.ll
  Transforms/LoopVectorize/select-cmp-predicated.ll
  Transforms/LoopVectorize/select-cmp.ll

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

3 years ago[SelectionDAG] Handle promotion + widening in getCopyToPartsVector
Sander de Smalen [Thu, 16 Sep 2021 15:03:52 +0000 (16:03 +0100)]
[SelectionDAG] Handle promotion + widening in getCopyToPartsVector

Some vectors require both widening and promotion for their legalization.
This case is not yet handled in getCopyToPartsVector and falls back
on scalarizing by default. BBecause scalable vectors can't easily be
scalarised, we need to implement this in two separate stages:
1. Widen the vector.
2. Promote the vector.

As part of this patch, PromoteIntRes_CONCAT_VECTORS also needed to be
made scalable aware. Instead of falling back on scalarizing the vector
(fixed-width only), each sub-part of the CONCAT vector is promoted,
and the operation is performed on the type with the widest element type,
finally truncating the result to the promoted result type.

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

3 years ago[fir][NFC] Move fir.select_type builder to cpp file
Valentin Clement [Fri, 1 Oct 2021 07:19:17 +0000 (09:19 +0200)]
[fir][NFC] Move fir.select_type builder to cpp file

Move the big builder out of the td file to the cpp file.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: kiranchandramohan

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

3 years ago[fir][NFC] Update doc for pinned attr in fir.alloca
Valentin Clement [Fri, 1 Oct 2021 07:17:41 +0000 (09:17 +0200)]
[fir][NFC] Update doc for pinned attr in fir.alloca

Add descritpion for the attribute added in D110815.

Reviewed By: kiranchandramohan

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

3 years ago[flang] Revert 3 commits pushed by mistake along b7c07ce15ffe6da9dcd69d457a3eca987452edc7
Jean Perier [Fri, 1 Oct 2021 06:58:52 +0000 (08:58 +0200)]
[flang] Revert 3 commits pushed by mistake along b7c07ce15ffe6da9dcd69d457a3eca987452edc7

Revert "[flang][NFC] Add debug dump method to evaluate::Expr and semantics::Symbol"
This reverts commit b0e35fde21ecb47799603e1acfc9ffa7b83dea13.

Revert "[flang] Add a wrapper for Fortran main program"
This reverts commit 2c1ce0755e09909c41db93845c4c3f42457cb9c8.

Revert "[flang][NFC] Fix header comments in some runtime headers"
This reverts commit a63f57674d511eb287edbabad9674c6298cf8b84.

3 years ago[flang] Improve runtime interface with C99 complex
Jean Perier [Fri, 1 Oct 2021 06:42:42 +0000 (08:42 +0200)]
[flang] Improve runtime interface with C99 complex

Follow up of https://reviews.llvm.org/D83397.

In folding, make pgmath usage conditional to C99 complex
support in C++. Disable warning in such case.

In lowering, use an empty class type to indicate C99 complex
type in runtime interface.

Add a unit test enforcing C99 complex can be processed
by FIR runtime interface builder.

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

3 years ago[flang][NFC] Add debug dump method to evaluate::Expr and semantics::Symbol
Jean Perier [Thu, 30 Sep 2021 14:22:16 +0000 (07:22 -0700)]
[flang][NFC] Add debug dump method to evaluate::Expr and semantics::Symbol

Helps debugging when working with symbol/expression issue. The dump
method is easy to call in the debugger.

3 years ago[flang] Add a wrapper for Fortran main program
Jean Perier [Thu, 30 Sep 2021 13:26:00 +0000 (06:26 -0700)]
[flang] Add a wrapper for Fortran main program

Add a C wrapper that calls the Fortran runtime initialization and
finalization routines as well as the compiled Fortran main program
_QQmain.

Place it in its own library to satisfy shared library builds since it
contains a C main function.

- https://github.com/flang-compiler/f18-llvm-project/commit/cc7ac498f916d32a9b197d3ace816f4de5d36aad#diff-fa35a5efa62731fd2845e5e982eca9a2e36439783e11a4e4a463753c2160ec10R53
- was created in flang/test/Examples/main.c in Eric's branch

3 years ago[flang][NFC] Fix header comments in some runtime headers
Jean Perier [Thu, 30 Sep 2021 12:04:47 +0000 (05:04 -0700)]
[flang][NFC] Fix header comments in some runtime headers

3 years ago[MemProf] Loosen matching of profile data to avoid bot flakes
Teresa Johnson [Fri, 1 Oct 2021 04:13:51 +0000 (21:13 -0700)]
[MemProf] Loosen matching of profile data to avoid bot flakes

Allow for the allocations to have migrated cpus, assuming they wouldn't
is causing some bot flakiness, e.g.:
https://lab.llvm.org/buildbot/#/builders/37/builds/7197

3 years agoExpose `DIBuilder::finalizeSubprogram()` through the LLVM C API
Koutheir Attouchi [Fri, 1 Oct 2021 03:57:53 +0000 (20:57 -0700)]
Expose `DIBuilder::finalizeSubprogram()` through the LLVM C API

The LLVM C API function is called `LLVMDIBuilderFinalizeSubprogram()`.

Reviewed By: CodaFi

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

3 years ago[PowerPC] Fix lharx and lbarx builtin signatures
Albion Fung [Thu, 30 Sep 2021 23:50:09 +0000 (18:50 -0500)]
[PowerPC] Fix lharx and lbarx builtin signatures

The signatures for the PowerPC builtins lharx and
lbarx are incorrect, and causes issues when used in a function
that requires the return of the builtin to be promoted.
This patch fixes these signatures.

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

3 years ago[NFC][asan] Remove redundant functions
Vitaly Buka [Fri, 1 Oct 2021 02:36:53 +0000 (19:36 -0700)]
[NFC][asan] Remove redundant functions

3 years ago[NFC][lsan] Expand use StackDepotReverseMap
Vitaly Buka [Fri, 1 Oct 2021 02:24:53 +0000 (19:24 -0700)]
[NFC][lsan] Expand use StackDepotReverseMap

Before StackDepotReverseMap was used only by ProcessPC.

3 years ago[NFC][sanitizer] Lazy init in StackDepotReverseMap
Vitaly Buka [Fri, 1 Oct 2021 02:10:20 +0000 (19:10 -0700)]
[NFC][sanitizer] Lazy init in StackDepotReverseMap

3 years ago[gn build] Port 3077bc90de8d
LLVM GN Syncbot [Fri, 1 Oct 2021 00:43:50 +0000 (00:43 +0000)]
[gn build] Port 3077bc90de8d

3 years ago[NFC] Restore magic and magicu to a globally visible location
Christopher Tetreault [Thu, 30 Sep 2021 17:34:56 +0000 (10:34 -0700)]
[NFC] Restore magic and magicu to a globally visible location

While these functions are only used in one location in upstream,
it has been reused in multiple downstreams. Restore this file to
a globally visibile location (outside of APInt.h) to eliminate
donwstream breakage and enable potential future reuse.

Additionally, this patch renames types and cleans up
clang-tidy issues.

3 years agoadd tsan shared library
ZijunZhao [Fri, 1 Oct 2021 00:19:35 +0000 (00:19 +0000)]
add tsan shared library

3 years ago[NFC][sanitizer] Add const into method
Vitaly Buka [Fri, 1 Oct 2021 00:15:07 +0000 (17:15 -0700)]
[NFC][sanitizer] Add const into method

3 years agoBPF: implement isLegalAddressingMode() properly
Yonghong Song [Mon, 27 Sep 2021 15:21:48 +0000 (08:21 -0700)]
BPF: implement isLegalAddressingMode() properly

Latest upstream llvm caused the kernel bpf selftest emitting the
following warnings:

  In file included from progs/profiler3.c:6:
  progs/profiler.inc.h:489:2: warning: loop not unrolled:
    the optimizer was unable to perform the requested transformation;
    the transformation might be disabled or specified as part of an unsupported
    transformation ordering [-Wpass-failed=transform-warning]
          for (int i = 0; i < MAX_PATH_DEPTH; i++) {
          ^

Further bisecting shows this SimplifyCFG patch ([1]) changed
the condition on how to fold branch to common dest. This caused
some unroll pragma is not honored in selftests/bpf.

The patch [1] test getUserCost() as the condition to
perform the certain basic block folding transformation.
For the above example, before the loop unroll pass, the control flow
looks like:
    cond_block:
       branch target: body_block, cleanup_block
    body_block:
       branch target: cleanup_block, end_block
    end_block:
       branch target: cleanup_block, end10_block
    end10_block:
       %add.ptr = getelementptr i8, i8* %payload.addr.0, i64 %call2
       %inc = add nuw nsw i32 %i.0, 1
       branch target: cond_block

In the above, %call2 is an unknown scalar.

Before patch [1], end10_block will be folded into end_block, forming
the code like
    cond_block:
       branch target: body_block, cleanup_block
    body_block:
       branch target: cleanup_block, end_block
    end_block:
       branch target: cleanup_block, cond_block
and the compiler is happy to perform unrolling.

With patch [1], getUserCost(), which calls getGEPCost(), which calls
isLegalAddressingMode() in TargetLoweringBase.cpp, considers IR
  %add.ptr = getelementptr i8, i8* %payload.addr.0, i64 %call2
is free, so the above basic block folding transformation is not performed
and unrolling does not happen.

For BPF target, the IR
  %add.ptr = getelementptr i8, i8* %payload.addr.0, i64 %call2
is not free and we don't have ld/st instruction address with 'r+r' mode.

This patch implemented a BPF hook for isLegalAddressingMode(), which is
identical to Mips isLegalAddressingMode() implementation where
the address pattern like 'r+r', 'r+r+i' or '2*r' are not allowed.
With testing kernel bpf selftests, all loop not unrolled warnings
are gone and all selftests run successfully.

  [1] https://reviews.llvm.org/D108837

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

3 years ago[test] Add tests covering a missing opt in SCEV's isSCEVExprNeverPoison
Philip Reames [Thu, 30 Sep 2021 23:14:55 +0000 (16:14 -0700)]
[test] Add tests covering a missing opt in SCEV's isSCEVExprNeverPoison

3 years ago[libcxx][test] Use python specified by build rather than system default python
Leonard Chan [Thu, 30 Sep 2021 22:34:30 +0000 (15:34 -0700)]
[libcxx][test] Use python specified by build rather than system default python

As of e9564c3698edffc64439a8f957c7c28b19214613, libcxx/gdb/gdb_pretty_printer_test.sh.cpp
fails locally for me because the REQUIRES check for host-has-gdb-with-python
uses python, which for me expands to python 2.7.18. This failure does not seem
to be caught on any upstream builders, potentially because they don't have gdb,
python, or a version of python that makes the test UNSUPPORTED (like python3).

This updates the check to use the python specified by the build (which should
be the python that runs this code), rather than just python.

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

3 years ago[SCEV] Modernize code style of isSCEVExprNeverPoison [NFC]
Philip Reames [Thu, 30 Sep 2021 22:13:00 +0000 (15:13 -0700)]
[SCEV] Modernize code style of isSCEVExprNeverPoison [NFC]

Use for-range and all_of to make code easier to read in advance of other changes.

3 years ago[MemProf] Record accesses for all words touched in mem intrinsic
Teresa Johnson [Thu, 30 Sep 2021 02:14:09 +0000 (19:14 -0700)]
[MemProf] Record accesses for all words touched in mem intrinsic

Previously for mem* intrinsics we only incremented the access count for
the first word in the range. However, after thinking it through I think
it makes more sense to record an access for every word in the range.
This better matches the behavior of inlined memory intrinsics, and also
allows better analysis of utilization at a future date.

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

3 years ago[MC] Fix buildbots with shared lib builds
Rafael Auler [Thu, 30 Sep 2021 21:35:38 +0000 (14:35 -0700)]
[MC] Fix buildbots with shared lib builds

In D109412 I forgot to add a dependency on libObject. Fix that.

Reviewed By: maksfb

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

3 years ago[GlobalISel] Extend CombinerHelper::matchConstantOp() to match constant splat vectors.
Amara Emerson [Thu, 30 Sep 2021 07:20:56 +0000 (00:20 -0700)]
[GlobalISel] Extend CombinerHelper::matchConstantOp() to match constant splat vectors.

This allows the "x op 0 -> x" fold to optimize vector constant RHSs.

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

3 years ago[flang][NFC] Add debug dump method to evaluate::Expr and semantics::Symbol
Jean Perier [Thu, 30 Sep 2021 21:16:29 +0000 (23:16 +0200)]
[flang][NFC] Add debug dump method to evaluate::Expr and semantics::Symbol

Helps debugging when working with symbol/expression issue. The dump
method is easy to call in the debugger.

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Differential Revision: https://reviews.llvm.org/D110856

3 years ago[RISCV] Remove Zbproposedc extension
Craig Topper [Thu, 30 Sep 2021 19:00:31 +0000 (12:00 -0700)]
[RISCV] Remove Zbproposedc extension

This consists of 3 compressed instructions, c.not, c.neg, and c.zext.w.
I believe these have been picked up by the Zce effort using different
encodings. I don't think it makes sense to keep them in bitmanip. It
will eventually cause a conflict if/when Zce is implemented in llvm.

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

3 years ago[flang] Take into account SubprogramDetails in GetInterfaceSymbol
Jean Perier [Thu, 30 Sep 2021 21:06:22 +0000 (23:06 +0200)]
[flang] Take into account SubprogramDetails in GetInterfaceSymbol

When the ProcRef is Symbol is a SubprogramDetails, the interface is
the SubprogramDetails. Do not return nullptr.

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

3 years ago[openmp][docs] Describe how the internal components are found
Jon Chesterfield [Thu, 30 Sep 2021 21:05:11 +0000 (22:05 +0100)]
[openmp][docs] Describe how the internal components are found

Add a FAQ entry about the names of openmp offloading components
and how they are searched for.

Reviewed By: jhuber6

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

3 years ago[flang][NFC] Fix header comments in some runtime headers
Jean Perier [Thu, 30 Sep 2021 21:04:03 +0000 (23:04 +0200)]
[flang][NFC] Fix header comments in some runtime headers

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

3 years ago[CMake] Remove the LLD LTO check for Darwin
Petr Hosek [Thu, 30 Sep 2021 20:41:57 +0000 (13:41 -0700)]
[CMake] Remove the LLD LTO check for Darwin

LLD now supports LTO on Darwin.

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

3 years ago[compiler-rt] Add -fno-omit-frame-pointer check to builtins
Gwen Mittertreiner [Thu, 30 Sep 2021 20:52:51 +0000 (13:52 -0700)]
[compiler-rt] Add -fno-omit-frame-pointer check to builtins

rG210d72e9d6b4a8e7633921d0bd7186fd3c7a2c8c moved the check from
builtin-config-ix to config-ix so that the check would be made even when
the builtins are not built. However, now the check is no longer made
when the builtins are built standalone which causes the builtins to fail
to build.

Add the check back to builtins-config-ix so that the check gets
performed both when the builtins are not built, and when they are built
standalone.

Reviewed By: smeenai

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

3 years ago[openmp] Add addrspacecast to getOrCreateIdent
Jon Chesterfield [Thu, 30 Sep 2021 20:36:30 +0000 (21:36 +0100)]
[openmp] Add addrspacecast to getOrCreateIdent

Fixes 51982. Adds a missing CreatePointerCast and allocates a global in
the correct address space.

Test case derived from https://github.com/ROCm-Developer-Tools/aomp/\
blob/aomp-dev/test/smoke/nest_call_par2/nest_call_par2.c by deleting
parts while checking the assertion failure still occurred.

Reviewed By: jdoerfert

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

3 years ago[libomptarget] Apply D110029 to amdgpu
Jon Chesterfield [Thu, 30 Sep 2021 20:29:36 +0000 (21:29 +0100)]
[libomptarget] Apply D110029 to amdgpu

Use enum for execution mode.

This is partly a port from ROCm and partly a port from D110029. Attempted to
make the same choices as ROCm as far as comments etc go to reduce the merge
conflicts.

There is some cleanup warranted here - in particular I like the cuda patch
factoring out the comparisons into named variables - but I'd like to leave
that for a follow up patch, keeping this one minimal.

Reviewed By: carlo.bertolli

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

3 years ago[cora async] Cleanup undefined llvm.coro.async.resume
Arnold Schwaighofer [Tue, 21 Sep 2021 18:07:07 +0000 (11:07 -0700)]
[cora async] Cleanup undefined llvm.coro.async.resume

In situations where the coroutine function is not split we can just
replace the async.resume by null.

rdar://82591919

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

3 years ago[mlir][Linalg] Refactor comprehensive bufferize for external uses - NFC
Nicolas Vasilache [Thu, 30 Sep 2021 19:51:45 +0000 (19:51 +0000)]
[mlir][Linalg] Refactor comprehensive bufferize for external uses - NFC

This revision exposes some minimal funcitonality to allow comprehensive
bufferization to interop with external projects.

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

3 years ago[AIX] Rename binder option for PGO support
Jinsong Ji [Thu, 30 Sep 2021 19:58:39 +0000 (19:58 +0000)]
[AIX] Rename binder option for PGO support

Update the binder option.

3 years agoRevert "Recommit "[SCEV] Look through single value PHIs." (take 2)"
Florian Hahn [Thu, 30 Sep 2021 17:52:38 +0000 (18:52 +0100)]
Revert "Recommit "[SCEV] Look through single value PHIs." (take 2)"

This reverts commit 764d9aa97905f202385b4f25f8d234630b4feef3.

This patch exposed a few additional cases where SCEV expressions are not
properly invalidated.

See PR52024, PR52023.

3 years ago[DFSan] Optimize code for writing to shadow. Move SetShadow to namespace.
Andrew Browne [Wed, 29 Sep 2021 17:07:17 +0000 (10:07 -0700)]
[DFSan] Optimize code for writing to shadow. Move SetShadow to namespace.

Writing zeros to shadow (including checking for existing zero) is now ~2x
faster on one example.

Reviewed By: morehouse

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

3 years ago[gn build] Port 050edef8538e
LLVM GN Syncbot [Thu, 30 Sep 2021 19:35:12 +0000 (19:35 +0000)]
[gn build] Port 050edef8538e

3 years ago[MC] Make MCDwarfLineStr class public
Maksim Panchenko [Fri, 17 Sep 2021 20:24:15 +0000 (13:24 -0700)]
[MC] Make MCDwarfLineStr class public

Add MCDwarfLineStr class to the public API.

Note that MCDwarfLineTableHeader::Emit(), takes MCDwarfLineStr as
an Optional<> parameter making it impossible to use the API if the class
is not publicly defined.

Reviewed By: alexander-shaposhnikov

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

3 years ago[PowerPC] Improved codegen related to xscvdpsxws/xscvdpuxws
Albion Fung [Thu, 30 Sep 2021 18:45:29 +0000 (13:45 -0500)]
[PowerPC] Improved codegen related to xscvdpsxws/xscvdpuxws

This patch removes the uneccessary mf/mtvsr generated in conjunction
with xscvdpsxws/xscvdpuxws.

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

3 years ago[GlobalISel] Extend G_SELECT of known condition combine to vectors.
Amara Emerson [Wed, 29 Sep 2021 22:38:59 +0000 (15:38 -0700)]
[GlobalISel] Extend G_SELECT of known condition combine to vectors.

Adds a new utility function: isConstantOrConstantSplatVector().

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

3 years ago[flang] Fold FINDLOC()
Peter Klausler [Tue, 28 Sep 2021 16:56:38 +0000 (09:56 -0700)]
[flang] Fold FINDLOC()

Fold the transformational intrinsic function FINDLOC() for
all combinations of optional arguments and data types.

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

3 years ago[InstCombine] restrict shift-trunc-shift fold to opposite direction shifts
Sanjay Patel [Thu, 30 Sep 2021 18:47:02 +0000 (14:47 -0400)]
[InstCombine] restrict shift-trunc-shift fold to opposite direction shifts

This is NFCI because the pattern with 2 left-shifts should get
folded independently by smaller folds.

The motivation is to refine this block to avoid infinite loops
seen with D110170.

3 years ago[InstCombine] add tests for shift-trunc-shift; NFC
Sanjay Patel [Thu, 30 Sep 2021 18:09:24 +0000 (14:09 -0400)]
[InstCombine] add tests for shift-trunc-shift; NFC

3 years agoReland "[clang-cl] Accept `#pragma warning(disable : N)` for some N"
Nico Weber [Thu, 30 Sep 2021 18:41:58 +0000 (14:41 -0400)]
Reland "[clang-cl] Accept `#pragma warning(disable : N)` for some N"

This reverts commit 0cd9d8a48bdddb17de2c6388f9d775353f9acab9 and
adds the changes described in https://reviews.llvm.org/D110668#3034461.

3 years ago[BasicAA] Move more extension logic into ExtendedValue (NFC)
Nikita Popov [Thu, 30 Sep 2021 17:09:11 +0000 (19:09 +0200)]
[BasicAA] Move more extension logic into ExtendedValue (NFC)

Add methods to appropriately extend KnownBits/ConstantRange there,
same as with APInt. Also clean up the known bits handling by
actually doing that extension rather than checking ZExtBits. This
doesn't matter now, but becomes relevant once truncation is
involved.

3 years ago[mlir][sparse] Correcting a few typos
wren romano [Wed, 29 Sep 2021 22:01:35 +0000 (15:01 -0700)]
[mlir][sparse] Correcting a few typos

Reviewed By: aartbik

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

3 years ago[clang] Don't modify OptRemark if the argument is not relevant
Arthur Eubanks [Wed, 29 Sep 2021 01:33:26 +0000 (18:33 -0700)]
[clang] Don't modify OptRemark if the argument is not relevant

A followup to D110201.

 For example, we'd set OptimizationRemarkMissed's Regex to '.*' when
encountering -Rpass. Normally this doesn't actually affect remarks we
emit because in clang::ProcessWarningOptions() we'll separately look at
all -R arguments and turn on/off corresponding diagnostic groups.
However, this is reproducible with -round-trip-args.

Reviewed By: JamesNagurne

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

3 years ago[flang] Fix test regression from SQRT folding
peter klausler [Tue, 28 Sep 2021 22:43:27 +0000 (15:43 -0700)]
[flang] Fix test regression from SQRT folding

The algorithm used to fold SQRT has some holes that
led to test failures; debug and add more tests.

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

3 years ago[clang] Make crash reproducer work with clang-cl
Nico Weber [Wed, 29 Sep 2021 22:46:24 +0000 (18:46 -0400)]
[clang] Make crash reproducer work with clang-cl

When clang crashes, it writes a standalone source file and shell script
to reproduce the crash.

The Driver used to set `Mode = CPPMode` in generateCompilationDiagnostics()
to force preprocessing mode. This has the side effect of making
IsCLMode() return false, which in turn meant Clang::AddClangCLArgs()
didn't get called when creating the standalone source file, which meant
the stand-alone file was preprocessed with the gcc driver's defaults
In particular, exceptions default to on with the gcc driver, but to
off with the cl driver. The .sh script did use the original command
line, so in the reproducer for a clang-cl crash, the standalone source
file could contain exception-using code after preprocessing that the
compiler invocation in the shell script would then complain about.

This patch removes the `Mode = CPPMode;` line and instead additionally
checks for `CCGenDiagnostics` in most places that check `CCCIsCPP().
This also matches the strategy Clang::ConstructJob() uses to add
-frewrite-includes for creating the standalone source file for a crash
report.

Fixes PR52007.

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

3 years ago[clang] do not emit note for bad conversion when destination type qualifiers are...
Zequan Wu [Wed, 29 Sep 2021 22:00:39 +0000 (15:00 -0700)]
[clang] do not emit note for bad conversion when destination type qualifiers are not compatibly include source type qualifiers

llvm.org/PR52014

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

3 years ago[clang] Remove duplication in types::getCompilationPhases()
Nico Weber [Wed, 29 Sep 2021 19:19:36 +0000 (15:19 -0400)]
[clang] Remove duplication in types::getCompilationPhases()

Call Driver::getFinalPhase() instead of duplicating it.

https://reviews.llvm.org/D65993 added the duplication, then
02e35832c301e maded it more obviously a copy of getFinalPhase().

The only difference is that getCompilationPhases() used to use
LastPhase / IfsMerge where getFinalPhase() used Link. Adapt
getFinalPhase() to return IfsMerge when needed.

No intentional behavior change.

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

3 years ago[libc++abi][NFCI] Consistently group new_handler, unexpected_handler and terminate_ha...
Louis Dionne [Thu, 30 Sep 2021 17:29:12 +0000 (13:29 -0400)]
[libc++abi][NFCI] Consistently group new_handler, unexpected_handler and terminate_handler

Previously, the definitions of __cxa_terminate_handler and __cxa_unexpected_handler
(and their set_xxx_handler functions) were grouped together, but the
definition of __cxa_new_handler wasn't. This commit simply moves those
to the same file to treat all handlers consistently.

3 years agoRevert "[libc++][libc++abi] Add tests for vendor-specific properties"
Haowei Wu [Thu, 30 Sep 2021 18:03:59 +0000 (11:03 -0700)]
Revert "[libc++][libc++abi] Add tests for vendor-specific properties"

This reverts commit 9892d1644f62cf8f5133ee0d2ebafb56f6500cc1, which
causes clang test failures in libcxx tests.

3 years ago[flang] Front-end and runtime support for CALL EXIT and ABORT
peter klausler [Thu, 23 Sep 2021 23:36:04 +0000 (16:36 -0700)]
[flang] Front-end and runtime support for CALL EXIT and ABORT

Support the extension intrinsic subroutines EXIT([status]) and ABORT()
in the intrinsic table and runtime support library.  Lowering remains
to be done.

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

3 years ago[mlir][linalg] Fix incorrect bound calculation for tiling conv
Lei Zhang [Thu, 30 Sep 2021 17:50:44 +0000 (13:50 -0400)]
[mlir][linalg] Fix incorrect bound calculation for tiling conv

For convolution, the input window dimension's access affine map
is of the form `(d0 * s0 + d1)`, where `d0`/`d1` is the output/
filter window dimension, and `s0` is the stride.

When tiling, https://reviews.llvm.org/D109267 changed how the
way dimensions are acquired. Instead of directly querying using
`*.dim` ops on the original convolution op, we now get it by
applying the access affine map to the loop upper bounds. This
is fine for dimensions having single-dimension affine maps,
like matmul, but not for convolution input. It will cause
incorrect compuation and out of bound. A concrete example, say
we have 1x225x225x3 (NHWC) input, 3x3x3x32 (HWCF) filter, and
1x112x112x3 (NHWC) output with stride 2, (112 * 2 + 3) would be
227, which is different from the correct input window dimension
size 225.

Instead, we should first calculate the max indices for each loop,
and apply the affine map to them, and then plus one to get the
dimension size. Note this makes no difference for matmul-like
ops given they will have `d0 - 1 + 1` effectively.

Reviewed By: nicolasvasilache

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

3 years ago[lldb] Remove support for replaying the test suite from a reproducer
Jonas Devlieghere [Thu, 30 Sep 2021 05:32:21 +0000 (22:32 -0700)]
[lldb] Remove support for replaying the test suite from a reproducer

This patch removes the infrastructure to replay the test suite from a
reproducer, as well as the modifications made to the individual tests.

3 years ago[AMDGPU] move hasAGPRs/hasVGPRs into header
Stanislav Mekhanoshin [Wed, 29 Sep 2021 19:43:12 +0000 (12:43 -0700)]
[AMDGPU] move hasAGPRs/hasVGPRs into header

It is now very simple and can go right into the header
allowing optimizer to combine callers, such as isVGPRClass
and similar.

It does not need anything from the TRI itself anymore, so
make it static class member along with the callers.

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

3 years agoManually create unique_ptr in various pass adaptors
Arthur Eubanks [Wed, 29 Sep 2021 23:04:39 +0000 (16:04 -0700)]
Manually create unique_ptr in various pass adaptors

This avoids creating tons of make_unique template instantiations. And we
only create a unique_ptr of the actual pass concept type, rather than
creating a unique_ptr of the pass model subclass then casting it to the
pass concept type.

This reduces the work spent compiling PassBuilder.cpp from 83M -> 73M
instructions according to perf stat.

Reviewed By: rnk

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

3 years ago[BasicAA] Use ExtendedValue in VariableGEPIndex (NFC)
Nikita Popov [Thu, 30 Sep 2021 16:18:15 +0000 (18:18 +0200)]
[BasicAA] Use ExtendedValue in VariableGEPIndex (NFC)

Use the ExtendedValue structure which is used for LinearExpression
in VariableGEPIndex as well.

3 years agoInstantiate fewer templates in PassManager::addPass()
Arthur Eubanks [Wed, 29 Sep 2021 19:12:03 +0000 (12:12 -0700)]
Instantiate fewer templates in PassManager::addPass()

We create many instantiations of PassManager::addPass() in
PassBuilder.cpp.  vector::emplace_back() and make_unique() are both
templated and would have many instantiations based on the number of
times we instantiate addPass().  Now we directly construct the
unique_ptr with the type as the actual unique_ptr type in the vector we
are adding it to, so we only have one unique_ptr constructor
instantiation across all addPass() instantiations and only the
non-templated push_back().

This makes PassBuilder.cpp slightly faster to build.

Reviewed By: rnk

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

3 years ago[CostModel] Update default cost model for sadd/ssub overflow to match TargetLowering
Craig Topper [Wed, 29 Sep 2021 17:21:44 +0000 (10:21 -0700)]
[CostModel] Update default cost model for sadd/ssub overflow to match TargetLowering

The expansion for these was updated in https://reviews.llvm.org/D47927 but the cost model was not adjusted.

I believe the cost model was also incorrect for the old expansion.
The expansion prior to D47927 used 3 icmps using LHS, RHS, and Result
to calculate theirs signs. Then 2 icmps to compare the signs. Followed
by an And. The previous cost model was using 3 icmps and 2 selects.
Digging back through git blame, those 2 selects in the cost model used to
be 2 icmps, but were changed in https://reviews.llvm.org/D90681

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

3 years ago[mlir] Remove old "tc" linalg ods generator.
Stella Laurenzo [Wed, 29 Sep 2021 23:47:17 +0000 (23:47 +0000)]
[mlir] Remove old "tc" linalg ods generator.

* This could have been removed some time ago as it only had one op left in it, which is redundant with the new approach.
* `matmul_i8_i8_i32` (the remaining op) can be trivially replaced by `matmul`, which natively supports mixed precision.

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

3 years agoImprove the effectiveness of BDCE's debug info salvaging
Adrian Prantl [Mon, 27 Sep 2021 17:51:04 +0000 (10:51 -0700)]
Improve the effectiveness of BDCE's debug info salvaging

This patch improves the effectiveness of BDCE's debug info salvaging
by processing the instructions in reverse order and delaying
dropAllReferences until after debug info salvaging. This allows
salvaging of entire chains of deleted instructions!

Previously we would remove all references from an instruction, which
would make it impossible to use that instruction to salvage a later
instruction in the instruction stream, because its operands were
already removed.

This reapplies the previous patch with a fix for a use-after-free.

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

3 years ago[libc++][NFC] Remove stray whitespace
Louis Dionne [Thu, 30 Sep 2021 16:18:30 +0000 (12:18 -0400)]
[libc++][NFC] Remove stray whitespace

3 years ago[fir][NFC] Rename lenParams to typeparams in builders
Eric Schweitz [Thu, 30 Sep 2021 15:55:31 +0000 (17:55 +0200)]
[fir][NFC] Rename lenParams to typeparams in builders

Fine tuning after couple of upstreamed patches.
Rename the lenParams varaiables in buidlers to typeparams.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: kiranchandramohan

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

Co-authored-by: Valentin Clement <clementval@gmail.com>
3 years ago[llvm] Migrate from arg_operands to args (NFC)
Kazu Hirata [Thu, 30 Sep 2021 15:51:21 +0000 (08:51 -0700)]
[llvm] Migrate from arg_operands to args (NFC)

Note that arg_operands is considered a legacy name.  See
llvm/include/llvm/IR/InstrTypes.h for details.

3 years ago[NFC][AMDGPU] Improve cost model tests coverage.
Daniil Fukalov [Thu, 30 Sep 2021 15:13:17 +0000 (18:13 +0300)]
[NFC][AMDGPU] Improve cost model tests coverage.

3 years ago[NFC] [hwasan] Remove unneeded member.
Florian Mayer [Wed, 29 Sep 2021 23:57:57 +0000 (00:57 +0100)]
[NFC] [hwasan] Remove unneeded member.

Reviewed By: hctim

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

3 years ago[x86] add test for 3 fcmps and logic; NFC
Sanjay Patel [Thu, 30 Sep 2021 14:34:29 +0000 (10:34 -0400)]
[x86] add test for 3 fcmps and logic; NFC

This is a more complex pattern than we handled with the
initial patch for PR51245:
D110342 / 09e71c367af3

We could extend the logic matching to allow a setcc as
one operand and an extract of vector setcc (or even an
arbitrary bool?) as the other.

3 years ago[fir] Update fir.alloca op
Kiran Chandramohan [Thu, 30 Sep 2021 15:00:17 +0000 (17:00 +0200)]
[fir] Update fir.alloca op

Add pinned attributes and speicifc builders.

The pinned attribute helps mark those allocas in OpenMP regions that should not
be hoisted out by an alloca hoisting pass.

This patch is part of the upstreaming effort from fir-dev branch.

Coming from PR: https://github.com/flang-compiler/f18-llvm-project/pull/1065

Reviewed By: kiranchandramohan

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

Co-authored-by: Valentin Clement <clementval@gmail.com>
3 years ago[libc++] Add a testing configuration specific to Apple's libc++
Louis Dionne [Wed, 29 Sep 2021 18:56:42 +0000 (14:56 -0400)]
[libc++] Add a testing configuration specific to Apple's libc++

Apple's libc++ has a few differences with the LLVM libc++, and it is
necessary to use a custom configuration file to test it properly.

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

3 years ago[fir][NFC] Removed unused declaration from td file
Valentin Clement [Thu, 30 Sep 2021 14:45:46 +0000 (16:45 +0200)]
[fir][NFC] Removed unused declaration from td file

Remove unused code from FIROps.td file after latest
patches.

Reviewed By: kiranchandramohan

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

3 years ago[clangd] Update comment after dea48079b90d40f2087435b778544dffb0ab1793
Kirill Bobyrev [Thu, 30 Sep 2021 14:45:10 +0000 (16:45 +0200)]
[clangd] Update comment after dea48079b90d40f2087435b778544dffb0ab1793

3 years ago[LoopPredication] Remove unused variable
Anna Thomas [Thu, 30 Sep 2021 14:37:18 +0000 (10:37 -0400)]
[LoopPredication] Remove unused variable

After rG452714f8f8037ff37f9358317651d1652e231db2, the Function `F` retrieved in LoopPredication is not used.
Remove this unused variable to stop some buildbots (ASAN, clang-ppc) from failing.

3 years ago[NFC][X86][Codegen] Add test coverage for interleaved i64 load/store stride=2
Roman Lebedev [Thu, 30 Sep 2021 14:30:57 +0000 (17:30 +0300)]
[NFC][X86][Codegen] Add test coverage for interleaved i64 load/store stride=2

3 years ago[NFC][X86][LV] Add costmodel test coverage for interleaved i64/f64 load/store stride=2
Roman Lebedev [Thu, 30 Sep 2021 14:14:16 +0000 (17:14 +0300)]
[NFC][X86][LV] Add costmodel test coverage for interleaved i64/f64 load/store stride=2

3 years ago[NFC] Improve file-level documentation for Sequence.h
Jakub Kuderski [Thu, 30 Sep 2021 14:28:10 +0000 (10:28 -0400)]
[NFC] Improve file-level documentation for Sequence.h

Add usage samples.

This was extracted from a bigger patch: https://reviews.llvm.org/D107378.

Reviewed By: aaron.ballman, gchatelet

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

3 years ago[fir][NFC] Move parser/printer for fir.global_len
Valentin Clement [Thu, 30 Sep 2021 14:27:02 +0000 (16:27 +0200)]
[fir][NFC] Move parser/printer for fir.global_len

Move parser and printer to the .cpp file.

Follow up to https://reviews.llvm.org/D110626.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: jeanPerier

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

3 years ago[BPI] Keep BPI available in loop passes through LoopStandardAnalysisResults
Anna Thomas [Fri, 24 Sep 2021 18:38:41 +0000 (14:38 -0400)]
[BPI] Keep BPI available in loop passes through LoopStandardAnalysisResults

This is analogous to D86156 (which preserves "lossy" BFI in loop
passes). Lossy means that the analysis preserved may not be up to date
with regards to new blocks that are added in loop passes, but BPI will
not contain stale pointers to basic blocks that are deleted by the loop
passes.

This is achieved through BasicBlockCallbackVH in BPI, which calls
eraseBlock that updates the data structures in BPI whenever a basic
block is deleted.

This patch does not have any changes in the upstream pipeline, since
none of the loop passes in the pipeline use BPI currently.
However, since BPI wasn't previously preserved in loop passes, the loop
predication pass was invoking BPI *on the entire
function* every time it ran in an LPM.  This caused massive compile time
in our downstream LPM invocation which contained loop predication.

See updated test with an invocation of a loop-pipeline containing loop
predication and -debug-pass turned ON.

Reviewed-By: asbirlea, modimo
Differential Revision: https://reviews.llvm.org/D110438

3 years ago[fir][NFC] Move fir.shape verifier to cpp file
Valentin Clement [Thu, 30 Sep 2021 14:26:29 +0000 (16:26 +0200)]
[fir][NFC] Move fir.shape verifier to cpp file

Move verifier code to the .cpp file.

Follow up to https://reviews.llvm.org/D110626.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: jeanPerier

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

3 years ago[fir][NFC] Update and move fir.freemem and fir.store
Valentin Clement [Thu, 30 Sep 2021 14:25:21 +0000 (16:25 +0200)]
[fir][NFC] Update and move fir.freemem and fir.store

Move fir.freemem and fir.store to the Memory SSA operations sections.
Move parser, printer and verifier of fir.store to the .cpp file.

This patch is part of the upstreaming effort from fir-dev branch.

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Reviewed By: jeanPerier

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

3 years ago[mlir][python] provide bindings for ops from the sparse_tensor dialect
Alex Zinenko [Thu, 30 Sep 2021 13:09:30 +0000 (15:09 +0200)]
[mlir][python] provide bindings for ops from the sparse_tensor dialect

Previously, the dialect was exposed for linking and pass management purposes,
but we did not generate op classes for it. Generate them.

Reviewed By: nicolasvasilache

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

3 years ago[ARM] Add more MVE intrinsics to sink splats to
David Green [Thu, 30 Sep 2021 13:41:23 +0000 (14:41 +0100)]
[ARM] Add more MVE intrinsics to sink splats to

This adds a few more unpredicated intrinsics to sink splats to, in order
to create more qr instruction variants. Notably this includes
saddsat/uaddsat but also some of the unpredicated mve intrinsics.

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

3 years ago[CodeView] Recognize Fortran95 as Fortran instead of MASM
Brock Wyma [Wed, 22 Sep 2021 23:41:05 +0000 (19:41 -0400)]
[CodeView] Recognize Fortran95 as Fortran instead of MASM

Map Fortran95 sources to Fortran so the CodeView language is not emitted as
MASM.

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

3 years ago[libc] move benchmark function registration to a different file
Guillaume Chatelet [Thu, 30 Sep 2021 13:10:45 +0000 (13:10 +0000)]
[libc] move benchmark function registration to a different file

3 years ago[clangd] Land D110386 again
Kirill Bobyrev [Thu, 30 Sep 2021 12:41:27 +0000 (14:41 +0200)]
[clangd] Land D110386 again

This time, use llvm::sys::fs::UniqueID instead of unstable
FileEntry::getName(), this should solve the problems on Windows and
elsewhere.

3 years ago[mlir] Remove unused namespace alias.
Adrian Kuegel [Thu, 30 Sep 2021 11:50:31 +0000 (13:50 +0200)]
[mlir] Remove unused namespace alias.

3 years ago[NFC][Costmodel][LV][X86] Add test coverage for f32 interleaved load/store stride=2
Roman Lebedev [Thu, 30 Sep 2021 11:24:42 +0000 (14:24 +0300)]
[NFC][Costmodel][LV][X86] Add test coverage for f32 interleaved load/store stride=2

3 years ago[AArch64][GlobalISel] Re-generate some tests for D110802.
Amara Emerson [Thu, 30 Sep 2021 11:15:30 +0000 (04:15 -0700)]
[AArch64][GlobalISel] Re-generate some tests for D110802.