platform/upstream/llvm.git
2 years agoFix UB in DwarfExpression::emitLegacyZExt()
Adrian Prantl [Tue, 25 Jan 2022 21:29:22 +0000 (13:29 -0800)]
Fix UB in DwarfExpression::emitLegacyZExt()

A shift-left > 63 triggers a UBSAN failure. This patch kicks the can
down the road (to the consumer) by emitting a more compact
representation of the shift computation in DWARF expressions.

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

2 years agoAMDGPU: Emit user sgpr count directives in text asm
Matt Arsenault [Fri, 21 Jan 2022 21:23:09 +0000 (16:23 -0500)]
AMDGPU: Emit user sgpr count directives in text asm

We were emitting these in the object file but not printing them.

2 years ago[NFC] Store Address's alignment into PointerIntPairs
Arthur Eubanks [Fri, 14 Jan 2022 00:30:29 +0000 (16:30 -0800)]
[NFC] Store Address's alignment into PointerIntPairs

This mitigates the extra memory caused by D115725.

On 32-bit arches where we only have 2 bits per PointerIntPair we fall
back to simply storing alignment separately.

Reviewed By: rnk, nikic

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

2 years ago[test][ASan][Win] Print more info when LoadLibrary fails
Arthur Eubanks [Wed, 26 Jan 2022 01:46:29 +0000 (17:46 -0800)]
[test][ASan][Win] Print more info when LoadLibrary fails

Reviewed By: hans

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

2 years ago[gn build] Make HAVE_MALLINFO2 a gn arg, default to false
Arthur Eubanks [Wed, 26 Jan 2022 17:43:44 +0000 (09:43 -0800)]
[gn build] Make HAVE_MALLINFO2 a gn arg, default to false

D117916 broke some people because some distros are still using a glibc
older than 2.33. Add gn arg llvm_have_mallinfo2 and default to false for
now.

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

2 years ago[ELF] Simplify writing the Elf_Chdr header. NFC
Fangrui Song [Wed, 26 Jan 2022 18:23:56 +0000 (10:23 -0800)]
[ELF] Simplify writing the Elf_Chdr header. NFC

And avoiding changing `size` in `writeTo`.

2 years ago[gn build] Manually port D118110
Arthur Eubanks [Wed, 26 Jan 2022 17:49:21 +0000 (09:49 -0800)]
[gn build] Manually port D118110

2 years ago[AMDGPU] SILoadStoreOptimizer: Precommit tests for merging across a swizzled access
Jay Foad [Wed, 26 Jan 2022 17:09:29 +0000 (17:09 +0000)]
[AMDGPU] SILoadStoreOptimizer: Precommit tests for merging across a swizzled access

2 years ago[Bazel] Update config.h to add the new define.
Adrian Kuegel [Wed, 26 Jan 2022 17:28:14 +0000 (18:28 +0100)]
[Bazel] Update config.h to add the new define.

2 years ago[clang][dataflow] Allow clients to disable built-in transfer functions.
Yitzhak Mandelbaum [Tue, 25 Jan 2022 20:36:14 +0000 (20:36 +0000)]
[clang][dataflow] Allow clients to disable built-in transfer functions.

These built-in functions build the (sophisticated) model of the code's
memory. This model isn't used by all analyses, so we provide for disabling it to
avoid incurring the costs associated with its construction.

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

2 years ago[clang] NFC: Use flush() idiomatically
Kirill Bobyrev [Wed, 26 Jan 2022 17:24:37 +0000 (18:24 +0100)]
[clang] NFC: Use flush() idiomatically

Using both `raw_ostream::flush()` and `raw_ostream::str()` consecutively is
redundant. The alternatives are:

- Use `raw_ostream::str()` without `raw_ostream::flush()`
- Use `raw_ostream::flush()` and then use the destination for `raw_ostream`
  writer

The latter is more idiomatic, so the fix resolves this particular case in its
favor.

Reviewed By: kadircet

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

2 years ago[lldb] Remove ConstString::StaticMemorySize
Jonas Devlieghere [Wed, 26 Jan 2022 17:10:50 +0000 (09:10 -0800)]
[lldb] Remove ConstString::StaticMemorySize

Remove ConstString::StaticMemorySize as it is unused and superseded by
GetMemoryStats. It is referenced in a bunch of doc comments but I don't
really understand why. My best guess it that the comments were
copy-pasted from ConstString::MemorySize() even though it didn't make
sense there either. The implementation of StaticMemorySize was being
called on the MemoryPool, not on the ConstString itself.

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

2 years ago[DebugInfo] Add stringLocationExp field to DIStringType
Chih-Ping Chen [Tue, 18 Jan 2022 19:54:01 +0000 (14:54 -0500)]
[DebugInfo] Add stringLocationExp field to DIStringType

DIStringType is used to encode the debug info of a character object
in Fortran. A Fortran deferred-length character object is typically
implemented as a pair of the following two pieces of info: An address
of the raw storage of the characters, and the length of the object.
The stringLocationExp field contains the DIExpression to get to the
raw storage.

This patch also enables the emission of DW_AT_data_location attribute
in a DW_TAG_string_type debug info entry based on stringLocationExp
in DIStringType.

A test is also added to ensure that the bitcode reader is backward
compatible with the old DIStringType format.

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

2 years ago[AMDGPU][SIWholeQuadMode] Use the right VCC register to activate the correct lanes.
Konstantina [Tue, 25 Jan 2022 04:10:20 +0000 (20:10 -0800)]
[AMDGPU][SIWholeQuadMode] Use the right VCC register to activate the correct lanes.

Reviewed By: critson

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

2 years ago[CMake] [Clang] Add option to specify PowerPC long double format
Qiu Chaofan [Wed, 26 Jan 2022 16:49:17 +0000 (00:49 +0800)]
[CMake] [Clang] Add option to specify PowerPC long double format

This method introduces new CMake variable
PPC_LINUX_DEFAULT_IEEELONGDOUBLE (false by default) to enable fp128 as
default long double format.

Reviewed By: jsji

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

2 years ago[AMDGPU] Remove feature register-banking
Stanislav Mekhanoshin [Tue, 25 Jan 2022 22:17:04 +0000 (14:17 -0800)]
[AMDGPU] Remove feature register-banking

Since RegBankReassign pass was removed this feature is not
use for anything.

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

2 years agoFIx typo in comment
Alex Tsao [Wed, 26 Jan 2022 16:32:32 +0000 (22:02 +0530)]
FIx typo in comment

Reviewed By: xgupta

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

2 years ago[AArch64] Add float vector compare/select cost-model tests.
Florian Hahn [Wed, 26 Jan 2022 16:26:19 +0000 (16:26 +0000)]
[AArch64] Add float vector compare/select cost-model tests.

2 years ago[lldb] Fix a couple of use-of-uninit-var errors in Materializer.cpp
Pavel Labath [Wed, 26 Jan 2022 15:46:19 +0000 (16:46 +0100)]
[lldb] Fix a couple of use-of-uninit-var errors in Materializer.cpp

These were probably not picked up before because they only run when
logging is enabled.

2 years agoRevert "Rename llvm::array_lengthof into llvm::size to match std::size from C++17"
Benjamin Kramer [Wed, 26 Jan 2022 15:55:53 +0000 (16:55 +0100)]
Revert "Rename llvm::array_lengthof into llvm::size to match std::size from C++17"

This reverts commit ef8206320769ad31422a803a0d6de6077fd231d2.

- It conflicts with the existing llvm::size in STLExtras, which will now
  never be called.
- Calling it without llvm:: breaks C++17 compat

2 years agoFix ambiguous call to llvm::size introduced in ef8206320769ad31422
serge-sans-paille [Wed, 26 Jan 2022 15:53:38 +0000 (16:53 +0100)]
Fix ambiguous call to llvm::size introduced in ef8206320769ad31422

2 years ago[clang][dataflow] Add a transfer function for CXXBoolLiteralExpr
Stanislav Gatev [Wed, 26 Jan 2022 12:10:38 +0000 (12:10 +0000)]
[clang][dataflow] Add a transfer function for CXXBoolLiteralExpr

This is part of the implementation of the dataflow analysis framework.
See "[RFC] A dataflow analysis framework for Clang AST" on cfe-dev.

Reviewed-by: xazax.hun
Differential Revision: https://reviews.llvm.org/D118236

2 years ago[NFC][ORC][AArch64] use isInt<N> to replace fitsRangeSignedInt on aarch64
dongAxis [Wed, 26 Jan 2022 15:22:09 +0000 (23:22 +0800)]
[NFC][ORC][AArch64] use isInt<N> to replace fitsRangeSignedInt on aarch64

Summary:
This is the first path to support more relocation types on aarch64.
 The patch just uses the isInt<N> to replace fitsRangeSignedInt.

Test Plan:
check-all

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

2 years ago[SDAG] fix bug in ComputeNumSignBits of target constant
Sanjay Patel [Wed, 26 Jan 2022 14:59:51 +0000 (09:59 -0500)]
[SDAG] fix bug in ComputeNumSignBits of target constant

The loop below the changed line assumes that the element
width of the target constant is the same as the element
width of the loaded value, but that is not always true.

We could try harder to do some kind of min/max calc even
if the sizes don't match, but that can be another patch
if needed. This fixes #53401 (miscompile) and does not
change the motivating cases added when this analysis
was introduced:
ad298f86b7ad2a

2 years ago[x86] add test for miscompile from wrong min signbits ( #53401 ); NFC
Sanjay Patel [Wed, 26 Jan 2022 14:55:17 +0000 (09:55 -0500)]
[x86] add test for miscompile from wrong min signbits ( #53401 ); NFC

2 years agoRename llvm::array_lengthof into llvm::size to match std::size from C++17
serge-sans-paille [Wed, 26 Jan 2022 15:11:12 +0000 (10:11 -0500)]
Rename llvm::array_lengthof into llvm::size to match std::size from C++17

As a conquence move llvm::array_lengthof from STLExtras.h to
STLForwardCompat.h (which is included by STLExtras.h so no build
breakage expected).

2 years ago[X86] Add 'getSplitVectorSrc' helper to determine if subvectors all come from the...
Simon Pilgrim [Wed, 26 Jan 2022 15:17:09 +0000 (15:17 +0000)]
[X86] Add 'getSplitVectorSrc' helper to determine if subvectors all come from the same source

Helps determine if the subvector ops come from the same larger vector and match the lower/upper extractions

2 years ago[AMDGPUEmitPrintf] Don't require specific pointer element type
Nikita Popov [Wed, 26 Jan 2022 15:15:09 +0000 (16:15 +0100)]
[AMDGPUEmitPrintf] Don't require specific pointer element type

Rather than checking for i8*, simply add a bitcast to i8*, so the
appendString() code sees the expected type.

2 years ago[clang-format] Correctly format lambdas with variadic template parameters.
Marek Kurdej [Wed, 26 Jan 2022 15:00:26 +0000 (16:00 +0100)]
[clang-format] Correctly format lambdas with variadic template parameters.

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

Reviewed By: MyDeveloperDay, owenpan

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

2 years ago[clang][DeclPrinter] Fix printing for noexcept expressions
Kadir Cetinkaya [Wed, 26 Jan 2022 13:50:40 +0000 (14:50 +0100)]
[clang][DeclPrinter] Fix printing for noexcept expressions

We are already building into the final result, no need to append it
again.

Fixes https://github.com/clangd/vscode-clangd/issues/290.

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

2 years ago[mlir][bufferization] Add an option to use memref types without layout maps
Matthias Springer [Wed, 26 Jan 2022 14:53:55 +0000 (23:53 +0900)]
[mlir][bufferization] Add an option to use memref types without layout maps

This is for compatibility with existing bufferization passes. Also clean up memref type generation a bit.

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

2 years ago[Visualizers] Fix SmallVector<T> visualizer for T inside an anonymous namespace....
Marek Kurdej [Wed, 26 Jan 2022 14:59:21 +0000 (15:59 +0100)]
[Visualizers] Fix SmallVector<T> visualizer for T inside an anonymous namespace. Use `value_type` instead of `$T1`.

At least on MSVC 2022, using $T1 does not work.

Reviewed By: RKSimon

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

2 years ago[PowerPC] Fix eq/ne comparison of v2i64 pre-Power8
Nemanja Ivanovic [Mon, 24 Jan 2022 19:19:20 +0000 (13:19 -0600)]
[PowerPC] Fix eq/ne comparison of v2i64 pre-Power8

In commit 1674d9b6b2da, I fixed the bug where we didn't consider
both words of the result of the comparison. However, the logic
needs to be different for eq and ne.
Namely for eq, we need both words of the doubleword to equal so it
is an AND. OTOH for ne, we need either word to be unequal so it
is an OR.

2 years ago[NVPTX] NFC: Remove unused arguments and attribute from test
Christian Sigg [Wed, 26 Jan 2022 14:52:25 +0000 (15:52 +0100)]
[NVPTX] NFC: Remove unused arguments and attribute from test

2 years ago[clang][lex] Include tracking: simplify and move to preprocessor
Jan Svoboda [Wed, 26 Jan 2022 14:20:19 +0000 (15:20 +0100)]
[clang][lex] Include tracking: simplify and move to preprocessor

This patch replaces the exact include count of each file in `HeaderFileInfo` with a set of included files in `Preprocessor`.

The number of includes isn't a property of a header file but rather a preprocessor state. The exact number of includes is not used anywhere except statistic tracking.

Reviewed By: vsapsai

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

2 years ago[CodeCompletion][clangd] Clean __uglified parameter names in completion & hover
Sam McCall [Thu, 30 Dec 2021 00:57:47 +0000 (01:57 +0100)]
[CodeCompletion][clangd] Clean __uglified parameter names in completion & hover

Underscore-uglified identifiers are used in standard library implementations to
guard against collisions with macros, and they hurt readability considerably.
(Consider `push_back(Tp_ &&__value)` vs `push_back(Tp value)`.
When we're describing an interface, the exact names of parameters are not
critical so we can drop these prefixes.

This patch adds a new PrintingPolicy flag that can applies this stripping
when recursively printing pieces of AST.
We set it in code completion/signature help, and in clangd's hover display.
All three features also do a bit of manual poking at names, so fix up those too.

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

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

2 years ago[AMDGPUHSAMetadataStreamer] Do not assume ABI alignment for pointers
Nikita Popov [Wed, 26 Jan 2022 09:53:21 +0000 (10:53 +0100)]
[AMDGPUHSAMetadataStreamer] Do not assume ABI alignment for pointers

AMDGPUHSAMetadataStreamer currently assumes that pointer arguments
without align attribute have ABI alignment of the pointee type.
This is incompatible with opaque pointers, but also plain incorrect:
Pointer arguments without explicit alignment have alignment 1. It is
the responsibility of the frontent to add correct align annotations.

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

2 years ago[lldb] Add option to show memory tags in memory read output
David Spickett [Fri, 29 Oct 2021 15:11:14 +0000 (16:11 +0100)]
[lldb] Add option to show memory tags in memory read output

This adds an option --show-tags to "memory read".

(lldb) memory read mte_buf mte_buf+32 -f "x" -s8 --show-tags
0x900fffff7ff8000: 0x0000000000000000 0x0000000000000000 (tag: 0x0)
0x900fffff7ff8010: 0x0000000000000000 0x0000000000000000 (tag: 0x1)

Tags are printed on the end of each line, if that
line has any tags associated with it. Meaning that
untagged memory output is unchanged.

Tags are printed based on the granule(s) of memory that
a line covers. So you may have lines with 1 tag, with many
tags, no tags or partially tagged lines.

In the case of partially tagged lines, untagged granules
will show "<no tag>" so that the ordering is obvious.
For example, a line that covers 2 granules where the first
is not tagged:

(lldb) memory read mte_buf-16 mte_buf+16 -l32 -f"x" --show-tags
0x900fffff7ff7ff0: 0x00000000 <...> (tags: <no tag> 0x0)

Untagged lines will just not have the "(tags: ..." at all.
Though they may be part of a larger output that does have
some tagged lines.

To do this I've extended DumpDataExtractor to also print
memory tags where it has a valid execution context and
is asked to print them.

There are no special alignment requirements, simply
use "memory read" as usual. All alignment is handled
in DumpDataExtractor.

We use MakeTaggedRanges to find all the tagged memory
in the current dump, then read all that into a MemoryTagMap.

The tag map is populated once in DumpDataExtractor and re-used
for each subsequently printed line (or recursive call of
DumpDataExtractor, which some formats do).

Reviewed By: omjavaid

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

2 years ago[SCEVExpander] Always use i8 GEP for reused value offset
Nikita Popov [Wed, 26 Jan 2022 14:32:11 +0000 (15:32 +0100)]
[SCEVExpander] Always use i8 GEP for reused value offset

We could keep the non-i8 GEP code for non-opaque pointers, but
there's two reasons I'm dropping it: First, this actually appears
to be dead code, at least it isn't hit in any of our tests. I
expect that this is because we usually expand trip counts, and
those are never pointers (anymore). Second, the non-i8 GEP was
actually incorrect in multiple ways, because it used SCEV type
sizes, which don't match DL type sizes (for pointers) and certainly
don't match type alloc sizes (which is what GEPs actually use).
As such, I'm simplifying the code to always use the i8 GEP code
path if it does get hit.

2 years agoImplement correct cost for SVE bitcasts
Alban Bridonneau [Wed, 26 Jan 2022 13:33:38 +0000 (13:33 +0000)]
Implement correct cost for SVE bitcasts

We have some bitcasts which we know will be simplified,
so their cost is zero.

Reviewed By: david-arm, sdesmalen

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

2 years ago[CMake] Disable mvsc warning for new versions
Sebastian Neubauer [Mon, 24 Jan 2022 19:39:54 +0000 (20:39 +0100)]
[CMake] Disable mvsc warning for new versions

Starting with VS 2019, CMake defaults to the x64 host toolchain, so the
warning does not apply anymore.

References:
VS 2017 defaults to x86
https://cmake.org/cmake/help/latest/generator/Visual%20Studio%2015%202017.html?highlight=host#toolset-selection
VS 2019 and 2022 default to x64 for x64 targets
https://cmake.org/cmake/help/latest/generator/Visual%20Studio%2016%202019.html?highlight=host#toolset-selection
https://cmake.org/cmake/help/latest/generator/Visual%20Studio%2017%202022.html?highlight=host#toolset-selection

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

2 years ago[lldb] Correct \params to \param in StackFrame Doxygen comments
David Spickett [Wed, 26 Jan 2022 13:41:03 +0000 (13:41 +0000)]
[lldb] Correct \params to \param in StackFrame Doxygen comments

2 years ago[lldb] Correct some uses of \b in Doxygen documentation
David Spickett [Wed, 26 Jan 2022 13:35:47 +0000 (13:35 +0000)]
[lldb] Correct some uses of \b in Doxygen documentation

2 years ago[SystemZ][z/OS] Add AutoConvert.h header to MemoryBuffer.cpp
Abhina Sreeskantharajan [Wed, 26 Jan 2022 14:01:28 +0000 (09:01 -0500)]
[SystemZ][z/OS] Add AutoConvert.h header to MemoryBuffer.cpp

This commit https://github.com/llvm/llvm-project/commit/75e164f61d391979b4829bf2746a5d74b94e95f2 removed the AutoConvert.h header causing a build break on z/OS. This patch adds it back to fix it.

Reviewed By: zibi

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

2 years ago[gn build] Port 37c4bd0fdbc6
LLVM GN Syncbot [Wed, 26 Jan 2022 13:56:09 +0000 (13:56 +0000)]
[gn build] Port 37c4bd0fdbc6

2 years ago[lldb] Add MemoryTagMap class
David Spickett [Fri, 29 Oct 2021 15:10:36 +0000 (16:10 +0100)]
[lldb] Add MemoryTagMap class

The tag map holds a sparse set of memory tags and allows
you to query ranges for tags.

Granules that do not have tags will be set to llvm::None.
to keep the ordering intact. If there are no tags for the
requested range we'll just return an empty result so that
callers don't need to check that all values are llvm::None.

This will be combined with MemoryTagManager's MakeTaggedRanges:
* MakeTaggedRanges
* Read from all those ranges
* Insert the results into the tag map
* Give the tag map to whatever needs to print tags

Which in this case will be "memory read"/DumpDataExtractor.

Reviewed By: JDevlieghere

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

2 years ago[DSE] Add test with sret argument (NFC)
Nikita Popov [Wed, 26 Jan 2022 13:25:05 +0000 (14:25 +0100)]
[DSE] Add test with sret argument (NFC)

2 years agoCleanup LLVMTextAPI headers
serge-sans-paille [Wed, 26 Jan 2022 13:02:49 +0000 (08:02 -0500)]
Cleanup LLVMTextAPI headers

Based on the output of iwyu. A full rebuild of llvm-project doesn't exhibit any
significant false dependencies.

The impact on preprocessed output is larger than expected, given the small
amount of changes

$ clang++ -E  -Iinclude -I../llvm/include ../llvm/lib/TextAPI/*.cpp -std=c++14 -fno-rtti -fno-exceptions | wc -l
before: 635319
After: 643716

Discourse thread on the topic: https://llvm.discourse.group/t/include-what-you-use-include-cleanup

2 years agoRewrite Doxygen comment to resolve -Wdocumentation warning (NFC)
Salman Javed [Wed, 26 Jan 2022 12:30:38 +0000 (01:30 +1300)]
Rewrite Doxygen comment to resolve -Wdocumentation warning (NFC)

Comment change only, no functional change intended.
Example of warning:
https://lab.llvm.org/buildbot/#/builders/188/builds/8696/steps/4/logs/warnings__2_

2 years ago[VE] Packed 32/64bit broadcast isel and tests
Simon Moll [Wed, 26 Jan 2022 09:32:26 +0000 (10:32 +0100)]
[VE] Packed 32/64bit broadcast isel and tests

Packed-mode broadcast of f32/i32 requires the subregister to be
replicated to the full I64 register prior. Add repl_i32 and repl_f32 to
faciliate this.

Reviewed By: kaz7

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

2 years agoFix conditional include in ThreadPool
serge-sans-paille [Wed, 26 Jan 2022 13:15:14 +0000 (14:15 +0100)]
Fix conditional include in ThreadPool

Should fix  https://lab.llvm.org/buildbot#builders/37/builds/10259

2 years ago[DSE] Use helper for unwind check (NFCI)
Nikita Popov [Wed, 26 Jan 2022 12:08:39 +0000 (13:08 +0100)]
[DSE] Use helper for unwind check (NFCI)

This should be no functional change, as the cases supported by the
helper and the cases supported by DSE are currently the same, the
code structure is just slightly different.

2 years ago[AArch64] Add NEON test cases for ISD::ABDS/U.
Paul Walker [Wed, 26 Jan 2022 12:55:15 +0000 (12:55 +0000)]
[AArch64] Add NEON test cases for ISD::ABDS/U.

2 years ago[flang][tco] Remove unneeded dependencies
Andrzej Warzynski [Tue, 25 Jan 2022 09:42:35 +0000 (09:42 +0000)]
[flang][tco] Remove unneeded dependencies

`tco` does not generate machine code, so it does not require (machine)
code-gen related dependencies.

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

2 years ago[demangler] refactor SpecialSubKind
Nathan Sidwell [Mon, 24 Jan 2022 15:59:57 +0000 (07:59 -0800)]
[demangler] refactor SpecialSubKind

Code generating the special substitutions in std is a switch statement
with each case block containing the same conststruction template.  It
is more efficient to commonize that after the switch, having
determined which SubKind to create.  Also, let's sort the cases.

Reviewed By: ChuanqiXu

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

2 years ago[demangler] improve test harness
Nathan Sidwell [Mon, 24 Jan 2022 19:07:29 +0000 (11:07 -0800)]
[demangler] improve test harness

The demangler test harness is a little unclear.  The failed demangling
message always causes me to think about 'reality', changing to a
simple 'Found' seems clearer.

The expected-to-fail tests abort as soon as one passes, rather than
continue, and then abort if any passed.  This changes that loop to
fail at the end, in a similar manner to the expected-to-work loop.

Reviewed By: ChuanqiXu

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

2 years agoCleanup headers for BinaryFormat
serge-sans-paille [Wed, 26 Jan 2022 11:22:41 +0000 (06:22 -0500)]
Cleanup headers for BinaryFormat

A few header removal, some forward declarations. As usual, this can
break your build due to false dependencies, the most notable change are:

- "llvm/BinaryFormat/AMDGPUMetadataVerifier.h" no longer includes "llvm/BinaryFormat/MsgPackDocument.h"

The impact on generated preprocessed lines for LLVMBinaryFormat is
pretty nice:

$ clang++ -E  -Iinclude -I../llvm/include ../llvm/lib/BinaryFormat/*.cpp -std=c++14 -fno-rtti -fno-exceptions | wc -l
before this patch: 705281
after this patch: 751456

Discourse thread on the topic: https://llvm.discourse.group/t/include-what-you-use-include-cleanup

2 years ago[mlir][LLVM] Add support for operand_attrs to InlineAsmOp
Nicolas Vasilache [Wed, 26 Jan 2022 10:57:09 +0000 (05:57 -0500)]
[mlir][LLVM] Add support for operand_attrs to InlineAsmOp

This revision adds enough support to allow InlineAsmOp to work properly with indirect memory constraints "*m".
These require an explicit "elementtype" TypeAttr on the operands to pass LLVM verification and need to be provided.

Reviewed By: bkramer

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

2 years ago[X86] Extend PR53419 test coverage
Simon Pilgrim [Wed, 26 Jan 2022 12:32:38 +0000 (12:32 +0000)]
[X86] Extend PR53419 test coverage

Test on SSE2/SSE41/AVX1 targets to compare PMOVMSK vs PTEST codegen paths

Add v8i8 reduction case and test on X64 and X86 targets to check 32-bit handling

2 years ago[AMDGPU] Enable divergence-driven XNOR selection
alex-t [Fri, 24 Dec 2021 14:40:49 +0000 (17:40 +0300)]
[AMDGPU] Enable divergence-driven XNOR selection

Currently not (xor_one_use) pattern is always selected to S_XNOR irrelative od the node divergence.
This relies on further custom selection pass which converts to VALU if necessary and replaces with V_NOT_B32 ( V_XOR_B32)
on those targets which have no V_XNOR.
Current change enables the patterns which explicitly select the not (xor_one_use) to appropriate form.
We assume that xor (not) is already turned into the not (xor) by the combiner.

Reviewed By: rampitec

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

2 years ago[gn build] Port 5da7c040030c
LLVM GN Syncbot [Wed, 26 Jan 2022 12:14:21 +0000 (12:14 +0000)]
[gn build] Port 5da7c040030c

2 years ago[lldb] Convert POSIXLog to use the new API
Pavel Labath [Wed, 26 Jan 2022 12:02:48 +0000 (13:02 +0100)]
[lldb] Convert POSIXLog to use the new API

2 years ago[SVE] Use DUPM to handling more splat immediate cases.
Paul Walker [Mon, 24 Jan 2022 12:35:18 +0000 (12:35 +0000)]
[SVE] Use DUPM to handling more splat immediate cases.

NOTE: Only considers i64 based vectors at this time because smaller
element types require extra isel operand parsing.

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

2 years agoRe-land "Cache the locations of NOLINTBEGIN/END blocks" with fix for build bot
Salman Javed [Wed, 26 Jan 2022 12:02:35 +0000 (01:02 +1300)]
Re-land "Cache the locations of NOLINTBEGIN/END blocks" with fix for build bot

2 years ago[gn build] Port 8e29d19b8d29
LLVM GN Syncbot [Wed, 26 Jan 2022 11:52:58 +0000 (11:52 +0000)]
[gn build] Port 8e29d19b8d29

2 years agoRevert "[clang-tidy] Cache the locations of NOLINTBEGIN/END blocks"
Salman Javed [Wed, 26 Jan 2022 11:52:25 +0000 (00:52 +1300)]
Revert "[clang-tidy] Cache the locations of NOLINTBEGIN/END blocks"

Build warning here:
https://lab.llvm.org/buildbot/#/builders/57/builds/14322

2 years ago[gn build] Port 19eaad94c47f
LLVM GN Syncbot [Wed, 26 Jan 2022 11:47:14 +0000 (11:47 +0000)]
[gn build] Port 19eaad94c47f

2 years ago[MemCpyOpt] Use helper for unwind check
Nikita Popov [Wed, 26 Jan 2022 10:27:44 +0000 (11:27 +0100)]
[MemCpyOpt] Use helper for unwind check

This extends support to byval arguments. It would be further
extended to handle the case of non-captured noalias returns.

2 years ago[clang][dataflow] Enable merging distinct values in Environment::join
Stanislav Gatev [Mon, 24 Jan 2022 13:29:06 +0000 (13:29 +0000)]
[clang][dataflow] Enable merging distinct values in Environment::join

Make specializations of `DataflowAnalysis` extendable with domain-specific
logic for merging distinct values when joining environments. This could be
a strict lattice join or a more general widening operation.

This is part of the implementation of the dataflow analysis framework.
See "[RFC] A dataflow analysis framework for Clang AST" on cfe-dev.

Reviewed-by: xazax.hun
Differential Revision: https://reviews.llvm.org/D118038

2 years ago[Dexter] Remove false requirement of lldb for dexter regression tests on Windows
OCHyams [Wed, 26 Jan 2022 11:09:21 +0000 (11:09 +0000)]
[Dexter] Remove false requirement of lldb for dexter regression tests on Windows

Not quite NFC because a little work was required to configure some tests to run
on Windows at all.

Before this patch on Windows:

    $ llvm-lit cross-project-tests\debuginfo-tests\dexter\feature-tests
       Unsupported: 49
       Passed     : 23

After this patch on Windows:

    $ llvm-lit cross-project-tests\debuginfo-tests\dexter\feature-tests
       Unsupported      : 27
       Passed           : 39
       Expectedly failed:  6

There are 3 main changes here. The first is to add a few more substitutions in
cross-project-tests/lit.cfg.py so that tests need to use specific flags can
still use the dexter regression test defaults for the native platform. These
are:

     %dexter_regression_test_debugger
     %dexter_regression_test_builder
     %dexter_regression_test_cflags
     %dexter_regression_test_ldflags

Tests that now use these options and therefore can be run on Windows too
(though the second is still failing for unknown reasons):

    cross-project-tests/debuginfo-tests/dexte/feature_tests
        /subtools/clang-opt-bisect/clang-opt-bisect.cpp
        /subtools/test/source-root-dir.cpp

The second change is to remove spurious `REQUIRES: system-linux, lldb` and
`UNSUPPORTED: system-windows` directives, and make changes to lit.local.cfg
files that have the same effect. I've also added comments to the genuine
REQUIRES, UNSUPPORTED, and XFAIL directives so it's easier to understand
requirements at a glance. The most common reason for a test to not be supported
on Windows is that it uses DexLimitSteps, DexDeclareAddress, or DexCommandLine,
none of which are supported in the dbgeng driver.

There are two failures on Windows that were previously hidden, which I've
XFAILed:

    cross-project-tests/debuginfo-tests/dexter/feature_tests
        /commands/perfect/dex_finish_test/default_conditional.cpp
        /commands/perfect/dex_finish_test/default_conditional_hit_count.cpp

And two that were easy to fix:

    cross-project-tests/debuginfo-tests/dexter/feature_tests
        /commands/perfect/dex_finish_test/default_simple.cpp
        /commands/perfect/dex_finish_test/default_hit_count.cpp

Lastly, I've set three directories as unsupported.

    cross-project-tests/debuginfo-tests/dexter/feature_tests
        /commands/perfect/limit_steps
        /commands/perfect/dex_declare_address
        /commands/perfect/dex_declare_file

The first two are unsupported on Windows because they contains tests for the
DexLimitSteps and DexDeclareAddress commands which aren't supported in the
dbgeng driver. The third is unsupported on all platforms as the tests involve
invoking clang directly, which isn't currently a supported way of building
tests for dexter in lit (it can cause problems for cross compilers that can
target the host, as the tests use the default triple and linker, which may
be aligned for the default target, not host).

Tested on Windows and Linux.

Reviewed By: jmorse

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

2 years agoFix MSVC 'not all control paths return a value' warning. NFC.
Simon Pilgrim [Wed, 26 Jan 2022 11:33:08 +0000 (11:33 +0000)]
Fix MSVC 'not all control paths return a value' warning. NFC.

2 years ago[AMDGPU][GlobalISel] Combine unmerge of undef
Sebastian Neubauer [Tue, 25 Jan 2022 14:20:42 +0000 (15:20 +0100)]
[AMDGPU][GlobalISel] Combine unmerge of undef

Fold (unmerge undef) -> undef, undef, ...

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

2 years ago[AMDGPU][NFC] Pre-commit regenerated test
Sebastian Neubauer [Tue, 25 Jan 2022 14:22:28 +0000 (15:22 +0100)]
[AMDGPU][NFC] Pre-commit regenerated test

2 years ago[lldb][AArch64] Add MakeTaggedRanges to MemoryTagManager
David Spickett [Fri, 29 Oct 2021 15:09:03 +0000 (16:09 +0100)]
[lldb][AArch64] Add MakeTaggedRanges to MemoryTagManager

This is to be used when you want to know what subranges
of a larger range have memory tagging. Like MakeTaggedRange
but memory without tags is skipped and you get a list of ranges back.

Will be used later by DumpDataExtractor to show memory tags.

MakeTaggedRanges assumes that the memory regions it is
given are sorted in ascending order and do not overlap.
For the current use case where you get regions from
GetMemoryRegions and are on some Linux like OS, this is
reasonable to assume.

I've used asserts to check those conditions. In future
any API binding will check them up front to prevent a crash.

Reviewed By: omjavaid

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

2 years ago[Test] Add test for PR53419
Max Kazantsev [Wed, 26 Jan 2022 10:48:32 +0000 (17:48 +0700)]
[Test] Add test for PR53419

These tests demonstrate how suboptimal is the lowering of
equality checks for short vectors.

2 years ago[clang-tidy] Cache the locations of NOLINTBEGIN/END blocks
Salman Javed [Wed, 26 Jan 2022 10:56:27 +0000 (23:56 +1300)]
[clang-tidy] Cache the locations of NOLINTBEGIN/END blocks

Support for NOLINT(BEGIN/END) blocks (implemented in D108560) is
currently costly. This patch aims to improve the performance with the
following changes:

- The use of tokenized NOLINTs instead of a series of repetitive ad-hoc
string operations (`find()`, `split()`, `slice()`, regex matching etc).
- The caching of NOLINT(BEGIN/END) block locations. Determining these
locations each time a new diagnostic is raised is wasteful as it
requires reading and parsing the entire source file.

Move NOLINT-specific code from `ClangTidyDiagnosticConsumer` to new
purpose-built class `NoLintDirectiveHandler`.

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

2 years ago[mlir][Linalg] Add GenericOp self-copy on buffers folding
Nicolas Vasilache [Wed, 26 Jan 2022 10:19:53 +0000 (05:19 -0500)]
[mlir][Linalg] Add GenericOp self-copy on buffers folding

Reviewed By: pifon2a

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

2 years ago[MemCpyOpt] Add additiona call slot unwind tests (NFC)
Nikita Popov [Wed, 26 Jan 2022 10:48:11 +0000 (11:48 +0100)]
[MemCpyOpt] Add additiona call slot unwind tests (NFC)

Test a possibly unwinding call with a byval and sret argument.

2 years agoremove spurious comma [NFC]
Nuno Lopes [Wed, 26 Jan 2022 10:48:43 +0000 (10:48 +0000)]
remove spurious comma [NFC]

2 years ago[LSV] Vectorize loads of vectors by turning it into a larger vector
Benjamin Kramer [Thu, 13 Jan 2022 12:12:50 +0000 (13:12 +0100)]
[LSV] Vectorize loads of vectors by turning it into a larger vector

Use shufflevector to do the subvector extracts. This allows a lot more
load merging on AMDGPU and also on NVPTX when <2 x half> is involved.

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

2 years ago[clang][dataflow] Assign aggregate storage locations to union stmts
Stanislav Gatev [Wed, 26 Jan 2022 09:15:07 +0000 (09:15 +0000)]
[clang][dataflow] Assign aggregate storage locations to union stmts

This patch ensures that the dataflow analysis framework does not crash
when it encounters access to members of union types.

This is part of the implementation of the dataflow analysis framework.
See "[RFC] A dataflow analysis framework for Clang AST" on cfe-dev.

Reviewed-by: xazax.hun
Differential Revision: https://reviews.llvm.org/D118226

2 years ago[mlir][openmp] Custom syntax for `omp.target` operation
Alexander Batashev [Wed, 26 Jan 2022 10:10:50 +0000 (10:10 +0000)]
[mlir][openmp] Custom syntax for `omp.target` operation

Add a custom parser and printer for `omp.target` operation.

Reviewed By: kiranchandramohan

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

2 years ago[clang] Fix serialized diagnostics edge-cases
Jan Svoboda [Wed, 26 Jan 2022 10:21:49 +0000 (11:21 +0100)]
[clang] Fix serialized diagnostics edge-cases

The Clang frontend sometimes fails on the following assertion when launched with `-serialize-diagnostic-file <x>`:

```
Assertion failed: (BlockScope.empty() && CurAbbrevs.empty() && "Block imbalance"), function ~BitstreamWriter, file BitstreamWriter.h, line 125.
```

This was first noticed when passing an unknown command-line argument to `-cc1`.

It turns out the `DiagnosticConsumer::finish()` function should be called as soon as processing of all source files ends, but there are some code paths where that doesn't happen:

1. when command line parsing fails in `cc1_main()`,
2. when `!Act.PrepareToExecute(*this)` or `!createTarget()` evaluate to `true` in `CompilerInstance::ExecuteAction` and the function returns early.

This patch ensures `finish()` is called in all those code paths.

Reviewed By: Bigcheese

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

2 years ago[clang][syntax] Replace `std::vector<bool>` use
Jan Svoboda [Wed, 26 Jan 2022 10:18:00 +0000 (11:18 +0100)]
[clang][syntax] Replace `std::vector<bool>` use

LLVM Programmer’s Manual strongly discourages the use of `std::vector<bool>` and suggests `llvm::BitVector` as a possible replacement.

This patch replaces `std::vector<bool>` with `llvm::BitVector` in the Syntax library and replaces range-based for loop with regular for loop. This is necessary due to `llvm::BitVector` not having `begin()` and `end()` (D117116).

Reviewed By: dexonsmith, dblaikie

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

2 years ago[llvm][support] Replace `std::vector<bool>` use in YAMLTraits
Jan Svoboda [Wed, 26 Jan 2022 10:16:11 +0000 (11:16 +0100)]
[llvm][support] Replace `std::vector<bool>` use in YAMLTraits

LLVM Programmer’s Manual strongly discourages the use of `std::vector<bool>` and suggests `llvm::BitVector` as a possible replacement.

This patch replaces the use of `std::vector` with `llvm::BitVector` in LLVM's YAML traits and replaces the call to `Vec.insert(Vec.begin(), N, false)` on empty `Vec` with `Vec.resize(N)`, which has the same semantics but avoids using `insert` and iterators, which `llvm::BitVector` doesn't possess.

Reviewed By: dexonsmith, dblaikie

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

2 years ago[NewGVN] FIx phi-of-ops in the presence of memory read operations
Nuno Lopes [Wed, 26 Jan 2022 10:10:22 +0000 (10:10 +0000)]
[NewGVN] FIx phi-of-ops in the presence of memory read operations

The phi-of-ops functionality has a function OpIsSafeForPHIOfOps
to determine when it's safe to create the new phi.
But this function only checks for the obvious dominator conditions
and ignores memory.
This patch takes the conservative approach and disables phi-of-ops
whenever there's a load that doesn't dominate the phi, as its
value may be affected by a store inside the loop.

This can be improved later to check aliasing between the
load/stores.

Fixes https://llvm.org/PR53277

Reviewed By: asbirlea

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

2 years ago[NFC] Additional header dependency cleanup LLVMSupport
serge-sans-paille [Wed, 26 Jan 2022 07:50:00 +0000 (02:50 -0500)]
[NFC] Additional header dependency cleanup LLVMSupport

A few more forward-declarations, a few less headers. the impact on number of
preprocessed lines for LLVMSupport is negligible (-3K lines) but it's always
good to remove dependencies.

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

2 years ago[LICM] Generalize unwinding check during scalar promotion
Nikita Popov [Tue, 11 Jan 2022 10:02:26 +0000 (11:02 +0100)]
[LICM] Generalize unwinding check during scalar promotion

This extract a common isNotVisibleOnUnwind() helper into
AliasAnalysis, which handles allocas, byval arguments and noalias
calls. After D116998 this could also handle sret arguments. We
have similar logic in DSE and MemCpyOpt, which will be switched
to use this helper as well.

The noalias call case is a bit different from the others, because
it also requires that the object is not captured. The caller is
responsible for doing the appropriate check.

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

2 years agoFix edb02d8c5df36bb375df7171b4ba61635564dfb4
serge-sans-paille [Wed, 26 Jan 2022 10:06:12 +0000 (05:06 -0500)]
Fix edb02d8c5df36bb375df7171b4ba61635564dfb4

2 years ago[LICM] Add additional tests for promotion with unwinding (NFC)
Nikita Popov [Tue, 11 Jan 2022 09:57:56 +0000 (10:57 +0100)]
[LICM] Add additional tests for promotion with unwinding (NFC)

2 years ago[OpenMPIRBuilderTest] Avoid pointer element type access
Nikita Popov [Wed, 26 Jan 2022 10:02:03 +0000 (11:02 +0100)]
[OpenMPIRBuilderTest] Avoid pointer element type access

This was reintroduced by D110114.

2 years agoRestrict performPostLD1Combine to 64 and 128 bit vectors
Maciej Gabka [Wed, 26 Jan 2022 09:46:32 +0000 (09:46 +0000)]
Restrict performPostLD1Combine to 64 and 128 bit vectors

When wider vectors are used, for example fixed width SVE,
there is no patterns to select AArch64ISD::LD1LANEpost
nodes, so we should do an early exit.

Reviewed By: paulwalker-arm

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

2 years ago[mlir][Bazel] Remove unnecessary dependencies
Adrian Kuegel [Wed, 26 Jan 2022 09:15:44 +0000 (10:15 +0100)]
[mlir][Bazel] Remove unnecessary dependencies

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

2 years ago[libcxx] [test] Fix mismatches between _aligned_malloc and free() on Windows
Martin Storsjö [Sun, 9 Jan 2022 22:32:47 +0000 (22:32 +0000)]
[libcxx] [test] Fix mismatches between _aligned_malloc and free() on Windows

This allows getting rid of one case of LIBCXX-WINDOWS-FIXME. The fixme
comment was inaccurate; aligned allocation functions are provided these
days, but the test kept failing as it was using mismatched allocation
and free functions.

A similar issue was fixed earlier, in
6596778b46ba69517191e7397289228168064ff4. That test was fixed by
overriding the aligned `operator new` too, and returning a dummy fixed
allocation instead. As this test is libcxx specific, it can use the
internal `std::__libcpp_aligned_free()` instead, to match libcxx's
internal aligned `operator new`.

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

2 years ago[SCEVExpander] Remove pointer element type access in assertion
Nikita Popov [Wed, 26 Jan 2022 09:34:23 +0000 (10:34 +0100)]
[SCEVExpander] Remove pointer element type access in assertion

Assert directly on i8 rather than the element type of i8*.

2 years ago[OpenMPOpt] Add const qualifier (NFC)
Nikita Popov [Wed, 26 Jan 2022 09:20:39 +0000 (10:20 +0100)]
[OpenMPOpt] Add const qualifier (NFC)

Make it clear that this large lambda does not modify the vector.

2 years ago[NFC] Use an llvm::DenseMap instead of std::map in CategorizedHelpPrinter::printOptions
serge-sans-paille [Tue, 25 Jan 2022 20:48:51 +0000 (15:48 -0500)]
[NFC] Use an llvm::DenseMap instead of std::map in CategorizedHelpPrinter::printOptions

It's a recommit of 6427f4c52c31cc36004 (patch included)

2 years ago[AddressSanitizer] Avoid pointer element type accesses
Nikita Popov [Wed, 26 Jan 2022 09:10:13 +0000 (10:10 +0100)]
[AddressSanitizer] Avoid pointer element type accesses

Determine masked load/store type based on the value operand and
result types, rather than pointer element type.

2 years ago[flang] Get rid of code duplication in wrapper. Fix checking of undefined variables.
Yury Gribov [Wed, 19 Jan 2022 08:21:44 +0000 (17:21 +0900)]
[flang] Get rid of code duplication in wrapper. Fix checking of undefined variables.

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

2 years ago[DAG] Create fptoui.sat from clamped fptoui
David Green [Wed, 26 Jan 2022 08:37:44 +0000 (08:37 +0000)]
[DAG] Create fptoui.sat from clamped fptoui

This is the unsigned variant of D111976, where we convert a clamped
fptoui to a fptoui.sat. Because we are unsigned, the condition this time
is only UMIN of UINT_MAX. Similarly to D111976 it handles ISD::UMIN,
ISD::SETCC/ISD::SELECT, ISD::VSELECT or ISD::SELECT_CC nodes.

This especially helps on ARM/AArch64 where the vcvt instructions
naturally saturate the result.

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