platform/upstream/llvm.git
3 years ago[mlir] Add LinalgInterface method to clone with a given BlockAndValueMapping.
MaheshRavishankar [Wed, 3 Mar 2021 17:24:29 +0000 (09:24 -0800)]
[mlir] Add LinalgInterface method to clone with a given BlockAndValueMapping.

Since Linalg operations have regions by default which are not isolated
from above, add an another method to the interface that will take a
BlockAndValueMapping to remap the values within the region as well.

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

3 years agoFix a build warning from ea7d208
Philip Reames [Wed, 3 Mar 2021 17:16:56 +0000 (09:16 -0800)]
Fix a build warning from ea7d208

3 years ago[basicaa] Rewrite isGEPBaseAtNegativeOffset in terms of index difference [mostly...
Philip Reames [Wed, 3 Mar 2021 16:58:53 +0000 (08:58 -0800)]
[basicaa] Rewrite isGEPBaseAtNegativeOffset in terms of index difference [mostly NFC]

This is almost purely NFC, it just fits more obviously in the flow of the code now that we've standardized on the index different approach.  The non-NFC bit is that because of canceling the VariableOffsets in the subtract, we can now handle the case where both sides involve a common variable offset.  This isn't an "interesting" improvement; it just happens to fall out of the natural code structure.

One subtle point - the placement of this above the BaseAlias check is important in the original code as this can return NoAlias even when we can't find a relation between the bases otherwise.

Also added some enhancement TODOs noticed while understanding the existing code.

Note: This is slightly different than the LGTMed version.  I fixed the "inbounds" issue Nikita noticed with the original code in e6e5ef4 and rebased this to include the same fix.

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

3 years ago[VirtRegRewriter] Insert missing killed flags when tracking subregister liveness
Baptiste Saleil [Wed, 3 Mar 2021 16:57:42 +0000 (11:57 -0500)]
[VirtRegRewriter] Insert missing killed flags when tracking subregister liveness

VirtRegRewriter may sometimes fail to correctly apply the kill flag where necessary,
which causes unecessary code gen on PowerPC. This patch fixes the way masks for
defined lanes are computed and the way mask for used lanes is computed.

Contact albion.fung@ibm.com instead of author for problems related to this commit.

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

3 years ago[basicaa] Fix a latent bug in isGEPBaseAtNegativeOffset
Philip Reames [Wed, 3 Mar 2021 16:43:32 +0000 (08:43 -0800)]
[basicaa] Fix a latent bug in isGEPBaseAtNegativeOffset

This was pointed out in review of D97520 by Nikita, but existed in the original code as well.

The basic issue is that a decomposed GEP expression describes (potentially) more than one getelementptr.  The "inbounds" derived UB which justifies this aliasing rule requires that the entire offset be composed of "inbounds" geps.  Otherwise, as can be seen in the recently added and changes in this patch test, we can end up with a large commulative offset with only a small sub-offset actually being "inbounds".  If that small sub-offset lies within the object, the result was unsound.

We could potentially be fancier here, but for the moment, simply be conservative when any of the GEPs parsed aren't inbounds.

3 years ago[basicaa] Minor indentation fix
Philip Reames [Wed, 3 Mar 2021 16:31:52 +0000 (08:31 -0800)]
[basicaa] Minor indentation fix

3 years ago[pstl] Fix broken policy_traits and clean up unused code
Louis Dionne [Tue, 2 Mar 2021 21:53:07 +0000 (16:53 -0500)]
[pstl] Fix broken policy_traits and clean up unused code

https://llvm.org/PR47602
https://llvm.org/PR47601

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

3 years ago[tests] Add tests for cases brought up during review of D97520
Philip Reames [Wed, 3 Mar 2021 16:30:36 +0000 (08:30 -0800)]
[tests] Add tests for cases brought up during review of D97520

3 years ago[coro async] Allow a coro.suspend.async to specify which argument is the context...
Arnold Schwaighofer [Tue, 23 Feb 2021 18:01:35 +0000 (10:01 -0800)]
[coro async] Allow a coro.suspend.async to specify which argument is the context argument

Before we used the same argument as the entry point. The resume partial
function might want to use a different ABI for its context argument

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

3 years ago[mlir][Shape] Lower cstr_eq to shape_eq + assert
Benjamin Kramer [Mon, 1 Mar 2021 19:41:12 +0000 (20:41 +0100)]
[mlir][Shape] Lower cstr_eq to shape_eq + assert

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

3 years ago[clang-tidy] Deprecate readability-deleted-default check
Nathan James [Wed, 3 Mar 2021 16:01:12 +0000 (16:01 +0000)]
[clang-tidy] Deprecate readability-deleted-default check

... For removal in next release cycle.
The clang warning that does the same thing is enabled by default and typically emits better diagnostics making this check surplus to requirements.

Reviewed By: aaron.ballman

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

3 years ago[clang-query] Fix help text after D91918
Nathan James [Wed, 3 Mar 2021 15:57:49 +0000 (15:57 +0000)]
[clang-query] Fix help text after D91918

After rG5e1801813d93210acae84ff3c68a01512c2df9bc The help command still lists IgnoreImplicitCastsAndParentheses as a valid option.

Reviewed By: aaron.ballman, rsmith

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

3 years ago[X86] Fold scalar_to_vector(x) -> extract_subvector(broadcast(x),0) iff broadcast...
Simon Pilgrim [Wed, 3 Mar 2021 15:30:32 +0000 (15:30 +0000)]
[X86] Fold scalar_to_vector(x) -> extract_subvector(broadcast(x),0) iff broadcast(x) exists

Add handling for reusing an existing broadcast(x) to a wider vector.

3 years ago[AIX][clang][driver] Restrict /usr/lib to internal library search paths
David Tenty [Thu, 25 Feb 2021 04:41:53 +0000 (23:41 -0500)]
[AIX][clang][driver] Restrict /usr/lib to internal library search paths

Adding it to the general filepaths results in it being added to the
linker arguments. The AIX linker always looks in this path anyway
and adds it as a default library path component. Adding this duplicate
explicitly results in duplicate entries in path in the loader section
of executables and messes up tools like CMake that parse the default
library flags.

Reviewed By: ZarkoCA

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

3 years ago[test] Fix apparent typo in clang/test/Driver/std.c
Daniel McIntosh [Wed, 3 Mar 2021 15:29:37 +0000 (10:29 -0500)]
[test] Fix apparent typo in clang/test/Driver/std.c

Currently the test on line 3 is identical to the test on line 1.
Looking at the rest of the file (particularily the use of FOVERRIDE
as the check-prefix), I think it's pretty clear that this line
was supposed to use `-ftrigraphs` instead of `-trigraphs`.

Reviewed By: thakis

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

3 years ago[mlir][Shape] Make shape_eq nary
Benjamin Kramer [Mon, 1 Mar 2021 19:34:17 +0000 (20:34 +0100)]
[mlir][Shape] Make shape_eq nary

This gets rid of a dubious shape_eq %a, %a fold, that folds shape_eq
even if %a is not an Attribute.

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

3 years agoRevert "[InstrProfiling] Place __llvm_prf_vnodes and __llvm_prf_names in llvm.used...
Nico Weber [Wed, 3 Mar 2021 15:17:31 +0000 (10:17 -0500)]
Revert "[InstrProfiling] Place __llvm_prf_vnodes and __llvm_prf_names in llvm.used on ELF"

This reverts commit 04c3040f417683e7c31b3ee3381a3263106f48c5.
Breaks instrprof-value-merge.c in bootstrap builds.

3 years ago[mlir][Shape] Make cstr_eq more like cstr_broadcastable
Benjamin Kramer [Mon, 1 Mar 2021 19:14:06 +0000 (20:14 +0100)]
[mlir][Shape] Make cstr_eq more like cstr_broadcastable

This includes allowing extents and not just shapes.

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

3 years ago[clang][patch] To solve PR26413, x86 interrupt routines may only call routines with...
Melanie Blower [Tue, 2 Mar 2021 12:58:42 +0000 (07:58 -0500)]
[clang][patch] To solve PR26413, x86 interrupt routines may only call routines with no_saved_reg

Reviewed By: Aaron Ballman

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

3 years agoImplement P2173 for attributes on lambdas
Aaron Ballman [Wed, 3 Mar 2021 15:02:51 +0000 (10:02 -0500)]
Implement P2173 for attributes on lambdas

https://wg21.link/P2173 is making its way through WG21 currently and
has not been formally adopted yet. This feature provides very useful
functionality in that you can specify attributes on the various
function *declarations* generated by a lambda expression, where the
current C++ grammar only allows attributes which apply to the various
function *types* so generated.

This patch implements P2173 on the assumption that it will be adopted
by WG21 with this syntax for C++23.

3 years ago[OpenCL] Prevent adding extension pragma by default.
Anastasia Stulova [Wed, 3 Mar 2021 12:05:38 +0000 (12:05 +0000)]
[OpenCL] Prevent adding extension pragma by default.

This commit refactors extension support to allow
specifying whether pragma is needed or not explicitly.

For backward compatibility pragmas are set to required
for all extensions that were added prior to this but
not for OpenCL 3.0 features.

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

3 years agoRevert "[ObjC][ARC] Use operand bundle 'clang.arc.attachedcall' instead of explicitly...
Hans Wennborg [Wed, 3 Mar 2021 14:50:08 +0000 (15:50 +0100)]
Revert "[ObjC][ARC] Use operand bundle 'clang.arc.attachedcall' instead of explicitly emitting retainRV or claimRV calls in the IR"

This caused miscompiles of Chromium tests for iOS due clobbering of live
registers. See discussion on the code review for details.

> Background:
>
> This fixes a longstanding problem where llvm breaks ARC's autorelease
> optimization (see the link below) by separating calls from the marker
> instructions or retainRV/claimRV calls. The backend changes are in
> https://reviews.llvm.org/D92569.
>
> https://clang.llvm.org/docs/AutomaticReferenceCounting.html#arc-runtime-objc-autoreleasereturnvalue
>
> What this patch does to fix the problem:
>
> - The front-end adds operand bundle "clang.arc.attachedcall" to calls,
>   which indicates the call is implicitly followed by a marker
>   instruction and an implicit retainRV/claimRV call that consumes the
>   call result. In addition, it emits a call to
>   @llvm.objc.clang.arc.noop.use, which consumes the call result, to
>   prevent the middle-end passes from changing the return type of the
>   called function. This is currently done only when the target is arm64
>   and the optimization level is higher than -O0.
>
> - ARC optimizer temporarily emits retainRV/claimRV calls after the calls
>   with the operand bundle in the IR and removes the inserted calls after
>   processing the function.
>
> - ARC contract pass emits retainRV/claimRV calls after the call with the
>   operand bundle. It doesn't remove the operand bundle on the call since
>   the backend needs it to emit the marker instruction. The retainRV and
>   claimRV calls are emitted late in the pipeline to prevent optimization
>   passes from transforming the IR in a way that makes it harder for the
>   ARC middle-end passes to figure out the def-use relationship between
>   the call and the retainRV/claimRV calls (which is the cause of
>   PR31925).
>
> - The function inliner removes an autoreleaseRV call in the callee if
>   nothing in the callee prevents it from being paired up with the
>   retainRV/claimRV call in the caller. It then inserts a release call if
>   claimRV is attached to the call since autoreleaseRV+claimRV is
>   equivalent to a release. If it cannot find an autoreleaseRV call, it
>   tries to transfer the operand bundle to a function call in the callee.
>   This is important since the ARC optimizer can remove the autoreleaseRV
>   returning the callee result, which makes it impossible to pair it up
>   with the retainRV/claimRV call in the caller. If that fails, it simply
>   emits a retain call in the IR if retainRV is attached to the call and
>   does nothing if claimRV is attached to it.
>
> - SCCP refrains from replacing the return value of a call with a
>   constant value if the call has the operand bundle. This ensures the
>   call always has at least one user (the call to
>   @llvm.objc.clang.arc.noop.use).
>
> - This patch also fixes a bug in replaceUsesOfNonProtoConstant where
>   multiple operand bundles of the same kind were being added to a call.
>
> Future work:
>
> - Use the operand bundle on x86-64.
>
> - Fix the auto upgrader to convert call+retainRV/claimRV pairs into
>   calls with the operand bundles.
>
> rdar://71443534
>
> Differential Revision: https://reviews.llvm.org/D92808

This reverts commit ed4718eccb12bd42214ca4fb17d196d49561c0c7.

3 years agorevert llvm/include/llvm/Analysis/ObjCARCUtil.h part of 1cc558bd4fa1acd1462226ef4796c...
Hans Wennborg [Wed, 3 Mar 2021 14:50:02 +0000 (15:50 +0100)]
revert llvm/include/llvm/Analysis/ObjCARCUtil.h part of 1cc558bd4fa1acd1462226ef4796c712f80ea8e8

3 years ago[clangd] Make WorkspaceSymbols request work with empty queries
Kadir Cetinkaya [Tue, 2 Mar 2021 15:43:21 +0000 (16:43 +0100)]
[clangd] Make WorkspaceSymbols request work with empty queries

Clangd uses codecompletion limit as the limit for workspacesymbols, so
in theory this should only be an order of magnitude slower than a
codecompletion request with empty identifier (as code completion limits
the available symbols).

This is also what LSP suggests "Clients may send an empty string here to request all symbols.".
Clangd doesn't really fulfill the "all" part of that statement, but we
never do unless user set the index query limit to zero explicitly.

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

3 years ago[AVR] Fix def state of operands
Ayke van Laethem [Sun, 21 Feb 2021 19:23:46 +0000 (20:23 +0100)]
[AVR] Fix def state of operands

Some instructions (especially mov+pop instructions) were setting the
wrong operands. For example, the pop instruction had the register set as
a source operand while it is a destination operand (the value is loaded
into the register).

I have found these issues using the machine verifier and using manual
code inspection.

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

3 years ago[AVR] Fix expansion of NEGW
Ayke van Laethem [Sun, 21 Feb 2021 00:23:02 +0000 (01:23 +0100)]
[AVR] Fix expansion of NEGW

The previous expansion used SBCI, which is incorrect because the NEGW
pseudo instruction accepts a DREGS operand (2xGPR8) and SBCI only allows
LD8 registers. One solution could be to correct the NEGW pseudo
instruction, but another solution is to use a different instruction
(sbc) that does accept a GPR8 register and therefore allows more freedom
to the register allocator.

The output now matches avr-gcc for the following code:

    int foo(int n) {
        return -n;
    }

I've found this issue using the machine instruction verifier: it was
complaining about the wrong register class in NEGWRd.mir.

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

3 years ago[AVR] Add register aliases XL, YH, etc
Ayke van Laethem [Thu, 11 Feb 2021 13:07:53 +0000 (14:07 +0100)]
[AVR] Add register aliases XL, YH, etc

These aliases are sometimes used in assembly code and make the code more
readable. They are supported by avr-gcc too.

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

3 years agoGlobalISel: Add default implementation of assignValueToReg
Matt Arsenault [Tue, 2 Mar 2021 22:40:50 +0000 (17:40 -0500)]
GlobalISel: Add default implementation of assignValueToReg

Refactor insertion of the asserting ops. This enables using them for
AMDGPU.

This code should essentially be the same for every target. Mips, X86
and ARM all have different code there now, but this seems to be an
accident. The assignment functions are called with different types
than they would be in the DAG, so this is all likely an assortment of
hacks to get around that.

3 years agoImprove static_assert/_Static_assert diagnostics
Aaron Ballman [Wed, 3 Mar 2021 13:44:04 +0000 (08:44 -0500)]
Improve static_assert/_Static_assert diagnostics

Our diagnostics relating to static assertions were a bit confused. For
instance, when in MS compatibility mode in C (where we accept
static_assert even without including <assert.h>), we would fail
to warn the user that they were using the wrong spelling (even in
pedantic mode), we were missing a compatibility warning about using
_Static_assert in earlier standards modes, diagnostics for the optional
message were not reflected in C as they were in C++, etc.

3 years ago[AMDGPU] Introduce Strict WQM mode
Piotr Sobczak [Wed, 3 Mar 2021 09:18:28 +0000 (10:18 +0100)]
[AMDGPU] Introduce Strict WQM mode

* Add amdgcn_strict_wqm intrinsic.
* Add a corresponding STRICT_WQM machine instruction.
* The semantic is similar to amdgcn_strict_wwm with a notable difference that not all threads will be forcibly enabled during the computations of the intrinsic's argument, but only all threads in quads that have at least one thread active.
* The difference between amdgc_wqm and amdgcn_strict_wqm, is that in the strict mode an inactive lane will always be enabled irrespective of control flow decisions.

Reviewed By: critson

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

3 years ago[mlir][ODS] Use StringLiteral instead of StringRef when applicable
Vladislav Vinogradov [Thu, 4 Feb 2021 17:12:15 +0000 (17:12 +0000)]
[mlir][ODS] Use StringLiteral instead of StringRef when applicable

Use `StringLiteral` for function return type if it is known to return
constant string literals only.

This will make it visible to API users, that such values can be safely
stored, since they refers to constant data, which will never be deallocated.

`StringRef` is general is not safe to store for a long term,
since it might refer to temporal data allocated in heap.

Add `inline` and `constexpr` methods support to `OpMethod`.

Reviewed By: mehdi_amini

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

3 years ago[mlir][NFC] Use `BaseMemRefType::isValidElementType` in Parser
Vladislav Vinogradov [Sat, 27 Feb 2021 11:08:43 +0000 (14:08 +0300)]
[mlir][NFC] Use `BaseMemRefType::isValidElementType` in Parser

Instead of hard-coded check.

Reviewed By: ftynse, rriddle

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

3 years ago[mlir] Silence -Wglobal-constructors error in CudaRuntimeWrapper.cpp
Christian Sigg [Wed, 3 Mar 2021 12:46:03 +0000 (13:46 +0100)]
[mlir] Silence -Wglobal-constructors error in CudaRuntimeWrapper.cpp

Until I have a better solution with dynamic initialization, to get
the nvidia build bot green again.

3 years ago[lldb][NFC] Delete unused AddressResolverName
Raphael Isemann [Wed, 3 Mar 2021 12:29:51 +0000 (13:29 +0100)]
[lldb][NFC] Delete unused AddressResolverName

That's all just dead code that hasn't been changed in years.

Reviewed By: JDevlieghere

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

3 years ago[mlir] Move cuda tests
Christian Sigg [Wed, 3 Mar 2021 10:24:38 +0000 (11:24 +0100)]
[mlir] Move cuda tests

Move test inputs to test/Integration directory.
Move runtime wrappers to ExecutionEngine.

Reviewed By: mehdi_amini

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

3 years ago[ASTMatchers] Make Param functors variadic
Stephen Kelly [Wed, 13 Jan 2021 03:07:03 +0000 (03:07 +0000)]
[ASTMatchers] Make Param functors variadic

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

3 years ago[clangd] Fix uninit member
Sam McCall [Wed, 3 Mar 2021 10:45:16 +0000 (11:45 +0100)]
[clangd] Fix uninit member

3 years ago[AArch64] Add missing intrinsics for vcls
JinGu Kang [Tue, 2 Mar 2021 09:54:44 +0000 (09:54 +0000)]
[AArch64] Add missing intrinsics for vcls

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

3 years ago[lld][MachO] Silence "enumeral and non-enumeral type" warning from gcc
Mikael Holmen [Wed, 3 Mar 2021 09:17:42 +0000 (10:17 +0100)]
[lld][MachO] Silence "enumeral and non-enumeral type" warning from gcc

gcc complained with

[1110/1140] Building CXX object tools/lld/MachO/CMakeFiles/lldMachO2.dir/SyntheticSections.cpp.o
../../lld/MachO/SyntheticSections.cpp: In function 'int16_t ordinalForDylibSymbol(const lld::macho::DylibSymbol&)':
../../lld/MachO/SyntheticSections.cpp:287:14: warning: enumeral and non-enumeral type in conditional expression [-Wextra]
  286 |   return config->namespaceKind == NamespaceKind::flat || dysym.isDynamicLookup()
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  287 |              ? MachO::BIND_SPECIAL_DYLIB_FLAT_LOOKUP
      |              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  288 |              : dysym.getFile()->ordinal;
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~

3 years ago[lldb] Fix handling of `DW_AT_decl_file` according to D91014 (attempt #2)
Andy Yankovsky [Tue, 2 Mar 2021 13:28:34 +0000 (14:28 +0100)]
[lldb] Fix handling of `DW_AT_decl_file` according to D91014 (attempt #2)

Apply changes from https://reviews.llvm.org/D91014 to other places where DWARF entries are being processed.

Test case is provided by @jankratochvil.
The test is marked to run only on x64 and exclude Windows and Darwin, because the assembly is not OS-independent.

(First attempt https://reviews.llvm.org/D96778 broke the build bots)

Reviewed By: jankratochvil

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

3 years ago[AMDGPU] Rename amdgcn_wwm to amdgcn_strict_wwm
Piotr Sobczak [Tue, 2 Mar 2021 08:38:07 +0000 (09:38 +0100)]
[AMDGPU] Rename amdgcn_wwm to amdgcn_strict_wwm

 * Introduce the new intrinsic amdgcn_strict_wwm
 * Deprecate the old intrinsic amdgcn_wwm

The change is done for consistency as the "strict"
prefix will become an important, distinguishing factor
between amdgcn_wqm and amdgcn_strictwqm in the future.

The "strict" prefix indicates that inactive lanes do not
take part in control flow, specifically an inactive lane
enabled by a strict mode will always be enabled irrespective
of control flow decisions.

The amdgcn_wwm will be removed, but doing so in two steps
gives users time to switch to the new name at their own pace.

Reviewed By: critson

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

3 years ago[AMDGPU] Rename llvm.amdgcn.msaa.load to llvm.amdgcn.msaa.load.x
Carl Ritson [Wed, 3 Mar 2021 08:09:57 +0000 (17:09 +0900)]
[AMDGPU] Rename llvm.amdgcn.msaa.load to llvm.amdgcn.msaa.load.x

While the underlying instruction is called image_msaa_load,
the resource must be x component only.
Rename the intrinsic for clarity.

Reviewed By: foad

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

3 years ago[FileCheck] Do not skip end of line in diagnostics
Thomas Preud'homme [Tue, 15 Dec 2020 00:58:16 +0000 (00:58 +0000)]
[FileCheck] Do not skip end of line in diagnostics

When commit da108b4ed4e6e7267701e76d5fd3b87609c9ab77 introduced
the CHECK-NEXT directive, it added logic to skip to the next line when
printing a diagnostic if the current matching position is at the end of
a line. This was fine while FileCheck did not support regular expression
but since it does now it can be confusing when the pattern to match
starts with the expectation of a newline (e.g. CHECK-NEXT: {{\n}}foo).
It is also inconsistent with the column information in the diagnostic
which does point to the end of line.

This commit removes this logic altogether, such that failure to match
diagnostic for such cases would show the end of line and be consistent
with the column information. The commit also adapts all existing
testcases accordingly.

Note to reviewers: An alternative approach would be to restrict the code
to only skip to the next line if the first character of the pattern is
known not to match a whitespace-like character. This would respect the
original intent but keep the inconsistency in terms of column info and
requires more code. I've only chosen this current approach by laziness
and would be happy to restrict the logic instead.

Reviewed By: jdenny, jhenderson

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

3 years ago[runtimes] Use standalone build only for compiler-rt
Petr Hosek [Fri, 26 Feb 2021 20:52:53 +0000 (12:52 -0800)]
[runtimes] Use standalone build only for compiler-rt

compiler-rt needs to use standalone build because of the assumptions
made by its build, but other runtimes can use non-standalone build.

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

3 years ago[ARM] Ensure undef is propagated to CBZ/CBNZ flags
David Green [Wed, 3 Mar 2021 08:02:58 +0000 (08:02 +0000)]
[ARM] Ensure undef is propagated to CBZ/CBNZ flags

In some rare circumstances we can be using an undef register for a
compare. When folded into a CBZ/CBNZ the undef flags are lost, leading
to machine verifier problems. This propagates the existing flags to the
new instruction.

3 years ago[WebAssembly] Swap operand order of call_indirect in text format
Andy Wingo [Tue, 2 Mar 2021 11:18:16 +0000 (12:18 +0100)]
[WebAssembly] Swap operand order of call_indirect in text format

The WebAssembly text and binary formats have different operand orders
for the "type" and "table" fields of call_indirect (and
return_call_indirect).  In LLVM we use the binary order for the MCInstr,
but when we produce or consume the text format we should use the text
order.  For compilation units targetting WebAssembly 1.0 (without the
reference types feature), we omit the table operand entirely.

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

3 years ago[Polly] Refabricating IsOutermostParallel() from Integer Set Libarary(ISL) to take...
Prateek Pardeshi [Wed, 3 Mar 2021 07:29:35 +0000 (01:29 -0600)]
[Polly] Refabricating IsOutermostParallel() from Integer Set Libarary(ISL) to take the C++ wrapper

Polly use algorithms from the Integer Set Library (isl), which is a library written in C and which is incompatible with the rest of the LLVM  as it is written in C++.

Changes made:
* Refabricating IsOutermostParallel() to take C++ bindings instead of reference-counting in C isl lib.
* Addition of manage_copy() to be used as reference for C objects instead of IsOutermostParallel()

Reviewed By: Meinersbur

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

3 years ago[RISCV] Use RISCVV_BUILTIN for vector intrinsic checking.
Hsiangkai Wang [Wed, 3 Mar 2021 01:41:31 +0000 (09:41 +0800)]
[RISCV] Use RISCVV_BUILTIN for vector intrinsic checking.

There may be other BUILTINs for other extensions. Use RISCVV_BUILTIN for
vector builtin checking.

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

3 years ago[PowerPC] Allow spilling GPR to VSR on AIX
Qiu Chaofan [Wed, 3 Mar 2021 05:32:39 +0000 (13:32 +0800)]
[PowerPC] Allow spilling GPR to VSR on AIX

This patch enables spilling GPR to VSRs instead of stack under AIX ABI.

Reviewed By: nemanjai

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

3 years ago[LegalizeVectorTypes] Improve SplitVecRes_INSERT_SUBVECTOR to handle subvector being...
Craig Topper [Wed, 3 Mar 2021 05:03:36 +0000 (21:03 -0800)]
[LegalizeVectorTypes] Improve SplitVecRes_INSERT_SUBVECTOR to handle subvector being in the high half of the split or not at element 0 of the low half.

This function isn't exercised in lit tests today today according to
the code coverage report. But will be after the tests in D97543 and
D97559.

Posting this patch to help a crash that Fraser hit.

Reviewed By: frasercrmck

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

3 years agoFix the build error caused by D97570
Jianzhou Zhao [Wed, 3 Mar 2021 04:47:00 +0000 (04:47 +0000)]
Fix the build error caused by D97570

3 years ago[dfsan] Propagate origin tracking at load
Jianzhou Zhao [Fri, 26 Feb 2021 19:41:49 +0000 (19:41 +0000)]
[dfsan] Propagate origin tracking at load

This is a part of https://reviews.llvm.org/D95835.

One issue is about origin load optimization: see the
comments of useCallbackLoadLabelAndOrigin

@gbalats This change may have some conflicts with your 8bit change. PTAL the change at visitLoad.

Reviewed By: morehouse, gbalats

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

3 years ago[clang][NFC] pack StaticDiagInfoRec
Nathan James [Wed, 3 Mar 2021 02:53:09 +0000 (02:53 +0000)]
[clang][NFC] pack StaticDiagInfoRec

Exchanging types, reordering fields and borrowing a bit from OptionGroupIndex shrinks this from 12 bytes to 8.
This knocks ~20k from the binary size.

Reviewed By: aaron.ballman

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

3 years ago[clang-tidy][NFC] Use equalsBoundNode matchers to simplify LoopConvertCheck
Nathan James [Wed, 3 Mar 2021 02:51:33 +0000 (02:51 +0000)]
[clang-tidy][NFC] Use equalsBoundNode matchers to simplify LoopConvertCheck

Make use of the `equalsBoundNode` matcher to ensure Init, Conditon and Increment variables all refer to the same variable during matching.

Reviewed By: steveire

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

3 years ago[NFC] Add x86_amx and some missed half, bfloat keywords to llvm plugin syntaxes
Wang, Pengfei [Wed, 3 Mar 2021 02:00:10 +0000 (10:00 +0800)]
[NFC] Add x86_amx and some missed half, bfloat keywords to llvm plugin syntaxes

Reviewed By: LuoYuanke

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

3 years ago[dfsan] Fix clang-tidy warnings
George Balatsouras [Tue, 2 Mar 2021 22:56:16 +0000 (14:56 -0800)]
[dfsan] Fix clang-tidy warnings

This addresses ~50 clang-tidy warnings on dfsan instrumentation pass.
It also contains some refactoring (all non-functional changes) to eliminate some variables and simplify code.

Reviewed By: stephan.yichao.zhao

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

3 years ago[clang-tidy] performance-for-range-copy: Don't trigger on implicit type conversions.
Felix Berger [Fri, 26 Feb 2021 21:27:06 +0000 (16:27 -0500)]
[clang-tidy] performance-for-range-copy: Don't trigger on implicit type conversions.

This disables the check for false positive cases where implicit type conversion
through either an implicit single argument constructor or a member conversion
operator is triggered when constructing the loop variable.

Fix the test cases that meant to cover these cases.

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

Reviewed-by: hokein
3 years agoRevert "[runtimes] Use standalone build only for compiler-rt"
Petr Hosek [Wed, 3 Mar 2021 00:59:32 +0000 (16:59 -0800)]
Revert "[runtimes] Use standalone build only for compiler-rt"

This reverts commit 4e421b2323b38e94e82ac71e5a4dfd78f6744e87 as this
seemed to have broke Python 3 executable detection on some builders.

3 years ago[CMake] Enable Polly for Fuchsia toolchain build
Petr Hosek [Wed, 3 Mar 2021 00:37:50 +0000 (16:37 -0800)]
[CMake] Enable Polly for Fuchsia toolchain build

We want to enable the use of Polly in Fuchsia.

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

3 years ago[lldb] Inline objc_opt->version >= 14 to avoid dealing with bool type
Jonas Devlieghere [Wed, 3 Mar 2021 00:41:42 +0000 (16:41 -0800)]
[lldb] Inline objc_opt->version >= 14 to avoid dealing with bool type

3 years ago[lldb] Add more logging to __lldb_apple_objc_v2_get_dynamic_class_info
Jonas Devlieghere [Wed, 3 Mar 2021 00:24:37 +0000 (16:24 -0800)]
[lldb] Add more logging to __lldb_apple_objc_v2_get_dynamic_class_info

3 years ago[AIX][TLS] Generate TLS variables in assembly files
Victor Huang [Wed, 3 Mar 2021 00:16:14 +0000 (18:16 -0600)]
[AIX][TLS] Generate TLS variables in assembly files

This patch allows generating TLS variables in assembly files on AIX.
Initialized and external uninitialized variables are generated with the
.csect pseudo-op and local uninitialized variables are generated with
the .comm/.lcomm pseudo-ops. The patch also adds a check to
explicitly say that TLS is not yet supported on AIX.

Reviewed by: daltenty, jasonliu, lei, nemanjai, sfertile
Originally patched by: bsaleil
Commandeered by: NeHuang

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

3 years ago[runtimes] Use standalone build only for compiler-rt
Petr Hosek [Fri, 26 Feb 2021 20:52:53 +0000 (12:52 -0800)]
[runtimes] Use standalone build only for compiler-rt

compiler-rt needs to use standalone build because of the assumptions
made by its build, but other runtimes can use non-standalone build.

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

3 years ago[libc++] Add bind_front function (P0356R5).
zoecarver [Wed, 3 Mar 2021 00:17:22 +0000 (16:17 -0800)]
[libc++] Add bind_front function (P0356R5).

Implementes [[ http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0356r5.html | P0356R5 ]]. Adds `bind_front` to `functional`.

Reviewed By: ldionne, #libc, Quuxplusone

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

3 years ago[lldb] Extend Python convenience variable table with equivalent APIs
Jonas Devlieghere [Wed, 3 Mar 2021 00:11:34 +0000 (16:11 -0800)]
[lldb] Extend Python convenience variable table with equivalent APIs

Add a column to the table of convenience variables with the equivalent
API to get to the current debugger, target, process, etc.

We often get asked to make convenience variables available outside of
the interactive interpreter. After explaining why that's not possible, a
common complaint is that it's hard to find out how to get to these
variables in a non-interactive context, for example how to get to the
current frame when given a thread. This patch aims to alleviate that by
including the APIs to navigate between these instances in the table.

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

3 years agoMigrate to llvm::unique_function instead of static member functions for callbacks
Neal (nealsid) [Tue, 2 Mar 2021 03:50:27 +0000 (19:50 -0800)]
Migrate to llvm::unique_function instead of static member functions for callbacks

A few cleanups suggested in another patch review's comments:

1. Use llvm:unique_function for storing & invoking callbacks from
   Editline to IOHandler
2. Change return type of one of the callback setters from bool to void,
   since it's return value was never used
3. Moved the callback setters inline & made them nonstatic, since that's
   more consistent with other setter definitions
4. Removed the baton parameter since we no longer need it anymore

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

3 years ago[opt] Error if -debug-pass is specified alongside the new PM
Arthur Eubanks [Tue, 2 Mar 2021 22:49:46 +0000 (14:49 -0800)]
[opt] Error if -debug-pass is specified alongside the new PM

Reviewed By: ychen

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

3 years ago[NFCI][VPlan] Modify Recipes' print methods to honor Indent parameter
Andrei Elovikov [Tue, 2 Mar 2021 23:08:19 +0000 (15:08 -0800)]
[NFCI][VPlan] Modify Recipes' print methods to honor Indent parameter

Reviewed By: fhahn

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

3 years ago[test] Fix CodeGen/VE/Scalar tests
Fangrui Song [Tue, 2 Mar 2021 23:30:44 +0000 (15:30 -0800)]
[test] Fix CodeGen/VE/Scalar tests

3 years ago[mlir][sparse] do not ignore ordering for "dense" tensor linked with sparse type
Aart Bik [Tue, 2 Mar 2021 20:17:13 +0000 (12:17 -0800)]
[mlir][sparse] do not ignore ordering for "dense" tensor linked with sparse type

Reviewed By: bixia

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

3 years ago[flang] Detect circularly defined interfaces of procedures
Peter Steinfeld [Tue, 2 Mar 2021 15:53:10 +0000 (07:53 -0800)]
[flang] Detect circularly defined interfaces of procedures

It's possible to define a procedure whose interface depends on a procedure
which has an interface that depends on the original procedure.  Such a circular
definition was causing the compiler to fall into an infinite loop when
resolving the name of the second procedure.  It's also possible to create
circular dependency chains of more than two procedures.

I fixed this by adding the function HasCycle() to the class DeclarationVisitor
and calling it from DeclareProcEntity() to detect procedures with such
circularly defined interfaces.  I marked the associated symbols of such
procedures by calling SetError() on them.  When processing subsequent
procedures, I called HasError() before attempting to analyze their interfaces.
Unfortunately, this did not work.

With help from Tim, we determined that the SymbolSet used to track the
erroneous symbols was instantiated using a "<" operator which was defined using
the location of the name of the procedure.  But the location of the procedure
name was being changed by a call to ReplaceName() between the times that the
calls to SetError() and HasError() were made.  This caused HasError() to
incorrectly report that a symbol was not in the set of erroneous symbols.

I fixed this by changing SymbolSet to be an unordered set that uses the
contents of the name of the symbol as the basis for its hash function.  This
works because the contents of the name of the symbol is preserved by
ReplaceName() even though its location changes.

I also fixed the error message used when reporting recursively defined
dummy procedure arguments by removing extra apostrophes and sorting the
list of symbols.

I also added tests that will crash the compiler without this change.

Note that the "<" operator is used in other contexts, for example, in the map
of characterized procedures, maps of items in equivalence sets, maps of
structure constructor values, ...  All of these situations happen after name
resolution has been completed and all calls to ReplaceName() have already
happened and thus are not subject to the problem I ran into when ReplaceName()
was called when processing procedure entities.

Note also that the implementation of the "<" operator uses the relative
location in the cooked character stream as the basis of its implementation.
This is potentially problematic when symbols from diffent compilation units
(for example symbols originating in .mod files) are put into the same map since
their names will appear in two different source streams which may not be
allocated in the same relative positions in memory.  But I was unable to create
a test that caused a problem.  Using a direct comparison of the content of the
name of the symbol in the "<" operator has problems.  Symbols in enclosing or
parallel scopes can have the same name.  Also using the location of the symbol
in the cooked character stream has the advantage that it preserves the the
order of the symbols in a structure constructor constant, which makes matching
the values with the symbols relatively easy.

This patch supersedes D97749.

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

3 years agohack to unbreak check-llvm on win after https://reviews.llvm.org/D97335
Nico Weber [Tue, 2 Mar 2021 23:10:25 +0000 (18:10 -0500)]
hack to unbreak check-llvm on win after https://reviews.llvm.org/D97335

fix attempt http://reviews.llvm.org/rGbbdb4c8c9bcef0e didn't work

The problem is that the test tries to look up
llvm_orc_registerJITLoaderGDBWrapper from the llvm-jitlink.exe
executable, but the symbol wasn't exported. Just manually export it
for now. There's a FIXME with a suggestion for a real fix.

3 years ago[libunwind] [risc-v] This patch is for fixing
Kamlesh Kumar [Tue, 2 Mar 2021 23:02:47 +0000 (04:32 +0530)]
[libunwind] [risc-v] This patch is for fixing
immediate build failure when Cross Unwinding enabled.
Follow up patch will cleanup some Macros handling.

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

3 years ago[OpenMP] Add allocator support for target memory
Hansang Bae [Fri, 12 Feb 2021 23:36:02 +0000 (17:36 -0600)]
[OpenMP] Add allocator support for target memory

This is a preview of allocator support for target memory that depends on the
offload runtime API which allocates memory as described below.

llvm_omp_target_alloc_host(size_t size, int device_num);
-- Returns non-migratable memory owned by host.
-- Memory is accessible by host and device(s).

llvm_omp_target_alloc_shared(size_t size, int device_num);
-- Returns migratable memory owned by host and device.
-- Memory is accessible by host and device.

llvm_omp_target_alloc_device(size_t size, int device_num);
-- Returns memory owned by device.
-- Memory is only accessible by device.

New memory space and predefined allocator names are
-- llvm_omp_target_host_mem_space
-- llvm_omp_target_shared_mem_space
-- llvm_omp_target_device_mem_space
-- llvm_omp_target_host_mem_alloc
-- llvm_omp_target_shared_mem_alloc
-- llvm_omp_target_device_mem_alloc

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

3 years ago[libcxx] adds common_reference to <type_traits>
Christopher Di Bella [Tue, 2 Mar 2021 22:33:21 +0000 (22:33 +0000)]
[libcxx] adds common_reference to <type_traits>

Implements part of P0898R3 Standard Library Concepts

Reworks D74351 to use requires-clauses over SFINAE and so that it more
closely follows the wording.

Co-authored by: Michael Schellenberger Costa <mschellenbergercosta@googlemail.com>

(Michael did all the heavy lifting and I came in to polish it for
 submission, since Michael is focussing on `std::format` now.)

Reviewed By: ldionne, #libc

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

3 years agoGlobalISel: Merge and cleanup more AMDGPU call lowering code
Matt Arsenault [Tue, 9 Feb 2021 17:09:20 +0000 (12:09 -0500)]
GlobalISel: Merge and cleanup more AMDGPU call lowering code

This merges more AMDGPU ABI lowering code into the generic call
lowering. Start cleaning up by factoring away more of the pack/unpack
logic into the buildCopy{To|From}Parts functions. These could use more
improvement, and the SelectionDAG versions are significantly more
complex, and we'll eventually have to emulate all of those cases too.

This is mostly NFC, but does result in some minor instruction
reordering. It also removes some of the limitations with mismatched
sizes the old code had. However, similarly to the merge on the input,
this is forcing gfx6/gfx7 to use the gfx8+ ABI (which is what we
actually want, but SelectionDAG is stuck using the weird emergent
ABI).

This also changes the load/store size for stack passed EVTs for
AArch64, which makes it consistent with the DAG behavior.

3 years agoPromote scalars to load addresses when dereferencing them.
Adrian Prantl [Tue, 2 Mar 2021 19:03:38 +0000 (11:03 -0800)]
Promote scalars to load addresses when dereferencing them.

This is a follow-up to 188b0747c1664d962e94f00b5e3caac529fa1e26. This
is a very narrow fix to a more general problem. LLDB should be better
at distinguishing between implict and memory location descriptions.

rdar://74902042

3 years ago[AST] Remove unused Loop member (NFC)
Nikita Popov [Tue, 2 Mar 2021 22:09:36 +0000 (23:09 +0100)]
[AST] Remove unused Loop member (NFC)

To fix some build bots after D89264.

3 years ago[clangd] Move DraftStore from ClangdLSPServer into ClangdServer.
Sam McCall [Mon, 1 Mar 2021 23:16:33 +0000 (00:16 +0100)]
[clangd] Move DraftStore from ClangdLSPServer into ClangdServer.

ClangdServer already gets notified of every change, so it makes sense for it to
be the source of truth.
This is a step towards having ClangdServer expose a FS that includes dirty
buffers: D94554

Related changes:
 - version is now optional for ClangdServer, to preserve our existing fuzziness
   in this area (missing version ==> autoincrement)
 - ClangdServer::format{File,Range} are now more regular ClangdServer functions
   that don't need the code passed in. While here, combine into one function.
 - incremental content update logic is moved from DraftStore to
   ClangdLSPServer, with most of the implementation in SourceCode.cpp.
   DraftStore is now fairly trivial, and will probably ultimately be
   *replaced* by the dirty FS stuff.

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

3 years ago[cte][NFC] Remove all references to stdlib stream headers.
Nathan James [Tue, 2 Mar 2021 21:57:16 +0000 (21:57 +0000)]
[cte][NFC] Remove all references to stdlib stream headers.

Inclusion of iostream is frobidden and using other stream classes from standard library is discouraged as per https://llvm.org/docs/CodingStandards.html#include-iostream-is-forbidden

Reviewed By: sammccall

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

3 years ago[PR48898][CMake] Support MinGW Toolchain tool sin llvm_ExternalProject_Add
Markus Böck [Tue, 2 Mar 2021 21:44:51 +0000 (22:44 +0100)]
[PR48898][CMake] Support MinGW Toolchain tool sin llvm_ExternalProject_Add

Windows is in the unique position of having two drivers, clang-cl and normal GNU clang, depending on whether a GNU or MSVC target is used. The current implementation with the USE_TOOLCHAIN argument assumes that when CMAKE_SYSTEM_NAME is set to Windows that clang-cl should be used, which is the incorrect choice when targeting a GNU environment.

This patch solves this problem by adding an optional TARGET_TRIPLE argument to llvm_ExternalProject_Add, which sets the various CMAKE_<LANG>_COMPILER_TARGET variables. Additionally, if the triple is detected as an MSVC environment, clang-cl and similar MSVC specific tools will be used instead of the GNU tools.

3 years ago[WebAssembly] Fix more ExceptionInfo grouping bugs
Heejin Ahn [Sun, 28 Feb 2021 05:59:05 +0000 (21:59 -0800)]
[WebAssembly] Fix more ExceptionInfo grouping bugs

This fixes two bugs in `WebAssemblyExceptionInfo` grouping, created by
D97247. These two bugs are not easy to split into two different CLs,
because tests that fail for one also tend to fail for the other.

- In D97247, when fixing `ExceptionInfo` grouping by taking out
  the unwind destination' exception from the unwind src's exception, we
  just iterated the BBs in the function order, but this was incorrect;
  this changes it to dominator tree preorder. Please refer to the
  comments in the code for the reason and an example.

- After this subexception-taking-out fix, there still can be remaining
  BBs we have to take out. When Exception B is taken out of Exception A
  (because EHPad B is the unwind destination of EHPad A), there can
  still be BBs within Exception A that are reachable from Exception B,
  which also should be taken out. Please refer to the comments in the
  code for more detailed explanation on why this can happen. To make
  this possible, this splits `WebAssemblyException::addBlock` into two
  parts: adding to a set and adding to a vector. We need to iterate on
  BBs within a `WebAssemblyException` to fix this, so we add BBs to sets
  first. But we add BBs to vectors later after we fix all incorrectness
  because deleting BBs from vectors is expensive. I considered removing
  the vector from `WebAssemblyException`, but it was not easy because
  this class has to maintain a similar interface with `MachineLoop` to
  be wrapped into a single interface `SortRegion`, which is used in
  CFGSort.

Other misc. drive-by fixes:
- Make `WebAssemblyExceptionInfo` do not even run when wasm EH is not
  used or the function doesn't have any EH pads, not to waste time
- Add `LLVM_DEBUG` lines for easy debugging
- Fix `preds` comments in cfg-stackify-eh.ll
- Fix `__cxa_throw`'s signature in cfg-stackify-eh.ll

Fixes https://github.com/emscripten-core/emscripten/issues/13554.

Reviewed By: dschuff, tlively

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

3 years ago[clang-tidy] Simplify unused RAII check
Stephen Kelly [Mon, 28 Dec 2020 01:47:25 +0000 (01:47 +0000)]
[clang-tidy] Simplify unused RAII check

Fix handling of default construction where the constructor has a default arg.

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

3 years ago[LICM] Make promotion faster
Nikita Popov [Sun, 11 Oct 2020 19:56:09 +0000 (21:56 +0200)]
[LICM] Make promotion faster

Even when MemorySSA-based LICM is used, an AST is still populated
for scalar promotion. As the AST has quadratic complexity, a lot
of time is spent in this step despite the existing access count
limit. This patch optimizes the identification of promotable stores.

The idea here is pretty simple: We're only interested in must-alias
mod sets of loop invariant pointers. As such, only populate the AST
with loop-invariant loads and stores (anything else is definitely
not promotable) and then discard any sets which alias with any of
the remaining, definitely non-promotable accesses.

If we promoted something, check whether this has made some other
accesses loop invariant and thus possible promotion candidates.

This is much faster in practice, because we need to perform AA
queries for O(NumPromotable^2 + NumPromotable*NumNonPromotable)
instead of O(NumTotal^2), and NumPromotable tends to be small.
Additionally, promotable accesses have loop invariant pointers,
for which AA is cheaper.

This has a signicant positive compile-time impact. We save ~1.8%
geomean on CTMark at O3, with 6% on lencod in particular and 25%
on individual files.

Conceptually, this change is NFC, but may not be so in practice,
because the AST is only an approximation, and can produce
different results depending on the order in which accesses are
added. However, there is at least no impact on the number of promotions
(licm.NumPromoted) in test-suite O3 configuration with this change.

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

3 years agoBPF: Fix a bug in peephole TRUNC elimination optimization
Yonghong Song [Tue, 2 Mar 2021 17:35:21 +0000 (09:35 -0800)]
BPF: Fix a bug in peephole TRUNC elimination optimization

Andrei Matei reported a llvm11 core dump for his bpf program
   https://bugs.llvm.org/show_bug.cgi?id=48578
The core dump happens in LiveVariables analysis phase.
  #4 0x00007fce54356bb0 __restore_rt
  #5 0x00007fce4d51785e llvm::LiveVariables::HandleVirtRegUse(unsigned int,
      llvm::MachineBasicBlock*, llvm::MachineInstr&)
  #6 0x00007fce4d519abe llvm::LiveVariables::runOnInstr(llvm::MachineInstr&,
      llvm::SmallVectorImpl<unsigned int>&)
  #7 0x00007fce4d519ec6 llvm::LiveVariables::runOnBlock(llvm::MachineBasicBlock*, unsigned int)
  #8 0x00007fce4d51a4bf llvm::LiveVariables::runOnMachineFunction(llvm::MachineFunction&)
The bug can be reproduced with llvm12 and latest trunk as well.

Futher analysis shows that there is a bug in BPF peephole
TRUNC elimination optimization, which tries to remove
unnecessary TRUNC operations (a <<= 32; a >>= 32).
Specifically, the compiler did wrong transformation for the
following patterns:
   %1 = LDW ...
   %2 = SLL_ri %1, 32
   %3 = SRL_ri %2, 32
   ... %3 ...
   %4 = SRA_ri %2, 32
   ... %4 ...

The current transformation did not check how many uses of %2
and did transformation like
   %1 = LDW ...
   ... %1 ...
   %4 = SRL_ri %2, 32
   ... %4 ...
and pseudo register %2 is used by not defined and
caused LiveVariables analysis core dump.

To fix the issue, when traversing back from SRL_ri to SLL_ri,
check to ensure SLL_ri has only one use. Otherwise, don't
do transformation.

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

3 years agoAdd __builtin_isnan(__fp16) testcase
Thomas Preud'homme [Tue, 2 Mar 2021 17:04:34 +0000 (17:04 +0000)]
Add __builtin_isnan(__fp16) testcase

Reviewed By: rjmccall

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

3 years ago[lld-macho] Rework length check when opening input files
Greg McGary [Tue, 2 Mar 2021 09:20:22 +0000 (01:20 -0800)]
[lld-macho] Rework length check when opening input files

This reverts diff D97610 (commit 0223ab035c199e537a0040857ba147ced87fd533) and adds a one-line fix to verify that a `MemoryBufferRef` has sufficient length before reading a 4-byte magic number.

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

3 years ago[AArch64][GlobalISel] Enable use of the optsize predicate in the selector.
Amara Emerson [Thu, 25 Feb 2021 06:45:25 +0000 (22:45 -0800)]
[AArch64][GlobalISel] Enable use of the optsize predicate in the selector.

To do this while supporting the existing functionality in SelectionDAG of using
PGO info, we add the ProfileSummaryInfo and LazyBlockFrequencyInfo analysis
dependencies to the instruction selector pass.

Then, use the predicate to generate constant pool loads for f32 materialization,
if we're targeting optsize/minsize.

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

3 years ago[mlir][linalg] Only generate one var for an attrUse.
Hanhan Wang [Tue, 2 Mar 2021 20:48:12 +0000 (12:48 -0800)]
[mlir][linalg] Only generate one var for an attrUse.

Some variables are unused after D97383 landed. We should generate one symbol for one attrUse.

Reviewed By: stellaraccident

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

3 years ago[llvm-jitlink] Prevent missing symbols from JITLoaderGDB with MSVC mangling
Stefan Gränitz [Tue, 2 Mar 2021 20:42:11 +0000 (21:42 +0100)]
[llvm-jitlink] Prevent missing symbols from JITLoaderGDB with MSVC mangling

The issue came up on builder clang-x64-windows-msvc after 5182a7901a5d83dfd15021d01e8a1899910130ec

3 years ago[libcxx] [test] Pass some windows environment variables through to test processes
Martin Storsjö [Sat, 17 Oct 2020 20:57:19 +0000 (20:57 +0000)]
[libcxx] [test] Pass some windows environment variables through to test processes

Normally, the run.py wrapper script runs the child processes in
a clean environment, with only the environment variables available
that are passed via the --env parameter.

However, the COMSPEC and TEMP variables are kind of necessary when
running some tests; COMSPEC is necessary for finding the interpreter
when executing commands via std::system().

Before f1a96de1bc8db527b5eb820c36c17e275900ca2b, tests were executed
via an intermediate shell which implicitly readded the COMSPEC variable.

The TEMP variable allows temp files to be placed in a sensible
location; if unset, they're placed in the default temp fallback of
C:\Windows instead.

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

3 years ago[libcxx] Explicitly return the expected error code in create_directories if the paren...
Martin Storsjö [Fri, 18 Dec 2020 11:34:35 +0000 (13:34 +0200)]
[libcxx] Explicitly return the expected error code in create_directories if the parent isn't a directory

On windows, going ahead and actually trying to create the directory
doesn't return an error code that maps to
std::errc::not_a_directory in this case.

This fixes two cases of
    TEST_CHECK(ErrorIs(ec, std::errc::not_a_directory))
in filesystems/fs.op.funcs/fs.op.create_directories/create_directories.pass.cpp
for windows (in testcases added in 59c72a70121567f7aee347e96b4ac8f3cfe9f4b2).

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

3 years ago[SDAG] allow partial undef vector constants with select->logic folds
Sanjay Patel [Tue, 2 Mar 2021 18:50:22 +0000 (13:50 -0500)]
[SDAG] allow partial undef vector constants with select->logic folds

This is an enhancement suggested in the original review/commit:
D97730 / 7fce3322a283

3 years ago[AArch64] add select tests with partial vector undefs; NFC
Sanjay Patel [Tue, 2 Mar 2021 18:07:16 +0000 (13:07 -0500)]
[AArch64] add select tests with partial vector undefs; NFC

3 years agoFix `debuginfo-tests/llvm-prettyprinters` build after MLIR API change in e6260ad043d8...
Mehdi Amini [Tue, 2 Mar 2021 19:20:10 +0000 (19:20 +0000)]
Fix `debuginfo-tests/llvm-prettyprinters` build after MLIR API change in e6260ad043d8 (NFC)

3 years ago[ARM] Use 0, not ZR during ISel for CSINC/INV/NEG
David Green [Tue, 2 Mar 2021 19:01:14 +0000 (19:01 +0000)]
[ARM] Use 0, not ZR during ISel for CSINC/INV/NEG

Instead of converting the 0 into a ZR reg during lowering, do that with
tablegen by matching the zero immediate. This when combined with other
optimizations is more likely to use ZR and helps keep the DAG more
easily optimizable. It should not otherwise effect code generation.

3 years ago[SystemZ] Assign the full space for promoted and split outgoing args.
Jonas Paulsson [Thu, 25 Feb 2021 22:05:43 +0000 (16:05 -0600)]
[SystemZ]  Assign the full space for promoted and split outgoing args.

When a large "irregular" (e.g. i96) integer call argument is converted to
indirect, 64-bit parts are stored to the stack. The full stack space
(e.g. i128) was not allocated prior to this patch, but rather just the exact
space of the original type. This caused neighboring values on the stack to be
overwritten.

Thanks to Josh Stone for reporting this.

Review: Ulrich Weigand
Fixes https://bugs.llvm.org/show_bug.cgi?id=49322
Differential Revision: https://reviews.llvm.org/D97514

3 years ago[flang] Detect circularly defined interfaces of procedures
Peter Steinfeld [Tue, 2 Mar 2021 15:53:10 +0000 (07:53 -0800)]
[flang] Detect circularly defined interfaces of procedures

It's possible to define a procedure whose interface depends on a procedure
which has an interface that depends on the original procedure.  Such a circular
definition was causing the compiler to fall into an infinite loop when
resolving the name of the second procedure.  It's also possible to create
circular dependency chains of more than two procedures.

I fixed this by adding the function HasCycle() to the class DeclarationVisitor
and calling it from DeclareProcEntity() to detect procedures with such
circularly defined interfaces.  I marked the associated symbols of such
procedures by calling SetError() on them.  When processing subsequent
procedures, I called HasError() before attempting to analyze their interfaces.
Unfortunately, this did not work.

With help from Tim, we determined that the SymbolSet used to track the
erroneous symbols was instantiated using a "<" operator which was defined using
the location of the name of the procedure.  But the location of the procedure
name was being changed by a call to ReplaceName() between the times that the
calls to SetError() and HasError() were made.  This caused HasError() to
incorrectly report that a symbol was not in the set of erroneous symbols.

I fixed this by changing SymbolSet to be an unordered set that uses the
contents of the name of the symbol as the basis for its hash function.  This
works because the contents of the name of the symbol is preserved by
ReplaceName() even though its location changes.

I also fixed the error message used when reporting recursively defined
dummy procedure arguments by removing extra apostrophes and sorting the
list of symbols.

I also added tests that will crash the compiler without this change.

Note that the "<" operator is used in other contexts, for example, in the map
of characterized procedures, maps of items in equivalence sets, maps of
structure constructor values, ...  All of these situations happen after name
resolution has been completed and all calls to ReplaceName() have already
happened and thus are not subject to the problem I ran into when ReplaceName()
was called when processing procedure entities.

Note also that the implementation of the "<" operator uses the relative
location in the cooked character stream as the basis of its implementation.
This is potentially problematic when symbols from diffent compilation units
(for example symbols originating in .mod files) are put into the same map since
their names will appear in two different source streams which may not be
allocated in the same relative positions in memory.  But I was unable to create
a test that caused a problem.  Using a direct comparison of the content of the
name of the symbol in the "<" operator has problems.  Symbols in enclosing or
parallel scopes can have the same name.  Also using the location of the symbol
in the cooked character stream has the advantage that it preserves the the
order of the symbols in a structure constructor constant, which makes matching
the values with the symbols relatively easy.

This patch supersedes D97749.

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

3 years ago[gn build] fix llvm-jitlink tests on linux after ef2389235c5dec0
Nico Weber [Tue, 2 Mar 2021 18:40:56 +0000 (13:40 -0500)]
[gn build] fix llvm-jitlink tests on linux after ef2389235c5dec0

3 years ago[AMDGPU] Make OMod explicit for V_CVT_{U,I}*
Joe Nash [Fri, 26 Feb 2021 21:31:56 +0000 (16:31 -0500)]
[AMDGPU] Make OMod explicit for V_CVT_{U,I}*

Make OMod explicit instead of implied by HasModifiers in the
operand list. Requires explicitly setting HasOMod=1 for
irregular OMod usage in instruction V_CVT_{U,I}*

Reviewed By: foad

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

Change-Id: I230e1476f529e816eec60e242531f23a99e3839f