platform/upstream/llvm.git
2 years ago[clang-tidy] getLambdaProperties - use cast<> instead of dyn_cast<> to avoid derefere...
Simon Pilgrim [Mon, 31 Jan 2022 17:23:03 +0000 (17:23 +0000)]
[clang-tidy] getLambdaProperties - use cast<> instead of dyn_cast<> to avoid dereference of nullptr

The pointers are dereferenced immediately, so assert the cast is correct instead of returning nullptr

2 years ago[libc++] [ranges] Implement std::ranges::distance
Arthur O'Dwyer [Fri, 21 Jan 2022 20:51:46 +0000 (15:51 -0500)]
[libc++] [ranges] Implement std::ranges::distance

This includes an experimental workaround for
LWG3664 "LWG3392 broke std::ranges::distance(a, a+3)",
but the workaround may be incomplete, I'm not sure.
This should be re-audited when LWG3664 is actually adopted,
to see if we need to change anything about our implementation.

See also https://github.com/microsoft/STL/pull/2500

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

2 years ago[OpenMP] Disable rpath test in windows for lack of a libomp.lib stub
Jon Chesterfield [Mon, 31 Jan 2022 17:22:50 +0000 (17:22 +0000)]
[OpenMP] Disable rpath test in windows for lack of a libomp.lib stub

2 years ago[RISCV] Add a fatal error if ISD::VSCALE is used with Zvl32b.
Craig Topper [Mon, 31 Jan 2022 17:08:17 +0000 (09:08 -0800)]
[RISCV] Add a fatal error if ISD::VSCALE is used with Zvl32b.

We convert VLEN to vscale by dividing by RVVBitsPerBlock which is
currently 64. This is only correct if VLEN is evenly divisible by
64. With only Zvl32b we can't assume that.

This patch adds a fatal_error to prevent generating code that may
be broken.

We probably need to look at how we size stack frame objects too.

Reviewed By: frasercrmck

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

2 years ago[RISCV] Update the computeKnownBitsForTargetNode for RISCVISD::READ_VLENB to consider...
Craig Topper [Mon, 31 Jan 2022 17:08:05 +0000 (09:08 -0800)]
[RISCV] Update the computeKnownBitsForTargetNode for RISCVISD::READ_VLENB to consider Zve/Zvl.

We had previously hardcoded this to assume that vector registers
are 128 bits. This was true when only V existed, but after Zve
extensions were added this became incorrect.

This patch adjusts it to support 128, 64, or 32 bit vectors depending
on Zvl. The 128-bit limit is artificial, but we don't have any test
coverage showing that we larger values so I was being conservative.

None of our lit tests depend on this code today due to the custom
lowering of ISD::VSCALE that inserts the appropriate left or right
shift to convert from VLENB to VSCALE. That code was added after
this code in computeKnownBitsForTargetNode.

Reviewed By: frasercrmck

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

2 years ago[libc++] [NFC] Audit LWG issues for "Nothing To Do" and "Complete".
Arthur O'Dwyer [Sat, 22 Jan 2022 17:26:27 +0000 (12:26 -0500)]
[libc++] [NFC] Audit LWG issues for "Nothing To Do" and "Complete".

Each "Nothing To Do" issue only changed nits in the English wording,
not anything to do with the code.
Each "Complete" issue was completed already, as far as I can tell.
I tried to err on the side of caution: I didn't mark a few issues
whose P/Rs were very invasive and would take time to verify, and I
didn't mark a lot of issues involving features we haven't even started
yet.

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

2 years ago[libc++] Merge _LIBCPP_HAS_NO_RANGES into _LIBCPP_HAS_NO_CONCEPTS. NFC.
Arthur O'Dwyer [Mon, 31 Jan 2022 17:04:08 +0000 (12:04 -0500)]
[libc++] Merge _LIBCPP_HAS_NO_RANGES into _LIBCPP_HAS_NO_CONCEPTS. NFC.

The macro that opts out of `std::ranges::` functionality is called
`_LIBCPP_HAS_NO_INCOMPLETE_RANGES`, and is unrelated to this macro
which is specifically about _compiler_ support for the _syntax_.

The only non-mechanical diff here is in `<__config>`.

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

2 years ago[RISCV] Separate the Zfhmin and Zfh extensions.
Craig Topper [Mon, 31 Jan 2022 16:56:32 +0000 (08:56 -0800)]
[RISCV] Separate the Zfhmin and Zfh extensions.

The spec doesn't seem to be written as if Zfh implies Zfhmin. They
seem to be separate extensions.

This patch moves the instructions from Zfhmin to be enabled with
either the Zfh or Zfhmin extensions.

Reviewed By: achieveartificialintelligence

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

2 years ago[RISCV] Make Zfhmin in march imply F.
Craig Topper [Mon, 31 Jan 2022 16:56:23 +0000 (08:56 -0800)]
[RISCV] Make Zfhmin in march imply F.

Zfhmin should imply F just like Zfh.

Reviewed By: achieveartificialintelligence

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

2 years ago[flang] Upstream partial lowering of COMMAND_ARGUMENT_COUNT intrinsic
Josh Mottley [Tue, 14 Dec 2021 14:23:11 +0000 (14:23 +0000)]
[flang] Upstream partial lowering of COMMAND_ARGUMENT_COUNT intrinsic

This patch adds partial lowering of the "COMMAND_ARGUMENT_COUNT" intrinsic
to the backend runtime hook implemented in patch D109048. Also adds a
"helper" function for retrieving the default integer type from
FIRBuilder, which will be used later when finishing the lowering of
intrinsic.

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

2 years ago[libc++][test] add vector<bool>::reference tests
Nikolas Klauser [Sat, 29 Jan 2022 16:58:05 +0000 (17:58 +0100)]
[libc++][test] add vector<bool>::reference tests

Add test coverage for `vector<bool>::reference`

Reviewed By: Quuxplusone, ldionne, #libc

Spies: libcxx-commits

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

2 years ago[DebugInfo][InstrRef][NFC] Refactor ahead of further optimisations
Jeremy Morse [Mon, 31 Jan 2022 16:24:20 +0000 (16:24 +0000)]
[DebugInfo][InstrRef][NFC] Refactor ahead of further optimisations

This patch shuffles some functions around so that some blocks of code can
be reused. In particular,
 * Move the determination of "which blocks are in scope" to its own
   function, as it's non-trivial to solve. Delete the "InScopeBlocks"
   collection too, which nothing reads from.
 * Split transfer emission (i.e., installing DBG_VALUEs into blocks) into
   its own function.
 * Name some useful types.
 * Rename "ScopeToBlocks" to "ScopeToAssignBlocks", as that's what the
   collection contains, blocks where assignments happen.

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

2 years agoAdd llvm-pdbutil in LLVM_TOOLCHAIN_TOOLS
Hans Wennborg [Mon, 31 Jan 2022 15:13:03 +0000 (16:13 +0100)]
Add llvm-pdbutil in LLVM_TOOLCHAIN_TOOLS

One can argue that it qualifies as a toolchain tool rather than "internal llvm
tool". This will make it part of builds which set the
LLVM_INSTALL_TOOLCHAIN_ONLY cmake option, such as the Windows installer.

Fixes https://github.com/llvm/llvm-project/issues/53461

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

2 years agoSet rpath on openmp executables
Jon Chesterfield [Mon, 31 Jan 2022 16:26:32 +0000 (16:26 +0000)]
Set rpath on openmp executables

Openmp executables need to find libomp and libomptarget at runtime.
This currently requires LD_LIBRARY_PATH or the user to specify rpath. Change
that to set the expected location of the openmp libraries in the install tree.

Whether rpath means rpath or runpath is system dependent. The attached test
shows that the Wl,--disable-new-dtags control interacts correctly with this feature.

The implicit rpath field is appended to any user specified ones which is ideal.

Reviewed By: jhuber6

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

2 years agoRevert "Set rpath on openmp executables"
Jon Chesterfield [Mon, 31 Jan 2022 16:16:55 +0000 (16:16 +0000)]
Revert "Set rpath on openmp executables"

Failed some buildbots, bad assumptions about structure of install path

This reverts commit a80d5c34e4b99f21fa371160ac7eb7e9db093997.

2 years agoRevert "[DebugInfo][InstrRef][NFC] Add a missing assignment operator"
Jeremy Morse [Mon, 31 Jan 2022 16:14:20 +0000 (16:14 +0000)]
Revert "[DebugInfo][InstrRef][NFC] Add a missing assignment operator"

This reverts commit f18429372f12b571aef539855c4dbef23a96f494.

Bitten by -Werror,-Wdeprecated-copy on a buildbot, alas!

2 years ago[InstCombine] add tests for potential mul demanded bits fold; NFC
Sanjay Patel [Mon, 31 Jan 2022 15:57:58 +0000 (10:57 -0500)]
[InstCombine] add tests for potential mul demanded bits fold; NFC

This is discussed as an enhancement in D118539.

2 years ago[DebugInfo][InstrRef][NFC] Add a missing assignment operator
Jeremy Morse [Sun, 30 Jan 2022 20:25:00 +0000 (20:25 +0000)]
[DebugInfo][InstrRef][NFC] Add a missing assignment operator

ValueIDNum is supposed to be a value type that boils down to a uint64_t,
that has some bitfields for convenience. If we use the default operator=,
we end up with each bit field being individually assigned, which is
un-necessarily slow.

Implement the assignment operator by just copying the uint64_t value of
the object. This is quicker, and matches how the comparison operators
work already. Doing so is 0.1% faster on the compile-time-tracker.

2 years agoSet rpath on openmp executables
Jon Chesterfield [Mon, 31 Jan 2022 16:01:04 +0000 (16:01 +0000)]
Set rpath on openmp executables

Openmp executables need to find libomp and libomptarget at runtime.
This currently requires LD_LIBRARY_PATH or the user to specify rpath. Change
that to set the expected location of the openmp libraries in the install tree.

Whether rpath means rpath or runpath is system dependent. The attached test
shows that the Wl,--disable-new-dtags control interacts correctly with this feature.

The implicit rpath field is appended to any user specified ones which is ideal.

Reviewed By: jhuber6

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

2 years ago[gn build] Port f3514af492ee
LLVM GN Syncbot [Mon, 31 Jan 2022 15:38:08 +0000 (15:38 +0000)]
[gn build] Port f3514af492ee

2 years ago[libc++][ranges] Add ranges::in_in_out_result
Nikolas Klauser [Tue, 25 Jan 2022 10:21:47 +0000 (11:21 +0100)]
[libc++][ranges]  Add ranges::in_in_out_result

Add `ranges::in_in_out_result`

Reviewed By: Quuxplusone, Mordante, #libc

Spies: CaseyCarter, libcxx-commits, mgorny

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

2 years ago[flang][NFC] Remove out of date IO helper
Valentin Clement [Mon, 31 Jan 2022 15:32:54 +0000 (16:32 +0100)]
[flang][NFC] Remove out of date IO helper

Functionality in IO.h and IO.cpp have been upstreamed together with the frontend
when flang landed upstream. Those files are out of date compared with fir-dev.
These functionality will be upstreamed again when needed in the lowering process
with an up to date code and a proper review.

These files (and the functions it contains) are not currently used. Hence
removing it is NFC.

Reviewed By: kiranchandramohan

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

2 years ago[cte] Add release notes for clangd-14
Kadir Cetinkaya [Mon, 31 Jan 2022 11:01:24 +0000 (12:01 +0100)]
[cte] Add release notes for clangd-14

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

2 years ago[mlir][bufferize][NFC] Move vector BufferizableOpInterface impl to vector dialect
Matthias Springer [Mon, 31 Jan 2022 15:27:13 +0000 (00:27 +0900)]
[mlir][bufferize][NFC] Move vector BufferizableOpInterface impl to vector dialect

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

2 years ago[clang][Lexer] Make raw and normal lexer behave the same for line comments
Kadir Cetinkaya [Fri, 28 Jan 2022 15:18:24 +0000 (16:18 +0100)]
[clang][Lexer] Make raw and normal lexer behave the same for line comments

Normally there are heruistics in lexer to treat `//*` specially in
language modes that don't have line comments (to emit `/`). Unfortunately this
only applied to the first occurence of a line comment inside the file, as the
subsequent line comments were treated as if language had support for them.

This unfortunately only holds in normal lexing mode, as in raw mode all
occurences of line comments received this treatment, which created discrepancies
when comparing expanded and spelled tokens.

The proper fix would be to just make sure we treat all the line comments with a
subsequent `*` the same way, but it would imply breaking some code that's
accepted by clang today. So instead we introduce the same bug into raw lexing
mode.

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

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

2 years agoRevert "[Local] invertCondition: try modifying an existing ICmpInst"
Jay Foad [Mon, 31 Jan 2022 14:55:36 +0000 (14:55 +0000)]
Revert "[Local] invertCondition: try modifying an existing ICmpInst"

This reverts commit a6b54ddaba2d5dc0f72dcc4591c92b9544eb0016.

Apparently it is not safe to modify the condition even if it passes the
hasOneUse test, because StructurizeCFG might have other references to
the condition that are not manifest in the IR use-def chains.

2 years ago[SVE] Fix TypeSize->uint64_t implicit conversion in visitAlloca()
Kerry McLaughlin [Mon, 31 Jan 2022 13:25:02 +0000 (13:25 +0000)]
[SVE] Fix TypeSize->uint64_t implicit conversion in visitAlloca()

Fixes a crash ('Invalid size request on a scalable vector') in visitAlloca()
when we call this function for a scalable alloca instruction, caused
by the implicit conversion of TySize to uint64_t.
This patch changes TySize to a TypeSize as returned by getTypeAllocSize()
and ensures the allocation size is multiplied by vscale for scalable vectors.

Reviewed By: sdesmalen, david-arm

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

2 years ago[ARM] Add Cortex-X1C Support for Clang and LLVM
Ties Stuij [Mon, 31 Jan 2022 14:02:51 +0000 (14:02 +0000)]
[ARM] Add Cortex-X1C Support for Clang and LLVM

This patch upstreams support for the Arm-v8 Cortex-X1C processor for AArch64 and
ARM.

For more information, see:
- https://community.arm.com/arm-community-blogs/b/announcements/posts/arm-cortex-x1c
- https://developer.arm.com/documentation/101968/0002/Functional-description/Technical-overview/Components

The following people contributed to this patch:
- Simon Tatham
- Ties Stuij

Reviewed By: dmgreen

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

2 years ago[Analysis] Attribute noundef should not prevent tail call optimization
Dávid Bolvanský [Mon, 31 Jan 2022 12:45:07 +0000 (13:45 +0100)]
[Analysis] Attribute noundef should not prevent tail call optimization

Very similar to https://reviews.llvm.org/D101230
Fixes https://github.com/llvm/llvm-project/issues/53501

2 years ago[X86] combineAnd() - per-element simplification - call SimplifyDemandedBits using...
Simon Pilgrim [Mon, 31 Jan 2022 13:57:47 +0000 (13:57 +0000)]
[X86] combineAnd() - per-element simplification - call SimplifyDemandedBits using mask demanded bits if SimplifyDemandedVectorElts fails

We already call SimplifyDemandedVectorElts using whether each vector mask element is zero/nonzero, this just extends this to also try SimplifyDemandedBits using the demanded bits mask generated from the nonzero elements.

This also requires an additional TargetLowering::SimplifyDemandedBits DemandedBits/DemandedElts wrapper.

2 years ago[DebugInfo][InstrRef] Don't fully propagate single assigned variables
Jeremy Morse [Mon, 31 Jan 2022 12:38:59 +0000 (12:38 +0000)]
[DebugInfo][InstrRef] Don't fully propagate single assigned variables

If we only assign a variable value a single time, we can take a short-cut
when computing its location: the variable value is only valid up to the
dominance frontier of where the assignemnt happens. Past that point, there
are other predecessors from where the variable has no value, meaning the
variable has no location past that point.

This patch recognises this scenario, and avoids expensive SSA computation,
to improve compile-time performance.

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

2 years agoDon't rely on clang being named clang in test
Benjamin Kramer [Mon, 31 Jan 2022 12:50:05 +0000 (13:50 +0100)]
Don't rely on clang being named clang in test

2 years agoRevert "[gn build] (manually) port 36892727e4f1"
Nico Weber [Mon, 31 Jan 2022 12:15:36 +0000 (07:15 -0500)]
Revert "[gn build] (manually) port 36892727e4f1"

This reverts commit 7b2dfe1c226a4e9f193b8432c64c32c58ca9990a.

Matches ab3b89855c53.

2 years agoSave some `std::string` allocations/deallocations when formatting attributes (NFC)
Momchil Velikov [Mon, 31 Jan 2022 10:48:14 +0000 (10:48 +0000)]
Save some `std::string` allocations/deallocations when formatting attributes (NFC)

Reviewed By: MaskRay

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

2 years ago[DAG] SimplifyDemandedBits - mul(x,x) - if only demand bit[1] then fold to zero
Simon Pilgrim [Mon, 31 Jan 2022 12:00:51 +0000 (12:00 +0000)]
[DAG] SimplifyDemandedBits - mul(x,x) - if only demand bit[1] then fold to zero

2 years ago[X86] Limit mul(x,x) knownbits tests with not undef/poison check
Simon Pilgrim [Mon, 31 Jan 2022 11:36:03 +0000 (11:36 +0000)]
[X86] Limit mul(x,x) knownbits tests with not undef/poison check

We can only assume bit[1] == zero if its the only demanded bit or the source is not undef/poison

2 years ago[AMDGPU] AMDGPUAnnotateUniformValues: inline a single-use lambda. NFC.
Jay Foad [Mon, 31 Jan 2022 11:22:00 +0000 (11:22 +0000)]
[AMDGPU] AMDGPUAnnotateUniformValues: inline a single-use lambda. NFC.

2 years ago[AMDGPU] Add test for a problem with noclobber metadata
Jay Foad [Fri, 28 Jan 2022 13:05:39 +0000 (13:05 +0000)]
[AMDGPU] Add test for a problem with noclobber metadata

If AMDGPUAnnotateUniformValues finds a load from a uniform pointer with
no potentially clobbering stores between the kernel entry point and the
load instruction, it adds noclobber metadata to the *address*. This is
unsafe because it can get applied to other loads in the same which do
have aliasing stores.

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

2 years ago[X86] Add mul(x,x) tests showing miscompile
Simon Pilgrim [Mon, 31 Jan 2022 11:06:02 +0000 (11:06 +0000)]
[X86] Add mul(x,x) tests showing miscompile

As raised by @efriedma on D117995 - the source must not be undef/poison to demand any bits in mul(x,x) other than bit[1]

https://alive2.llvm.org/ce/z/Cxkjen

2 years ago[Local] invertCondition: try modifying an existing ICmpInst
Jay Foad [Fri, 28 Jan 2022 14:45:06 +0000 (14:45 +0000)]
[Local] invertCondition: try modifying an existing ICmpInst

This avoids various cases where StructurizeCFG would otherwise insert an
xor i1 instruction, and it since it generally runs late in the pipeline,
instcombine does not clean up the xor-of-cmp pattern.

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

2 years ago[WebAssembly] Refactor and fix emission of external IR global decls
Paulo Matos [Mon, 31 Jan 2022 10:42:02 +0000 (11:42 +0100)]
[WebAssembly] Refactor and fix emission of external IR global decls

This patches fixes the visibility and linkage information of symbols
referring to IR globals.

Emission of external declarations is now done in the first execution
of emitConstantPool rather than in emitLinkage (and a few other
places). This is the point where we have already gathered information
about used symbols (by running the MC Lower PrePass) and not yet
started emitting any functions so that any declarations that need to
be emitted are done so at the top of the file before any functions.

This changes the order of a few directives in the final asm file which
required an update to a few tests.

Reviewed By: sbc100

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

2 years ago[flang][driver][nfc] Fix capitalisation
Andrzej Warzynski [Thu, 27 Jan 2022 16:44:44 +0000 (16:44 +0000)]
[flang][driver][nfc] Fix capitalisation

As pointed out in https://reviews.llvm.org/D93401, some methods in the
Flang driver are named inconsistently. The driver strives to follow
Flang's C++ style [1] and this patch updates these methods accordingly.

[1]
https://github.com/llvm/llvm-project/blob/main/flang/docs/C%2B%2Bstyle.md

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

2 years ago[Analyzer] Add docs to StdCLibraryFunctionArgsChecker
Gabor Marton [Tue, 18 Jan 2022 16:47:32 +0000 (17:47 +0100)]
[Analyzer] Add docs to StdCLibraryFunctionArgsChecker

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

2 years ago[OpenCL] Make generic addrspace optional for -fdeclare-opencl-builtins
Sven van Haastregt [Mon, 31 Jan 2022 10:21:05 +0000 (10:21 +0000)]
[OpenCL] Make generic addrspace optional for -fdeclare-opencl-builtins

Currently, -fdeclare-opencl-builtins always adds the generic address
space overloads of e.g. the vload builtin functions in OpenCL 3.0
mode, even when the generic address space feature is disabled.

Guard the generic address space overloads by the
`__opencl_c_generic_address_space` feature instead of by OpenCL
version.

Guard the private, global, and local overloads using the internal
`__opencl_c_named_address_space_builtins` feature.

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

2 years ago[AArch64] Fix costs of float vector compare/selects pairs.
Florian Hahn [Mon, 31 Jan 2022 10:18:28 +0000 (10:18 +0000)]
[AArch64] Fix costs of float vector compare/selects pairs.

The current cost-model overestimates the cost of vector compares &
selects for ordered floating point compares. This patch fixes that by
extending the existing logic for integer predicates.

Reviewed By: dmgreen

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

2 years ago[clang-tidy] Make header compile standalone. NFC.
Benjamin Kramer [Mon, 31 Jan 2022 10:17:41 +0000 (11:17 +0100)]
[clang-tidy] Make header compile standalone. NFC.

2 years ago[mlir][vector][NFC] Split into IR, Transforms and Utils
Matthias Springer [Mon, 31 Jan 2022 10:10:51 +0000 (19:10 +0900)]
[mlir][vector][NFC] Split into IR, Transforms and Utils

This reduces the dependencies of the MLIRVector target and makes the dialect consistent with other dialects.

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

2 years agoFix -Wreserved-identifier in presence of system macro
serge-sans-paille [Sat, 29 Jan 2022 08:17:53 +0000 (09:17 +0100)]
Fix -Wreserved-identifier in presence of system macro

Do not warn on reserved identifiers resulting from expansion of system macros.
Also properly test -Wreserved-identifier wrt. system headers.

Should fix #49592

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

2 years agoCleanup LLVMRemarks includes
serge-sans-paille [Fri, 28 Jan 2022 14:03:45 +0000 (15:03 +0100)]
Cleanup LLVMRemarks includes

Based on the output of include-what you-use.

Most notably, llvm/Remarks/Remark.h is no longer automatically included by
llvm/Remarks/RemarkParser.h, so client code may need to include explicitly.

clang++ -E  -Iinclude -I../llvm/include ../llvm/lib/Remarks/*.cpp -std=c++14 -fno-rtti -fno-exceptions | wc -l
before: 770253
after:  759347

Related discourse thread: https://llvm.discourse.group/t/include-what-you-use-include-cleanup

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

2 years agoCleanup llvm/utils/TableGen headers
serge-sans-paille [Fri, 28 Jan 2022 13:55:42 +0000 (14:55 +0100)]
Cleanup llvm/utils/TableGen headers

Based on the output of include-what-you-use.
It's an utility directory, so no much impact on other code areas.

clang++ -E  -Iinclude -I../llvm/include ../llvm/utils/TableGen/*.cpp -std=c++14 -fno-rtti -fno-exceptions | wc -l
before: 4327274
after:  4316190

Related discourse thread: https://llvm.discourse.group/t/include-what-you-use-include-cleanup
Differential Revision: https://reviews.llvm.org/D118466

2 years ago[clang-tidy] bugprone-signal-handler improvements: display call chain
Balázs Kéri [Mon, 31 Jan 2022 08:47:49 +0000 (09:47 +0100)]
[clang-tidy] bugprone-signal-handler improvements: display call chain

Display notes for a possible call chain if an unsafe function is found to be
called (maybe indirectly) from a signal handler.
The call chain displayed this way includes probably not the first calls of
the functions, but it is a valid possible (in non path-sensitive way) one.

Reviewed By: aaron.ballman

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

2 years agoRevert "enable plugins for clang-tidy"
Petr Hosek [Mon, 31 Jan 2022 08:54:17 +0000 (00:54 -0800)]
Revert "enable plugins for clang-tidy"

This reverts commit 36892727e4f19a60778e371d78f8fb09d8122c85 which
breaks the build when LLVM_INSTALL_TOOLCHAIN_ONLY is enabled with:

  CMake Error at cmake/modules/AddLLVM.cmake:683 (add_dependencies):
  The dependency target "clang-tidy-headers" of target "CTTestTidyModule"
  does not exist.

2 years ago[Inline][Cloning] Reliably remove unreachable blocks during cloning (PR53206)
Nikita Popov [Fri, 28 Jan 2022 11:37:28 +0000 (12:37 +0100)]
[Inline][Cloning] Reliably remove unreachable blocks during cloning (PR53206)

The pruning cloner already tries to remove unreachable blocks. The
original cloning process will simplify instructions and constant
terminators, and only clone blocks that are reachable at that point.
However, phi nodes can only be simplified after everything has been
cloned. For that reason, additional blocks may become unreachable
after phi simplification.

The code does try to handle this as well, but only removes blocks
that don't have predecessors. It misses unreachable cycles. This
can cause issues if SEH exception handling code is part of an
unreachable cycle, as the inliner is not prepared to deal with that.

This patch instead performs an explicit scan for reachable blocks,
and drops everything else.

Fixes https://github.com/llvm/llvm-project/issues/53206.

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

2 years ago[RISCV] Avoid pointer element type access for masked atomicrmw intrinsics
Nikita Popov [Thu, 27 Jan 2022 10:15:31 +0000 (11:15 +0100)]
[RISCV] Avoid pointer element type access for masked atomicrmw intrinsics

masked.atomicrmw.*.i32 intrinsics access an i32 (and then possibly
mask it), so hardcode MVT::i32 as the access type here, rather than
determining it from the pointer element type.

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

2 years ago[clang-format] Use EXPECT_EQ instead of setting style to a default value. NFC.
Marek Kurdej [Mon, 31 Jan 2022 08:04:26 +0000 (09:04 +0100)]
[clang-format] Use EXPECT_EQ instead of setting style to a default value. NFC.

2 years ago[lldb] Convert Process KDP Log to the new API
Pavel Labath [Mon, 31 Jan 2022 07:22:31 +0000 (08:22 +0100)]
[lldb] Convert Process KDP Log to the new API

2 years agoAdd missing include to mlir/Target/LLVMIR/Import.h to be standalone (NFC)
Mehdi Amini [Mon, 31 Jan 2022 07:55:00 +0000 (07:55 +0000)]
Add missing include to mlir/Target/LLVMIR/Import.h to be standalone (NFC)

2 years ago[llvm] Remove redundant `;` (NFC)
Amir Ayupov [Mon, 31 Jan 2022 06:36:53 +0000 (22:36 -0800)]
[llvm] Remove redundant `;` (NFC)

2 years ago[InstCombine] Generalize and-reduce pattern to handle `ne` case as well as `eq`
Max Kazantsev [Mon, 31 Jan 2022 05:12:48 +0000 (12:12 +0700)]
[InstCombine] Generalize and-reduce pattern to handle `ne` case as well as `eq`

Following Sanjay's proposal from discussion in D118317, this patch
generalizes and-reduce handling to fold the following pattern
```
  icmp ne (bitcast(icmp ne (lhs, rhs)), 0)
```
into
```
  icmp ne (bitcast(lhs), bitcast(rhs))
```

https://alive2.llvm.org/ce/z/WDcuJ_

Differential Revision: https://reviews.llvm.org/D118431
Reviewed By: lebedev.ri

2 years agoSupport affine.load/store ops in fold-memref-subview-ops pass
Uday Bondhugula [Sun, 30 Jan 2022 13:17:03 +0000 (18:47 +0530)]
Support affine.load/store ops in fold-memref-subview-ops pass

Support affine.load/store ops in fold-memref-subview ops pass. The
existing pass just "inlines" the subview operation on load/stores by
inserting affine.apply ops in front of the memref load/store ops: this
is by design always consistent with the semantics on affine.load/store
ops and the same would work even more naturally/intuitively with the
latter.

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

2 years ago[BOLT][TEST] Fix building some tests with clang-14 by passing -no-pie
Amir Ayupov [Sun, 30 Jan 2022 07:48:48 +0000 (23:48 -0800)]
[BOLT][TEST] Fix building some tests with clang-14 by passing -no-pie

Reviewed By: yota9

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

2 years ago[RISCV] Use existing variable intead of calling getOperand again. NFCI
Craig Topper [Mon, 31 Jan 2022 02:08:00 +0000 (18:08 -0800)]
[RISCV] Use existing variable intead of calling getOperand again. NFCI

This is a slight change because I'm using the ANY_EXTEND result
instead of the original operand, but getNode should constant fold.

While there, add a comment about why the code specifically checks
for a ConstantSDNode.

2 years ago[MLIR][NFC] Update SCF pass cmd line names to prefix scf
Uday Bondhugula [Sun, 30 Jan 2022 11:44:24 +0000 (17:14 +0530)]
[MLIR][NFC] Update SCF pass cmd line names to prefix scf

Update SCF pass cmd line names to prefix `scf`. This is consistent with
guidelines/convention on how to name dialect passes. This also avoids
ambiguity on the context given the multiple `for` operations in the
tree.

NFC.

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

2 years ago[ELF] splitStrings: replace entSize==1 special case with manual loop unswitch. NFC
Fangrui Song [Mon, 31 Jan 2022 01:15:45 +0000 (17:15 -0800)]
[ELF] splitStrings: replace entSize==1 special case with manual loop unswitch. NFC

My x86-64 lld executable is actually smaller.

2 years ago[RISCV] Add more pack and packw test case for Zbkb. NFC
Craig Topper [Sun, 30 Jan 2022 22:32:56 +0000 (14:32 -0800)]
[RISCV] Add more pack and packw test case for Zbkb. NFC

Make sure we cover the encodings use for zext.h and other encodings
not used for zext.h.

2 years ago[RISCV] Merge rv64zbkb-valid.s and rv64zbkb-only-valid.s. NFC
Craig Topper [Sun, 30 Jan 2022 22:07:35 +0000 (14:07 -0800)]
[RISCV] Merge rv64zbkb-valid.s and rv64zbkb-only-valid.s. NFC

Based on the existing naming "only" tests are used for rv32 instructions
that don't exist in rv64. rv32 tests without "only" are for instructions
that are in both rv32 and rv64. The rv64 tests are for instructions
that are only in rv64.

Both of these test files have instruction encodings that are only
valid in rv64 so they can be the same file.

2 years ago[RISCV] Rename rv64-zbkb-valid.s to rv64zbkb-valid.s. NFC
Craig Topper [Sun, 30 Jan 2022 22:03:45 +0000 (14:03 -0800)]
[RISCV] Rename rv64-zbkb-valid.s to rv64zbkb-valid.s. NFC

2 years ago[RISCV] Fix bad CHECK prefix in rv32zbkb-valid.s.
Craig Topper [Sun, 30 Jan 2022 21:58:21 +0000 (13:58 -0800)]
[RISCV] Fix bad CHECK prefix in rv32zbkb-valid.s.

"pack t0, t1, zero" disassembles to "pack t0, t1, zero" with Zbkb
not "zext.h t0, t1"

Part of the test was using a CHECK prefix that doesn't appear on
the RUN line.

2 years ago[clang-tools-extra] Remove unused forward declarations (NFC)
Kazu Hirata [Mon, 31 Jan 2022 00:05:00 +0000 (16:05 -0800)]
[clang-tools-extra] Remove unused forward declarations (NFC)

2 years ago[Analysis] Drop an unnecessary const from a return type (NFC)
Kazu Hirata [Mon, 31 Jan 2022 00:04:58 +0000 (16:04 -0800)]
[Analysis] Drop an unnecessary const from a return type (NFC)

Identified with readability-const-return-type.

2 years ago[llvm] Use = default (NFC)
Kazu Hirata [Mon, 31 Jan 2022 00:04:56 +0000 (16:04 -0800)]
[llvm] Use = default (NFC)

2 years ago[mlgo][regalloc] Fix -Wunused-variable in -DLLVM_ENABLE_ASSERTIONS=off builds after...
Fangrui Song [Sun, 30 Jan 2022 23:18:30 +0000 (15:18 -0800)]
[mlgo][regalloc] Fix -Wunused-variable in -DLLVM_ENABLE_ASSERTIONS=off builds after a8a7bf922cea8af01168f7a4adf4ed0365bcc2b4

2 years ago[ELF] Simplify SectionBase::partition handling and make it live by default. NFC
Fangrui Song [Sun, 30 Jan 2022 23:12:09 +0000 (15:12 -0800)]
[ELF] Simplify SectionBase::partition handling and make it live by default. NFC

Previously an InputSectionBase is dead (`partition==0`) by default.
SyntheticSection calls markLive and BssSection overrides that with markDead.

It is more natural to make InputSectionBase live by default and let
--gc-sections mark InputSectionBase dead.

When linking a Release build of clang:

* --no-gc-sections:, the removed `inputSections` loop decreases markLive time from 4ms to 1ms.
* --gc-sections: the extra `inputSections` loop increases markLive time from 0.181296s to 0.188526s.
  This is as of we lose the removing one `inputSections` loop optimization (4374824ccf6e7ae68264d996a9ae5bb5e3be7fc5).
  I believe the loss can be mitigated if we refactor markLive.

2 years ago[mlgo][regalloc] Fix register masking
Mircea Trofin [Sun, 30 Jan 2022 22:56:38 +0000 (14:56 -0800)]
[mlgo][regalloc] Fix register masking

If AllocationOrder has less than 32 elements, we were treating the extra
positions as if they were valid. This was detected by a subsequent
assert. The fix also tightens the asserts.

2 years ago[mlir] Silence warnings when building with MSVC
Alexandre Ganea [Sun, 30 Jan 2022 22:31:26 +0000 (17:31 -0500)]
[mlir] Silence warnings when building with MSVC

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

2 years agoReplace OwningModuleRef with OwningOpRef<ModuleOp>
Sanjoy Das [Sun, 30 Jan 2022 02:41:10 +0000 (18:41 -0800)]
Replace OwningModuleRef with OwningOpRef<ModuleOp>

This addresses a TODO in BuiltinOps.h.

Reviewed By: rriddle

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

2 years ago[ELF] Change splitSections to objectFiles based parallelForEach. NFC
Fangrui Song [Sun, 30 Jan 2022 21:34:27 +0000 (13:34 -0800)]
[ELF] Change splitSections to objectFiles based parallelForEach. NFC

The work is more balanced.

2 years ago[RISCV] Lower riscv_zip/unzip intrinsic to RISCVISD::SHFL/UNSHFL.
Craig Topper [Sun, 30 Jan 2022 21:18:43 +0000 (13:18 -0800)]
[RISCV] Lower riscv_zip/unzip intrinsic to RISCVISD::SHFL/UNSHFL.

These are special versions of the more general shfli/unshfli
instructions. We can use the general ISD opcodes with the correct
immediates.

2 years ago[Support][NFC] Fix generic `ChildrenGetterTy` of `IDFCalculatorBase`
Markus Böck [Sun, 30 Jan 2022 21:08:53 +0000 (22:08 +0100)]
[Support][NFC] Fix generic `ChildrenGetterTy` of `IDFCalculatorBase`

Both IDFCalculatorBase and its accompanying DominatorTreeBase only supports pointer nodes. The template argument is the block type itself and any uses of GraphTraits is therefore done via a pointer to the node type.
However, the ChildrenGetterTy type of IDFCalculatorBase has a use on just the node type instead of a pointer to the node type. Various parts of the monorepo has worked around this issue by providing specializations of GraphTraits for the node type directly, or not been affected by using specializations instead of the generic case. These are unnecessary however and instead the generic code should be fixed instead.

An example from within Tree is eg. A use of IDFCalculatorBase in InstrRefBasedImpl.cpp. It basically instantiates a IDFCalculatorBase<MachineBasicBlock, false> but due to the bug above then goes on to specialize GraphTraits<MachineBasicBlock> although GraphTraits<MachineBasicBlock*> exists (and should be used instead).

Similar dead code exists in clang which defines redundant GraphTraits to work around this bug.

This patch fixes both the original issue and removes the dead code that was used to work around the issue.

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

2 years ago[RISCV] Custom lower brev8 intrinsic to RISCVISD::GREV.
Craig Topper [Sun, 30 Jan 2022 20:36:15 +0000 (12:36 -0800)]
[RISCV] Custom lower brev8 intrinsic to RISCVISD::GREV.

We can use the RISCVISD::GREV encoding that swaps the bits in
each byte.  This allows it to use the existing computeKnownBits
support for RISCVISD::GREV.

2 years ago[OpenMP] Use nullptr instead of NULL (NFC)
Kazu Hirata [Sun, 30 Jan 2022 20:32:59 +0000 (12:32 -0800)]
[OpenMP] Use nullptr instead of NULL (NFC)

Identified with modernize-use-nullptr.

2 years ago[Analysis] Use != to compare strings (NFC)
Kazu Hirata [Sun, 30 Jan 2022 20:32:57 +0000 (12:32 -0800)]
[Analysis] Use != to compare strings (NFC)

Identified with readability-string-compare.

2 years ago[clang] Remove redundant string initialization (NFC)
Kazu Hirata [Sun, 30 Jan 2022 20:32:55 +0000 (12:32 -0800)]
[clang] Remove redundant string initialization (NFC)

Identified with readability-redundant-string-init.

2 years ago[lldb] Forward-declare ClangExpressionParser (NFC)
Kazu Hirata [Sun, 30 Jan 2022 20:32:53 +0000 (12:32 -0800)]
[lldb] Forward-declare ClangExpressionParser (NFC)

ClangUserExpression.h is relying on the forward declaration of
ClangExpressionParser in ClangFunctionCaller.h.  This patch moves the
forward declaration to ClangUserExpression.h.

2 years ago[CodeGen] Use default member initialization (NFC)
Kazu Hirata [Sun, 30 Jan 2022 20:32:51 +0000 (12:32 -0800)]
[CodeGen] Use default member initialization (NFC)

Identified with modernize-use-default-member-init.

2 years ago[X86] combineVectorTruncation - use PACKUSDW(BLENDW(X,0),BLENDW(Y,0)) for v8i32-...
Simon Pilgrim [Sun, 30 Jan 2022 20:06:59 +0000 (20:06 +0000)]
[X86] combineVectorTruncation - use PACKUSDW(BLENDW(X,0),BLENDW(Y,0)) for v8i32->v8i16 truncation

Limit this to SSE41 - AVX1 targets to avoid UNPCKL(PSHUFB,PSHUFB), pre-SSE41 we don't have PACKUSDW/BLENDW and with AVX2 we can perform this as PERMQ(PSHUFB()).

2 years ago[compiler-rt][builtins] Use c[tl]zsi macro instead of __builtin_c[tl]z
Anatoly Trosinenko [Sun, 30 Jan 2022 18:23:00 +0000 (21:23 +0300)]
[compiler-rt][builtins] Use c[tl]zsi macro instead of __builtin_c[tl]z

`__builtin_c[tl]z` accepts `unsigned int` argument that is not always the
same as uint32_t. For example, `unsigned int` is uint16_t on MSP430.

Reviewed By: aykevl

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

2 years ago[mlir][bufferize] Clean up remaining references to `tensor-constant-bufferize`
Matthias Springer [Sun, 30 Jan 2022 20:01:24 +0000 (05:01 +0900)]
[mlir][bufferize] Clean up remaining references to `tensor-constant-bufferize`

2 years ago[clang-format] Handle C variables with name that matches c++ access specifier
Philip Sigillito [Sun, 30 Jan 2022 19:45:32 +0000 (20:45 +0100)]
[clang-format] Handle C variables with name that matches c++ access specifier

Reviewed By: MyDeveloperDay, curdeius, HazardyKnusperkeks

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

2 years agoApply clang-tidy fixes for llvm-include-order in AttrOrTypeFormatGen.cpp (NFC)
Mehdi Amini [Sun, 30 Jan 2022 11:24:36 +0000 (11:24 +0000)]
Apply clang-tidy fixes for llvm-include-order in AttrOrTypeFormatGen.cpp (NFC)

2 years agoApply clang-tidy fixes for performance-move-const-arg in TestLinalgCodegenStrategy...
Mehdi Amini [Sun, 30 Jan 2022 10:59:42 +0000 (10:59 +0000)]
Apply clang-tidy fixes for performance-move-const-arg in TestLinalgCodegenStrategy.cpp (NFC)

2 years agoApply clang-tidy fixes for readability-identifier-naming in TosaOps.cpp (NFC)
Mehdi Amini [Sun, 30 Jan 2022 10:17:41 +0000 (10:17 +0000)]
Apply clang-tidy fixes for readability-identifier-naming in TosaOps.cpp (NFC)

2 years agoApply clang-tidy fixes for readability-identifier-naming in PolynomialApproximation...
Mehdi Amini [Sun, 30 Jan 2022 09:56:28 +0000 (09:56 +0000)]
Apply clang-tidy fixes for readability-identifier-naming in PolynomialApproximation.cpp (NFC)

2 years agoApply clang-tidy fixes for performance-for-range-copy in SCFInterfaceImpl.cpp (NFC)
Mehdi Amini [Sun, 30 Jan 2022 09:41:27 +0000 (09:41 +0000)]
Apply clang-tidy fixes for performance-for-range-copy in SCFInterfaceImpl.cpp (NFC)

2 years agoApply clang-tidy fixes for modernize-use-equals-default in BufferizableOpInterface...
Mehdi Amini [Sun, 30 Jan 2022 09:34:39 +0000 (09:34 +0000)]
Apply clang-tidy fixes for modernize-use-equals-default in BufferizableOpInterface.cpp (NFC)

2 years agoApply clang-tidy fixes for readability-identifier-naming in AsyncToLLVM.cpp (NFC)
Mehdi Amini [Sun, 30 Jan 2022 09:03:19 +0000 (09:03 +0000)]
Apply clang-tidy fixes for readability-identifier-naming in AsyncToLLVM.cpp (NFC)

2 years ago[compiler-rt][builtins] Use explicitly-sized integer types for LibCalls
Anatoly Trosinenko [Sun, 30 Jan 2022 16:28:08 +0000 (19:28 +0300)]
[compiler-rt][builtins] Use explicitly-sized integer types for LibCalls

Use s[iu]_int instead of `(unsigned) int` and d[ui]_int instead of
`(unsigned) long long` for LibCall arguments.

Note: the `*vfp` LibCall versions were NOT touched.

Reviewed By: aykevl

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

2 years ago[lld-macho] Add support for -add_empty_section
Keith Smiley [Sat, 29 Jan 2022 02:46:51 +0000 (18:46 -0800)]
[lld-macho] Add support for -add_empty_section

This is a ld64 option equivalent to `-sectcreate seg sect /dev/null`
that's useful for creating sections like the RESTRICT section.

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

2 years ago[X86][AVX] matchUnaryShuffle - avoid creation of on-the-fly nodes (PR45974)
Simon Pilgrim [Sun, 30 Jan 2022 17:59:05 +0000 (17:59 +0000)]
[X86][AVX] matchUnaryShuffle - avoid creation of on-the-fly nodes (PR45974)

Don't extract the ANY/ZERO_EXTEND_VECTOR_INREG subvector source until we're definitely combining to a new node.

2 years ago[test][lld-macho] Improve LC_FUNCTION_STARTS test coverage
Keith Smiley [Sat, 29 Jan 2022 01:03:02 +0000 (17:03 -0800)]
[test][lld-macho] Improve LC_FUNCTION_STARTS test coverage

Previously functions that aren't included in the symtab were also
excluded from the function starts. Symbols missing from function starts
degrades the debugger experience in the case you don't have debug info
for them.

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