platform/upstream/llvm.git
3 years ago[OpenMP] libomp: fix non-X86, non-AARCH64 builds
AndreyChurbanov [Wed, 25 Nov 2020 17:40:23 +0000 (20:40 +0300)]
[OpenMP] libomp: fix non-X86, non-AARCH64 builds

Commit https://reviews.llvm.org/rG7b5254223acbf2ef9cd278070c5a84ab278d7e5f
broke the build for some architectures, because macro KMP_PREFIX_UNDERSCORE
was defined only for x86, x86_64 and aarch64. This patch defines it for other
architectures (as a no-op).

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

3 years ago[OpenMP][OMPT] Introduce a guard to handle OMPT return address
Joachim Protze [Wed, 18 Nov 2020 11:49:19 +0000 (12:49 +0100)]
[OpenMP][OMPT] Introduce a guard to handle OMPT return address

This is an alternative approach to address inconsistencies pointed out in: D90078
This patch makes sure that the return address is reset, when leaving the scope.
In some cases, I had to move the macro out of an if-statement to have it in the
right scope, in some cases I added an additional block to restrict the scope.

This patch does not handle inconsistencies, which might occur if the return
address is still set when we call into the application.

Test case (repeated_calls.c) provided by @hbae

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

3 years ago[OpenMP][OMPT] Implement verbose tool loading
Isabel Thärigen [Tue, 27 Oct 2020 13:05:28 +0000 (14:05 +0100)]
[OpenMP][OMPT] Implement verbose tool loading

OpenMP 5.1 introduces the new env variable
OMP_TOOL_VERBOSE_INIT=(disabled|stdout|stderr|<filename>) to enable verbose
loading and initialization of OMPT tools.
This env variable helps to understand the cause when loading of a tool fails
(e.g., undefined symbols or dependency not in LD_LIBRARY_PATH)
Output of OMP_TOOL_VERBOSE_INIT is added for OMP_DISPLAY_ENV

Tests for this patch are integrated into the different existing tool loading
tests, making these tests more verbose. An Archer specific verbose test is
integrated into an existing Archer test.

Patch prepared by: Isabel Thärigen

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

3 years ago[gn build] Download prebuilt mac-arm64 binary now that it exists
Nico Weber [Wed, 25 Nov 2020 17:08:10 +0000 (12:08 -0500)]
[gn build] Download prebuilt mac-arm64 binary now that it exists

Sadly requires an ugly workaround for an ugly bug, but still nicer than
building locally.

3 years ago[clang][test] Fix prefix operator++ signature in iterators
Endre Fülöp [Fri, 16 Oct 2020 07:37:42 +0000 (09:37 +0200)]
[clang][test] Fix prefix operator++ signature in iterators

Prefix operator++ should return the iterator incremented by reference.

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

3 years ago[ELF] Rename adjustRelaxExpr to adjustTlsExpr and delete the unused `data` parameter...
Fangrui Song [Wed, 25 Nov 2020 17:00:55 +0000 (09:00 -0800)]
[ELF] Rename adjustRelaxExpr to adjustTlsExpr and delete the unused `data` parameter. NFC

Reviewed By: psmith

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

3 years ago[SVE] Fix TypeSize warning in RuntimePointerChecking::insert
Joe Ellis [Tue, 24 Nov 2020 10:08:04 +0000 (10:08 +0000)]
[SVE] Fix TypeSize warning in RuntimePointerChecking::insert

The TypeSize warning would occur because RuntimePointerChecking::insert
was not scalable vector aware. The fix is to use
ScalarEvolution::getSizeOfExpr to grab the size of types.

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

3 years ago[ELF] Add TargetInfo::adjustGotPcExpr for `R_GOT_PC` relaxations. NFC
Fangrui Song [Wed, 25 Nov 2020 16:43:26 +0000 (08:43 -0800)]
[ELF] Add TargetInfo::adjustGotPcExpr for `R_GOT_PC` relaxations. NFC

With this change, `TargetInfo::adjustRelaxExpr` is only related to TLS
relaxations and a subsequent clean-up can delete the `data` parameter.

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

3 years ago[AMDGPU] Actually fully update opt-pipeline.ll test to account for -loop-idiom vs...
Roman Lebedev [Wed, 25 Nov 2020 16:38:51 +0000 (19:38 +0300)]
[AMDGPU] Actually fully update opt-pipeline.ll test to account for -loop-idiom vs -indvars switch

3 years ago[MC][WebAssembly] Only emit indirect function table import if needed
Andy Wingo [Wed, 25 Nov 2020 16:31:05 +0000 (08:31 -0800)]
[MC][WebAssembly] Only emit indirect function table import if needed

The indirect function table, synthesized by the linker, is needed if and
only if there are TABLE_INDEX relocs.

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

3 years ago[PassManager] Run Induction Variable Simplification pass *after* Recognize loop idiom...
Roman Lebedev [Wed, 25 Nov 2020 16:17:25 +0000 (19:17 +0300)]
[PassManager] Run Induction Variable Simplification pass *after* Recognize loop idioms pass, not before

Currently, `-indvars` runs first, and then immediately after `-loop-idiom` does.
I'm not really sure if `-loop-idiom` requires `-indvars` to run beforehand,
but i'm *very* sure that `-indvars` requires `-loop-idiom` to run afterwards,
as it can be seen in the phase-ordering test.

LoopIdiom runs on two types of loops: countable ones, and uncountable ones.
For uncountable ones, IndVars obviously didn't make any change to them,
since they are uncountable, so for them the order should be irrelevant.
For countable ones, well, they should have been countable before IndVars
for IndVars to make any change to them, and since SCEV is used on them,
it shouldn't matter if IndVars have already canonicalized them.
So i don't really see why we'd want the current ordering.

Should this cause issues, it will give us a reproducer test case
that shows flaws in this logic, and we then could adjust accordingly.

While this is quite likely beneficial in-the-wild already,
it's a required part for the full motivational pattern
behind `left-shift-until-bittest` loop idiom (D91038).

Reviewed By: dmgreen

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

3 years ago[WebAssembly] Factor out WasmTableType in binary format
Andy Wingo [Wed, 25 Nov 2020 15:54:31 +0000 (07:54 -0800)]
[WebAssembly] Factor out WasmTableType in binary format

This commit factors out a WasmTableType definition from WasmTable, as is
the case for WasmGlobal and other data types.  Also add support for
extracting the SymbolName for a table from the linking section's symbol
table.

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

3 years ago[AMDGPU] Emit stack frame size in metadata
Sebastian Neubauer [Fri, 23 Oct 2020 09:20:20 +0000 (11:20 +0200)]
[AMDGPU] Emit stack frame size in metadata

Add .shader_functions to pal metadata, which contains the stack frame
size for all non-entry-point functions.

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

3 years ago[flang][openacc] Semantic check for cache directive
Valentin Clement [Wed, 25 Nov 2020 15:28:02 +0000 (10:28 -0500)]
[flang][openacc] Semantic check for cache directive

Add semantic check for the cache directive. According to section 2.10 from the specification:
A var in a cache directive must be a single array element or a simple subarray.

Reviewed By: kiranchandramohan

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

3 years ago[DAG] Legalize abs(x) -> smax(x,sub(0,x)) iff smax/sub are legal
Simon Pilgrim [Wed, 25 Nov 2020 15:03:03 +0000 (15:03 +0000)]
[DAG] Legalize abs(x) -> smax(x,sub(0,x)) iff smax/sub are legal

If smax() is legal, this is likely to result in smaller codegen expansion for abs(x) than the xor(add,ashr) method.

This is also what PowerPC has been doing for its abs implementation, so it lets us get rid of a load of custom lowering code there (and which was never updated when they added smax lowering).

Alive2: https://alive2.llvm.org/ce/z/xRk3cD

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

3 years ago[PowerPC] Regenerate vec_select.ll tests and add <1 x i128> test case
Simon Pilgrim [Wed, 25 Nov 2020 11:50:16 +0000 (11:50 +0000)]
[PowerPC] Regenerate vec_select.ll tests and add <1 x i128> test case

3 years agoFix case mismatch between definition and declaration
Guillaume Chatelet [Wed, 25 Nov 2020 14:23:31 +0000 (14:23 +0000)]
Fix case mismatch between definition and declaration

3 years ago[libc++] ADL-proof <variant> by adding _VSTD:: qualification on calls.
Arthur O'Dwyer [Tue, 24 Nov 2020 14:59:26 +0000 (09:59 -0500)]
[libc++] ADL-proof <variant> by adding _VSTD:: qualification on calls.

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

3 years ago[clangd] PopulateSwitch: disable on dependent enums.
Adam Czachorowski [Tue, 24 Nov 2020 19:47:37 +0000 (20:47 +0100)]
[clangd] PopulateSwitch: disable on dependent enums.

If the enum is a dependent type, we would crash somewhere in
getIntWidth(). -Wswitch diagnostic doesn't work on dependent enums
either.

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

3 years ago[LAA] NFC: Rename [get]MaxSafeRegisterWidth -> [get]MaxSafeVectorWidthInBits
Cullen Rhodes [Wed, 18 Nov 2020 18:13:08 +0000 (18:13 +0000)]
[LAA] NFC: Rename [get]MaxSafeRegisterWidth -> [get]MaxSafeVectorWidthInBits

MaxSafeRegisterWidth is a misnomer since it actually returns the maximum
safe vector width. Register suggests it relates directly to a physical
register where it could be a vector spanning one or more physical
registers.

Reviewed By: sdesmalen

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

3 years agoRevert "[libc++] P1645 constexpr for <numeric>"
Mark de Wever [Wed, 25 Nov 2020 12:46:08 +0000 (13:46 +0100)]
Revert "[libc++] P1645 constexpr for <numeric>"

This reverts commit eb9b063539c34d0d4dd14e8516eeb77bb8b9e4bd.

The commit fails to build on build bots using LLVM 8.

3 years agoFix a typo in the documentation to unbreak the sphinx builder.
Aaron Ballman [Wed, 25 Nov 2020 12:33:38 +0000 (07:33 -0500)]
Fix a typo in the documentation to unbreak the sphinx builder.

3 years ago[llvm-readelf/obj] - Stop using `reportError` when dumping notes.
Georgii Rymar [Tue, 24 Nov 2020 11:54:48 +0000 (14:54 +0300)]
[llvm-readelf/obj] - Stop using `reportError` when dumping notes.

This starts using `reportUniqueWarnings` instead of `reportError`
in the code that is responsible for dumping notes.

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

3 years ago[libc++] P1645 constexpr for <numeric>
Mark de Wever [Tue, 24 Nov 2020 13:55:55 +0000 (14:55 +0100)]
[libc++] P1645 constexpr for <numeric>

Implements P1645: constexpr for <numeric> algorithms

Reviewed By: ldionne, #libc

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

3 years ago[clangd] Use TimePoint<> instead of system_clock::time_point, it does matter after...
Sam McCall [Wed, 25 Nov 2020 11:49:18 +0000 (12:49 +0100)]
[clangd] Use TimePoint<> instead of system_clock::time_point, it does matter after all.

3 years ago[ARM][AArch64] Adding Neoverse N2 CPU support
Mark Murray [Mon, 16 Nov 2020 13:11:35 +0000 (13:11 +0000)]
[ARM][AArch64] Adding Neoverse N2 CPU support

Add support for the Neoverse N2 CPU to the ARM and AArch64 backends.

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

3 years agoSemaExpr.cpp - use castAs<> instead of getAs<> as we dereference the pointer directly...
Simon Pilgrim [Tue, 24 Nov 2020 17:36:58 +0000 (17:36 +0000)]
SemaExpr.cpp - use castAs<> instead of getAs<> as we dereference the pointer directly. NFCI.

castAs<> will assert the correct cast type instead of just returning null, which we then try to dereference immediately.

3 years agoTargetInfo.cpp - use castAs<> instead of getAs<> as we dereference the pointer direct...
Simon Pilgrim [Tue, 24 Nov 2020 16:56:24 +0000 (16:56 +0000)]
TargetInfo.cpp - use castAs<> instead of getAs<> as we dereference the pointer directly. NFCI.

castAs<> will assert the correct cast type instead of just returning null, which we then try to dereference immediately.

3 years agoCGCall.cpp - use castAs<> instead of getAs<> as we dereference the pointer directly...
Simon Pilgrim [Tue, 24 Nov 2020 16:55:26 +0000 (16:55 +0000)]
CGCall.cpp - use castAs<> instead of getAs<> as we dereference the pointer directly. NFCI.

castAs<> will assert the correct cast type instead of just returning null, which we then try to dereference immediately in the setUsedBits call.

3 years agoSemaExpr.cpp - use castAs<> instead of getAs<> as we dereference the pointer directly...
Simon Pilgrim [Tue, 24 Nov 2020 16:51:55 +0000 (16:51 +0000)]
SemaExpr.cpp - use castAs<> instead of getAs<> as we dereference the pointer directly. NFCI.

castAs<> will assert the correct cast type instead of just returning null, which we then try to dereference immediately.

3 years agoDetectDeadLanes.cpp - remove unused headers. NFCI.
Simon Pilgrim [Tue, 24 Nov 2020 16:20:03 +0000 (16:20 +0000)]
DetectDeadLanes.cpp - remove unused headers. NFCI.

3 years ago[SVE][CodeGen] Add a DAG combine to extend mscatter indices
Kerry McLaughlin [Wed, 25 Nov 2020 10:54:31 +0000 (10:54 +0000)]
[SVE][CodeGen] Add a DAG combine to extend mscatter indices

This patch adds a target-specific DAG combine for mscatter to promote indices
with element types i8 or i16 before legalisation, plus various tests with illegal types.

Reviewed By: sdesmalen

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

3 years ago[gn build] Port d95db1693cb
LLVM GN Syncbot [Wed, 25 Nov 2020 11:13:15 +0000 (11:13 +0000)]
[gn build] Port d95db1693cb

3 years ago[clangd] Extract common file-caching logic from ConfigProvider.
Sam McCall [Wed, 23 Sep 2020 17:58:32 +0000 (19:58 +0200)]
[clangd] Extract common file-caching logic from ConfigProvider.

The plan is to use this to use this for .clang-format, .clang-tidy, and
compile_commands.json. (Currently the former two are reparsed every
time, and the latter is cached forever and changes are never seen).

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

3 years ago[VPlan] Add VPReductionSC to VPUser::classof, unify VPValue IDs.
Florian Hahn [Wed, 25 Nov 2020 10:04:22 +0000 (10:04 +0000)]
[VPlan] Add VPReductionSC to VPUser::classof, unify VPValue IDs.

This is a follow-up to 00a66011366c7b037d6680e6015524a41b761c34 to make
isa<VPReductionRecipe> work and unifies the VPValue ID names, by making
sure they all consistently start with VPV*.

3 years ago[clangd] Fix a tsan failure.
Haojian Wu [Wed, 25 Nov 2020 10:46:41 +0000 (11:46 +0100)]
[clangd] Fix a tsan failure.

Tracer must be set up before calling any clangd-specific functions.

3 years ago[OpenCL] Move kernel arg type tests into one file
Sven van Haastregt [Wed, 25 Nov 2020 10:20:30 +0000 (10:20 +0000)]
[OpenCL] Move kernel arg type tests into one file

Keep all kernel parameter type diagnostic tests in
invalid-kernel-parameters.cl .

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

3 years ago[clang][SVE] Activate macro `__ARM_FEATURE_SVE_VECTOR_OPERATORS`.
Francesco Petrogalli [Wed, 25 Nov 2020 09:37:00 +0000 (09:37 +0000)]
[clang][SVE] Activate macro `__ARM_FEATURE_SVE_VECTOR_OPERATORS`.

The macro is emitted when wargeting SVE code generation with the additional command line option `-msve-vector-bits=<N>`.

The behavior implied by the macro is described in sections "3.7.3.3. Behavior specific to SVE vectors" of the SVE ACLE (Version 00bet6) that can be found at https://developer.arm.com/documentation/100987/latest

Reviewed By: rengolin, rsandifo-arm

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

3 years ago[ORC] Cast to const void* to silence a GCC warning. NFC.
Martin Storsjö [Wed, 25 Nov 2020 10:06:26 +0000 (12:06 +0200)]
[ORC] Cast to const void* to silence a GCC warning. NFC.

3 years ago[ORC] Remove a superfluous semicolon, silencing GCC warnings. NFC.
Martin Storsjö [Wed, 25 Nov 2020 10:05:53 +0000 (12:05 +0200)]
[ORC] Remove a superfluous semicolon, silencing GCC warnings. NFC.

3 years ago[libObject,llvm-readelf] - Stop describing a section/segment in `notes_begin()`.
Georgii Rymar [Tue, 24 Nov 2020 14:34:12 +0000 (17:34 +0300)]
[libObject,llvm-readelf] - Stop describing a section/segment in `notes_begin()`.

`notes_begin()` is used for iterating over notes. This API in some cases might print
section type and index. At the same time during iterating, the `Elf_Note_Iterator`
might omit it as it doesn't have this info.

Because of above we might have the redundant duplication of information in warnings:
(See D92021).

```
warning: '[[FILE]]': unable to read notes from the SHT_NOTE section with index 1: SHT_NOTE section [index 1] has invalid offset (0x40) or size (0xffff0000)
```

This change stops reporting section index/type in Object/ELF.h/notes_begin().
(FTR, this was introduced by me for llvm-readobj in D64470).
Instead we can describe sections/program headers on the caller side.

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

3 years ago[clangd] Add metrics for invalid name.
Haojian Wu [Wed, 25 Nov 2020 09:49:54 +0000 (10:49 +0100)]
[clangd] Add metrics for invalid name.

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

3 years ago[obj2yaml] - Dump section offsets in some cases.
Georgii Rymar [Mon, 9 Nov 2020 11:52:46 +0000 (14:52 +0300)]
[obj2yaml] - Dump section offsets in some cases.

Currently we never dump the `sh_offset` key.
Though it sometimes an important information.

To reduce the noise this patch implements the following logic:
1) The "Offset" key for the first section is always emitted.
2) If we can derive the offset for a next section naturally,
   then the "Offset" key is omitted.

By "naturally" I mean that section[X] offset is expected to be:
```
offsetOf(section[X]) == alignTo(section[X - 1].sh_offset + section[X - 1].sh_size, section[X].sh_addralign)
```

So, when it has the expected value, we omit it from the output.

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

3 years ago[SchedModels] Return earlier removed checks
Evgeny Leviant [Wed, 25 Nov 2020 09:07:35 +0000 (12:07 +0300)]
[SchedModels] Return earlier removed checks

It is possible that some write resource is variant in model A
and sequence in model B. Such case will trigger assertion in
getAllPredicates function.

3 years ago[clangd] Avoid type hierarchy crash on incomplete type
Nathan Ridge [Wed, 25 Nov 2020 08:11:54 +0000 (03:11 -0500)]
[clangd] Avoid type hierarchy crash on incomplete type

Fixes https://github.com/clangd/clangd/issues/597

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

3 years ago[llvm-readobj] - An attempt to fix BB after D92018.
Georgii Rymar [Wed, 25 Nov 2020 08:37:40 +0000 (11:37 +0300)]
[llvm-readobj] - An attempt to fix BB after D92018.

AVR and PPC64 bots reports link errors:
(http://lab.llvm.org:8011/#/builders/112/builds/1522)
(http://lab.llvm.org:8011/#/builders/52/builds/1764)

/tmp/cclOvLx0.s: Assembler messages:
/tmp/cclOvLx0.s:9223: Error: symbol `_ZN4llvm12function_refIFvvEE11callback_fnIUlvE2_EEvl' is already defined
/tmp/cclOvLx0.s:9227: Error: symbol `.L._ZN4llvm12function_refIFvvEE11callback_fnIUlvE2_EEvl' is already defined
/tmp/cclOvLx0.s:10272: Error: symbol `_ZN4llvm12function_refIFvvEE11callback_fnIUlvE2_EEvl' is already defined
/tmp/cclOvLx0.s:10276: Error: symbol `.L._ZN4llvm12function_refIFvvEE11callback_fnIUlvE2_EEvl' is already defined
/tmp/cclOvLx0.s:10285: Error: symbol `_ZN4llvm12function_refIFvvEE11callback_fnIUlvE2_EEvl' is already defined
/tmp/cclOvLx0.s:10289: Error: symbol `.L._ZN4llvm12function_refIFvvEE11callback_fnIUlvE2_EEvl' is already defined

/tmp/ccFJYr6I.s: Assembler messages:
/tmp/ccFJYr6I.s:6284: Error: symbol `_ZN4llvm12function_refIFvvEE11callback_fnIUlvE2_EEvl' is already defined
/tmp/ccFJYr6I.s:7053: Error: symbol `_ZN4llvm12function_refIFvvEE11callback_fnIUlvE2_EEvl' is already defined
/tmp/ccFJYr6I.s:7093: Error: symbol `_ZN4llvm12function_refIFvvEE11callback_fnIUlvE2_EEvl' is already defined

I *guess* the reason might be the default lambda argument. I've removed it.

3 years ago[VPlan] Switch VPWidenRecipe to be a VPValue
David Green [Wed, 25 Nov 2020 08:25:06 +0000 (08:25 +0000)]
[VPlan] Switch VPWidenRecipe to be a VPValue

Similar to other patches, this makes VPWidenRecipe a VPValue. Because of
the way it interacts with the reduction code it also slightly alters the
way that VPValues are registered, removing the up front NeedDef and
using getOrAddVPValue to create them on-demand if needed instead.

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

3 years ago[VPlan] Turn VPReductionRecipe into a VPValue
David Green [Tue, 24 Nov 2020 10:08:59 +0000 (10:08 +0000)]
[VPlan] Turn VPReductionRecipe into a VPValue

This converts the VPReductionRecipe into a VPValue, like other
VPRecipe's in preparation for traversing def-use chains. It also makes
it a VPUser, now storing the used VPValues as operands.

It doesn't yet change how the VPReductionRecipes are created. It will
need to call replaceAllUsesWith from the original recipe they replace,
but that is not done yet as VPWidenRecipe need to be created first.

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

3 years ago[llvm-readelf/obj] - Deduplicate the logic that prints notes. NFCI.
Georgii Rymar [Tue, 24 Nov 2020 10:49:40 +0000 (13:49 +0300)]
[llvm-readelf/obj] - Deduplicate the logic that prints notes. NFCI.

We have a similar logic for LLVM/GNU styles that can be deduplicated.
This will allow to replace `reportError` calls with `reportUniqueWarning`
calls in a single place.

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

3 years ago[NFC][ARM][PhaseOrdering] Add one more test for D91800: LoopIdiom should be before...
Roman Lebedev [Wed, 25 Nov 2020 07:51:54 +0000 (10:51 +0300)]
[NFC][ARM][PhaseOrdering] Add one more test for D91800: LoopIdiom should be before IndVars

3 years ago[PowerPC] Probe the gap between stackptr and realigned stackptr
Kai Luo [Wed, 25 Nov 2020 01:38:19 +0000 (01:38 +0000)]
[PowerPC] Probe the gap between stackptr and realigned stackptr

During reviewing https://reviews.llvm.org/D84419, @efriedma mentioned the gap between realigned stack pointer and origin stack pointer should be probed too whatever the alignment is. This patch fixes the issue for PPC64.

Reviewed By: jsji

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

3 years ago[CHR] Use pred_size (NFC)
Kazu Hirata [Wed, 25 Nov 2020 06:52:29 +0000 (22:52 -0800)]
[CHR] Use pred_size (NFC)

3 years agoRevert "[SCEV] Generalize no-self-wrap check in isLoopInvariantExitCondDuringFirstIte...
Max Kazantsev [Wed, 25 Nov 2020 06:20:15 +0000 (13:20 +0700)]
Revert "[SCEV] Generalize no-self-wrap check in isLoopInvariantExitCondDuringFirstIterations"

This reverts commit 7dcc8899174f44b7447bc48a9f2ff27f5458f8b7.

This patch introduced a logical error that breaks whole logic of this analysis.
All checks we are making are supposed to be loop-independent, so that we could
safely remove the range check. The 'nw' fact is loop-dependent, so we can remove
the check basing on facts from this very check.

Motivating examples will follow-up.

3 years ago[DAGCombine] Add hook to allow target specific test for sqrt input
QingShan Zhang [Wed, 25 Nov 2020 05:37:15 +0000 (05:37 +0000)]
[DAGCombine] Add hook to allow target specific test for sqrt input

PowerPC has instruction ftsqrt/xstsqrtdp etc to do the input test for software square root.
LLVM now tests it with smallest normalized value using abs + setcc. We should add hook to
target that has test instructions.

Reviewed By: Spatel, Chen Zheng, Qiu Chao Fang

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

3 years ago[NewPM] Add pipeline EP callback after initial frontend cleanup
Arthur Eubanks [Thu, 19 Nov 2020 17:38:14 +0000 (09:38 -0800)]
[NewPM] Add pipeline EP callback after initial frontend cleanup

This matches the legacy PM's EP_ModuleOptimizerEarly. Some backends use
this extension point and adding the pass somewhere else like
PipelineStartEPCallback doesn't work.

Reviewed By: ychen

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

3 years ago[IndVars] Use more precise context when eliminating narrowing
Max Kazantsev [Wed, 25 Nov 2020 04:46:22 +0000 (11:46 +0700)]
[IndVars] Use more precise context when eliminating narrowing

When deciding to widen narrow use, we may need to prove some facts
about it. For proof, the context is used. Currently we take the instruction
being widened as the context.

However, we may be more precise here if we take as context the point that
dominates all users of instruction being widened.

Differential Revision: https://reviews.llvm.org/D90456
Reviewed By: skatkov

3 years ago[DAG][PowerPC] Fix dropped `nsw` flag in `SimplifySetCC` by adding `doesNodeExist...
Kai Luo [Wed, 25 Nov 2020 03:28:48 +0000 (03:28 +0000)]
[DAG][PowerPC] Fix dropped `nsw` flag in `SimplifySetCC` by adding `doesNodeExist` helper

`SimplifySetCC` invokes `getNodeIfExists` without passing `Flags` argument and `getNodeIfExists` uses a default `SDNodeFlags` to intersect the original flags, as a consequence, flags like `nsw` is dropped. Added a new helper function `doesNodeExist` to check if a node exists without modifying its flags.

Reviewed By: #powerpc, nemanjai

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

3 years ago[PPC][AIX] Add vector callee saved registers for AIX extended vector ABI
Zarko Todorovski [Wed, 25 Nov 2020 03:37:03 +0000 (22:37 -0500)]
[PPC][AIX] Add vector callee saved registers for AIX extended vector ABI

This patch is the initial patch for support of the AIX extended vector ABI.  The extended ABI treats vector registers V20-V31 as non-volatile and we add them as callee saved registers in this patch.

Reviewed By: sfertile

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

3 years agoTry to fix tests after e16c0a9a68971 with CLANG_DEFAULT_LINKER=lld
Nico Weber [Wed, 25 Nov 2020 03:34:10 +0000 (22:34 -0500)]
Try to fix tests after e16c0a9a68971 with CLANG_DEFAULT_LINKER=lld

Tests that pass -mlinker-version=old version and that then don't
expect new flags to be passed need to explicitly request the system
linker now.

3 years ago[NFC][Test] Format the test for IEEE Long double
QingShan Zhang [Wed, 25 Nov 2020 03:00:24 +0000 (03:00 +0000)]
[NFC][Test] Format the test for IEEE Long double

3 years agoDon't assume the clang binary name contains the string "clang".
Richard Smith [Wed, 25 Nov 2020 02:51:08 +0000 (18:51 -0800)]
Don't assume the clang binary name contains the string "clang".

Also ensure the -cc1 argument is actually part of the clang -cc1 command
line rather than some unrelated command line.

3 years ago[SCEV] Use isa<> pattern for testing for CouldNotCompute [NFC]
Philip Reames [Wed, 25 Nov 2020 02:45:37 +0000 (18:45 -0800)]
[SCEV] Use isa<> pattern for testing for CouldNotCompute [NFC]

Some older code - and code copied from older code - still directly tested against the singelton result of SE::getCouldNotCompute.  Using the isa<SCEVCouldNotCompute> form is both shorter, and more readable.

3 years agoMake CallInst::updateProfWeight emit i32 weights instead of i64
Arthur Eubanks [Sat, 31 Oct 2020 19:38:03 +0000 (12:38 -0700)]
Make CallInst::updateProfWeight emit i32 weights instead of i64

Typically branch_weights are i32, not i64.
This fixes entry_counts_cold.ll under NPM.

Reviewed By: asbirlea

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

3 years agoDebugInfo: Remove llc_dwarf usage from tests already relying on a target triple in...
David Blaikie [Wed, 25 Nov 2020 01:45:47 +0000 (17:45 -0800)]
DebugInfo: Remove llc_dwarf usage from tests already relying on a target triple in the IR

3 years ago[PowerPC][FP128] Fix the incorrect calling convention for IEEE long double on Power8
QingShan Zhang [Wed, 25 Nov 2020 01:38:57 +0000 (01:38 +0000)]
[PowerPC][FP128] Fix the incorrect calling convention for IEEE long double on Power8

For now, we are using the GPR to pass the arguments/return value for fp128 on Power8,
which is incorrect. It should be VSR. The reason why we do it this way is that,
we are setting the fp128 as illegal which make LLVM try to emulate it with i128 on
Power8. So, we need to correct it as legal.

Reviewed By: Nemanjai

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

3 years agoDebugInfo: Add some missing explicit target triples.
David Blaikie [Wed, 25 Nov 2020 01:32:34 +0000 (17:32 -0800)]
DebugInfo: Add some missing explicit target triples.

Based on D91043 by Luís Marques. Thanks Luís!

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

3 years agoFix compilation issue reported by MSVC user on cfe-dev
Reid Kleckner [Wed, 25 Nov 2020 01:26:11 +0000 (17:26 -0800)]
Fix compilation issue reported by MSVC user on cfe-dev

MSVC seems to think this `friend class TrailingObjects;` declaration is
declaring a TrailingObjects class instead of naming the injected base
class. Remove `class` so it does the right thing.

3 years ago[clang-tidy] Support IgnoredRegexp configuration to selectively suppress identifier...
smhc [Wed, 25 Nov 2020 01:18:38 +0000 (01:18 +0000)]
[clang-tidy] Support IgnoredRegexp configuration to selectively suppress identifier naming checks

The idea of suppressing naming checks for variables is to support code bases that allow short variables named e.g 'x' and 'i' without prefix/suffixes or casing styles. This was originally proposed as a 'ShortSizeThreshold' however has been made more generic with a regex to suppress identifier naming checks for those that match.

Reviewed By: njames93, aaron.ballman

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

3 years ago[mlir][sparse] add parallelization strategies to sparse compiler
Aart Bik [Tue, 24 Nov 2020 23:36:10 +0000 (15:36 -0800)]
[mlir][sparse] add parallelization strategies to sparse compiler

This CL adds the ability to request different parallelization strategies
for the generate code. Every "parallel" loop is a candidate, and converted
to a parallel op if it is an actual for-loop (not a while) and the strategy
allows dense/sparse outer/inner parallelization.

This will connect directly with the work of @ezhulenev on parallel loops.

Still TBD: vectorization strategy

Reviewed By: penpornk

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

3 years agoTreat a placeholder type for class template argument deduction as
Richard Smith [Wed, 25 Nov 2020 00:53:58 +0000 (16:53 -0800)]
Treat a placeholder type for class template argument deduction as
substitutable for the deduced template.

As agreed in https://github.com/itanium-cxx-abi/cxx-abi/issues/109.

3 years ago[lld] Add --no-lto-whole-program-visibility
Teresa Johnson [Tue, 24 Nov 2020 22:53:02 +0000 (14:53 -0800)]
[lld] Add --no-lto-whole-program-visibility

Enables overriding earlier --lto-whole-program-visibility.

Variant of D91583 while discussing alternate ways to identify and
handle the --export-dynamic case.

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

3 years agoFix mangling of substitutions for template-prefixes.
Richard Smith [Tue, 24 Nov 2020 23:20:06 +0000 (15:20 -0800)]
Fix mangling of substitutions for template-prefixes.

Previously we only considered using a substitution for a template-name
after already having mangled its prefix, so we'd produce nonsense
manglings like NS3_S4_IiEE where we should simply produce NS4_IiEE.

This is not ABI-compatible with previous Clang versions, and the old
behavior is restored by -fclang-abi-compat=11.0 or earlier.

3 years ago[Sanitizer][RISCV] Fix redefinition of REG_SP
Luís Marques [Wed, 25 Nov 2020 00:03:34 +0000 (00:03 +0000)]
[Sanitizer][RISCV] Fix redefinition of REG_SP

The include header sys/ucontext.h already defines REG_SP as 2, causing
redefinition warnings during compilation. This patch fixes that issue.
(We also can't just use the numerical definition provided by the header,
as REG_SP is used in this file this refers to a struct field.)

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

3 years ago[LAA] Minor code style tweaks [NFC]
Philip Reames [Tue, 24 Nov 2020 23:49:16 +0000 (15:49 -0800)]
[LAA] Minor code style tweaks [NFC]

3 years ago[SelectionDAG] Add PseudoProbeSDNode to LargestSDNode to fix 32-bt build break.
Hongtao Yu [Tue, 24 Nov 2020 20:35:12 +0000 (12:35 -0800)]
[SelectionDAG] Add PseudoProbeSDNode to LargestSDNode to fix 32-bt build break.

3 years ago[AIX] Add mabi=vec-extabi options to enable the AIX extended and default vector ABIs.
Zarko Todorovski [Tue, 24 Nov 2020 23:11:46 +0000 (18:11 -0500)]
[AIX] Add mabi=vec-extabi options to enable the AIX extended and default vector ABIs.

Added support for the options mabi=vec-extabi and mabi=vec-default which are analogous to qvecnvol and qnovecnvol when using XL on AIX.
The extended Altivec ABI on AIX is enabled using mabi=vec-extabi in clang and vec-extabi in llc.

Reviewed By: Xiangling_L, DiggerLin

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

3 years ago[mlir] use STATUS instead of CHECK_* in MLIRDetectPythonEnv.cmake
Alex Zinenko [Mon, 23 Nov 2020 12:58:03 +0000 (13:58 +0100)]
[mlir] use STATUS instead of CHECK_* in MLIRDetectPythonEnv.cmake

CHECK_* directives for message() where added in Cmake 3.17, LLVM
requires 3.14 as minimum so they may not be intepreted correctly and
just print "CHECK_*" into the message stream. Replace them with STATUS.

Reviewed By: stellaraccident

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

3 years ago[MC/AsmParser] Fix use of Arm calling convention in target-agnostic test
Luís Marques [Tue, 24 Nov 2020 22:54:24 +0000 (22:54 +0000)]
[MC/AsmParser] Fix use of Arm calling convention in target-agnostic test

Remove target-specific calling convention specifier in target-agnostic test.

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

3 years ago[RISCV] Set __GCC_HAVE_SYNC_COMPARE_AND_SWAP_x defines
Luís Marques [Tue, 24 Nov 2020 22:46:38 +0000 (22:46 +0000)]
[RISCV] Set __GCC_HAVE_SYNC_COMPARE_AND_SWAP_x defines

The RISCV target did not set the GCC atomic compare and swap defines,
unlike other targets. This broke builds for things like glib on RISCV.

Patch by Kristof Provost (kprovost)

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

3 years ago[ASTImporter] Make the Import() return value consistent with the map of imported...
Raphael Isemann [Tue, 24 Nov 2020 22:08:57 +0000 (23:08 +0100)]
[ASTImporter] Make the Import() return value consistent with the map of imported decls when merging ClassTemplateSpecializationDecls

When importing a `ClassTemplateSpecializationDecl` definition into a TU with a matching
`ClassTemplateSpecializationDecl` definition and a more recent forward decl, the ASTImporter
currently will call `MapImported()` for the definitions, but will return the forward declaration
from the `ASTImporter::Import()` call.

This is triggering some assertions in LLDB when we try to fully import some DeclContexts
before we delete the 'From' AST. The returned 'To' Decl before this patch is just the most recent
forward decl but that's not the Decl with the definition to which the ASTImporter will import
the child declarations.

This patch just changes that the ASTImporter returns the definition that the imported Decl was
merged with instead of the found forward declaration.

Reviewed By: martong

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

3 years ago[RISCV] Add GHC calling convention
Luís Marques [Tue, 24 Nov 2020 22:29:56 +0000 (22:29 +0000)]
[RISCV] Add GHC calling convention

This is a special calling convention to be used by the GHC compiler.

Patch by Andreas Schwab (schwab)

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

3 years agoRevert "[RISCV] Add GHC calling convention"
Luís Marques [Tue, 24 Nov 2020 22:34:20 +0000 (22:34 +0000)]
Revert "[RISCV] Add GHC calling convention"

This reverts commit f8317bb256be2cd8ed81ebc567f0fa626b645f63 due to lack of
proper attribution.

3 years ago[gn build] Port 8d06a678a5c
LLVM GN Syncbot [Tue, 24 Nov 2020 22:27:19 +0000 (22:27 +0000)]
[gn build] Port 8d06a678a5c

3 years ago[SelectionDAG] Avoid aliasing analysis if the object size is unknown.
Hsiangkai Wang [Fri, 20 Nov 2020 00:52:03 +0000 (08:52 +0800)]
[SelectionDAG] Avoid aliasing analysis if the object size is unknown.

If the size of memory access is unknown, do not use it to analysis. One
example of unknown size memory access is to load/store scalable vector
objects on the stack.

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

3 years ago[OpenMP50][DOCS] Mark target data non-contiguous as done, NFC.
cchen [Tue, 24 Nov 2020 22:07:39 +0000 (16:07 -0600)]
[OpenMP50][DOCS] Mark target data non-contiguous as done, NFC.

3 years ago[clangd] Addusing tweak: find insertion point after definition
Adam Czachorowski [Mon, 23 Nov 2020 13:48:57 +0000 (14:48 +0100)]
[clangd] Addusing tweak: find insertion point after definition

When type/function is defined in the middle of the file, previuosly we
would sometimes insert a "using" line before that definition, leading to
a compilation error. With this fix, we pick a point after such
definition in translation unit.

This is not a perfect solution. For example, it still doesn't handle
"using namespace" directives. It is, however, a significant improvement.

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

3 years ago[RISCV] Add GHC calling convention
Luís Marques [Tue, 24 Nov 2020 21:55:06 +0000 (21:55 +0000)]
[RISCV] Add GHC calling convention

This is a special calling convention to be used by the GHC compiler.

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

3 years ago[mlir] Remove SameOperandsAndResultShape when redundant with ElementwiseMappable
Sean Silva [Fri, 13 Nov 2020 01:08:56 +0000 (17:08 -0800)]
[mlir] Remove SameOperandsAndResultShape when redundant with ElementwiseMappable

SameOperandsAndResultShape and ElementwiseMappable have similar
verification, but in general neither is strictly redundant with the
other.

Examples:
- SameOperandsAndResultShape allows
  `"foo"(%0) : tensor<2xf32> -> tensor<?xf32> but ElementwiseMappable
  does not.
- ElementwiseMappable allows
  `select %scalar_pred, %true_tensor, %false_tensor` but
  SameOperandsAndResultShape does not.

SameOperandsAndResultShape is redundant with ElementwiseMappable when
we can prove that the mixed scalar/non-scalar case cannot happen. In
those situations, `ElementwiseMappable & SameOperandsAndResultShape ==
ElementwiseMappable`:
- Ops with 1 operand: the case of mixed scalar and non-scalar operands
  cannot happen since there is only one operand.
- When SameTypeOperands is also present, the mixed scalar/non-scalar
  operand case cannot happen.

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

3 years ago[mlir][sparse] generalize invariant expression handling in sparse compiler
Aart Bik [Mon, 23 Nov 2020 19:01:39 +0000 (11:01 -0800)]
[mlir][sparse] generalize invariant expression handling in sparse compiler

Generalizes invariant handling to anything defined outside the Linalg op
(parameters and SSA computations). Fixes bug that was using parameter number
as tensor number.

Reviewed By: penpornk

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

3 years ago[PowerPC] Don't reuse an illegal typed load for int_to_fp conversion.
Sean Fertile [Tue, 24 Nov 2020 15:07:41 +0000 (10:07 -0500)]
[PowerPC] Don't reuse an illegal typed load for int_to_fp conversion.

When the operand to an (s/u)int_to_fp node is an illegally typed load we
cannot reuse the load address since we can not build a proper dependancy
chain. The legalized loads will use a different chain output then the
illegal load. If we reuse the load address then we will build a
conversion node that uses the chain of the illegal load and operations
which modify the memory address in the other dependancy chain can be
scheduled before the floating point load which feeds the conversion.

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

3 years ago[mlir] Add conversion from SCF parallel loops to OpenMP
Alex Zinenko [Mon, 23 Nov 2020 19:29:27 +0000 (20:29 +0100)]
[mlir] Add conversion from SCF parallel loops to OpenMP

Introduce a conversion pass from SCF parallel loops to OpenMP dialect
constructs - parallel region and workshare loop. Loops with reductions are not
supported because the OpenMP dialect cannot model them yet.

The conversion currently targets only one level of parallelism, i.e. only
one top-level `omp.parallel` operation is produced even if there are nested
`scf.parallel` operations that could be mapped to `omp.wsloop`. Nested
parallelism support is left for future work.

Reviewed By: kiranchandramohan

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

3 years ago[libc++] [P0482] [C++20] Implement missing bits for atomic
Marek Kurdej [Tue, 24 Nov 2020 20:07:06 +0000 (21:07 +0100)]
[libc++] [P0482] [C++20] Implement missing bits for atomic

Added: ATOMIC_CHAR8_T_LOCK_FREE, atomic<char8_t>, atomic_char8_t.
http://wg21.link/P0482

Reviewed By: ldionne, #libc

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

3 years agoAvoid redundant work when computing vtable vcall visibility
Teresa Johnson [Tue, 17 Nov 2020 22:44:25 +0000 (14:44 -0800)]
Avoid redundant work when computing vtable vcall visibility

Add a Visited set to avoid repeatedly processing the same base classes
in complex class hierarchies. This cut down the compile time of one
source file from >12min to ~1min.

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

3 years ago[mlir] NFC - Refactor and expose a helper printOffsetSizesAndStrides helper function.
Nicolas Vasilache [Tue, 24 Nov 2020 19:52:24 +0000 (19:52 +0000)]
[mlir] NFC - Refactor and expose a helper printOffsetSizesAndStrides helper function.

Print part of an op of the form:
```
  <optional-offset-prefix>`[` offset-list `]`
  <optional-size-prefix>`[` size-list `]`
  <optional-stride-prefix>[` stride-list `]`
```

Also address some leftover nits.

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

3 years ago[test] Clean up ppc-features.cpp and improve tests
Fangrui Song [Tue, 24 Nov 2020 19:59:15 +0000 (11:59 -0800)]
[test] Clean up ppc-features.cpp and improve tests

And add ppc-cpus.cpp for -mcpu= specific tests.

3 years ago[mlir] NFC - Refactor and expose a parsing helper for OffsetSizeAndStrideInterface
Nicolas Vasilache [Tue, 24 Nov 2020 14:54:06 +0000 (14:54 +0000)]
[mlir] NFC - Refactor and expose a parsing helper for OffsetSizeAndStrideInterface

Parse trailing part of an op of the form:
```
  <optional-offset-prefix>`[` offset-list `]`
  <optional-size-prefix>`[` size-list `]`
  <optional-stride-prefix>[` stride-list `]`
```
Each entry in the offset, size and stride list either resolves to an integer
constant or an operand of index type.
Constants are added to the `result` as named integer array attributes with
name `OffsetSizeAndStrideOpInterface::getStaticOffsetsAttrName()` (resp.
`getStaticSizesAttrName()`, `getStaticStridesAttrName()`).

Append the number of offset, size and stride operands to `segmentSizes`
before adding it to `result` as the named attribute:
`OpTrait::AttrSizedOperandSegments<void>::getOperandSegmentSizeAttr()`.
Offset, size and stride operands resolution occurs after `preResolutionFn`
to give a chance to leading operands to resolve first, after parsing the
types.
```
ParseResult parseOffsetsSizesAndStrides(
    OpAsmParser &parser, OperationState &result, ArrayRef<int> segmentSizes,
    llvm::function_ref<ParseResult(OpAsmParser &, OperationState &)>
        preResolutionFn = nullptr,
    llvm::function_ref<ParseResult(OpAsmParser &)> parseOptionalOffsetPrefix =
        nullptr,
    llvm::function_ref<ParseResult(OpAsmParser &)> parseOptionalSizePrefix =
        nullptr,
    llvm::function_ref<ParseResult(OpAsmParser &)> parseOptionalStridePrefix =
        nullptr);
```

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

3 years ago[mlir][Python] Sync Python bindings with C API MlirStringRef modification.
zhanghb97 [Tue, 24 Nov 2020 18:35:22 +0000 (18:35 +0000)]
[mlir][Python] Sync Python bindings with C API MlirStringRef modification.

MLIR C API use the `MlirStringRef` instead of `const char *` for the string type now. This patch sync the Python bindings with the C API modification.

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

3 years ago[clangd] Add more trace spans for rename, NFC.
Haojian Wu [Tue, 24 Nov 2020 18:44:42 +0000 (19:44 +0100)]
[clangd] Add more trace spans for rename, NFC.

3 years ago[InstCombine] try difference-of-shifts factorization before negator
Sanjay Patel [Tue, 24 Nov 2020 18:33:12 +0000 (13:33 -0500)]
[InstCombine] try difference-of-shifts factorization before negator

We need to preserve wrapping flags to allow better folds.
The cases with geps may be non-intuitive, but that appears to agree with Alive2:
https://alive2.llvm.org/ce/z/JQcqw7
We create 'nsw' ops independent from the original wrapping on the sub.

3 years ago[InstCombine] add tests for sub of muls; NFC
Sanjay Patel [Tue, 24 Nov 2020 18:22:06 +0000 (13:22 -0500)]
[InstCombine] add tests for sub of muls; NFC