platform/upstream/llvm.git
2 years ago[flang] Add TargetRewrite pass
Diana Picus [Fri, 29 Oct 2021 07:11:12 +0000 (07:11 +0000)]
[flang] Add TargetRewrite pass

This patch adds the basic infrastructure for the TargetRewrite pass,
which rewrites certain FIR dialect operations into target specific
forms. In particular, it converts boxchar function parameters, call
arguments and return values. Other convertions will be included in
future patches.

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

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

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Kiran Chandramohan <kiran.chandramohan@arm.com>
Co-authored-by: Tim Keith <tkeith@nvidia.com>
2 years ago[gn build] Port ef717f385232
LLVM GN Syncbot [Tue, 9 Nov 2021 07:11:34 +0000 (07:11 +0000)]
[gn build] Port ef717f385232

2 years agoRevert "[clang][openmp][NFC] Remove arch-specific CGOpenMPRuntimeGPU files"
Atmn Patel [Tue, 9 Nov 2021 07:09:41 +0000 (02:09 -0500)]
Revert "[clang][openmp][NFC] Remove arch-specific CGOpenMPRuntimeGPU files"

This reverts commit 81a7cad2ffc18f15b732f69d991c8398c979c5ca.

2 years ago[gn build] Port 81a7cad2ffc1
LLVM GN Syncbot [Tue, 9 Nov 2021 06:54:23 +0000 (06:54 +0000)]
[gn build] Port 81a7cad2ffc1

2 years ago[clang][openmp][NFC] Remove arch-specific CGOpenMPRuntimeGPU files
Atmn Patel [Tue, 9 Nov 2021 04:16:54 +0000 (23:16 -0500)]
[clang][openmp][NFC] Remove arch-specific CGOpenMPRuntimeGPU files

The existing CGOpenMPRuntimeAMDGCN and CGOpenMPRuntimeNVPTX classes are
just code bloat. By removing them, the codebase gets a bit cleaner.

Reviewed By: jdoerfert, JonChesterfield, tianshilei1992

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

2 years ago[ObjC][ARC] Replace uses of ObjC intrinsics that are arguments of
Akira Hatanaka [Tue, 9 Nov 2021 05:19:07 +0000 (21:19 -0800)]
[ObjC][ARC] Replace uses of ObjC intrinsics that are arguments of
operand bundle "clang.arc.attachedcall" with ObjC runtime functions

The existing code only handles the case where the intrinsic being
rewritten is used as the called function pointer of a call/invoke.

2 years ago[debugserver] Put building for arm64e behind a CMake flag
Jonas Devlieghere [Tue, 9 Nov 2021 05:01:36 +0000 (21:01 -0800)]
[debugserver] Put building for arm64e behind a CMake flag

2 years ago[gn build] Port 6cad45d5c6f5
LLVM GN Syncbot [Tue, 9 Nov 2021 04:15:33 +0000 (04:15 +0000)]
[gn build] Port 6cad45d5c6f5

2 years ago[gn build] (manually) port 38be8f4057c1 (llvm-tli-checker)
Nico Weber [Tue, 9 Nov 2021 04:14:44 +0000 (23:14 -0500)]
[gn build] (manually) port 38be8f4057c1 (llvm-tli-checker)

2 years ago[NFC][dfsan] Split Init and ThreadStart
Vitaly Buka [Tue, 9 Nov 2021 03:10:10 +0000 (19:10 -0800)]
[NFC][dfsan] Split Init and ThreadStart

2 years agoPartially revert "[NFC][msan] Split ThreadStart and Init"
Vitaly Buka [Tue, 9 Nov 2021 03:12:56 +0000 (19:12 -0800)]
Partially revert "[NFC][msan] Split ThreadStart and Init"

I don't know if removing "if (!start_routine_)" from ThreadStart
is NFC.

This reverts commit b3267bb3afd3c70a415ae81c855462affae92f6b.

2 years ago[llvm][Inline] Add a module level inliner
Liqiang Tao [Tue, 9 Nov 2021 03:01:48 +0000 (11:01 +0800)]
[llvm][Inline] Add a module level inliner

Add module level inliner, which is a minimum viable product at this point.
Also add some tests for it.

RFC: https://lists.llvm.org/pipermail/llvm-dev/2021-August/152297.html

Reviewed By: kazu

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

2 years ago[NFC][msan] Split ThreadStart and Init
Vitaly Buka [Tue, 9 Nov 2021 02:54:51 +0000 (18:54 -0800)]
[NFC][msan] Split ThreadStart and Init

2 years ago[ObjC][ARC] Use operand bundle "clang.arc.attachedcall" on x86-64
Akira Hatanaka [Tue, 9 Nov 2021 02:01:48 +0000 (18:01 -0800)]
[ObjC][ARC] Use operand bundle "clang.arc.attachedcall" on x86-64

https://reviews.llvm.org/D92808 made clang use the operand bundle
instead of emitting retainRV/claimRV calls on arm64. This commit makes
changes to clang that are needed to use the operand bundle on x86-64.

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

2 years ago[ObjC][ARC] Handle operand bundle "clang.arc.attachedcall" on targets
Akira Hatanaka [Tue, 9 Nov 2021 01:50:08 +0000 (17:50 -0800)]
[ObjC][ARC] Handle operand bundle "clang.arc.attachedcall" on targets
that don't use the inline asm marker

This patch makes the changes to the ARC middle-end passes that are
needed to handle operand bundle "clang.arc.attachedcall" on targets that
don't use the inline asm marker for the retainRV/autoreleaseRV
handshake (e.g., x86-64).

Note that anyone who wants to use the operand bundle on their target has
to teach their backend to handle the operand bundle. The x86-64 backend
already knows about the operand bundle (see
https://reviews.llvm.org/D94597).

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

2 years agoadd tsan shared lib
ZijunZhao [Wed, 1 Sep 2021 21:52:25 +0000 (21:52 +0000)]
add tsan shared lib

Change-Id: Ic83ff1ec86d6a7d61b07fa3df7e0cb2790b5ebc7

2 years ago[NFC] Move setuid.c test into sanitizer_common
Vitaly Buka [Tue, 9 Nov 2021 02:23:42 +0000 (18:23 -0800)]
[NFC] Move setuid.c test into sanitizer_common

2 years ago[mlir] Remove the non-templated DenseElementsAttr::getSplatValue
River Riddle [Tue, 9 Nov 2021 01:40:17 +0000 (01:40 +0000)]
[mlir] Remove the non-templated DenseElementsAttr::getSplatValue

This predates the templated variant, and has been simply forwarding
to getSplatValue<Attribute> for some time. Removing this makes the
API a bit more uniform, and also helps prevent users from thinking
it is "cheap".

2 years ago[Tablegen] Collect all global state into one managed static
River Riddle [Tue, 9 Nov 2021 01:05:41 +0000 (01:05 +0000)]
[Tablegen] Collect all global state into one managed static

Tablegen uses copious amounts of global state for uniquing various records.
This was fine under the original vision where tablegen was a tool, and not a
library, but there are various usages of tablegen that want to use it as a library.
One concrete example is that downstream we have a kythe indexer for tablegen
constructs that allows for IDEs to serve go-to-definition/references/and more.
We currently (kind of hackily) keep the tablegen parts in a shared library that
gets loaded/unloaded.

This revision starts to remedy this by globbing all of the static state into a
managed static so that they can at least be unloaded with llvm_shutdown.
A better solution would be to feed in a context variable (much like how
the IR in LLVM/MLIR do), but that is a more invasive change that can come later.

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

2 years agoFix test dependencies to add llvm-tli-checker
Paul Robinson [Tue, 9 Nov 2021 01:22:10 +0000 (17:22 -0800)]
Fix test dependencies to add llvm-tli-checker

2 years ago[WebAssembly] fix __stack_pointer being added to .debug_aranges
Wouter van Oortmerssen [Mon, 8 Nov 2021 23:27:14 +0000 (15:27 -0800)]
[WebAssembly] fix __stack_pointer being added to .debug_aranges

When emitting a reloc for the Wasm global __stack_pointer, it was inadvertedly added to the symbols used for generating aranges, which caused some aranges to use it as the end symbol in a symbol diff, which caused a reloc for it to be emitted, which then caused an assert in `wasm64` since we have no 64-bit relocs for Wasm globals.
Fixes: https://bugs.llvm.org/show_bug.cgi?id=52376
Differential Revision: https://reviews.llvm.org/D113438

2 years agoAdd llvm-tli-checker
Paul Robinson [Tue, 9 Nov 2021 00:29:28 +0000 (16:29 -0800)]
Add llvm-tli-checker

A new tool that compares TargetLibraryInfo's opinion of the availability
of library function calls against the functions actually exported by a
specified set of libraries. Can be helpful in verifying the correctness
of TLI for a given target, and avoid mishaps such as had to be addressed
in D107509 and 94b4598d.

The tool currently supports ELF object files only, although it's unlikely
to be hard to add support for other formats.

Re-commits 62dd488 with changes to use pre-generated objects, as not all
bots have ld.lld available.

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

2 years ago[mlir] Refactor ElementsAttr's value access API
River Riddle [Tue, 9 Nov 2021 00:05:55 +0000 (00:05 +0000)]
[mlir] Refactor ElementsAttr's value access API

There are several aspects of the API that either aren't easy to use, or are
deceptively easy to do the wrong thing. The main change of this commit
is to remove all of the `getValue<T>`/`getFlatValue<T>` from ElementsAttr
and instead provide operator[] methods on the ranges returned by
`getValues<T>`. This provides a much more convenient API for the value
ranges. It also removes the easy-to-be-inefficient nature of
getValue/getFlatValue, which under the hood would construct a new range for
the type `T`. Constructing a range is not necessarily cheap in all cases, and
could lead to very poor performance if used within a loop; i.e. if you were to
naively write something like:

```
DenseElementsAttr attr = ...;
for (int i = 0; i < size; ++i) {
  // We are internally rebuilding the APFloat value range on each iteration!!
  APFloat it = attr.getFlatValue<APFloat>(i);
}
```

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

2 years ago[WebAssembly] Fix fixBrTableIndex removing instruction without checking uses
Wouter van Oortmerssen [Fri, 5 Nov 2021 00:21:00 +0000 (17:21 -0700)]
[WebAssembly] Fix fixBrTableIndex removing instruction without checking uses

Fixes: https://bugs.llvm.org/show_bug.cgi?id=52352
Differential Revision: https://reviews.llvm.org/D113230

2 years agoRevert "Add llvm-tli-checker"
Paul Robinson [Mon, 8 Nov 2021 23:47:35 +0000 (15:47 -0800)]
Revert "Add llvm-tli-checker"

Not all bots have ld.lld available.
This reverts commit 62dd488164f5b68cce1ac3825f857b0108476c3c.

2 years ago[bugpoint] Fix repeated off-by-one error in debug output
Jessica Clarke [Mon, 8 Nov 2021 23:44:45 +0000 (23:44 +0000)]
[bugpoint] Fix repeated off-by-one error in debug output

This resulted in the final argument being dropped from the output, which
can be rather important.

2 years ago[docs] Remove outdated documentation for the legacy Atom-based LLD
Fangrui Song [Mon, 8 Nov 2021 23:20:16 +0000 (15:20 -0800)]
[docs] Remove outdated documentation for the legacy Atom-based LLD

The outdated documentation diverges a lot from the current state of
COFF/Mach-O/ELF/wasm ports and may just confuse users. It is better rewriting
some if useful.

Tested with `ninja docs-lld-html`

Reviewed By: #lld-macho, lhames, Jez Ng

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

2 years ago[mlir-tblgen] Support `either` in Tablegen DRR.
Chia-hung Duan [Mon, 8 Nov 2021 22:56:40 +0000 (22:56 +0000)]
[mlir-tblgen] Support `either` in Tablegen DRR.

Add a new directive `either` to specify the operands can be matched in either order

Reviewed By: jpienaar, Mogball

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

2 years ago[NFC] Initial documentation for declare target indirect support.
Vyacheslav Zakharin [Tue, 21 Sep 2021 19:17:55 +0000 (12:17 -0700)]
[NFC] Initial documentation for declare target indirect support.

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

2 years ago[RISCV] Use TargetConstant for CSR number for READ_CSR/WRITE_CSR.
Craig Topper [Mon, 8 Nov 2021 23:05:27 +0000 (15:05 -0800)]
[RISCV] Use TargetConstant for CSR number for READ_CSR/WRITE_CSR.

This is consistent with what we do for other operands that are required
to be constants.

I don't think this results in any real changes. The pattern match
code for isel treats ConstantSDNode and TargetConstantSDNode the same.

2 years ago[NFC][FuncAttrs] Keep track of modified functions
Arthur Eubanks [Fri, 5 Nov 2021 18:07:54 +0000 (11:07 -0700)]
[NFC][FuncAttrs] Keep track of modified functions

This is in preparation for only invalidating analyses on changed
functions.

Reviewed By: asbirlea

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

2 years agoAdd llvm-tli-checker
Paul Robinson [Mon, 8 Nov 2021 22:44:32 +0000 (14:44 -0800)]
Add llvm-tli-checker

A new tool that compares TargetLibraryInfo's opinion of the availability
of library function calls against the functions actually exported by a
specified set of libraries. Can be helpful in verifying the correctness
of TLI for a given target, and avoid mishaps such as had to be addressed
in D107509 and 94b4598d.

The tool currently supports ELF object files only, although it's unlikely
to be hard to add support for other formats.

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

2 years ago[mlir][docs] Unify style (nfc)
Marius Brehler [Mon, 8 Nov 2021 22:40:09 +0000 (22:40 +0000)]
[mlir][docs] Unify style (nfc)

2 years ago[ObjC][ARC] Invalidate an entry of UnderlyingObjCPtrCache when the
Akira Hatanaka [Mon, 8 Nov 2021 22:39:16 +0000 (14:39 -0800)]
[ObjC][ARC] Invalidate an entry of UnderlyingObjCPtrCache when the
instruction the key points to is deleted

Use weak value handles for both the key and the value. The entry is
invalid if either value handle is null.

This fixes an assertion failure in BasicAAResult::alias that is caused
by UnderlyingObjCPtrCache returning a wrong value.

I don't have a test case for this patch that fails reliably.

rdar://83984790

2 years ago[compiler-rt] TlsBaseAddr value for darwin arm64
David CARLIER [Mon, 8 Nov 2021 22:26:32 +0000 (22:26 +0000)]
[compiler-rt] TlsBaseAddr value for darwin arm64

getting the tls base address. unlike linux arm64, the tpidr_el0 returns always 0 (aka unused)
thus using tpidrro_el0 instead clearing up the cpu id encoded in the lower bits.

Reviewed-By: yln
Differential Revision: https://reviews.llvm.org/D112866

2 years ago[ARM] implement LOAD_STACK_GUARD for remaining targets
Ard Biesheuvel [Mon, 8 Nov 2021 21:22:04 +0000 (22:22 +0100)]
[ARM] implement LOAD_STACK_GUARD for remaining targets

Currently, LOAD_STACK_GUARD on ARM is only implemented for Mach-O targets, and
other targets rely on the generic support which may result in spilling of the
stack canary value or address, or may cause it to be kept in a callee save
register across function calls, which means they essentially get spilled as
well, only by the callee when it wants to free up this register.

So let's implement LOAD_STACK GUARD for other targets as well. This ensures
that the load of the stack canary is rematerialized fully in the epilogue.

This code was split off from

  D112768: [ARM] implement support for TLS register based stack protector

for which it is a prerequisite.

Reviewed By: nickdesaulniers

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

2 years ago[libc++] [test] Eliminate the libcpp-no-if-constexpr feature flag.
Arthur O'Dwyer [Sat, 6 Nov 2021 18:37:49 +0000 (14:37 -0400)]
[libc++] [test] Eliminate the libcpp-no-if-constexpr feature flag.

At this point, every supported compiler that claims a -std=c++17 mode
should also support `if constexpr`. This was an issue for GCC 5
and GCC 6, but hasn't been an issue since GCC 7. (Our current
minimum supported GCC version, IIUC, is GCC 10 or 11.)

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

2 years ago[NFC] Update the test compiler to use clangxx.
Snehasish Kumar [Mon, 8 Nov 2021 21:57:32 +0000 (13:57 -0800)]
[NFC] Update the test compiler to use clangxx.

This ensures that the c++ test gets the right CXXFLAGS if required.

2 years ago[modules] Update visibility for merged ObjCProtocolDecl definitions.
Volodymyr Sapsai [Fri, 15 Oct 2021 00:45:53 +0000 (17:45 -0700)]
[modules] Update visibility for merged ObjCProtocolDecl definitions.

Merge definition visibility the same way we do for other decls. Without
the fix the added test emits `-Wobjc-method-access` as it cannot find a
visible protocol. Make this warning `-Werror` so the test would fail
when protocol visibility regresses.

rdar://83600696

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

2 years ago[InferAddressSpaces] Support assumed addrspaces from addrspace predicates.
Michael Liao [Fri, 15 Oct 2021 03:41:16 +0000 (23:41 -0400)]
[InferAddressSpaces] Support assumed addrspaces from addrspace predicates.

- CUDA cannot associate memory space with pointer types. Even though Clang could add extra attributes to specify the address space explicitly on a pointer type, it breaks the portability between Clang and NVCC.
- This change proposes to assume the address space from a pointer from the assumption built upon target-specific address space predicates, such as `__isGlobal` from CUDA. E.g.,

```
  foo(float *p) {
    __builtin_assume(__isGlobal(p));
    // From there, we could assume p is a global pointer instead of a
    // generic one.
  }
```

This makes the code portable without introducing the implementation-specific features.

Note that NVCC starts to support __builtin_assume from version 11.

Reviewed By: arsenm

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

2 years agoStatic verifier for type/attribute in DRR
Chia-hung Duan [Mon, 8 Nov 2021 21:34:02 +0000 (21:34 +0000)]
Static verifier for type/attribute in DRR

Generate static function for matching the type/attribute to reduce the
memory footprint.

Reviewed By: Mogball

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

2 years ago[flang] Don't reference non-invariant symbols in shape expressions
Peter Klausler [Mon, 1 Nov 2021 23:24:01 +0000 (16:24 -0700)]
[flang] Don't reference non-invariant symbols in shape expressions

When an array's shape involves references to symbols that are not
invariant in a scope -- the classic example being a dummy array
with an explicit shape involving other dummy arguments -- the
compiler was creating shape expressions that referenced those
symbols.  This might be valid if those symbols are somehow
captured and copied at each entry point to a subprogram, and
the copies referenced in the shapes instead, but that's not
the case.

This patch introduces a new expression predicate IsScopeInvariantExpr(),
which defines a class of expressions that contains constant expressions
(in the sense that the standard uses that term) as well as references
to items that may be safely accessed in a context-free way throughout
their scopes.   This includes dummy arguments that are INTENT(IN)
and not VALUE, descriptor inquiries into descriptors that cannot
change, and bare LEN type parameters within the definitions of
derived types.  The new predicate is then used in shape analysis
to winnow out results that would have otherwise been contextual.

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

2 years agoAttempt to work around type checking error on older compilers
Adrian Prantl [Mon, 8 Nov 2021 20:42:09 +0000 (12:42 -0800)]
Attempt to work around type checking error on older compilers

2 years ago[mlir][ods] fix c++11 build
Mogball [Mon, 8 Nov 2021 20:36:10 +0000 (20:36 +0000)]
[mlir][ods] fix c++11 build

2 years ago[ELF][ARM] Improve error message for unknown relocation
Fangrui Song [Mon, 8 Nov 2021 20:39:08 +0000 (12:39 -0800)]
[ELF][ARM] Improve error message for unknown relocation

Like rLLD354040.

Before: `error: unrecognized relocation Unknown (254)`
Now:    `error: unknown relocation (254) against symbol foo`

2 years agoRevert "[OpenMP] Lower printf to __llvm_omp_vprintf"
Jon Chesterfield [Mon, 8 Nov 2021 20:28:57 +0000 (20:28 +0000)]
Revert "[OpenMP] Lower printf to __llvm_omp_vprintf"

This reverts commit db81d8f6c4d6c4f8dfaa036d6959528c9f14e7d7.

2 years agoRevert "[openmp] Fix build, test passes on CI unexpectedly"
Jon Chesterfield [Mon, 8 Nov 2021 20:28:52 +0000 (20:28 +0000)]
Revert "[openmp] Fix build, test passes on CI unexpectedly"

This reverts commit c499d690cdb7ead72bcd086b08328a6d3a91b682.

2 years ago[clang-move] Fix unit tests with forward slash as separator on windows
Martin Storsjö [Fri, 8 Oct 2021 13:30:36 +0000 (13:30 +0000)]
[clang-move] Fix unit tests with forward slash as separator on windows

Also remove a comment that seems to be left behind.

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

2 years ago[clang] [DirectoryWatcher] Remove leading \\?\ from GetFinalPathNameByHandleW
Martin Storsjö [Thu, 7 Oct 2021 21:14:15 +0000 (21:14 +0000)]
[clang] [DirectoryWatcher] Remove leading \\?\ from GetFinalPathNameByHandleW

This is needed for the paths to work when using forward slashes;
this fixes the DirectoryWatcherTests unit tests.

Also allocate missing space for the null terminator, which seems to
have been missing all along (writing the terminator out of bounds).

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

2 years ago[Support] [VirtualFileSystem] Detect the windows_slash path style
Martin Storsjö [Fri, 8 Oct 2021 10:41:46 +0000 (10:41 +0000)]
[Support] [VirtualFileSystem] Detect the windows_slash path style

This fixes the following clang VFS tests, if `windows_slash` is the
default style:

  Clang :: VFS/implicit-include.c
  Clang :: VFS/relative-path.c
  Clang-Unit :: Frontend/./FrontendTests.exe/CompilerInstance.DefaultVFSOverlayFromInvocation

Also clarify a couple references to `Style::windows` into
`Style::windows_backslash`, to make it clearer that each of them are
opinionated in different directions (even if it doesn't matter for
calls to e.g. `is_absolute`).

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

2 years ago[AArch][x86] add tests for vselect; NFC
Sanjay Patel [Mon, 8 Nov 2021 17:43:51 +0000 (12:43 -0500)]
[AArch][x86] add tests for vselect; NFC

This is a potential follow-up suggested in D113212.

2 years ago[InstCombine] Canonicalize range test idiom
Nikita Popov [Sat, 6 Nov 2021 23:05:00 +0000 (00:05 +0100)]
[InstCombine] Canonicalize range test idiom

InstCombine converts range tests of the form (X > C1 && X < C2) or
(X < C1 || X > C2) into checks of the form (X + C3 < C4) or
(X + C3 > C4). It is possible to express all range tests in either
of these forms (with different choices of constants), but currently
neither of them is considered canonical. We may have equivalent
range tests using either ult or ugt.

This proposes to canonicalize all range tests to use ult. An
alternative would be to canonicalize to either ult or ugt depending
on the specific constants involved -- e.g. in practice we currently
generate ult for && style ranges and ugt for || style ranges when
going through the insertRangeTest() helper. In fact, the "clamp like"
fold was relying on this, which is why I had to tweak it to not
assume whether inversion is needed based on just the predicate.

Proof: https://alive2.llvm.org/ce/z/_SP_rQ

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

2 years ago[flang] Make subscript list argument a nullable pointer
peter klausler [Wed, 20 Oct 2021 23:01:52 +0000 (16:01 -0700)]
[flang] Make subscript list argument a nullable pointer

Component::CreatePointerDescriptor unconditionally expects a
vector of subscripts to be passed as an argument, but is called
from NAMELIST input with a null pointer.  Make that argument
a nullable pointer, move it to the end of the argument list,
and give it a default value of nullptr.

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

2 years ago[flang] Distinguish error/warning cases for bad jumps into constructs
Peter Klausler [Fri, 29 Oct 2021 23:23:22 +0000 (16:23 -0700)]
[flang] Distinguish error/warning cases for bad jumps into constructs

Previously, jumps to labels in constructs from exterior statements
would elicit only a warning.  Upgrade these to errors unless the
branch into the construct would enter into only DO, IF, and SELECT CASE
constructs, whose interiors don't scope variables or have other
set-up/tear-down semantics.  Branches into these "safe" constructs
are still errors if they're nested in an unsafe construct that doesn't
also enclose the exterior branch statement.

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

2 years ago[libc++] Trigger a rebuild of the CI Docker images
Louis Dionne [Mon, 8 Nov 2021 19:34:24 +0000 (14:34 -0500)]
[libc++] Trigger a rebuild of the CI Docker images

2 years agoExtend obj2yaml to optionally preserve raw __LINKEDIT/__DATA segments.
Adrian Prantl [Mon, 8 Nov 2021 19:29:04 +0000 (11:29 -0800)]
Extend obj2yaml to optionally preserve raw __LINKEDIT/__DATA segments.

I am planning to upstream MachOObjectFile code to support Darwin
chained fixups. In order to test the new parser features we need a way
to produce correct (and incorrect) chained fixups. Right now the only
tool that can produce them is the Darwin linker. To avoid having to
check in binary files, this patch allows obj2yaml to print a hexdump
of the raw LINKEDIT and DATA segment, which both allows to
bootstrap the parser and enables us to easily create malformed inputs
to test error handling in the parser.

This patch adds two new options to obj2yaml:

  -raw-data-segment
  -raw-linkedit-segment

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

2 years ago[ASTMatcher] Provide a definition for the lambdaCapture matcher
Benjamin Kramer [Mon, 8 Nov 2021 19:26:37 +0000 (20:26 +0100)]
[ASTMatcher] Provide a definition for the lambdaCapture matcher

This is an empty object, but depending on your optimizer settings the
compiler may emit a reference to the symbol.

2 years ago[flang] Fix crash in semantic error recovery situation
Peter Klausler [Tue, 2 Nov 2021 23:41:15 +0000 (16:41 -0700)]
[flang] Fix crash in semantic error recovery situation

A CHECK() in semantics is triggering when analyzing a program
with an undefined derived type pointer because the CHECK is
expecting a new error message to have been issued in a function
but not allowing for the case that a diagnostic could have been
produced earlier.  Adjust the predicate.

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

2 years agoAdd `LambdaCapture`-related matchers.
James King [Mon, 8 Nov 2021 18:39:00 +0000 (18:39 +0000)]
Add `LambdaCapture`-related matchers.

This provides better support for `LambdaCapture`s by making them first-
class and allowing them to be bindable. In addition, this implements several
`LambdaCapture`-related matchers. This does not update how lambdas are
traversed. As a result, something like trying to match `lambdaCapture()` by
itself will not work - it must be used as an inner matcher.

Reviewed By: aaron.ballman, sammccall

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

2 years ago[flang] Fix folding of EPSILON()
Peter Klausler [Fri, 29 Oct 2021 20:00:43 +0000 (13:00 -0700)]
[flang] Fix folding of EPSILON()

The value of EPSILON() was off by one power of two due to my
misreading of the standard; this patch corrects it.
Confirmed by checking other Fortran compilers, which all agree.

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

2 years ago[openmp] Fix build, test passes on CI unexpectedly
Jon Chesterfield [Mon, 8 Nov 2021 18:45:10 +0000 (18:45 +0000)]
[openmp] Fix build, test passes on CI unexpectedly

2 years ago[llvm] Inclusive language: replace master with main in file paths in LIT tests
Quinn Pham [Wed, 27 Oct 2021 18:12:33 +0000 (13:12 -0500)]
[llvm] Inclusive language: replace master with main in file paths in LIT tests

[NFC] As part of using inclusive language within the llvm project, this patch
replaces master with main in file/directory paths in llvm LIT tests.

Reviewed By: bjope

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

2 years ago[OpenMP] Lower printf to __llvm_omp_vprintf
Jon Chesterfield [Mon, 8 Nov 2021 18:37:57 +0000 (18:37 +0000)]
[OpenMP] Lower printf to __llvm_omp_vprintf

Extension of D112504. Lower amdgpu printf to `__llvm_omp_vprintf`
which takes the same const char*, void* arguments as cuda vprintf and also
passes the size of the void* alloca which will be needed by a non-stub
implementation of `__llvm_omp_vprintf` for amdgpu.

This removes the amdgpu link error on any printf in a target region in favour
of silently compiling code that doesn't print anything to stdout.

The exact set of changes to check-openmp probably needs revision before commit

Reviewed By: jdoerfert

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

2 years ago[NFC][llvm-libtool-darwin] Clean up names
Roger Kim [Mon, 8 Nov 2021 18:26:50 +0000 (10:26 -0800)]
[NFC][llvm-libtool-darwin] Clean up names

Removing unclear abbreviations.

Reviewed By: jhenderson

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

2 years ago[NFC][llvm-libtool-darwin] Remove unnecessary conditionals around errors
Roger Kim [Mon, 8 Nov 2021 18:26:43 +0000 (10:26 -0800)]
[NFC][llvm-libtool-darwin] Remove unnecessary conditionals around errors

The existing code has unnecessary logic to indirectly pass
errors through function calls. This diff gets rid of the fluff.

Test Plan: Existing unit tests

Reviewed By: jhenderson, drodriguez, alexander-shaposhnikov

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

2 years ago[mlir][tosa] Spec v0.23 updates
Suraj Sudhir [Mon, 8 Nov 2021 18:13:42 +0000 (10:13 -0800)]
[mlir][tosa] Spec v0.23 updates

Add pad_const field to tosa.pad.
Add builders to enable optional construction of pad_const in pad op.
Update documentation of tosa.clamp to match spec wording.

Signed-off-by: Suraj Sudhir <suraj.sudhir@arm.com>
Reviewed By: rsuderman

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

2 years ago[flang] Complete the fix for NAMELIST look-ahead case
Peter Klausler [Wed, 3 Nov 2021 22:33:29 +0000 (15:33 -0700)]
[flang] Complete the fix for NAMELIST look-ahead case

When processing the devious NAMELIST input

  &group logarray = t t t
    = 666 /

for LOGICAL::logarray(3) and INTEGER::t, the runtime library
needs to do some look-ahead on the input stream to make sure
that the last "t" on the first line is a truth value rather than
an item name -- which in this case it is.  This look-ahead
was implemented in a previous patch but only worked for internal
input cases; this patch implements look-ahead capabilities for
input from an external file, too (and also adjusts repeated
list-directed input items to use this infrastructure, too).

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

2 years ago[Flang][driver] Update the docs
Andrzej Warzynski [Mon, 11 Oct 2021 20:03:54 +0000 (20:03 +0000)]
[Flang][driver] Update the docs

Please note that the updated documentation reflects the design that we are
working towards, but haven't implemented competely yet. We took this approach
in order to provide a more holisitic and complete overview of the design.

In particular, this document assumes that Flang's frontend and compiler
driver can already generate code. This is still work-in-progress and is
being developed on the `fir-dev` branch in the F18 repository [1].

[1] https://github.com/flang-compiler/f18-llvm-project/tree/fir-dev

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

2 years ago[NFC] Fix lit test failures for clang/CodegenCoroutines
hyeongyu kim [Mon, 8 Nov 2021 17:42:55 +0000 (02:42 +0900)]
[NFC] Fix lit test failures for clang/CodegenCoroutines

2 years ago[clang] Fortify warning for scanf calls with field width too big.
Michael Benfield [Thu, 14 Oct 2021 20:02:28 +0000 (20:02 +0000)]
[clang] Fortify warning for scanf calls with field width too big.

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

2 years ago[VPlan] Make sure recurrence splice is not inserted between phis.
Florian Hahn [Mon, 8 Nov 2021 17:42:32 +0000 (17:42 +0000)]
[VPlan] Make sure recurrence splice is not inserted between phis.

All phi-like recipes should be at the beginning of a VPBasicBlock with
no other recipes in between. Ensure that the recurrence-splicing recipe
is not added between phi-like recipes, but after them.

Reviewed By: Ayal

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

2 years ago[RISCV] SMUL_LOHI/UMUL_LOHI should expand for RVV.
Craig Topper [Mon, 8 Nov 2021 17:25:10 +0000 (09:25 -0800)]
[RISCV] SMUL_LOHI/UMUL_LOHI should expand for RVV.

These and MULHS/MULHU both default to Legal. Targets need to set
the ones they don't support to Expand.

I think MULHS/MULHU likely has priority in most places so this
change probably isn't directly testable. I found it while looking
at disabling MULHS/MULHU for nxvXi64 as required for Zve64x.

Reviewed By: frasercrmck

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

2 years ago[MLIR] Attribute and type formats in ODS
Jeff Niu [Fri, 15 Oct 2021 21:39:07 +0000 (21:39 +0000)]
[MLIR] Attribute and type formats in ODS

Declarative attribute and type formats with assembly formats. Define an
`assemblyFormat` field in attribute and type defs with a `mnemonic` to
generate a parser and printer.

```tablegen
def MyAttr : AttrDef<MyDialect, "MyAttr"> {
  let parameters = (ins "int64_t":$count, "AffineMap":$map);
  let mnemonic = "my_attr";
  let assemblyFormat = "`<` $count `,` $map `>`";
}
```

Use `struct` to define a comma-separated list of key-value pairs:

```tablegen
def MyType : TypeDef<MyDialect, "MyType"> {
  let parameters = (ins "int":$one, "int":$two, "int":$three);
  let mnemonic = "my_attr";
  let assemblyFormat = "`<` $three `:` struct($one, $two) `>`";
}
```

Use `struct(*)` to capture all parameters.

Reviewed By: rriddle

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

2 years ago[mlir][vector] Use dyn_cast instead of cast in patterns
Lei Zhang [Mon, 8 Nov 2021 17:33:55 +0000 (12:33 -0500)]
[mlir][vector] Use dyn_cast instead of cast in patterns

This avoids crashes when the pattern is applied to ops with
tensor semantics.

Reviewed By: ThomasRaoux

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

2 years agoRevert "[Clang/Test]: Rename enable_noundef_analysis to disable-noundef-analysis...
hyeongyu kim [Mon, 8 Nov 2021 17:09:49 +0000 (02:09 +0900)]
Revert "[Clang/Test]: Rename enable_noundef_analysis to disable-noundef-analysis and turn it off by default"

This reverts commit aacfbb953eb705af2ecfeb95a6262818fa85dd92.

Revert "Fix lit test failures in CodeGenCoroutines"

This reverts commit 63fff0f5bffe20fa2c84a45a41161afa0043cb34.

2 years ago[llvm] Use make_early_inc_range (NFC)
Kazu Hirata [Mon, 8 Nov 2021 17:09:39 +0000 (09:09 -0800)]
[llvm] Use make_early_inc_range (NFC)

2 years ago[LV] Use VScaleForTuning to fine-tune the cost per lane.
Sander de Smalen [Mon, 8 Nov 2021 15:24:31 +0000 (15:24 +0000)]
[LV] Use VScaleForTuning to fine-tune the cost per lane.

When targeting a specific CPU with scalable vectorization, the knowledge
of that particular CPU's vscale value can be used to tune the cost-model
and make the cost per lane less pessimistic.

If the target implements 'TTI.getVScaleForTuning()', the cost-per-lane
is calculated as:

  Cost / (VScaleForTuning * VF.KnownMinLanes)

Otherwise, it assumes a value of 1 meaning that the behavior
is unchanged and calculated as:

  Cost / VF.KnownMinLanes

Reviewed By: kmclaughlin, david-arm

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

2 years ago[fir] Add !fir.logical type conversion
Valentin Clement [Mon, 8 Nov 2021 16:52:22 +0000 (17:52 +0100)]
[fir] Add !fir.logical type conversion

Add conversion from !fir.logical types to LLVM IR Dialect types.

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

Reviewed By: kiranchandramohan

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years agoRevert "Making the code compliant to the documentation about Floating Point"
Aaron Ballman [Mon, 8 Nov 2021 16:43:49 +0000 (11:43 -0500)]
Revert "Making the code compliant to the documentation about Floating Point"

This reverts commit 438437cbb61a39ce27b3d6218ac426b8f8a0132e.

There are still broken bots from this:

https://lab.llvm.org/buildbot/#/builders/188/builds/5495
https://lab.llvm.org/buildbot/#/builders/171/builds/5710

2 years ago[ARM] Precommit i128 test from D111530
Simon Pilgrim [Mon, 8 Nov 2021 16:08:08 +0000 (16:08 +0000)]
[ARM] Precommit i128 test from D111530

2 years ago[gn build] Port 16b07c866ae7
LLVM GN Syncbot [Mon, 8 Nov 2021 15:59:52 +0000 (15:59 +0000)]
[gn build] Port 16b07c866ae7

2 years ago[clang-tidy] Add check for initialization of `absl::Cleanup`.
CJ Johnson [Mon, 8 Nov 2021 15:40:18 +0000 (15:40 +0000)]
[clang-tidy] Add check for initialization of `absl::Cleanup`.

Suggests switching the initialization pattern of `absl::Cleanup` instances from the factory function to class template argument deduction (CTAD) in C++17 and higher.

Reviewed By: ymandel

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

2 years ago[AMDGPU] Make getInstSizeInBytes more generic
Joe Nash [Fri, 5 Nov 2021 20:19:22 +0000 (16:19 -0400)]
[AMDGPU] Make getInstSizeInBytes more generic

NFC. This check mainly handles size affecting literals. Make it check all
explicit operands instead of a few by name. Also make the isLiteral
check handle the KIMM operands, see https://reviews.llvm.org/D111067

Change-Id: I1a362d55b2a10f5c74d445272e8b7829a8b77597

Reviewed By: arsenm

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

Change-Id: Ie6c688f30a71e0335d1c6dd1ff65019bd7ce684e

2 years ago[SCCP] Tune cast instruction handling for overdefined operand
Anton Afanasyev [Sun, 24 Oct 2021 19:43:12 +0000 (22:43 +0300)]
[SCCP] Tune cast instruction handling for overdefined operand

Extended value is known to be inside range smaller than full one.
Prevent SCCP to mark such value as overdefined.

Fixes PR52253

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

2 years ago[libc++][CI] Add AIX pipeline config
David Tenty [Tue, 19 Oct 2021 18:09:46 +0000 (14:09 -0400)]
[libc++][CI] Add AIX pipeline config

This changes adds the pipeline config for both 32-bit and 64-bit AIX targets. As well, we add a lit feature `LIBCXX-AIX-FIXME` which is used to mark the failing tests which remain to be investigated on AIX, so that the CI produces a clean build.

Reviewed By: #libc, ldionne

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

2 years ago[X86] combineMulToPMADDWD - use ComputeMinSignedBits(). NFCI.
Simon Pilgrim [Mon, 8 Nov 2021 15:02:27 +0000 (15:02 +0000)]
[X86] combineMulToPMADDWD - use ComputeMinSignedBits(). NFCI.

Use ComputeMinSignedBits() to ensure the mul source operands at least sign-extend down from the bottom 16 bits.

This will make it easier if/when we try to support handling of source types larger than 32-bits.

2 years ago[NFC][LoopVectorize] Make the createStepForVF interface more caller-friendly
David Sherwood [Wed, 3 Nov 2021 14:21:50 +0000 (14:21 +0000)]
[NFC][LoopVectorize] Make the createStepForVF interface more caller-friendly

The common use case for calling createStepForVF is currently something
like:

  Value *Step = createStepForVF(Builder, ConstantInt::get(Ty, UF), VF);

and it makes more sense to reduce overall lines of code and change the
function to let it create the constant instead. With my patch this
becomes:

  Value *Step = createStepForVF(Builder, Ty, VF, UF);

and the ConstantInt is created instead createStepForVF. A side-effect of
this is that the code in createStepForVF is also becomes simpler.

As part of this patch I've also replaced some calls to getRuntimeVF
with calls to createStepForVF, i.e.

  getRuntimeVF(Builder, Count->getType(), VFactor * UFactor) ->
  createStepForVF(Builder, Count->getType(), VFactor, UFactor)

because this feels semantically better.

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

2 years ago[LLVM][llvm-cfi] Inclusive language: replace uses of blacklist with ignorelist
Zarko Todorovski [Mon, 8 Nov 2021 14:44:26 +0000 (09:44 -0500)]
[LLVM][llvm-cfi] Inclusive language: replace uses of blacklist with ignorelist

Replace the description and file names for this argument. As far as I understand
this is a positional argument and I don't believe this changes breaks any existing
interfaces.

Reviewed By: hctim, MaskRay

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

2 years ago[nfc] Refactor CGGPUBuiltin to help review D112680
Jon Chesterfield [Mon, 8 Nov 2021 14:09:08 +0000 (14:09 +0000)]
[nfc] Refactor CGGPUBuiltin to help review D112680

2 years ago[AArch64][SVE] Add FP types to the supported SVE structure load/stores vector type...
Mindong Chen [Mon, 8 Nov 2021 14:27:35 +0000 (22:27 +0800)]
[AArch64][SVE] Add FP types to the supported SVE structure load/stores vector type list

This adds FP type support to the SVE Container type list as a supplement to D112303.

Reviewed By: peterwaller-arm, paulwalker-arm

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

2 years ago[NFC] Inclusive Language: change master to main for .chm files
Quinn Pham [Fri, 5 Nov 2021 17:33:13 +0000 (12:33 -0500)]
[NFC] Inclusive Language: change master to main for .chm files

[NFC] As part of using inclusive language within the llvm project,
this patch replaces master with main when referring to `.chm` files.

Reviewed By: teemperor

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

2 years ago[analyzer] Retrieve a value from list initialization of multi-dimensional array decla...
Denys Petrov [Fri, 22 Oct 2021 00:24:19 +0000 (03:24 +0300)]
[analyzer] Retrieve a value from list initialization of multi-dimensional array declaration.

Summary: Add support of multi-dimensional arrays in `RegionStoreManager::getBindingForElement`. Handle nested ElementRegion's getting offsets and checking for being in bounds. Get values from the nested initialization lists using obtained offsets.

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

2 years ago[DAG] Add SelectionDAG::ComputeMinSignedBits helper
Simon Pilgrim [Mon, 8 Nov 2021 14:12:35 +0000 (14:12 +0000)]
[DAG] Add SelectionDAG::ComputeMinSignedBits helper

As suggested on D113371, this adds a wrapper to SelectionDAG::ComputeNumSignBits, similar to the llvm::ComputeMinSignedBits wrapper.

I've included some usage, its not exhaustive, just the more obvious cases where the intention is obvious.

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

2 years ago[Test][SCCP] Precommit tests for PR52253
Anton Afanasyev [Sun, 24 Oct 2021 19:35:50 +0000 (22:35 +0300)]
[Test][SCCP] Precommit tests for PR52253

2 years ago[Test][SCCP] Update autogenerated test before precommit
Anton Afanasyev [Thu, 28 Oct 2021 14:21:51 +0000 (17:21 +0300)]
[Test][SCCP] Update autogenerated test before precommit

2 years ago[SVE][CodeGen] Improve codegen for some FP insert_subvector cases
David Sherwood [Fri, 5 Nov 2021 11:42:51 +0000 (11:42 +0000)]
[SVE][CodeGen] Improve codegen for some FP insert_subvector cases

When inserting an unpacked FP subvector into a packed vector we
can simply cast the unpacked value into a packed value, since
both types are legal for SVE. We can then use this as the input
for the UZP instruction. This avoids us expanding the operation
by going through the stack.

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

2 years agoMaking the code compliant to the documentation about Floating Point
Zahira Ammarguellat [Thu, 12 Aug 2021 20:13:16 +0000 (16:13 -0400)]
Making the code compliant to the documentation about Floating Point
support default values for C/C++. FPP-MODEL=PRECISE enables FFP-CONTRACT
FMA is enabled.

Fix for https://bugs.llvm.org/show_bug.cgi?id=50222

2 years ago[SPIR-V] Add SPIR-V triple and clang target info.
Anastasia Stulova [Mon, 8 Nov 2021 11:13:09 +0000 (11:13 +0000)]
[SPIR-V] Add SPIR-V triple and clang target info.

Add new triple and target info for ‘spirv32’ and ‘spirv64’ and,
thus, enabling clang (LLVM IR) code emission to SPIR-V target.

The target for SPIR-V is mostly reused from SPIR by derivation
from a common base class since IR output for SPIR-V is mostly
the same as SPIR. Some refactoring are made accordingly.

Added and updated tests for parts that are different between
SPIR and SPIR-V.

Patch by linjamaki (Henry Linjamäki)!

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

2 years agoRevert "Making the code compliant to the documentation about Floating Point"
Nico Weber [Mon, 8 Nov 2021 13:32:42 +0000 (08:32 -0500)]
Revert "Making the code compliant to the documentation about Floating Point"

This reverts commit 17d9560294eee1eae5e2d3ac1ab84f514318409e.
Breaks check-clang everywhere, see e.g.:
https://lab.llvm.org/buildbot/#/builders/105/builds/17229
https://lab.llvm.org/buildbot/#/builders/109/builds/25831
https://lab.llvm.org/buildbot/#/builders/188/builds/5493
https://lab.llvm.org/buildbot/#/builders/123/builds/7073

2 years ago[fir] Add fir.box type conversion
Valentin Clement [Mon, 8 Nov 2021 13:17:26 +0000 (14:17 +0100)]
[fir] Add fir.box type conversion

This patch add the `!fir.box` type conversion to llvm.
`fir.box` is converted to the descriptor as defined in the ISO_Fortran_binding.h
and the addendum defined in descriptor.h.

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

Reviewed By: awarzynski

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: V Donaldson <vdonaldson@nvidia.com>