platform/upstream/llvm.git
2 years ago[Bitcode] Encode alloca address space
Nikita Popov [Fri, 11 Mar 2022 15:06:02 +0000 (16:06 +0100)]
[Bitcode] Encode alloca address space

Since D101045, allocas are no longer required to be part of the
default alloca address space. There may be allocas in multiple
different address spaces. However, the bitcode reader would
simply assume the default alloca address space, resulting in
either an error or incorrect IR.

Add an optional record for allocas which encodes the address
space.

2 years agoConditional include of missing headers under Z3
serge-sans-paille [Fri, 11 Mar 2022 14:52:10 +0000 (15:52 +0100)]
Conditional include of missing headers under Z3

2 years agoConditional include of Twine.h under Z3
serge-sans-paille [Fri, 11 Mar 2022 14:48:06 +0000 (15:48 +0100)]
Conditional include of Twine.h under Z3

2 years ago[BFI] Use SmallPtrSets. NFCI.
Benjamin Kramer [Fri, 11 Mar 2022 14:18:52 +0000 (15:18 +0100)]
[BFI] Use SmallPtrSets. NFCI.

2 years ago[libc++] Remove workaround for missing declarations on Windows store apps
Louis Dionne [Tue, 24 Aug 2021 14:37:07 +0000 (10:37 -0400)]
[libc++] Remove workaround for missing declarations on Windows store apps

We don't need preprocessor logic to exclude those declarations when compiling for
the Windows App Store, because that is handled by using_if_exists now.

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

2 years ago[libc++] Remove workaround for C11 features on compilers that don't support using_if_...
Louis Dionne [Wed, 18 Aug 2021 13:08:17 +0000 (09:08 -0400)]
[libc++] Remove workaround for C11 features on compilers that don't support using_if_exists

Instead of carrying around #ifdefs to determine whether those functions
are available on the platform, unconditionally use the using_if_exists
attribute to import it into namespace std only when available. That was
the purpose of this attribute from the start.

This change means that trying to use libc++ with an old SDK (or on an
old platform for platforms that ship system headers in /usr/include)
will require a recent Clang that supports the using_if_exists attribute.
When using an older Clang or GCC, the underlying platform has to support
a C11 standard library.

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

2 years ago[libc++] Remove raw call to debug handler from __char_traits_length_checked
Louis Dionne [Tue, 8 Mar 2022 18:05:55 +0000 (13:05 -0500)]
[libc++] Remove raw call to debug handler from __char_traits_length_checked

As a fly-by fix, also move it closer to where it is needed, and add a
comment explaining the existence of this weird function.

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

2 years ago[Verifier] Check type of swifterror alloca
Nikita Popov [Fri, 11 Mar 2022 13:51:20 +0000 (14:51 +0100)]
[Verifier] Check type of swifterror alloca

Per LangRef, swifterror alloca must be a pointer.

Not checking this may result in a verifier error after transforms
instead, so make sure it's discarded early.

2 years ago[VPlan] Helper to check if a recipe uses scalar values of op.
Florian Hahn [Fri, 11 Mar 2022 13:41:08 +0000 (13:41 +0000)]
[VPlan] Helper to check if a recipe uses scalar values of op.

This patch adds a helper to check if a recipe only uses scalars of a
given operand. This is similar to onlyFirstLaneUsed, which was
introduced earlier.

By default, usesScalars falls back on onlyFirstLaneUsed.

Will be used by D120828.

Reviewed By: Ayal

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

2 years ago[ConstantFold] Fix scalable shufflevector fold with all-undef mask
Nikita Popov [Fri, 11 Mar 2022 13:30:02 +0000 (14:30 +0100)]
[ConstantFold] Fix scalable shufflevector fold with all-undef mask

If the input is scalable, we should not be returning a fixed-width
vector as a result.

2 years ago[FuzzMutate] Support scalable shufflevector
Nikita Popov [Fri, 11 Mar 2022 13:19:00 +0000 (14:19 +0100)]
[FuzzMutate] Support scalable shufflevector

2 years ago[IRMutator] Handle module with only declarations
Nikita Popov [Fri, 11 Mar 2022 13:14:16 +0000 (14:14 +0100)]
[IRMutator] Handle module with only declarations

There was a mismatch here, with one check checking whether there
are any functions, and the other collecting only non-declaration
functions.

2 years ago[ConstFold] Don't fold calls with mismatching function type
Nikita Popov [Fri, 11 Mar 2022 13:08:06 +0000 (14:08 +0100)]
[ConstFold] Don't fold calls with mismatching function type

With opaque pointers, this is no longer ensured through pointer
type identity.

2 years ago[libc] Implement expf function that is correctly rounded for all rounding modes.
Tue Ly [Fri, 11 Mar 2022 05:08:34 +0000 (00:08 -0500)]
[libc] Implement expf function that is correctly rounded for all rounding modes.

Implement expf function that is correctly rounded for all rounding modes.

Reviewed By: sivachandra, zimmermann6

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

2 years ago[clang-format] Refactor condition in AnnotatingParser::modifyContext(). NFC.
Marek Kurdej [Fri, 11 Mar 2022 11:12:27 +0000 (12:12 +0100)]
[clang-format] Refactor condition in AnnotatingParser::modifyContext(). NFC.

2 years ago[FunctionAttrs] Rename addReadAttrs -> addMemoryAttrs.
Florian Hahn [Fri, 11 Mar 2022 11:49:22 +0000 (11:49 +0000)]
[FunctionAttrs] Rename addReadAttrs -> addMemoryAttrs.

The addReadAttrs name is out of date, as the function also adds
the writeonly attribute. addMemoryAttrs is more accurate.

2 years ago[flang] Remove deprecated fields from FIROps.td
Andrzej Warzynski [Thu, 10 Mar 2022 16:46:03 +0000 (16:46 +0000)]
[flang] Remove deprecated fields from FIROps.td

This patch removes deprecated parser/printer/verifier fields from
FIROps.td. This is a follow-up of https://reviews.llvm.org/D119776 - it
takes care of operations deriving from `fir_IntegralSwitchTerminatorOp`
and `region_Op`.

No new functionality is added, hence no tests. This patch addresses:
https://github.com/llvm/llvm-project/issues/54314.

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

Some changes were extracted from D121090 (by River Riddle).

co-authored-by: River Riddle <riddleriver@gmail.com>

2 years ago[AArch64][SVE][Clang] Fix crash for incorrect svptrue and svcnt parameters
Matt Devereau [Wed, 9 Mar 2022 15:44:33 +0000 (15:44 +0000)]
[AArch64][SVE][Clang] Fix crash for incorrect svptrue and svcnt parameters

Giving an int parameter to SVE intrinsics svptrue and svcnt caused Clang
to crash on compilation. Changing their parameter types to void instead of
omitting args results in a diagnostic error message instead.

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

2 years ago[Bitcode] Check for type mismatch when assigning value
Nikita Popov [Fri, 11 Mar 2022 11:10:00 +0000 (12:10 +0100)]
[Bitcode] Check for type mismatch when assigning value

If the value is forward-declared, then the type must match,
otherwise we can't RAUW.

2 years agoCleanup include: TableGen
serge-sans-paille [Wed, 9 Mar 2022 21:28:44 +0000 (22:28 +0100)]
Cleanup include: TableGen

This also includes a few cleanup from Support.

Discourse thread: https://discourse.llvm.org/t/include-what-you-use-include-cleanup
Differential Revision: https://reviews.llvm.org/D121331

2 years ago[Bitcode] Delete phi node on error
Nikita Popov [Fri, 11 Mar 2022 10:35:15 +0000 (11:35 +0100)]
[Bitcode] Delete phi node on error

These error conditions are checked after the phi node has been
created, so we also need to delete it.

2 years ago[Bitcode] Improve some error messages
Nikita Popov [Fri, 11 Mar 2022 10:07:23 +0000 (11:07 +0100)]
[Bitcode] Improve some error messages

It's not particularly helpful if 95% of our errors just say
"Invalid record". This at least adds the record type to a subset
of errors.

2 years ago[AArch64] Improve costs for some conversions to fp16.
Florian Hahn [Fri, 11 Mar 2022 10:27:17 +0000 (10:27 +0000)]
[AArch64] Improve costs for some conversions to fp16.

Currently the cost model under-estimates the cost of certain
FP16 conversions.

This patch updates getCastInstrCost to return more accurate costs for
the cases improved in c2ed9fd05479.

Reviewed By: dmgreen

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

2 years ago[ADT] Make BitmaskEnum operations constant expressions
Pavel Labath [Wed, 9 Mar 2022 12:07:33 +0000 (13:07 +0100)]
[ADT] Make BitmaskEnum operations constant expressions

This avoids runtime initialization (a global constructor) whenever they appear
in the initializer.

The patch just adds the constexpr keyword to a couple of functions.

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

2 years ago[AArch64][SVE] Change the asserts in LowerToPredicatedOp to check for legal types
David Sherwood [Wed, 9 Mar 2022 14:39:12 +0000 (14:39 +0000)]
[AArch64][SVE] Change the asserts in LowerToPredicatedOp to check for legal types

When building the LLVM test suite with SVE I discovered a crash
when compiling some Halide tests, which occurs because we try to
use SVE to lower 64-bit vector multiplies and there is no
vscale_range attribute on the function. In this case the min SVE
vector bits was 0, which caused an assert in LowerToPredicatedOp
to fire. I have amended the asserts in this function to check that the
fixed-width type is legal. If the fixed-width type is larger than NEON
and is legal then it must be because we've set the min SVE vector
bits to something > 128. Or if the min SVE bits is 0, then the only
legal types allowed are 128 bit types - for any other types the assert
will fire.

Tests added here:

  CodeGen/AArch64/sve-fixed-length-no-vscale-range.ll

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

2 years ago[InstSimplify] Handle vector GEP when simplifying zero indices
Nikita Popov [Fri, 11 Mar 2022 09:55:48 +0000 (10:55 +0100)]
[InstSimplify] Handle vector GEP when simplifying zero indices

If the base is a scalar and the index is a vector, we can't
simplify, as this is effectively a splat operation.

2 years ago[Bitcode] Delete instruction on error
Nikita Popov [Fri, 11 Mar 2022 09:38:00 +0000 (10:38 +0100)]
[Bitcode] Delete instruction on error

As these errors are detected after the instruction has already been
created (but before it has been inserted into the function), we
also need to delete it.

2 years ago[MLIR][python binding] Add OpaqueAttribute to python binding.
Yun Long [Fri, 11 Mar 2022 09:50:10 +0000 (10:50 +0100)]
[MLIR][python binding] Add OpaqueAttribute to python binding.

Reviewed By: ftynse

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

2 years ago[clang-repl] Add an accessor to our underlying execution engine
Vassil Vassilev [Fri, 11 Mar 2022 08:12:11 +0000 (08:12 +0000)]
[clang-repl] Add an accessor to our underlying execution engine

This patch will allow better incremental adoption of these changes in downstream
cling and other users which want to experiment by customizing the execution
engine.

2 years ago[Bitcode] Report error for missing element type for attr upgrade
Nikita Popov [Fri, 11 Mar 2022 09:17:31 +0000 (10:17 +0100)]
[Bitcode] Report error for missing element type for attr upgrade

Otherwise this is going to crash either the TypeFinder or the
Verifier.

2 years agoFixed a roll-over on size_t in getNewUninitMemBuffer()
Dmitry Vassiliev [Fri, 11 Mar 2022 09:16:58 +0000 (13:16 +0400)]
Fixed a roll-over on size_t in getNewUninitMemBuffer()

Reviewed By: serge-sans-paille

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

2 years ago[docs] Update opaque pointers transition state (NFC)
Nikita Popov [Fri, 11 Mar 2022 08:34:37 +0000 (09:34 +0100)]
[docs] Update opaque pointers transition state (NFC)

Bitcode is now supported.

2 years ago[llvm-c] Document that LLVMGetElementType on pointers is deprecated (NFC)
Nikita Popov [Fri, 11 Mar 2022 08:27:22 +0000 (09:27 +0100)]
[llvm-c] Document that LLVMGetElementType on pointers is deprecated (NFC)

We can't actually deprecate the function, because it is also used
for arrays and vectors, so we can only document this.

2 years ago[flang] Do not return true for pointer sub-object in IsPointerObject
Jean Perier [Fri, 11 Mar 2022 08:22:47 +0000 (09:22 +0100)]
[flang] Do not return true for pointer sub-object in IsPointerObject

evaluate::IsPointerObject used to return true for pointer suboject like
`pointer(10)` while these object are not pointers. This prevented some
checks like 15.5.2.7 to be correctly enforced (e.g., it was possible to
pass `pointer(10)` to a non intent(in) dummy pointer).

After updating IsPointerObject behavior and adding a test for 15.5.2.7 in
call07.f90, a test in call03.f90 for 15.5.2.4(14) was failing.
It appeared the related semantics check was relying on IsPointerObject
to return true for `pointer(10)`. Adapt the code to detect pointer element
in another way.
While looking at the code, I also noticed that semantics was
rejecting `character(1)` pointer/assumed shape suboject when these are
allowed (the standard has a special case for character(1) in
15.5.2.4(14), and I verified that other compilers that enforce 15.5.2.4(14)
do accept this).

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

2 years ago[AMDGPUPromoteAlloca] Make compatible with opaque pointers
Nikita Popov [Thu, 10 Mar 2022 09:44:19 +0000 (10:44 +0100)]
[AMDGPUPromoteAlloca] Make compatible with opaque pointers

This mainly changes the handling of bitcasts to not check the types
being casted from/to -- we should only care about the actual
load/store types. The GEP handling is also changed to not care about
types, and just make sure that we get an offset corresponding to
a vector element.

This was a bit of a struggle for me, because this code seems to be
pretty sensitive to small changes. The end result seems to produce
strictly better results for the existing test coverage though,
because we can now deal with more situations involving bitcasts.

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

2 years ago[CommandLine] Keep option default value unset if no cl::init() is used
Yevgeny Rouban [Fri, 11 Mar 2022 07:21:45 +0000 (14:21 +0700)]
[CommandLine] Keep option default value unset if no cl::init() is used

Current declaration of cl::opt is incoherent between class and non-class
specializations of the opt_storage template. There is an inconsistency
in the initialization of the Default field: for inClass instances
the default constructor is used - it sets the Optional Default field to
None; though for non-inClass instances the Default field is set to
the type's default value. For non-inClass instances it is impossible
to know if the option is defined with cl::init() initializer or not:

cl::opt<int> i1("option-i1");
cl::opt<int> i2("option-i2", cl::init(0));
cl::opt<std::string> s1("option-s1");
cl::opt<std::string> s2("option-s2", cl::init(""));

assert(s1.Default.hasValue() != s2.Default.hasValue()); // Ok
assert(i1.Default.hasValue() != i2.Default.hasValue()); // Fails

This patch changes constructor of the non-class specializations to keep
the Default field unset (that is None) rather than initialize it with
DataType().

Reviewed By: lattner
Differential Revision: https://reviews.llvm.org/D114645

2 years ago[flang] Fix processing ModuleLikeUnit evaluationList
Peixin-Qiao [Fri, 11 Mar 2022 07:20:23 +0000 (15:20 +0800)]
[flang] Fix processing ModuleLikeUnit evaluationList

Push the ModuleLikeUnit evalutionList when entering module unit. Pop it
when exiting module unit if there is no module procedure. Otherwise, pop
it when entering the first module procedure.

Reviewed By: V Donaldson

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

2 years ago[RISCV] Add tablegen helper classes to create PatFrag to check for one use. NFC
Craig Topper [Fri, 11 Mar 2022 06:53:22 +0000 (22:53 -0800)]
[RISCV] Add tablegen helper classes to create PatFrag to check for one use. NFC

Reduces code and the class can be instantiated in isel patterns to
avoid creating more *_oneuse classes.

2 years ago[flang] Support for dump OpenMP/OpenACC declarative directives PFT in module
Peixin-Qiao [Fri, 11 Mar 2022 06:33:17 +0000 (14:33 +0800)]
[flang] Support for dump OpenMP/OpenACC declarative directives PFT in module

OpenMP/OpenACC declarative directives can also be used in module unit.
Add support for dump them in module.

Reviewed By: kiranchandramohan, V Donaldson

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

2 years ago[RISCV] Fix typo in comment. NFC
Craig Topper [Fri, 11 Mar 2022 05:56:57 +0000 (21:56 -0800)]
[RISCV] Fix typo in comment. NFC

2 years ago[RISCV] Add alias for HFENCE.VVMA
Eric Tang [Thu, 3 Mar 2022 09:17:23 +0000 (17:17 +0800)]
[RISCV] Add alias for HFENCE.VVMA

Signed-off-by: Eric Tang <eric.tang@starfivetech.com>
Differential Revision: https://reviews.llvm.org/D120878

2 years ago[Attributor][NFCI] Make AAPointerInfo deterministic
Johannes Doerfert [Tue, 8 Mar 2022 22:46:49 +0000 (16:46 -0600)]
[Attributor][NFCI] Make AAPointerInfo deterministic

The order in which we kept accesses was non-deterministic and a debug
output was a pointer value. Fixed both.

2 years ago[Attributor][NFCI] Remove non-deterministic behavior and debug output
Johannes Doerfert [Tue, 8 Mar 2022 22:35:23 +0000 (16:35 -0600)]
[Attributor][NFCI] Remove non-deterministic behavior and debug output

2 years ago[RISCV] Use ZERO_EXTEND instead of ANY_EXTEND when promoting i32 RISCVISD::SHFL. NFC
Craig Topper [Fri, 11 Mar 2022 04:03:23 +0000 (20:03 -0800)]
[RISCV] Use ZERO_EXTEND instead of ANY_EXTEND when promoting i32 RISCVISD::SHFL. NFC

We know the shift amount is a constant with bit 31 clear. anyext
of constant will be either zext or sext which will produce the
same result here. But we really shouldn't rely on that. It would
be valid to put a random number in the upper bits. Our isel patterns
expect the upper bits to be 0 so we should ask for it explicitly.

2 years ago[LoongArch] Use getLoc() directly to construct error message
Weining Lu [Fri, 11 Mar 2022 03:51:26 +0000 (11:51 +0800)]
[LoongArch] Use getLoc() directly to construct error message

2 years ago[ELF] Add -z pack-relative-relocs
Fangrui Song [Fri, 11 Mar 2022 03:54:20 +0000 (19:54 -0800)]
[ELF] Add -z pack-relative-relocs

GNU ld 2.38 added -z pack-relative-relocs which is similar to
--pack-dyn-relocs=relr but synthesizes the `GLIBC_ABI_DT_RELR` version
dependency if a shared object named `libc.so.*` has a `GLIBC_2.*` version
dependency.

This is used to implement the (as some glibc folks call) version lockout
mechanism. Add this option, because glibc does not want to support
--pack-dyn-relocs=relr which does not add `GLIBC_ABI_DT_RELR`.
See https://maskray.me/blog/2021-10-31-relative-relocations-and-relr for
detail.

Close https://github.com/llvm/llvm-project/issues/53775

Reviewed By: peter.smith

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

2 years ago[llvm-mt] Add support /notify_update
Alex Brachet [Fri, 11 Mar 2022 03:46:46 +0000 (03:46 +0000)]
[llvm-mt] Add support /notify_update

`/notify_update` is an undocumented feature used by CMake. From their usage, it looks like this feature just changes `mt`'s exit code if the output file was changed. See https://gitlab.kitware.com/cmake/cmake/-/blob/master/Source/cmcmd.cxx#L2300 this is also consistent with some testing I have done of the mt.exeshipped with Visual Studio. See also the comment at https://gitlab.kitware.com/cmake/cmake/-/blob/master/Source/cmcmd.cxx#L2440.

There might be a more performant way to implement this by first checking calling `llvm::sys::fs::file_size()` and if it is the same as the new output's size use `llvm::WritableMemoryBuffer` and fallback to `llvm::FileOutputBuffer` otherwise,  but these don't inherit from a common ancestor so any implementation doing this would be really ugly.

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

Reviewed By: phosek

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

2 years ago[builtins] Use mcr for dmb instruction on armv6
Khem Raj [Fri, 11 Mar 2022 03:30:00 +0000 (19:30 -0800)]
[builtins] Use mcr for dmb instruction on armv6

At present compiler-rt cross compiles for armv6 ( -march=armv6 ) but includes
dmb instructions which are only available in armv7+ this causes SIGILL on
clang+compiler-rt compiled components on rpi0w platforms.

Reviewed By: MaskRay

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

2 years agoSplit up large test files(over 10k lines) under clang/test/CodeGen/RISCV including:
4vtomat [Fri, 11 Mar 2022 01:26:48 +0000 (17:26 -0800)]
Split up large test files(over 10k lines) under clang/test/CodeGen/RISCV including:

The llvm pre-merge test got timeout due to large test files, this commit
split up the files that have over 10k lines under clang/test/CodeGen/RISCV
into even smaller ones.

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

2 years ago[mlir] Support verification order (3/3)
Chia-hung Duan [Thu, 10 Mar 2022 22:10:45 +0000 (22:10 +0000)]
[mlir] Support verification order (3/3)

In this CL, update the function name of verifier according to the
behavior. If a verifier needs to access the region then it'll be updated
to `verifyRegions`.

Reviewed By: rriddle

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

2 years ago[lld-macho][nfc] Fix formatting in ld64-vs-lld.rst
Jez Ng [Thu, 10 Mar 2022 23:33:18 +0000 (18:33 -0500)]
[lld-macho][nfc] Fix formatting in ld64-vs-lld.rst

2 years ago[x86] add tests for and+setcc; NFC
Sanjay Patel [Thu, 10 Mar 2022 22:56:15 +0000 (17:56 -0500)]
[x86] add tests for and+setcc; NFC

2 years ago[ARM] Fix 8-bit immediate overflow in the instruction of segmented stack prologue.
Zhiyao Ma [Thu, 10 Mar 2022 23:13:41 +0000 (15:13 -0800)]
[ARM] Fix 8-bit immediate overflow in the instruction of segmented stack prologue.

It fixes the overflow of 8-bit immediate field in the emitted
instruction that allocates large stacklet.

For thumb2 targets, load large immediate by a pair of movw and movt
instruction. For thumb1 and ARM targets, load large immediate by reading
from literal pool.

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

2 years ago[AArch64] Use correct calling convention for each vararg
Philippe Valembois [Thu, 10 Mar 2022 23:05:29 +0000 (15:05 -0800)]
[AArch64] Use correct calling convention for each vararg

While checking is tail call optimization is possible, the calling
convention applied to fixed arguments is not the correct one.
This implies for DarwinPCS that all arguments of a vararg function will
go to the stack although fixed ones can go in registers.

This prevents non-virtual thunks to be tail optimized although they are
marked as musttail.

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

2 years ago[clang-format] Fix namespace format when the name is followed by a macro
Zequan Wu [Wed, 9 Mar 2022 02:59:46 +0000 (18:59 -0800)]
[clang-format] Fix namespace format when the name is followed by a macro

Example:
```
$ cat a.cpp
namespace my_namespace::yeah API_AVAILABLE(macos(10.15)) {
void test() {}
}

$ clang-format a.cpp
namespace my_namespace::yeah API_AVAILABLE(macos(10.15)) {
void test() {}
}// namespace my_namespace::yeahAPI_AVAILABLE(macos(10.15))
```
After:
```
$ clang-format a.cpp
namespace my_namespace::yeah API_AVAILABLE(macos(10.15)) {
void test() {}
}// namespace my_namespace::yeah
```

Reviewed By: MyDeveloperDay, owenpan, curdeius

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

2 years ago[clang-tools-extra] Don't consider python below LLVM_MINIMUM_PYTHON_VERSION. NFC
Sam McCall [Thu, 10 Mar 2022 22:57:05 +0000 (23:57 +0100)]
[clang-tools-extra] Don't consider python below LLVM_MINIMUM_PYTHON_VERSION. NFC

2 years ago[lldb] Remove unused include in ScriptedProcessInterface.h
Dave Lee [Thu, 10 Mar 2022 22:51:11 +0000 (14:51 -0800)]
[lldb] Remove unused include in ScriptedProcessInterface.h

2 years ago[Sema][Windows] Don't special-case void* in __unaligned conversions.
Eli Friedman [Thu, 3 Mar 2022 20:29:59 +0000 (12:29 -0800)]
[Sema][Windows] Don't special-case void* in __unaligned conversions.

As far as I can tell, MSVC allows the relevant conversions for all
pointer types. Found compiling a Windows SDK header.

I've verified that the updated errors in MicrosoftExtensions.cpp match
the ones that MSVC actually emits, except for the one with a FIXME. (Not
sure why this wasn't done for the patch that added the tests.)

To make up for the missing error, add a warning that triggers on
conversions that drop the __unaligned qualfier.

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

2 years ago[mlir][Vector] Modernize default lowering of vector transpose
Diego Caballero [Thu, 10 Mar 2022 20:44:24 +0000 (20:44 +0000)]
[mlir][Vector] Modernize default lowering of vector transpose

This patch removes an old recursive implementation to lower vector.transpose to extract/insert operations
and replaces it with a iterative approach that leverages newer linearization/delinearization utilities.
The patch should be NFC except by the order in which the extract/insert ops are generated.

Reviewed By: nicolasvasilache

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

2 years ago[FunctionAttrs] Add tests for argmemonly inference.
Florian Hahn [Thu, 10 Mar 2022 22:32:29 +0000 (22:32 +0000)]
[FunctionAttrs] Add tests for argmemonly inference.

2 years ago[clang-format][NFC] Group all C++ passes under isCpp()
owenca [Thu, 10 Mar 2022 22:20:24 +0000 (14:20 -0800)]
[clang-format][NFC] Group all C++ passes under isCpp()

Also removes a not very helpful comment.

2 years ago[clang-tools-extra] Remove unused lit features/substitutions. NFCI
Sam McCall [Thu, 10 Mar 2022 22:28:43 +0000 (23:28 +0100)]
[clang-tools-extra] Remove unused lit features/substitutions. NFCI

2 years agoFix reference to execute_external leftover in 69924ccf7a328f
Sam McCall [Thu, 10 Mar 2022 22:20:03 +0000 (23:20 +0100)]
Fix reference to execute_external leftover in 69924ccf7a328f

2 years agoRemove redundant lit config already handled in llvm_config. NFCI
Sam McCall [Thu, 10 Mar 2022 22:09:46 +0000 (23:09 +0100)]
Remove redundant lit config already handled in llvm_config. NFCI

This logic duplicates lit.llvm.initialize, which we're already calling
(in lit.site.cfg.py.in).
The equivalent logic was removed from clang in d4401d354a938dd366bf but
never cleaned up here.

2 years ago[lldb] Call ThreadPlan::DiscardPlan from Thread::DiscardPlan
Dave Lee [Thu, 10 Mar 2022 20:11:57 +0000 (12:11 -0800)]
[lldb] Call ThreadPlan::DiscardPlan from Thread::DiscardPlan

Correct `Thread::DiscardPlan` to call `DiscardPlan` instead of `PopPlan`.

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

2 years agollvm-ifs doc: Replace a utf-8 char by a more classic one
Sylvestre Ledru [Thu, 10 Mar 2022 21:40:18 +0000 (22:40 +0100)]
llvm-ifs doc: Replace a utf-8 char by a more classic one

Fails on old python (like on ubuntu bionic) otherwise with:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 2130: ordinal not in range(128)

2 years ago[ASan] Added back @PLT to __asan_report_* calls to avoid compile errors.
Kirill Stoimenov [Thu, 10 Mar 2022 21:29:55 +0000 (21:29 +0000)]
[ASan] Added back @PLT to __asan_report_* calls to avoid compile errors.

Reviewed By: vitalybuka

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

2 years agolldb/ObjectFile,Disassembler: read some state from the executable
Saleem Abdulrasool [Thu, 10 Mar 2022 20:55:46 +0000 (20:55 +0000)]
lldb/ObjectFile,Disassembler: read some state from the executable

Add support to inspect the ELF headers for RISCV targets to determine if
RVC or RVE are enabled and the floating point support to enable.  As per
the RISCV specification, d implies f, q implies d implies f, which gives
us the cascading effect that is used to enable the features when setting
up the disassembler.  With this change, it is now possible to attach the
debugger to a remote process and be able to disassemble the instruction
stream.

~~~
$ bin/lldb tmp/reduced
(lldb) target create "reduced"
Current executable set to '/tmp/reduced' (riscv64).
(lldb) gdb-remote localhost:1234
(lldb) Process 5737 stopped
* thread #1, name = 'reduced', stop reason = signal SIGTRAP
    frame #0: 0x0000003ff7fe1b20
->  0x3ff7fe1b20: mv     a0, sp
    0x3ff7fe1b22: jal    1936
    0x3ff7fe1b26: mv     s0, a0
    0x3ff7fe1b28: auipc  a0, 27
~~~

2 years ago[libc][Obvious] Destroy the block store var in block store test.
Siva Chandra Reddy [Thu, 10 Mar 2022 21:35:43 +0000 (21:35 +0000)]
[libc][Obvious] Destroy the block store var in block store test.

2 years ago[clang-format] Handle "// clang-format off" for RemoveBracesLLVM
owenca [Thu, 10 Mar 2022 04:38:43 +0000 (20:38 -0800)]
[clang-format] Handle "// clang-format off" for RemoveBracesLLVM

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

2 years ago[libc] Add a resizable container with constexpr constructor and destructor.
Siva Chandra Reddy [Wed, 9 Mar 2022 20:54:06 +0000 (20:54 +0000)]
[libc] Add a resizable container with constexpr constructor and destructor.

The new container is used to store atexit callbacks. This way, we avoid
the possibility of the destructor of the container itself getting added
as an at exit callback.

Reviewed By: abrachet

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

2 years agoDiagnose when `#pragma clang fp eval_method` doesn't have a supported value.
Zahira Ammarguellat [Thu, 10 Mar 2022 16:08:12 +0000 (08:08 -0800)]
Diagnose when `#pragma clang fp eval_method` doesn't have a supported value.
Currently the compiler is crashing.

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

2 years ago[ASan] Moved optimized callbacks out of asan_static to avoid DSO size increase.
Kirill Stoimenov [Thu, 10 Mar 2022 20:38:37 +0000 (20:38 +0000)]
[ASan] Moved optimized callbacks out of asan_static to avoid DSO size increase.

Reviewed By: vitalybuka

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

2 years ago[FunctionAttrs] Add initial test for pass statistics.
Florian Hahn [Thu, 10 Mar 2022 21:02:41 +0000 (21:02 +0000)]
[FunctionAttrs] Add initial test for pass statistics.

2 years ago[X86] Add (u)comiss/sd tests showing eflags handling (PR38960)
Simon Pilgrim [Thu, 10 Mar 2022 20:59:31 +0000 (20:59 +0000)]
[X86] Add (u)comiss/sd tests showing eflags handling (PR38960)

2 years ago[libc++] Add tests for the content of <cstddef>
Louis Dionne [Mon, 7 Mar 2022 13:43:14 +0000 (08:43 -0500)]
[libc++] Add tests for the content of <cstddef>

As discussed in D114786.

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

2 years ago[libc++] Remove operator-> from iterator archetypes that don't need it
Louis Dionne [Thu, 27 Jan 2022 18:57:49 +0000 (13:57 -0500)]
[libc++] Remove operator-> from iterator archetypes that don't need it

operator-> is not a requirement for most iterators, so remove it. To
account for this change, the `common_iterator.operator->` test needs to
be refactored quite a bit -- improve test coverage while we're at it.

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

2 years ago[lldb] Always listen for progress events in the default event handler
Jonas Devlieghere [Thu, 10 Mar 2022 20:48:46 +0000 (12:48 -0800)]
[lldb] Always listen for progress events in the default event handler

We came to the conclusion that this doesn't matter for VSCode/Xcode
because they don't use the default event loop and that other clients
who might care should use the setting.

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

2 years ago[LLDB][NativePDB] Add support for S_DEFRANGE_REGISTER and S_DEFRANGE_SUBFIELD_REGISTER
Zequan Wu [Fri, 11 Feb 2022 02:18:59 +0000 (18:18 -0800)]
[LLDB][NativePDB] Add support for S_DEFRANGE_REGISTER and S_DEFRANGE_SUBFIELD_REGISTER

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

2 years ago[mlir][NVVM] Add ldmatrix op to NVVM dialect
Thomas Raoux [Thu, 10 Mar 2022 01:21:07 +0000 (01:21 +0000)]
[mlir][NVVM] Add ldmatrix op to NVVM dialect

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

2 years ago[AMDGPU] Updated some tests to run on gfx940. NFC.
Stanislav Mekhanoshin [Thu, 10 Mar 2022 20:32:38 +0000 (12:32 -0800)]
[AMDGPU] Updated some tests to run on gfx940. NFC.

2 years ago[cmake] Remove unused OUTPUT_MAPPING param to configure_lit_site_cfg(). NFC
Sam McCall [Thu, 10 Mar 2022 20:18:37 +0000 (21:18 +0100)]
[cmake] Remove unused OUTPUT_MAPPING param to configure_lit_site_cfg(). NFC

Looks like it never did anything.
Added in 71deeee593c40ff01e529a6a4b30fa5b55494b82

2 years ago[lld-macho] Align cstrings less conservatively
Jez Ng [Thu, 10 Mar 2022 20:04:31 +0000 (15:04 -0500)]
[lld-macho] Align cstrings less conservatively

Previously, we aligned every cstring to 16 bytes as a temporary hack to
deal with https://github.com/llvm/llvm-project/issues/50135. However, it
was highly wasteful in terms of binary size.

To recap, in contrast to ELF, which puts strings that need different
alignments into different sections, `clang`'s Mach-O backend puts them
all in one section.  Strings that need to be aligned have the .p2align
directive emitted before them, which simply translates into zero padding
in the object file. In other words, we have to infer the alignment of
the cstrings from their addresses.

We differ slightly from ld64 in how we've chosen to align these
cstrings. Both LLD and ld64 preserve the number of trailing zeros in
each cstring's address in the input object files. When deduplicating
identical cstrings, both linkers pick the cstring whose address has more
trailing zeros, and preserve the alignment of that address in the final
binary. However, ld64 goes a step further and also preserves the offset
of the cstring from the last section-aligned address.  I.e. if a cstring
is at offset 18 in the input, with a section alignment of 16, then both
LLD and ld64 will ensure the final address is 2-byte aligned (since
`18 == 16 + 2`). But ld64 will also ensure that the final address is of
the form 16 * k + 2 for some k (which implies 2-byte alignment).

Note that ld64's heuristic means that a dedup'ed cstring's final address is
dependent on the order of the input object files. E.g. if in addition to the
cstring at offset 18 above, we have a duplicate one in another file with a
`.cstring` section alignment of 2 and an offset of zero, then ld64 will pick
the cstring from the object file earlier on the command line (since both have
the same number of trailing zeros in their address). So the final cstring may
either be at some address `16 * k + 2` or at some address `2 * k`.

I've opted not to follow this behavior primarily for implementation
simplicity, and secondarily to save a few more bytes. It's not clear to me
that preserving the section alignment + offset is ever necessary, and there
are many cases that are clearly redundant. In particular, if an x86_64 object
file contains some strings that are accessed via SIMD instructions, then the
.cstring section in the object file will be 16-byte-aligned (since SIMD
requires its operand addresses to be 16-byte aligned). However, there will
typically also be other cstrings in the same file that aren't used via SIMD
and don't need this alignment. They will be emitted at some arbitrary address
`A`, but ld64 will treat them as being 16-byte aligned with an offset of
`16 % A`.

I have verified that the two repros in https://github.com/llvm/llvm-project/issues/50135
work well with the new alignment behavior.

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

Reviewed By: #lld-macho, oontvoo

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

2 years ago[BOLT] Divide RegularPageSize for X86 and AArch64 cases
Elvina Yakubova [Thu, 10 Mar 2022 20:04:03 +0000 (23:04 +0300)]
[BOLT] Divide RegularPageSize for X86 and AArch64 cases

For AArch64 in some cases/some distributions ld uses 64K alignment of LOAD segments by default.

Reviewed By: yota9, maksfb

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

2 years ago[lldb] Remove extra space in step logging message
Dave Lee [Thu, 10 Mar 2022 20:01:15 +0000 (12:01 -0800)]
[lldb] Remove extra space in step logging message

When seeing the extra space in the log, it wasn't clear if there was a missing
printf argument. Removing the extra space removes the potential confusion.

2 years ago[mlir][sparse] Improving error messages for openSparseTensorCOO
wren romano [Wed, 9 Mar 2022 23:53:04 +0000 (15:53 -0800)]
[mlir][sparse] Improving error messages for openSparseTensorCOO

Reviewed By: aartbik

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

2 years ago[RISCV] Remove performANY_EXTENDCombine.
Craig Topper [Thu, 10 Mar 2022 19:26:05 +0000 (11:26 -0800)]
[RISCV] Remove performANY_EXTENDCombine.

This doesn't appear to be needed any more. I did some inspecting
of the gcc torture suite and SPEC2006 with this removed and didn't
find any meaningful changes.

I think we're more aggressive about forming ADDIW now using
sign_extend_inreg during type legalization and hasAllWUsers in isel.
This probably helps catch the cases this helped with before.

2 years ago[lldb/gdb-remote] Remove ancient debugserver workaround
Pavel Labath [Wed, 9 Mar 2022 17:19:58 +0000 (18:19 +0100)]
[lldb/gdb-remote] Remove ancient debugserver workaround

This workaround is the source of an awkwared Process->Platform
dependency. While this could be solved in various ways (the only thing
we really use is the plugin name), it may be better to just remove it --
the workaround was added 10 years ago (43c555dfc), and the affected
debugservers were "old" even then, so hopefully they are not in use
anymore.

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

2 years ago[flang] Lower pointer component in derived type
Valentin Clement [Thu, 10 Mar 2022 19:19:57 +0000 (20:19 +0100)]
[flang] Lower pointer component in derived type

This patch lowers pointer component part of derived types to
FIR.

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

Depends on D121383

Reviewed By: PeteSteinfeld, schweitz

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

Co-authored-by: V Donaldson <vdonaldson@nvidia.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[lldb/crashlog] Reformat module loading logs (NFC)
Med Ismail Bennani [Thu, 10 Mar 2022 19:06:42 +0000 (11:06 -0800)]
[lldb/crashlog] Reformat module loading logs (NFC)

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2 years ago[lldb/Plugin] Test that a scripted process blueprint can be loaded for the dSYM
Med Ismail Bennani [Wed, 9 Mar 2022 19:11:49 +0000 (11:11 -0800)]
[lldb/Plugin] Test that a scripted process blueprint can be loaded for the dSYM

This patch ensures that lldb can automatically load a scripted process
blueprint from a dSYM bundle and launch a scripted process with it.

rdar://74502750

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2 years ago[lldb/crashlog] Make interactive mode display more user-friendly
Med Ismail Bennani [Wed, 9 Mar 2022 00:34:31 +0000 (16:34 -0800)]
[lldb/crashlog] Make interactive mode display more user-friendly

This patch makes the crashlog interactive mode show the scripted process
status with the crashed scripted thread backtrace after launching it.

rdar://89634338

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2 years ago[JMCInstrument] infer proper path style based on debug info
Yuanfang Chen [Thu, 10 Mar 2022 18:50:30 +0000 (10:50 -0800)]
[JMCInstrument] infer proper path style based on debug info

By default, the path style is decided by the host. This patch makes JMC
uses the path style used by the SP directory. This makes JMC output
host-independent.

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

Reviewed By: rnk

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

2 years ago[flang] Lower general forall statement
Valentin Clement [Thu, 10 Mar 2022 18:43:11 +0000 (19:43 +0100)]
[flang] Lower general forall statement

This patch lowers general forall statements. The forall
are lowered to nested loops.

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

Depends on D121385

Reviewed By: PeteSteinfeld, schweitz

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

Co-authored-by: V Donaldson <vdonaldson@nvidia.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[CMake] Include runtimes test suites in check-all
Petr Hosek [Wed, 9 Mar 2022 08:48:49 +0000 (00:48 -0800)]
[CMake] Include runtimes test suites in check-all

Prior to this change, we would make check-all depend on check-runtimes
which is a target that runs tests in the runtimes build. This means that
the runtimes tests are going to run prior to other test suites in
check-all, and if one of them fails, we won't run the other test suites
at all.

To address this issue, we instead collect the list of test suites and
their dependencies from the runtimes subbuild, and include them in
check-all, so a failure of runtimes test suite doesn't prevent other
test suites from being executed.

This addresses https://github.com/llvm/llvm-project/issues/54154.

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

2 years ago[AMDGPU] Use subreg encoding instead of reassign
Joe Nash [Thu, 10 Mar 2022 17:25:11 +0000 (12:25 -0500)]
[AMDGPU] Use subreg encoding instead of reassign

The HWEncoding for these 64 bit registers should be the same as as the
encoding for the previously defined low halves of the registers. So
reuse that value instead of repeating the assignment. NFC.

Reviewed By: foad

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

2 years agoFix the dates for the C and C++ language working group
Aaron Ballman [Thu, 10 Mar 2022 18:08:08 +0000 (13:08 -0500)]
Fix the dates for the C and C++ language working group

It's 1st and 3rd Wed of the month instead of every other.

2 years ago[RISCV] Add isel patterns for masked RISCVISD::FMA_VL with RISCVISD::FNEG_VL.
Craig Topper [Thu, 10 Mar 2022 17:37:03 +0000 (09:37 -0800)]
[RISCV] Add isel patterns for masked RISCVISD::FMA_VL with RISCVISD::FNEG_VL.

This helps us form vfnmsub, vfnmadd, and vfmusb from masked VP
intrinsics.

I've used "srcvalue" for the mask parameter in the fneg nodes. We
can't match "V0" because that doesn't ensure the mask the is the same.
Instead it matches two different nodes and generates two copies to
V0 of those separate values.

Reviewed By: rogfer01

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

2 years ago[InstCombine] replace negated operand in fcmp with 0.0
Sanjay Patel [Thu, 10 Mar 2022 17:37:36 +0000 (12:37 -0500)]
[InstCombine] replace negated operand in fcmp with 0.0

X (any pred) -X --> X (any pred) 0.0

This works with all FP values and preserves FMF.
Alive2 examples:
https://alive2.llvm.org/ce/z/dj6jhp

This can also create one of the patterns that we match as "fabs"
as shown in one of the test diffs.

2 years ago[InstCombine] add tests for fcmp with fneg common operand; NFC
Sanjay Patel [Thu, 10 Mar 2022 16:35:23 +0000 (11:35 -0500)]
[InstCombine] add tests for fcmp with fneg common operand; NFC