platform/upstream/llvm.git
3 years ago[OpenMP][NFC] Eliminate sign comparison warning via explicit casts
Johannes Doerfert [Wed, 10 Feb 2021 20:14:22 +0000 (14:14 -0600)]
[OpenMP][NFC] Eliminate sign comparison warning via explicit casts

Reviewed By: tianshilei1992

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

3 years ago[OpenMP][NFC] Clang format libomptarget code (src & include)
Johannes Doerfert [Wed, 10 Feb 2021 17:45:39 +0000 (11:45 -0600)]
[OpenMP][NFC] Clang format libomptarget code (src & include)

The struct and enum alignments are kept by disabling clang-format for
that code region.

Reviewed By: tianshilei1992, JonChesterfield, grokos

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

3 years ago[NFC][PPC] Refactor TOC representation to allow several entries for the same symbol
Victor Huang [Tue, 16 Feb 2021 21:29:07 +0000 (21:29 +0000)]
[NFC][PPC] Refactor TOC representation to allow several entries for the same symbol

We currently represent TOC entries by an MCSymbol. This is not enough in some situations.
For example, when accessing an initialized TLS variable v on AIX using the general dynamic
model, we need to generate the two following entries for v:

.tc .v[TC],v@m
.tc v[TC],v

One is for the region handle (with the @m relocation), the other is for the variable offset.
This refactoring allows storing several entries for the same symbol with different VariantKind
in the TOC. If the VariantKind is not specified, we default to VK_None.

The AIX TLS implementation using this refactoring to generate the two entries will be posted
in a subsequent patch.

Patched By: bsaleil
Reviewed By: sfertile

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

3 years ago[lldb] [Process/FreeBSD] Ensure that errors are always handled
Michał Górny [Thu, 11 Feb 2021 23:51:42 +0000 (00:51 +0100)]
[lldb] [Process/FreeBSD] Ensure that errors are always handled

Ensure that the llvm::Error instances are always considered handled
by replacing LLDB_LOG with LLDB_LOG_ERROR.

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

3 years ago[SampleFDO] Provide a virtual desructor for SampleProfileLoaderBaseImpl
Kazu Hirata [Tue, 16 Feb 2021 21:17:33 +0000 (13:17 -0800)]
[SampleFDO] Provide a virtual desructor for SampleProfileLoaderBaseImpl

This patch fixes a warning:

  llvm-project/llvm/include/llvm/ProfileData/SampleProfileLoaderBaseImpl.h:69:7:
  error: 'llvm::SampleProfileLoaderBaseImpl' has virtual functions but
  non-virtual destructor [-Werror,-Wnon-virtual-dtor]

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

3 years agoseparate AffineMapAccessInterface from AffineRead/WriteOpInterface
Adam Straw [Tue, 16 Feb 2021 21:03:03 +0000 (13:03 -0800)]
separate AffineMapAccessInterface from AffineRead/WriteOpInterface

Separating the AffineMapAccessInterface from AffineRead/WriteOp interface so that dialects which extend Affine capabilities (e.g. PlaidML PXA = parallel extensions for Affine) can utilize relevant passes (e.g. MemRef normalization).

Reviewed By: bondhugula

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

3 years agoRevert "[DAG] Fold shuffle(bop(shuffle(x,y),shuffle(z,w)),bop(shuffle(a,b),shuffle...
Sterling Augustine [Tue, 16 Feb 2021 20:37:19 +0000 (12:37 -0800)]
Revert "[DAG] Fold shuffle(bop(shuffle(x,y),shuffle(z,w)),bop(shuffle(a,b),shuffle(c,d)))"

This reverts commit 5dfba562dd247f731528448ee83785b099f93629.

That commit causes an assertion failure with the following repro:

typedef long b __attribute__((__vector_size__(16)));
b *d;
b e;
b __attribute__((__always_inline__)) c(b h, b i) {
  return (__attribute__((__vector_size__(8 * sizeof(short)))) short)h + i;
}
j() {
  b k, l, m, n, o[6], p, q;
  m = d[5];
  b r = m;
  b s = f(r, 8);
  q = s;
  l = d[1];
  p = l;
  t(q);
  n = c(m, l);
  o[1] = c(s, f(p, 8));
  k = __builtin_shufflevector(n, o[1], 0, 2);
  e = __builtin_ia32_psrlwi128(k, j);
}

./bin/clang -cc1 -triple x86_64-grtev4-linux-gnu -emit-obj -O1 -std=c99 test.c

3 years ago[doc] Use cmake's -S option to simplify the build instructions
Ebrahim Byagowi [Tue, 16 Feb 2021 20:36:56 +0000 (14:36 -0600)]
[doc] Use cmake's -S option to simplify the build instructions

Now that llvm's minimum version is 3.13.4 anyway and `-S` is
introduced in the same version[1], let's use this little
time saving option to simplify the build instructions.

[1]: https://cgold.readthedocs.io/en/latest/glossary/-S.html

Authored-By: Ebrahim Byagowi <ebrahim@gnu.org>
Differential-Revision: https://reviews.llvm.org/D95049

3 years agoFix flang after D76342
Valentin Clement [Tue, 16 Feb 2021 20:37:46 +0000 (15:37 -0500)]
Fix flang after D76342

Fix Flang build after addition of a new OpenMP clauses for a clang patch (D76342).
Flang is using TableGen to generation the declaration of clause checks and the new clause
was missing a definiton.

Reviewed By: klausler

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

3 years ago[lldb] Delete superfluous semicolon
Pavel Labath [Tue, 16 Feb 2021 20:04:23 +0000 (21:04 +0100)]
[lldb] Delete superfluous semicolon

3 years ago[lldb] Remove some nanosleep preprocessor magic
Pavel Labath [Tue, 16 Feb 2021 19:55:40 +0000 (20:55 +0100)]
[lldb] Remove some nanosleep preprocessor magic

It's obsolete, as we use (portable) std::this_thread::sleep_for now.

3 years ago[RISCV] Add isel patterns for fixed vector fmsub/fnmadd/fnmsub.
Craig Topper [Tue, 16 Feb 2021 20:03:27 +0000 (12:03 -0800)]
[RISCV] Add isel patterns for fixed vector fmsub/fnmadd/fnmsub.

3 years ago[mlir] Fix memref_cast + subview folder when reducing rank
Thomas Raoux [Tue, 16 Feb 2021 19:03:58 +0000 (11:03 -0800)]
[mlir] Fix memref_cast + subview folder when reducing rank

When the destination of the subview has a lower rank than its source we need to
fix the result type of the new subview op.

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

3 years ago[clangd] Fix windows buildbots after ecea7218fb9b994b26471e9877851cdb51a5f1d4
Kadir Cetinkaya [Tue, 16 Feb 2021 19:57:00 +0000 (20:57 +0100)]
[clangd] Fix windows buildbots after ecea7218fb9b994b26471e9877851cdb51a5f1d4

3 years ago[gn build] Port ecea7218fb9b
LLVM GN Syncbot [Tue, 16 Feb 2021 19:23:52 +0000 (19:23 +0000)]
[gn build] Port ecea7218fb9b

3 years ago[gn build] Port 310b35304cdf
LLVM GN Syncbot [Tue, 16 Feb 2021 19:23:52 +0000 (19:23 +0000)]
[gn build] Port 310b35304cdf

3 years ago[FileCollector] Fix that the file system case-sensitivity check was inverted
Raphael Isemann [Tue, 16 Feb 2021 19:19:25 +0000 (20:19 +0100)]
[FileCollector] Fix that the file system case-sensitivity check was inverted

real_path returns an `std::error_code` which evaluates to `true` in case an
error happens and `false` if not. This code was checking the inverse, so
case-insensitive file systems ended up being detected as case sensitive.

Tested using an LLDB reproducer test as we anyway need a real file system and
also some matching logic to detect whether the respective file system is
case-sensitive (which the test is doing via some Python checks that we can't
really emulate with the usual FileCheck logic).

Fixes rdar://67003004

Reviewed By: JDevlieghere

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

3 years ago[clangd] Treat paths case-insensitively depending on the platform
Kadir Cetinkaya [Mon, 15 Feb 2021 08:00:49 +0000 (09:00 +0100)]
[clangd] Treat paths case-insensitively depending on the platform

Path{Match,Exclude} and MountPoint were checking paths case-sensitively
on all platforms, as with other features, this was causing problems on
windows. Since users can have capital drive letters on config files, but
editors might lower-case them.

This patch addresses that issue by:
- Creating regexes with case-insensitive matching on those platforms.
- Introducing a new pathIsAncestor helper, which performs checks in a
  case-correct manner where needed.

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

3 years ago[RISCV] Add add/sub saturation tests that exist on ARM/AArch64/X86
Craig Topper [Tue, 16 Feb 2021 18:32:06 +0000 (10:32 -0800)]
[RISCV] Add add/sub saturation tests that exist on ARM/AArch64/X86

There have been some recent changes to the type legalization for
some of these intrinsics so I thought it would be good to have
coverage.

3 years ago[SampleFDO][NFC] Refactor SampleProfile.cpp
Rong Xu [Tue, 16 Feb 2021 18:53:38 +0000 (10:53 -0800)]
[SampleFDO][NFC] Refactor SampleProfile.cpp

Refactor SampleProfile.cpp to use the core code in CodeGen.
The main changes are:
(1) Move SampleProfileLoaderBaseImpl class to a header file.
(2) Split SampleCoverageTracker to a head file and a cpp file.
(3) Move the common codes (common options and callsiteIsHot())
to the common cpp file.

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

3 years agolibunwind: Don't attempt to authenticate a null return address.
Peter Collingbourne [Fri, 12 Feb 2021 00:16:51 +0000 (16:16 -0800)]
libunwind: Don't attempt to authenticate a null return address.

Null return addresses can appear at the bottom of the stack (i.e. the
frame corresponding to the entry point). Authenticating these addresses
will set the error code in the address, which will lead to a segfault
in the sigreturn trampoline detection code. Fix this problem by not
authenticating null addresses.

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

3 years agoRevert "[AArch64][GlobalISel] Fold constants into G_GLOBAL_VALUE"
Jessica Paquette [Tue, 16 Feb 2021 18:50:12 +0000 (10:50 -0800)]
Revert "[AArch64][GlobalISel] Fold constants into G_GLOBAL_VALUE"

This reverts commit 61b4702a408834228c1c139b0e9af98616774db4.

We were seeing some test failures in SPECINT2006 due to this change. Reverting
to investigate.

3 years ago[SystemZ][ZOS] Prefer -nostdlib++ as opposed to -nodefaultlibs when building c++...
Zbigniew Sarbinowski [Tue, 16 Feb 2021 18:02:22 +0000 (18:02 +0000)]
[SystemZ][ZOS] Prefer -nostdlib++ as opposed to -nodefaultlibs when building c++ libraries

Let's use -nostdlib++ rather than -nodefaultlibs when building libc++/libc++abi/libunwind libraries. The default is -nostdlib++ if supported by a build compiler like it is the case with clang, otherwise -nodefaultlibs is used as before.

This change is needed to avoid additional changes at the link step and not to increase the maintenance costs. If clang with -nodefaultlibs is used all the libraries which are removed but required would have to be manually added in. This set of libraries are unique and will send out.

The propose change will allow to make the link step simple for other platforms as well.

Reviewed By: #libc, #libc_abi, ldionne

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

3 years ago[OpenMP] Implement '#pragma omp tile', by Michael Kruse (@Meinersbur).
Michael Kruse [Fri, 12 Feb 2021 19:26:59 +0000 (11:26 -0800)]
[OpenMP] Implement '#pragma omp tile', by Michael Kruse (@Meinersbur).

The tile directive is in OpenMP's Technical Report 8 and foreseeably will be part of the upcoming OpenMP 5.1 standard.

This implementation is based on an AST transformation providing a de-sugared loop nest. This makes it simple to forward the de-sugared transformation to loop associated directives taking the tiled loops. In contrast to other loop associated directives, the OMPTileDirective does not use CapturedStmts. Letting loop associated directives consume loops from different capture context would be difficult.

A significant amount of code generation logic is taking place in the Sema class. Eventually, I would prefer if these would move into the CodeGen component such that we could make use of the OpenMPIRBuilder, together with flang. Only expressions converting between the language's iteration variable and the logical iteration space need to take place in the semantic analyzer: Getting the of iterations (e.g. the overload resolution of `std::distance`) and converting the logical iteration number to the iteration variable (e.g. overload resolution of `iteration + .omp.iv`). In clang, only CXXForRangeStmt is also represented by its de-sugared components. However, OpenMP loop are not defined as syntatic sugar. Starting with an AST-based approach allows us to gradually move generated AST statements into CodeGen, instead all at once.

I would also like to refactor `checkOpenMPLoop` into its functionalities in a follow-up. In this patch it is used twice. Once for checking proper nesting and emitting diagnostics, and additionally for deriving the logical iteration space per-loop (instead of for the loop nest).

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

3 years ago[mlir] Simplify ModuleTranslation for LLVM IR
Alex Zinenko [Tue, 16 Feb 2021 16:36:45 +0000 (17:36 +0100)]
[mlir] Simplify ModuleTranslation for LLVM IR

A series of preceding patches changed the mechanism for translating MLIR to
LLVM IR to use dialect interface with delayed registration. It is no longer
necessary for specific dialects to derive from ModuleTranslation. Remove all
virtual methods from ModuleTranslation and factor out the entry point to be a
free function.

Also perform some cleanups in ModuleTranslation internals.

Depends On D96774

Reviewed By: nicolasvasilache

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

3 years ago[DAG] PromoteIntRes_ADDSUBSHLSAT - promote ISD::UADDSAT as clamped add
Simon Pilgrim [Tue, 16 Feb 2021 17:37:32 +0000 (17:37 +0000)]
[DAG] PromoteIntRes_ADDSUBSHLSAT - promote ISD::UADDSAT as clamped add

Similar to D96622, we're better off just promoting uaddsat(x,y) -> umin(add(x,y),c) instead of trying to perform a shifted uaddsat.

I initially tried to just use shifted promotion in cases where we didn't have a legal/custom umin - but we don't appear to have any targets that have uaddsat but not umin, so imo we're better off always using the umin and avoid an untested shifted uaddsat code path.

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

3 years ago[RISCV] Add support for fixed vector mask logic operations.
Craig Topper [Tue, 16 Feb 2021 17:26:22 +0000 (09:26 -0800)]
[RISCV] Add support for fixed vector mask logic operations.

Reviewed By: frasercrmck

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

3 years ago[SelectionDAG][AArch64] Restrict matchUnaryPredicate to only handle SPLAT_VECTOR...
Craig Topper [Tue, 16 Feb 2021 17:22:44 +0000 (09:22 -0800)]
[SelectionDAG][AArch64] Restrict matchUnaryPredicate to only handle SPLAT_VECTOR for scalable vectors.

fde24661718c7812a20a10e518cd853e8e060107 added support for
scalable vectors to matchUnaryPredicate by handling SPLAT_VECTOR in
addition to BUILD_VECTOR. This was used to enabled UDIV/SDIV/UREM/SREM
by constant expansion in BuildUDIV/BuildSDIV in TargetLowering.cpp

The caller there expects to call getBuildVector from the match factors.
This leads to a crash right now if there is a SPLAT_VECTOR of
fixed vectors since the number of vectors won't match the number
of elements.

To fix this, this patch updates the callers to check the opcode
instead of whether the type is fixed or scalable. This assumes
that only 3 opcodes are handled by matchUnaryPredicate so
I've added an assertion to the final else to check that opcode.

Reviewed By: RKSimon

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

3 years ago[mlir] tighten LLVM dialect verifiers to generate valid LLVM IR
Alex Zinenko [Tue, 16 Feb 2021 16:36:20 +0000 (17:36 +0100)]
[mlir] tighten LLVM dialect verifiers to generate valid LLVM IR

Verification of the LLVM IR produced when translating various MLIR dialects was
only active when calling the translation programmatically. This has led to
several cases of invalid LLVM IR being generated that could not be caught with
textual mlir-translate tests. Add verifiers for these cases and fix the tests
in preparation for enforcing the validation of LLVM IR.

Reviewed By: nicolasvasilache

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

3 years ago[AArch64] Convert CMP/SELECT sign patterns to OR & ASR.
Florian Hahn [Tue, 16 Feb 2021 17:12:30 +0000 (17:12 +0000)]
[AArch64] Convert CMP/SELECT sign patterns to OR & ASR.

ICMP & SELECT patterns extracting the sign of a value can be simplified
to OR & ASR (see  https://alive2.llvm.org/ce/z/Xx4iZ0).

This does not save any instructions in IR, but it is profitable on
AArch64, because we need at least 2 extra instructions to materialize 1
and -1 for the SELECT.

The improvements result in ~5% speedups on loops of the form

    static int sign_of(int x) {
      if (x < 0) return -1;
      return 1;
    }

    void foo(const int *x, int *res, int cnt) {
      for (int i=0;i<cnt;i++)
        res[i] = sign_of(x[i]);
    }

Reviewed By: dmgreen

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

3 years ago[libc][NFC] Make few maths functions buildable outside of LLVM libc build.
Siva Chandra Reddy [Tue, 16 Feb 2021 06:58:21 +0000 (22:58 -0800)]
[libc][NFC] Make few maths functions buildable outside of LLVM libc build.

Few math functions manipulate errno. They assumed that LLVM libc's errno
is available. However, that might not be the case when these functions
are used in a libc which does not use LLVM libc's errno. This change
switches such uses of LLVM libc's errno to the normal public errno macro.
This does not affect LLVM libc's build because the include order ensures
we get LLVM libc's errno. Also, the header check rule ensures we are only
including LLVM libc's errno.h.

3 years ago[analyzer] Fix a warning
Kazu Hirata [Tue, 16 Feb 2021 17:12:07 +0000 (09:12 -0800)]
[analyzer] Fix a warning

This patch fixes a warning from -Wcovered-switch-default.  The switch
statement in question handles all the enum values.

3 years ago[mlir] add verifiers for NVVM and ROCDL kernel attributes
Alex Zinenko [Tue, 16 Feb 2021 17:05:47 +0000 (18:05 +0100)]
[mlir] add verifiers for NVVM and ROCDL kernel attributes

Make sure they can only be attached to LLVM functions as a result of converting
GPU functions to the LLVM Dialect.

3 years ago[coro async] Don't promote allocas to the frame or rewrite swifterror if there are...
Arnold Schwaighofer [Fri, 12 Feb 2021 18:27:31 +0000 (10:27 -0800)]
[coro async] Don't promote allocas to the frame or rewrite  swifterror if there are no suspend points

Also don't call function to update the call graph if there are no
clones. The function will fail.

rdar://74277860

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

3 years ago[flang][fir] Add fir-opt tool
clementval [Tue, 16 Feb 2021 16:48:20 +0000 (11:48 -0500)]
[flang][fir] Add fir-opt tool

This patch introduce the fir-opt tool. Similar to mlir-opt for FIR.
It will be used in following patches to test fir opt and round-trip.

Reviewed By: schweitz, mehdi_amini

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

3 years ago[ARM] Use rGPR for writeback vldrs
David Green [Tue, 16 Feb 2021 16:44:47 +0000 (16:44 +0000)]
[ARM] Use rGPR for writeback vldrs

From what I can tell, a writeback is unpredictable with LR for both
loads and stores. This changes the operand from a gprnopc to a rGPR in
both cases (which I believe is essentially a NFC due to the tied-def
already being a rGPR.)

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

3 years agoAMDGPU: Remove kills following clusters of memory instruction
Matt Arsenault [Sun, 14 Feb 2021 14:54:25 +0000 (09:54 -0500)]
AMDGPU: Remove kills following clusters of memory instruction

In a future commit, soft clauses will be hinted with kill instructions
rather than forced together with bundles. Look for kills that look
like this, and erase them. I'm not sure if the check for specific uses
is worthwhile, or if it would be better to just unconditionally erase
kills.

This reduces test churn in a future patch.

3 years ago[DAG] Fold shuffle(bop(shuffle(x,y),shuffle(z,w)),bop(shuffle(a,b),shuffle(c,d)))
Simon Pilgrim [Tue, 16 Feb 2021 15:24:23 +0000 (15:24 +0000)]
[DAG] Fold shuffle(bop(shuffle(x,y),shuffle(z,w)),bop(shuffle(a,b),shuffle(c,d)))

Fold shuffle(bop(shuffle(x,y),shuffle(z,w)),bop(shuffle(a,b),shuffle(c,d))) -> bop(shuffle(x,y),shuffle(z,w)),bop(shuffle(a,b),shuffle(c,d))

Attempt to fold from a shuffle of a pair of binops to a binop of shuffles, as long as one/both of the binop sources are also shuffles that can be merged with the outer shuffle. This should guarantee that we remove one binop without introducing any additional shuffles.

Technically there's potential for a merged shuffle's lowering to be poorer than the original shuffle, but it could also be better, and I'm not seeing any regressions as long as we keep the 'don't merge splats' rule already present in MergeInnerShuffle.

This expands and generalizes an existing X86 combine and attempts to merge either of each binop's sources (with an on-the-fly commutation of the shuffle mask) - we couldn't do that in the x86 version as it had to stay in a form that DAGCombine's MergeInnerShuffle would still recognise.

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

3 years agoAMDGPU: Fix debug info handling in post-RA bundler
Matt Arsenault [Sun, 14 Feb 2021 15:46:10 +0000 (10:46 -0500)]
AMDGPU: Fix debug info handling in post-RA bundler

This was allowing debug instructions to break the bundling, which
would change scheduling behavior. Bundle debug info / kills inside
the bundle. This seems to work OK, although the asm printer doesn't
understand these in a bundle. This implicitly expects the memory
legalizer to unbundle. It would probably be slightly nicer to move
these after.

Rewrite the loop to be clearer and make sure we don't end a bundle on
a meta instruction, only allow them in between other valid bundle
instructions.

3 years agoReduce the number of attributes attached to each function
serge-sans-paille [Wed, 10 Feb 2021 08:42:50 +0000 (09:42 +0100)]
Reduce the number of attributes attached to each function

This takes advantage of the implicit default behavior to reduce the number of
attributes, which in turns reduces compilation time. I've observed -3% in
instruction count when compiling sqlite3 amalgamation with -O0

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

3 years ago[mlir][vector] Add missing support for contract of integer lowering.
Thomas Raoux [Wed, 10 Feb 2021 23:57:02 +0000 (15:57 -0800)]
[mlir][vector] Add missing support for contract of integer lowering.

Some of the lowering of vector.contract didn't support integer case. Since
reduction of integer cannot accumulate we always break up the reduction op, it
should be merged by a separate canonicalization if possible.

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

3 years ago[mlir] Add canonicalization for tensor_cast + tensor_to_memref
Thomas Raoux [Tue, 16 Feb 2021 05:10:07 +0000 (21:10 -0800)]
[mlir] Add canonicalization for tensor_cast + tensor_to_memref

This helps bufferization passes by removing tensor_cast operations.

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

3 years ago[mlir][vector] Move splitting transfer ops into a separate entry point
Lei Zhang [Tue, 16 Feb 2021 15:00:32 +0000 (10:00 -0500)]
[mlir][vector] Move splitting transfer ops into a separate entry point

These patterns unrolls transfer read/write ops if the vector consumers/
producers are extract/insert slices op. Transfer ops can map to hardware
load/store functionalities, where the vector size matters for bandwidth
considerations. So these patterns should be collected separately, instead
of being generic canonicalization patterns.

Reviewed By: nicolasvasilache

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

3 years ago[libc++] Build thread_win32.cpp only if LIBCXX_HAS_PTHREAD_API is not set
Colin Finck [Tue, 16 Feb 2021 15:03:04 +0000 (10:03 -0500)]
[libc++] Build thread_win32.cpp only if LIBCXX_HAS_PTHREAD_API is not set

This allows building libc++ against winpthreads from mingw-w64 to support
operating systems older than Windows 7. The remaining libc++ code already
supports `WIN32` with `LIBCXX_HAS_PTHREAD_API`.

Note that there is also the older "pthreads-win32". However, that support
library implements `pthread_t` as a struct, which violates the libc++
assumption that `pthread_t` is always a scalar and can be compared,
ordered, and set to zero.

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

3 years ago[mlir][vector] Add support for unrolling vector.fma
Lei Zhang [Tue, 16 Feb 2021 14:56:01 +0000 (09:56 -0500)]
[mlir][vector] Add support for unrolling vector.fma

Reviewed By: nicolasvasilache

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

3 years ago[lldb/test] Test lldb-server named pipe functionality on windows
Pavel Labath [Mon, 8 Feb 2021 09:28:42 +0000 (10:28 +0100)]
[lldb/test] Test lldb-server named pipe functionality on windows

lldb-server can use a named pipe to communicate the port number it is
listening on. This windows bits of this are already implemented, but we
did not have a test for that, most likely because python does not have
native pipe functionality.

This patch implements the windows bits necessary to test this. I'm using
the ctypes package to call the native APIs directly to avoid a
dependency to non-standard python packages. This introduces some amount
of boilerplate, but our named pipe use case is fairly limited, so we
should not end up needing to wrap large chunks of windows APIs.

Surprisingly to changes to lldb-server were needed to make the test
pass.

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

3 years ago[clangd] Give modules access to filesystem, scheduler, and index.
Sam McCall [Mon, 15 Feb 2021 19:26:48 +0000 (20:26 +0100)]
[clangd] Give modules access to filesystem, scheduler, and index.

This finally makes it possible to implement useful modules.

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

3 years ago[gn build] Port 40cc63ea6eec
LLVM GN Syncbot [Tue, 16 Feb 2021 14:23:58 +0000 (14:23 +0000)]
[gn build] Port 40cc63ea6eec

3 years ago[clangd] Modules can have a public API. NFC
Sam McCall [Mon, 15 Feb 2021 20:43:11 +0000 (21:43 +0100)]
[clangd] Modules can have a public API. NFC

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

3 years ago[NFC][LoopInterchange] Explicitly pass both `InnerLoop` and `OuterLoop` to `processLoop`
Ta-Wei Tu [Tue, 16 Feb 2021 14:16:53 +0000 (22:16 +0800)]
[NFC][LoopInterchange] Explicitly pass both `InnerLoop` and `OuterLoop` to `processLoop`

This is a split patch of D96644.

Explicitly pass both `InnerLoop` and `OuterLoop` to function `processLoop` to remove the need to swap elements in loop list and allow making loop list an `ArrayRef`.
Also, fix inconsistent spellings of `OuterLoopId` and `Inner Loop Id` in debug log.

Reviewed By: fhahn

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

3 years ago[llvm][Aarch64][SVE] Remove extra fmov instruction with certain literals
David Truby [Tue, 16 Feb 2021 14:15:28 +0000 (14:15 +0000)]
[llvm][Aarch64][SVE] Remove extra fmov instruction with certain literals

When a literal that cannot fit in the immediate form of the fmov instruction
is used to initialise an SVE vector, an extra unnecessary fmov is currently
generated. This patch adds an extra codegen pattern preventing the extra
instruction from being generated.

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

Co-Authored-By: Paul Walker <paul.walker@arm.com>
3 years ago[clang][cli] Add explicit round-trip test
Jan Svoboda [Tue, 16 Feb 2021 13:41:25 +0000 (14:41 +0100)]
[clang][cli] Add explicit round-trip test

This patch adds a test that verifies all `CompilerInvocation` members are filled correctly during command line round-trip.

Reviewed By: dexonsmith

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

3 years ago[VPlan] Remove unused Phi member from VPWidenPHIRecipe (NFC).
Florian Hahn [Tue, 16 Feb 2021 13:46:01 +0000 (13:46 +0000)]
[VPlan] Remove unused Phi member from VPWidenPHIRecipe (NFC).

The member is not needed any longer after recent changes.

3 years ago[DAG] Avoid APInt copies by directly using the APInt reference from getAPIntValue...
Simon Pilgrim [Tue, 16 Feb 2021 12:40:10 +0000 (12:40 +0000)]
[DAG] Avoid APInt copies by directly using the APInt reference from getAPIntValue. NFCI.

3 years ago[DAG] Use APInt::extractBits instead of lshr().trunc(). NFCI.
Simon Pilgrim [Tue, 16 Feb 2021 12:02:41 +0000 (12:02 +0000)]
[DAG] Use APInt::extractBits instead of lshr().trunc(). NFCI.

Avoids so many APInt instances by directly using the APInt reference from getAPIntValue.

3 years ago[SVE] Add support for scalable vectorization of loops with int/fast FP reductions
Kerry McLaughlin [Tue, 16 Feb 2021 10:43:42 +0000 (10:43 +0000)]
[SVE] Add support for scalable vectorization of loops with int/fast FP reductions

This patch enables scalable vectorization of loops with integer/fast reductions, e.g:

```
unsigned sum = 0;
for (int i = 0; i < n; ++i) {
  sum += a[i];
}
```

A new TTI interface, isLegalToVectorizeReduction, has been added to prevent
reductions which are not supported for scalable types from vectorizing.
If the reduction is not supported for a given scalable VF,
computeFeasibleMaxVF will fall back to using fixed-width vectorization.

Reviewed By: david-arm, fhahn, dmgreen

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

3 years ago[clang][cli] Generate -f[no-]finite-loops arguments
Jan Svoboda [Tue, 16 Feb 2021 13:27:21 +0000 (14:27 +0100)]
[clang][cli] Generate -f[no-]finite-loops arguments

This patch generates the `-f[no-]finite-loops` arguments from `CompilerInvocation` (added in D96419), fixing test failures of Clang built with `-DCLANG_ROUND_TRIP_CC1_ARGS=ON`.

Reviewed By: fhahn

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

3 years ago[analyzer] Rework SValBuilder::evalCast function into maintainable and clear way
Denys Petrov [Tue, 16 Feb 2021 12:29:45 +0000 (14:29 +0200)]
[analyzer] Rework SValBuilder::evalCast function into maintainable and clear way

Summary: Refactor SValBuilder::evalCast function. Make the function clear and get rid of redundant and repetitive code. Unite SValBuilder::evalCast, SimpleSValBuilder::dispatchCast, SimpleSValBuilder::evalCastFromNonLoc and SimpleSValBuilder::evalCastFromLoc functions into single SValBuilder::evalCast.
This patch shall not change any previous behavior.

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

3 years ago[flang][driver] Add extension options and -finput-charset
Faris Rehman [Thu, 4 Feb 2021 21:11:22 +0000 (21:11 +0000)]
[flang][driver] Add extension options and -finput-charset

Add the following options:
* -fimplicit-none and -fno-implicit-none
* -fbackslash and -fno-backslash
* -flogical-abbreviations and -fno-logical-abbreviations
* -fxor-operator and -fno-xor-operator
* -falternative-parameter-statement
* -finput-charset=<value>

Summary of changes:
- Enable extensions in CompilerInvocation#ParseFrontendArgs
- Add encoding_ to Fortran::frontend::FrontendOptions
- Add encoding to Fortran::parser::Options

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

3 years ago[mlir] Don't return nullptrs from scf::IfOp::getSuccessorRegions
Tres Popp [Tue, 16 Feb 2021 10:31:41 +0000 (11:31 +0100)]
[mlir] Don't return nullptrs from scf::IfOp::getSuccessorRegions

Previously this might happen if there was no elseRegion and the method
was asked for all successor regions.

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

3 years ago[llvm-symbolizer][test] Add explicit tests for CODE and DATA
James Henderson [Mon, 15 Feb 2021 15:42:31 +0000 (15:42 +0000)]
[llvm-symbolizer][test] Add explicit tests for CODE and DATA

These directives force the associated address to be interpreted as a
function or data respectively. CODE is the default when not specified.

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

Reviewed by: MaskRay

3 years ago[RISCV] Remove unused CHECKs from recent test addition
Fraser Cormack [Tue, 16 Feb 2021 10:33:33 +0000 (10:33 +0000)]
[RISCV] Remove unused CHECKs from recent test addition

These didn't show up as failures locally.

3 years ago[RISCV] Fix a crash in fixed-length build_vector lowering
Fraser Cormack [Mon, 15 Feb 2021 16:35:34 +0000 (16:35 +0000)]
[RISCV] Fix a crash in fixed-length build_vector lowering

Non-splatted non-integer build_vector nodes were mistakenly being
lowered as VID expressions, which should not happen. VID can only be
used to select integer build_vector nodes.

Reviewed By: craig.topper

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

3 years ago[RISCV] Add patterns for scalable-vector fabs & fcopysign
Fraser Cormack [Thu, 4 Feb 2021 12:07:59 +0000 (12:07 +0000)]
[RISCV] Add patterns for scalable-vector fabs & fcopysign

The patterns mostly follow the scalar counterparts, save for some extra
optimizations to match the vector/scalar forms.

The patch adds a DAGCombine for ISD::FCOPYSIGN to try and reorder
ISD::FNEG around any ISD::FP_EXTEND or ISD::FP_TRUNC of the second
operand. This helps us achieve better codegen to match vfsgnjn.

Reviewed By: craig.topper

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

3 years ago[flang][driver] Remove unused code (nfc)
Andrzej Warzynski [Tue, 16 Feb 2021 10:00:41 +0000 (10:00 +0000)]
[flang][driver] Remove unused code (nfc)

3 years ago[mlir][Linalg] Generalize vector::transfer hoisting on tensors.
Nicolas Vasilache [Tue, 16 Feb 2021 09:24:28 +0000 (09:24 +0000)]
[mlir][Linalg] Generalize vector::transfer hoisting on tensors.

This revision adds support for hoisting "subtensor + vector.transfer_read" / "subtensor_insert + vector.transfer_write pairs" across scf.for.
The unit of hoisting becomes a HoistableRead / HoistableWrite struct which contains a pair of "vector.transfer_read + optional subtensor" / "vector.transfer_write + optional subtensor_insert".
scf::ForOp canonicalization patterns are applied greedily on the successful application of the transformation to cleanup the IR more eagerly and potentially expose more transformation opportunities.

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

3 years ago[flang][driver] Add options for unparsing
Andrzej Warzynski [Thu, 4 Feb 2021 11:14:57 +0000 (11:14 +0000)]
[flang][driver] Add options for unparsing

This patch adds the following compiler frontend driver options:
  * -fdebug-unparse (f18 spelling: -funparse)
  * -fdebug-unparse-with-symbols (f18 spelling: -funparse-with-symbols)
The new driver will only accept the new spelling. `f18` will accept both
the original and the new spelling.

A new base class for frontend actions is added: `PrescanAndSemaAction`.
This is added to reduce code duplication that otherwise these new
options would lead to. Implementation from
  * `ParseSyntaxOnlyAction::ExecutionAction`
is moved to:
  * `PrescanAndSemaAction::BeginSourceFileAction`
This implementation is now shared between:
  * PrescanAndSemaAction
  * ParseSyntaxOnlyAction
  * DebugUnparseAction
  * DebugUnparseWithSymbolsAction

All tests that don't require other yet unimplemented options are
updated. This way `flang-new -fc1` is used instead of `f18` when
`FLANG_BUILD_NEW_DRIVER` is set to `On`. In order to facilitate this,
`%flang_fc1` is added in the LIT configuration (lit.cfg.py).

`asFortran` from f18.cpp is duplicated as `getBasicAsFortran` in
FrontendOptions.cpp. At this stage it's hard to find a good place to
share this method. I suggest that we revisit this once a switch from
`f18` to `flang-new` is complete.

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

3 years ago[SCEVExpander] Migrate costAndCollectOperands to use InstructionCost.
Sander de Smalen [Tue, 16 Feb 2021 08:42:19 +0000 (08:42 +0000)]
[SCEVExpander] Migrate costAndCollectOperands to use InstructionCost.

This patch changes costAndCollectOperands to use InstructionCost for
accumulated cost values.

isHighCostExpansion will return true if the cost has exceeded the budget.

Reviewed By: CarolineConcatto, ctetreau

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

3 years agoLower math.expm1 to intrinsics in the GPUToNVVM and GPUToROCDL conversions.
Adrian Kuegel [Tue, 16 Feb 2021 08:18:34 +0000 (09:18 +0100)]
Lower math.expm1 to intrinsics in the GPUToNVVM and GPUToROCDL conversions.

This adds the lowering for expm1 for GPU backends.

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

3 years ago[flang][f18] Make -fdebug-dump-{symbols|parse-tree} imply -fsyntax-only
Andrzej Warzynski [Thu, 11 Feb 2021 18:28:25 +0000 (18:28 +0000)]
[flang][f18] Make -fdebug-dump-{symbols|parse-tree} imply -fsyntax-only

The following _action_ options are always used with `-fsyntax-only`
(also an _action_ option):
  * -fdebug-dump-symbols
  * -fdebug-dump-parse-tree
This patch makes the above options imply `-fsyntax-only`.

From the perspective of `f18` this change saves typing and is otherwise
a non-functional change. But it will simplify things in the new driver,
`flang-new`, in which only the last action option is taken into account
and executed. In other words, the following would only run
`-fsyntax-only`:
```
flang-new -fdebug-dump-symbols -fsyntax-only <input>
```
whereas this would only run `-fdebug-dump-symbols`:
```
flang-new -fsyntax-only -fdebug-dump-symbols <input>
```

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

3 years ago[gn build] Port 9510b0940265
LLVM GN Syncbot [Tue, 16 Feb 2021 09:12:07 +0000 (09:12 +0000)]
[gn build] Port 9510b0940265

3 years ago[clangd] Factor out the heuristic resolver code into its own class
Nathan Ridge [Mon, 18 Jan 2021 07:58:43 +0000 (02:58 -0500)]
[clangd] Factor out the heuristic resolver code into its own class

The patch also does some cleanup on the interface of the entry
points from TargetFinder into the heuristic resolution code.

Since the heuristic resolver is created in a place where the
ASTContext is available, it can store the ASTContext and the
NameFactory hack can be removed.

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

3 years ago[VPlan] Manage scalarized values using VPValues.
Florian Hahn [Tue, 16 Feb 2021 09:04:10 +0000 (09:04 +0000)]
[VPlan] Manage scalarized values using VPValues.

This patch updates codegen to use VPValues to manage the generated
scalarized instructions.

Reviewed By: gilr

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

3 years agoAdd Expm1 op to the math dialect.
Adrian Kuegel [Mon, 15 Feb 2021 12:56:12 +0000 (13:56 +0100)]
Add Expm1 op to the math dialect.

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

3 years ago[mlir] Drop reliance of SliceAnalysis on specific ops.
Nicolas Vasilache [Mon, 15 Feb 2021 21:44:44 +0000 (21:44 +0000)]
[mlir] Drop reliance of SliceAnalysis on specific ops.

SliceAnalysis originally was developed in the context of affine.for within mlfunc.
It predates the notion of region.
This revision updates it to not hardcode specific ops like scf::ForOp.
When rooted at an op, the behavior of the slice computation changes as it recurses into the regions of the op. This does not support gathering all values transitively depending on a loop induction variable anymore.
Additional variants rooted at a Value are added to also support the existing behavior.

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

3 years ago[NewPM] Introduce (GPU)DivergenceAnalysis in the new pass manager
Sameer Sahasrabuddhe [Tue, 16 Feb 2021 04:56:45 +0000 (10:26 +0530)]
[NewPM] Introduce (GPU)DivergenceAnalysis in the new pass manager

The GPUDivergenceAnalysis is now renamed to just "DivergenceAnalysis"
since there is no conflict with LegacyDivergenceAnalysis. In the
legacy PM, this analysis can only be used through the legacy DA
serving as a wrapper. It is now made available as a pass in the new
PM, and has no relation with the legacy DA.

The new DA currently cannot handle irreducible control flow; its
presence can cause the analysis to run indefinitely. The analysis is
now modified to detect this and report all instructions in the
function as divergent. This is super conservative, but allows the
analysis to be used without hanging the compiler.

Reviewed By: aeubanks

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

3 years ago[debugserver] Correctly pass argv[0] to execl
Jonas Devlieghere [Tue, 16 Feb 2021 02:38:21 +0000 (18:38 -0800)]
[debugserver] Correctly pass argv[0] to execl

The execl function takes both the executable and argv[0].

3 years ago[lldb] Remove very old misleading comment (NFC)
Dave Lee [Tue, 16 Feb 2021 02:14:47 +0000 (18:14 -0800)]
[lldb] Remove very old misleading comment (NFC)

3 years ago[lldb] Remove unused ThreadPlan tracer utilities (NFC)
Dave Lee [Sat, 13 Feb 2021 23:48:05 +0000 (15:48 -0800)]
[lldb] Remove unused ThreadPlan tracer utilities (NFC)

Delete unused `EnableTracer()` and `SetTracer()` functions on `Thread`. By deleting
these, their `ThreadPlan` counterparts also become unused.

Then, by deleting `ThreadPlanStack::EnableTracer`, `EnableSingleStep` becomes unused.
With no more callers to `EnableSingleStep`, the value `m_single_step` is always true and
can be removed as well.

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

3 years ago[lldb] Lower GetRealStopInfo into ThreadPlanCallFunction (NFC)
Dave Lee [Mon, 15 Feb 2021 06:59:31 +0000 (22:59 -0800)]
[lldb] Lower GetRealStopInfo into ThreadPlanCallFunction (NFC)

`GetRealStopInfo` has only one call site, and in that call site a reference to the
concrete thread plan is available (`ThreadPlanCallUserExpression`), from which
`GetRealStopInfo` can be called.

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

3 years ago[lldb] Minor refinements to ThreadPlan::RestoreThreadState (NFC)
Dave Lee [Mon, 15 Feb 2021 06:49:16 +0000 (22:49 -0800)]
[lldb] Minor refinements to ThreadPlan::RestoreThreadState (NFC)

Correct `RestoreThreadState` to a `void` return type. Also, update the signature of its
callee, `Thread::RestoreThreadStateFromCheckpoint`, by updating it to a `void` return
type, and making it non-`virtual`.

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

3 years ago[ObjC][ARC] Do not perform code motion on precise release calls
Akira Hatanaka [Tue, 16 Feb 2021 01:39:36 +0000 (17:39 -0800)]
[ObjC][ARC] Do not perform code motion on precise release calls

This fixes a bug where an object can get deallocated before reaching the
end of its full formal lifetime.

rdar://72110887
rdar://74123176

3 years ago[CodeGen] Use range-based for loops (NFC)
Kazu Hirata [Mon, 15 Feb 2021 22:46:10 +0000 (14:46 -0800)]
[CodeGen] Use range-based for loops (NFC)

3 years ago[Support] Use ListSeparator (NFC)
Kazu Hirata [Mon, 15 Feb 2021 22:46:09 +0000 (14:46 -0800)]
[Support] Use ListSeparator (NFC)

3 years ago[LazyCallGraph] Remove forward declarations of nonexistent classes (NFC)
Kazu Hirata [Mon, 15 Feb 2021 22:46:07 +0000 (14:46 -0800)]
[LazyCallGraph] Remove forward declarations of nonexistent classes (NFC)

3 years ago[RISCV] Add expicit i32/i64 types to RV32 or RV64 only isel patterns. NFC
Craig Topper [Mon, 15 Feb 2021 22:23:42 +0000 (14:23 -0800)]
[RISCV] Add expicit i32/i64 types to RV32 or RV64 only isel patterns. NFC

This stops tablegen from generating patterns with the opposite type
in the opposite HwMode. This just adds wasted bytes to the isel table.

This reduces the isel table by about 1800 bytes.

3 years agoGlobalISel: Handle arguments partially passed on the stack
Matt Arsenault [Sun, 7 Feb 2021 20:17:04 +0000 (15:17 -0500)]
GlobalISel: Handle arguments partially passed on the stack

The API is a bit awkward since you need to index into an array in the
passed struct. I guess an alternative would be to pass all of the
individual fields.

3 years agoCodeGen: Move function to get subregister indexes to cover a LaneMask
Matt Arsenault [Wed, 2 Dec 2020 00:34:54 +0000 (19:34 -0500)]
CodeGen: Move function to get subregister indexes to cover a LaneMask

Return the best covering index, and additional needed to complete the
mask. This logically belongs in TargetRegisterInfo, although I ended
up not needing it for why I originally split this out.

3 years ago[mlir][Vector] Add a canonicalization pattern for vector.contract + add
Nicolas Vasilache [Mon, 15 Feb 2021 12:11:29 +0000 (12:11 +0000)]
[mlir][Vector] Add a canonicalization pattern for vector.contract + add

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

3 years ago[libc++] Change `std::numeric_limits` to just `numeric_limits` in <chrono>.
Arthur O'Dwyer [Mon, 15 Feb 2021 21:10:28 +0000 (16:10 -0500)]
[libc++] Change `std::numeric_limits` to just `numeric_limits` in <chrono>.

The namespace is unnecessary, and libc++ style is not to include it on type names.
(As opposed to function names, where qualification affects ADL; and in certain
function signatures where `std::` and `_VSTD::` might be mangled differently.
This is none of those situations.)

3 years ago[RISCV] Add support for fixed vector floating point setcc.
Craig Topper [Mon, 15 Feb 2021 20:42:33 +0000 (12:42 -0800)]
[RISCV] Add support for fixed vector floating point setcc.

This is annoying because the condition code legalization belongs
to LegalizeDAG, but our custom handler runs in Legalize vector ops
which occurs earlier.

This adds some of the mask binary operations so that we can combine
multiple compares that we need for expansion.

I've also fixed up RISCVISelDAGToDAG.cpp to handle copies of masks.

This patch contains a subset of the integer setcc patch as well.
That patch is dependent on the integer binary ops patch. I'll rebase
based on what order the patches go in.

Reviewed By: frasercrmck

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

3 years ago[RISCV][LegalizeTypes] Try to expand BITREVERSE before promoting if the promoted...
Craig Topper [Mon, 15 Feb 2021 20:33:14 +0000 (12:33 -0800)]
[RISCV][LegalizeTypes] Try to expand BITREVERSE before promoting if the promoted BITREVERSE would expand anyway.

If we're going to end up expanding anyway, we should do it early
so we don't create extra operations to handle the bytes added by
promotion.

Simlilar was done for BSWAP previously.

Reviewed By: RKSimon

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

3 years ago[LLDB] Skip TestMultipleTargets.py on Arm/AArch64 Linux
Muhammad Omair Javaid [Mon, 15 Feb 2021 20:25:48 +0000 (01:25 +0500)]
[LLDB] Skip TestMultipleTargets.py on Arm/AArch64 Linux

TestMultipleTargets.py fails randomly on Arm/AArch64 Linux buildbot with
no reasonable clues. I am marking it skipped for avoiding LLDB buildbot
failures due to this test.

3 years ago[libc++] Mark __cpp_lib_constexpr_memory as being implemented
Louis Dionne [Mon, 15 Feb 2021 20:26:29 +0000 (15:26 -0500)]
[libc++] Mark __cpp_lib_constexpr_memory as being implemented

3 years ago[ValueTracking] add scan limit for assumes
Sanjay Patel [Mon, 15 Feb 2021 19:53:07 +0000 (14:53 -0500)]
[ValueTracking] add scan limit for assumes

In the motivating example from https://llvm.org/PR49171 and
reduced test here, we would unroll and clone assumes so much
that compile-time effectively became infinite while analyzing
all of those assumes.

3 years agoDefine new/delete in libc++ when using libcxxrt
Dimitry Andric [Mon, 15 Feb 2021 17:22:01 +0000 (18:22 +0100)]
Define new/delete in libc++ when using libcxxrt

Always turn on LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS, if libcxxrt is used
as the C++ ABI library, since libcxxrt does not provide the full set
ofnew and delete operators. In particular, the aligned versions of these
operators are completely missing. This primarily addresses builds on
FreeBSD, as this platform uses libcxxrt by default.

Also, attempt to provide a FreeBSD.cmake cache file, with hopefully sane
settings, partially copied from the Apple.cmake cache file. This needs
more work, probably some additions to ci build scripts (although I am
not aware of any 'official' FreeBSD build bots).

Reviewed By: ldionne, #libc

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

3 years ago[clangd] Pass raw client capabilities to modules. NFC
Sam McCall [Mon, 15 Feb 2021 19:56:57 +0000 (20:56 +0100)]
[clangd] Pass raw client capabilities to modules. NFC

3 years agoTransformUtils: Fix metadata handling in CloneModule (and improve CloneFunctionInto)
Duncan P. N. Exon Smith [Thu, 11 Feb 2021 16:23:39 +0000 (08:23 -0800)]
TransformUtils: Fix metadata handling in CloneModule (and improve CloneFunctionInto)

This commit fixes how metadata is handled in CloneModule to be sound,
and improves how it's handled in CloneFunctionInto (although the latter
is still awkward when called within a module).

Ruiling Song pointed out in PR48841 that CloneModule was changed to
unsoundly use the RF_ReuseAndMutateDistinctMDs flag (renamed in
fa35c1f80f0ea080a7cbc581416929b0a654f25c for clarity). This flag papered
over a crash caused by other various changes made to CloneFunctionInto
over the past few years that made it unsound to use cloning between
different modules.

(This commit partially addresses PR48841, fixing the repro from
preprocessed source but not textual IR. MDNodeMapper::mapDistinctNode
became unsound in df763188c9a1ecb1e7e5c4d4ea53a99fbb755903 and this
commit does not address that regression.)

RF_ReuseAndMutateDistinctMDs is designed for the IRMover to use,
avoiding unnecessary clones of all referenced metadata when linking
between modules (with IRMover, the source module is discarded after
linking). It never makes sense to use when you're not discarding the
source. This commit drops its incorrect use in CloneModule.

Sadly, the right thing to do with metadata when cloning a function is
complicated, and this patch doesn't totally fix it.

The first problem is that there are two different types of referenceable
metadata and it's not obvious what to with one of them when remapping.

- `!0 = !{!1}` is metadata's version of a constant. Programatically it's
  called "uniqued" (probably a better term would be "constant") because,
  like `ConstantArray`, it's stored in uniquing tables. Once it's
  constructed, it's illegal to change its arguments.
- `!0 = distinct !{!1}` is a bit closer to a global variable. It's legal
  to change the operands after construction.

What should be done with distinct metadata when cloning functions within
the same module?

- Should new, cloned nodes be created?
- Should all references point to the same, old nodes?

The answer depends on whether that metadata is effectively owned by a
function.

And that's the second problem. Referenceable metadata's ownership model
is not clear or explicit. Technically, it's all stored on an
LLVMContext. However, any metadata that is `distinct`, that transitively
references a `distinct` node, or that transitively references a
GlobalValue is specific to a Module and is effectively owned by it. More
specifically, some metadata is effectively owned by a specific Function
within a module.

Effectively function-local metadata was introduced somewhere around
c10d0e5ccd12f049bddb24dcf8bbb7fbbc6c68f2, which made it illegal for two
functions to share a DISubprogram attachment.

When cloning a function within a module, you need to clone the
function-local debug info and suppress cloning of global debug info (the
status quo suppresses cloning some global debug info but not all). When
cloning a function to a new/different module, you need to clone all of
the debug info.

Here's what I think we should do (eventually? soon? not this patch
though):
- Distinguish explicitly (somehow) between pure constant metadata owned
  by the LLVMContext, global metadata owned by the Module, and local
  metadata owned by a GlobalValue (such as a function).
- Update CloneFunctionInto to trigger cloning of all "local" metadata
  (only), perhaps by adding a bit to RemapFlag. Alternatively, split
  out a separate function CloneFunctionMetadataInto to prime the
  metadata map that callers are updated to call ahead of time as
  appropriate.

Here's the somewhat more isolated fix in this patch:
- Converted the `ModuleLevelChanges` parameter to `CloneFunctionInto` to
  an enum called `CloneFunctionChangeType` that is one of
  LocalChangesOnly, GlobalChanges, DifferentModule, and ClonedModule.
- The code maintaining the "functions uniquely own subprograms"
  invariant is now only active in the first two cases, where a function
  is being cloned within a single module. That's necessary because this
  code inhibits cloning of (some) "global" metadata that's effectively
  owned by the module.
- The code maintaining the "all compile units must be explicitly
  referenced by !llvm.dbg.cu" invariant is now only active in the
  DifferentModule case, where a function is being cloned into a new
  module in isolation.
- CoroSplit.cpp's call to CloneFunctionInto in CoroCloner::create
  uses LocalChangeOnly, since fa635d730f74f3285b77cc1537f1692184b8bf5b
  only set `ModuleLevelChanges` to trigger cloning of local metadata.
- CloneModule drops its unsound use of RF_ReuseAndMutateDistinctMDs
  and special handling of !llvm.dbg.cu.
- Fixed some outdated header docs and left a couple of FIXMEs.

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

3 years ago[lto] Enable new PM when the PM config is non-empty
Benjamin Kramer [Mon, 15 Feb 2021 19:49:09 +0000 (20:49 +0100)]
[lto] Enable new PM when the PM config is non-empty

This restores the behavior before 964f8103c58d, which broke 2 tests:
  LLVM :: tools/llvm-lto2/X86/pipeline.ll
  lld :: ELF/lto/ltopasses-custom.ll

3 years ago[AMDGPU] Add two TSFlags: IsAtomicNoRtn and IsAtomicRtn
Stanislav Mekhanoshin [Fri, 12 Feb 2021 22:19:10 +0000 (14:19 -0800)]
[AMDGPU] Add two TSFlags: IsAtomicNoRtn and IsAtomicRtn

We are using AtomicNoRet map in multiple places to determine
if an instruction atomic, rtn or nortn atomic. This method
does not work always since we have some instructions which
only has rtn or nortn version.

One such instruction is ds_wrxchg_rtn_b32 which does not have
nortn version. This has caused changes in memory legalizer
tests.

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