platform/upstream/llvm.git
2 years ago[RISCV] Precommit test for D122634
wangpc [Thu, 21 Apr 2022 08:07:57 +0000 (16:07 +0800)]
[RISCV] Precommit test for D122634

Reviewed By: luismarques

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

2 years ago[GVNSink] Regenerate test checks (NFC)
Nikita Popov [Thu, 21 Apr 2022 08:06:47 +0000 (10:06 +0200)]
[GVNSink] Regenerate test checks (NFC)

2 years ago[CMake] Check for problematic MSVC + /arch:AVX configuration
Tobias Hieta [Thu, 21 Apr 2022 07:42:08 +0000 (09:42 +0200)]
[CMake] Check for problematic MSVC + /arch:AVX configuration

Add a new CMake file to expand on for more problematic configurations
in the future.

Related to #54645

Reviewed By: beanz, phosek, smeenai

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

2 years ago[NFC] Code cleanups for coroutine after we remvoed legacy passes
Chuanqi Xu [Thu, 21 Apr 2022 07:32:39 +0000 (15:32 +0800)]
[NFC] Code cleanups for coroutine after we remvoed legacy passes

2 years agoAdded lowering support for atomic read and write constructs
Nimish Mishra [Thu, 21 Apr 2022 03:45:45 +0000 (09:15 +0530)]
Added lowering support for atomic read and write constructs

This patch adds lowering support for atomic read and write constructs.
Also added is pointer modelling code to allow FIR pointer like types to
be inferred and converted while lowering.

Reviewed By: kiranchandramohan

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

Co-authored-by: Kiran Chandramohan <kiran.chandramohan@arm.com>
2 years ago[HLSL] Add shader attribute
Xiang Li [Thu, 7 Apr 2022 20:48:39 +0000 (13:48 -0700)]
[HLSL] Add shader attribute

Shader attribute is for shader library identify entry functions.
Here's an example,

[shader("pixel")]
float ps_main() : SV_Target {
  return 1;
}

When compile this shader to library target like -E lib_6_3, compiler needs to know ps_main is an entry function for pixel shader. Shader attribute is to offer the information.

A new attribute HLSLShader is added to support shader attribute. It has an EnumArgument which included all possible shader stages.

Reviewed By: aaron.ballman, MaskRay

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

2 years ago[RISCV] Don't emit fractional VIDs with negative steps
Fraser Cormack [Tue, 19 Apr 2022 08:25:40 +0000 (09:25 +0100)]
[RISCV] Don't emit fractional VIDs with negative steps

We can't shift-right negative numbers to divide them, so avoid emitting
such sequences. Use negative numerators as a proxy for this situation, since
the indices are always non-negative.

An alternative strategy could be to add a compiler flag to emit division
instructions, which would at least allow us to test the VID sequence
matching itself.

Reviewed By: craig.topper

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

2 years ago[RISCV] Add another test showing incorrect BUILD_VECTOR lowering
Fraser Cormack [Tue, 19 Apr 2022 08:25:40 +0000 (09:25 +0100)]
[RISCV] Add another test showing incorrect BUILD_VECTOR lowering

This test shows a (contrived) BUILD_VECTOR which is correctly identified
as a sequence of ((vid * -3) / 8) + 5. However, the issue is that using
shift-right for the divide is invalid as the step values are negative.

This patch just adds the test: the fix is added in D123796.

Reviewed By: craig.topper

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

2 years ago[ELF] Fix spurious GOT/PLT assertion failure when .dynsym is discarded
Fangrui Song [Thu, 21 Apr 2022 05:49:49 +0000 (22:49 -0700)]
[ELF] Fix spurious GOT/PLT assertion failure when .dynsym is discarded

Linux kernel arch/arm64/kernel/vmlinux.lds.S discards .dynsym . D123985 triggers
a spurious assertion failure. Detect the case with
`!mainPart->dynSymTab->getParent()`.

2 years ago[mlir][NFC] Update remaining textual references of un-namespaced `func` operations
River Riddle [Thu, 21 Apr 2022 04:39:02 +0000 (21:39 -0700)]
[mlir][NFC] Update remaining textual references of un-namespaced `func` operations

The special case parsing of operations in the `func` dialect is being removed, and
operations will require the dialect namespace prefix.

2 years ago[mlir][NFC] Update textual references of `func` to `func.func` in Transform tests
River Riddle [Wed, 20 Apr 2022 23:22:21 +0000 (16:22 -0700)]
[mlir][NFC] Update textual references of `func` to `func.func` in Transform tests

The special case parsing of `func` operations is being removed.

2 years ago[mlir][NFC] Update textual references of `func` to `func.func` in Pass/Target tests
River Riddle [Wed, 20 Apr 2022 23:22:03 +0000 (16:22 -0700)]
[mlir][NFC] Update textual references of `func` to `func.func` in Pass/Target tests

The special case parsing of `func` operations is being removed.

2 years ago[mlir][NFC] Update textual references of `func` to `func.func` in tool/runner tests
River Riddle [Wed, 20 Apr 2022 23:21:36 +0000 (16:21 -0700)]
[mlir][NFC] Update textual references of `func` to `func.func` in tool/runner tests

The special case parsing of `func` operations is being removed.

2 years ago[mlir][NFC] Update textual references of `func` to `func.func` in IR/Interface tests
River Riddle [Wed, 20 Apr 2022 23:20:54 +0000 (16:20 -0700)]
[mlir][NFC] Update textual references of `func` to `func.func` in IR/Interface tests

The special case parsing of `func` operations is being removed.

2 years ago[mlir][NFC] Update textual references of `func` to `func.func` in Integration tests
River Riddle [Wed, 20 Apr 2022 23:20:21 +0000 (16:20 -0700)]
[mlir][NFC] Update textual references of `func` to `func.func` in Integration tests

The special case parsing of `func` operations is being removed.

2 years ago[mlir][NFC] Update textual references of `func` to `func.func` in Tensor/Tosa/Vector...
River Riddle [Wed, 20 Apr 2022 23:19:48 +0000 (16:19 -0700)]
[mlir][NFC] Update textual references of `func` to `func.func` in Tensor/Tosa/Vector tests

The special case parsing of `func` operations is being removed.

2 years ago[mlir][NFC] Update textual references of `func` to `func.func` in SPIRV tests
River Riddle [Wed, 20 Apr 2022 23:19:21 +0000 (16:19 -0700)]
[mlir][NFC] Update textual references of `func` to `func.func` in SPIRV tests

The special case parsing of `func` operations is being removed.

2 years ago[mlir][NFC] Update textual references of `func` to `func.func` in SparseTensor tests
River Riddle [Wed, 20 Apr 2022 23:18:14 +0000 (16:18 -0700)]
[mlir][NFC] Update textual references of `func` to `func.func` in SparseTensor tests

The special case parsing of `func` operations is being removed.

2 years ago[mlir][NFC] Update textual references of `func` to `func.func` in LLVM/Math/MemRef...
River Riddle [Wed, 20 Apr 2022 23:17:16 +0000 (16:17 -0700)]
[mlir][NFC] Update textual references of `func` to `func.func` in LLVM/Math/MemRef/NVGPU/OpenACC/OpenMP/Quant/SCF/Shape tests

The special case parsing of `func` operations is being removed.

2 years ago[mlir][NFC] Update textual references of `func` to `func.func` in Linalg tests
River Riddle [Wed, 20 Apr 2022 23:16:23 +0000 (16:16 -0700)]
[mlir][NFC] Update textual references of `func` to `func.func` in Linalg tests

The special case parsing of `func` operations is being removed.

2 years ago[mlir][NFC] Update textual references of `func` to `func.func` in Bufferization/Compl...
River Riddle [Wed, 20 Apr 2022 23:15:59 +0000 (16:15 -0700)]
[mlir][NFC] Update textual references of `func` to `func.func` in Bufferization/Complex/EmitC/CF/Func/GPU tests

The special case parsing of `func` operations is being removed.

2 years ago[mlir][NFC] Update textual references of `func` to `func.func` in AMX/Arithmetic...
River Riddle [Wed, 20 Apr 2022 23:14:19 +0000 (16:14 -0700)]
[mlir][NFC] Update textual references of `func` to `func.func` in AMX/Arithmetic/ArmSVE/Async tests

The special case parsing of `func` operations is being removed.

2 years ago[mlir][NFC] Update textual references of `func` to `func.func` in Affine/ tests
River Riddle [Wed, 20 Apr 2022 23:13:44 +0000 (16:13 -0700)]
[mlir][NFC] Update textual references of `func` to `func.func` in Affine/ tests

The special case parsing of `func` operations is being removed.

2 years ago[mlir][NFC] Update textual references of `func` to `func.func` in Conversion/ tests
River Riddle [Wed, 20 Apr 2022 23:12:25 +0000 (16:12 -0700)]
[mlir][NFC] Update textual references of `func` to `func.func` in Conversion/ tests

The special case parsing of `func` operations is being removed.

2 years ago[mlir][NFC] Update textual references of `func` to `func.func` in Analysis/ tests
River Riddle [Wed, 20 Apr 2022 23:06:22 +0000 (16:06 -0700)]
[mlir][NFC] Update textual references of `func` to `func.func` in Analysis/ tests

The special case parsing of `func` operations is being removed.

2 years ago[mlir][NFC] Update textual references of `func` to `func.func` in ODS documentation
River Riddle [Wed, 20 Apr 2022 23:05:29 +0000 (16:05 -0700)]
[mlir][NFC] Update textual references of `func` to `func.func` in ODS documentation

The special case parsing of `func` operations is being removed.

2 years ago[mlir][NFC] Update textual references of `func` to `func.func` in examples+python...
River Riddle [Wed, 20 Apr 2022 23:01:51 +0000 (16:01 -0700)]
[mlir][NFC] Update textual references of `func` to `func.func` in examples+python scripts

The special case parsing of `func` operations is being removed.

2 years ago[RISCV] Make getInstSeqCost handle other Zb* instructions.
Craig Topper [Thu, 21 Apr 2022 05:00:10 +0000 (22:00 -0700)]
[RISCV] Make getInstSeqCost handle other Zb* instructions.

We haven't been updating this as Zb* instructions have been used
for immediate materialization. They will hit the default case and
trigger an llvm_unreachable. Instead of trying to list them all,
assume instructions that aren't explicitly listed aren't compressible.

Spotted while looking at integer materialization for other reasons.
I haven't seen a crash from this yet.

2 years ago[C++20] [Modules] Judge current module correctly
Chuanqi Xu [Thu, 21 Apr 2022 03:08:52 +0000 (11:08 +0800)]
[C++20] [Modules] Judge current module correctly

Now the implementation would accept following code:
```
//--- impl.cppm
module M:impl;
class A {};

//--- M.cppm
export module M;
import :impl;

//--- Use.cpp
import M;
void test() {
    A a; // Expected error. A is not visible here.
}
```

which is clearly wrong.  The root cause is the implementation of
`isInCurrentModule` would return true if the module is a partition! So
in the above example, although Use.cpp is not a module unit,
`isInCurrentModule ` would still return true when the compiler tries to
see if the owning module of `A` is the current module. I believe this is
an oversight. This patch tries to fix this problem.

Reviewed By: iains

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

2 years ago[Pipelines] Remove Legacy Passes in Coroutines
Chuanqi Xu [Thu, 21 Apr 2022 02:57:01 +0000 (10:57 +0800)]
[Pipelines] Remove Legacy Passes in Coroutines

The legacy passes are deprecated now and would be removed in near
future. This patch tries to remove legacy passes in coroutines.

Reviewed By: aeubanks

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

2 years ago[AMDGPU] On gfx908, reserve VGPR for AGPR copy based on register budget.
hsmahesha [Thu, 21 Apr 2022 02:27:26 +0000 (07:57 +0530)]
[AMDGPU] On gfx908, reserve VGPR for AGPR copy based on register budget.

Based on available register budget, reserve highest available VGPR for
AGPR copy before RA. After RA, shift it to lowest unused VGPR if the one
exist.

Fixes SWDEV-330006.

Reviewed By: rampitec

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

2 years ago[LoongArch] Add basic floating-point instructions definition
Weining Lu [Tue, 29 Mar 2022 12:50:41 +0000 (20:50 +0800)]
[LoongArch] Add basic floating-point instructions definition

These instructions are added by following the `LoongArch Reference
Manual Volume 1: Basic Architecture Version 1.00`.

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

2 years ago[mlir][OpenMP] Add checks and tests for hint clause and fix empty hint
Shraiysh Vaishay [Thu, 21 Apr 2022 01:22:38 +0000 (06:52 +0530)]
[mlir][OpenMP] Add checks and tests for hint clause and fix empty hint

This patch handles empty hint value for critical and atomic constructs.

This also adds checks and tests for hint clause on atomic constructs.

Reviewed By: peixin, kiranchandramohan, NimishMishra

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

2 years ago[AMDGPU] Split the lit test spill-vgpr-to-agpr.ll to different tests
hsmahesha [Thu, 21 Apr 2022 01:18:16 +0000 (06:48 +0530)]
[AMDGPU] Split the lit test spill-vgpr-to-agpr.ll to different tests

[1]. Move the test which reject the usage of agpr before gfx908 into a separate file - reject-agpr-usage-before-gfx908.ll.
[2]. Move those tests which are applicable to both gfx900 and gfx908 into a separate file - spill-vgpr.ll.
[3]. Keep those tests which are specific to only gfx908 in the file spill-vgpr-to-agpr.ll.

Above split is required to properly update the tests in D123525.

Reviewed By: rampitec

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

2 years agoTreat `std::move`, `forward`, etc. as builtins.
Richard Smith [Thu, 21 Apr 2022 00:13:56 +0000 (17:13 -0700)]
Treat `std::move`, `forward`, etc. as builtins.

This is extended to all `std::` functions that take a reference to a
value and return a reference (or pointer) to that same value: `move`,
`forward`, `move_if_noexcept`, `as_const`, `addressof`, and the
libstdc++-specific function `__addressof`.

We still require these functions to be declared before they can be used,
but don't instantiate their definitions unless their addresses are
taken. Instead, code generation, constant evaluation, and static
analysis are given direct knowledge of their effect.

This change aims to reduce various costs associated with these functions
-- per-instantiation memory costs, compile time and memory costs due to
creating out-of-line copies and inlining them, code size at -O0, and so
on -- so that they are not substantially more expensive than a cast.
Most of these improvements are very small, but I measured a 3% decrease
in -O0 object file size for a simple C++ source file using the standard
library after this change.

We now automatically infer the `const` and `nothrow` attributes on these
now-builtin functions, in particular meaning that we get a warning for
an unused call to one of these functions.

In C++20 onwards, we disallow taking the addresses of these functions,
per the C++20 "addressable function" rule. In earlier language modes, a
compatibility warning is produced but the address can still be taken.

The same infrastructure is extended to the existing MSVC builtin
`__GetExceptionInfo`, which is now only recognized in namespace `std`
like it always should have been.

This is a re-commit of
  fc3090109643af8d2da9822d0f99c84742b9c877,
  a571f82a50416b767fd3cce0fb5027bb5dfec58c,
  64c045e25b8471bbb572bd29159c294a82a86a2, and
  de6ddaeef3aaa8a9ae3663c12cdb57d9afc0f906,
and reverts aa643f455a5362de7189eac630050d2c8aefe8f2.
This change also includes a workaround for users using libc++ 3.1 and
earlier (!!), as apparently happens on AIX, where std::move sometimes
returns by value.

Reviewed By: aaron.ballman

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

Revert "Fixup D123950 to address revert of D123345"

This reverts commit aa643f455a5362de7189eac630050d2c8aefe8f2.

2 years ago[LLDB] Skip TestCrashDuringStep.py AArch64/Windows
Muhammad Omair Javaid [Thu, 21 Apr 2022 00:09:33 +0000 (05:09 +0500)]
[LLDB] Skip TestCrashDuringStep.py AArch64/Windows

TestCrashDuringStep.py hangs on AArch64 windows with no resonable
possible fix. I am marking it skipped for now.

2 years ago[BOLT] Add fuzzy function name matching for LLVM LTO
Maksim Panchenko [Wed, 20 Apr 2022 23:59:41 +0000 (16:59 -0700)]
[BOLT] Add fuzzy function name matching for LLVM LTO

LLVM with LTO can generate function names in the form
func.llvm.<number>, where <number> could vary based on the compilation
environment. As a result, if a profiled binary originated from a
different build than a corresponding binary used for BOLT optimization,
then profiles for such LTO functions will be ignored.

To fix the problem, use "fuzzy" matching with "func.llvm.*" form.

Reviewed By: yota9, Amir

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

2 years agoFixup D123950 to address revert of D123345
David Tenty [Wed, 20 Apr 2022 23:59:07 +0000 (19:59 -0400)]
Fixup D123950 to address revert of D123345

Since D123345 got reverted Builtin::BIaddressof and Builtin::BI__addressof don't exist and cause build breaks.

2 years ago[BOLT][DWARF] Handle Error returned by visitLocationList
Alexander Yermolovich [Wed, 20 Apr 2022 23:40:46 +0000 (16:40 -0700)]
[BOLT][DWARF] Handle Error returned by visitLocationList

Looks like implementation in llvm changed, and now we need to process error
being returned.

Reviewed By: maksfb

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

2 years agoRevert "Treat `std::move`, `forward`, etc. as builtins."
David Tenty [Wed, 20 Apr 2022 23:06:48 +0000 (19:06 -0400)]
Revert "Treat `std::move`, `forward`, etc. as builtins."

This reverts commit b27430f9f46b88bcd54d992debc8d72e131e1bd0 as the
    parent https://reviews.llvm.org/D123345 breaks the AIX CI:

    https://lab.llvm.org/buildbot/#/builders/214/builds/819

2 years agoRevert "Don't treat 'T &forward(T&&)' as builtin."
David Tenty [Wed, 20 Apr 2022 23:03:04 +0000 (19:03 -0400)]
Revert "Don't treat 'T &forward(T&&)' as builtin."

This reverts commit e43c93dd63cca295ef26ab69cd305816a71d45fd as the
parent https://reviews.llvm.org/D123345 breaks the AIX CI.

2 years ago[clang][CUDA][Windows] Fix compilation error on Windows with `uint32_t __nvvm_get_sme...
Evgeny Mankov [Wed, 20 Apr 2022 21:41:20 +0000 (00:41 +0300)]
[clang][CUDA][Windows] Fix compilation error on Windows with `uint32_t __nvvm_get_smem_pointer`

The change fixes https://github.com/llvm/llvm-project/issues/54609 (the second reported issue) by eliminating a compilation error occurring only on Windows while trying to compile any CUDA source file by clang (-x cuda).

[Repro]
clang -x cuda <any_cu_source>

[Error]

__clang_cuda_runtime_wrapper.h:473:
__clang_cuda_intrinsics.h(517,19): error GC871EEFB: unknown type name 'uint32_t'; did you mean 'cuuint32_t'?
__device__ inline uint32_t __nvvm_get_smem_pointer(void *__ptr) {
                          ^
C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.6/include\cuda.h:57:26: note: 'cuuint32_t' declared here
typedef unsigned __int32 cuuint32_t;

Reviewed By: tra

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

2 years ago[MC][NFC] Ensure tests that intended to cover compact unwind code paths do so
Jez Ng [Wed, 20 Apr 2022 22:11:19 +0000 (18:11 -0400)]
[MC][NFC] Ensure tests that intended to cover compact unwind code paths do so

These two tests were intended to cover the CU code paths, but invoked
llvm-mc using a generic "darwin" platform. However, MC only attempts to
emit CU for `macos >= 10.6` [1]. Thus we adjust the tests accordingly.

compact-unwind-cfi_def_cfa.s was added in 2fca51d3b45efcf00ffcfe2879cd6d7d98c26258
fp-setup-macho.s was added in 03ffa797ad4fe8f85da532aa3f687841a60b4c0c

[1]: https://github.com/llvm/llvm-project/blob/16c93aaa4a955676fe05f876bd036719a1b14b2d/llvm/lib/MC/MCObjectFileInfo.cpp#L43

Reviewed By: MaskRay, smeenai

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

2 years ago[flang] Semantics limits on kP scale factors
V Donaldson [Wed, 20 Apr 2022 18:42:44 +0000 (11:42 -0700)]
[flang] Semantics limits on kP scale factors

When known at compile time, Ew.d and Dw.d output edit descriptors
should respect limitations from the standard on the value of a
kP scale factor with respect to the digit count (d), at least for
values of k other than zero.

2 years ago[Hexagon] Establish size limit for RegisterSet in hexbit
Krzysztof Parzyszek [Wed, 20 Apr 2022 16:51:35 +0000 (09:51 -0700)]
[Hexagon] Establish size limit for RegisterSet in hexbit

This should reduce compilation time for huge functions.

2 years ago[clang] Add a raw_ostream operator<< overload for QualType
Nathan James [Wed, 20 Apr 2022 21:09:03 +0000 (22:09 +0100)]
[clang] Add a raw_ostream operator<< overload for QualType

Under the hood this prints the same as `QualType::getAsString()` but cuts out the middle-man when that string is sent to another raw_ostream.

Also cleaned up all the call sites where this occurs.

Reviewed By: aaron.ballman

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

2 years ago[libc++] Granularize <functional> includes
Nikolas Klauser [Sun, 17 Apr 2022 14:01:38 +0000 (16:01 +0200)]
[libc++] Granularize <functional> includes

Reviewed By: Mordante, #libc

Spies: libcxx-commits, miyuki

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

2 years agoImprove invalid-ir-print-after-failure.mlir to show the effects of -mlir-print-assume...
Mehdi Amini [Wed, 20 Apr 2022 20:39:44 +0000 (20:39 +0000)]
Improve invalid-ir-print-after-failure.mlir to show the effects of -mlir-print-assume-verified (NFC)

2 years ago[LLDB] Update inspect getargspec to getfullargspec
Muhammad Omair Javaid [Wed, 20 Apr 2022 20:32:23 +0000 (01:32 +0500)]
[LLDB] Update inspect getargspec to getfullargspec

This patch replaces getargspec with getfullargspec in funcutils.py.
getargspec has been deprecated by python 11x release. This is
important to run LLDB testsuite in Windows/Arm64 platform
where Python native will be available from python release onwards.

Note: getfullargspec is not available in python 2

Reviewed By: labath

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

2 years agoReland "[COFF, ARM64] Add __break intrinsic"
Pengxuan Zheng [Fri, 15 Apr 2022 21:57:40 +0000 (14:57 -0700)]
Reland "[COFF, ARM64] Add __break intrinsic"

https://docs.microsoft.com/en-us/cpp/intrinsics/arm64-intrinsics?view=msvc-170

Reland after fixing the test failure. The failure was due to conflict with a
change (D122983) which was merged right before this patch.

Reviewed By: rnk, mstorsjo

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

2 years ago[clang-tblgen] Automatically document options values
serge-sans-paille [Wed, 13 Apr 2022 13:28:58 +0000 (15:28 +0200)]
[clang-tblgen] Automatically document options values

This is a port of f5c666742f7bb4ae79ec79c8acf61dced4d37cc9 to clang's tablegen,
with a better wording.

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

2 years ago[libc] Add the implementation of the fflush function.
Siva Chandra Reddy [Wed, 20 Apr 2022 08:29:22 +0000 (08:29 +0000)]
[libc] Add the implementation of the fflush function.

Note that the underlying flush implementation does not yet fully implement
the POSIX standard. It is complete with respect to the C standard
however. A future change will add the POSIX behavior. It should not affect
the implementation of the fflush function however as the POSIX behavior
will be added in a lower layer.

Reviewed By: lntue

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

2 years agoRevert "[COFF, ARM64] Add __break intrinsic"
Pengxuan Zheng [Wed, 20 Apr 2022 18:57:49 +0000 (11:57 -0700)]
Revert "[COFF, ARM64] Add __break intrinsic"

This reverts commit 8a9b4fb4aa6d2dde026d9ae08459aa9e7a1edb05.

2 years ago[AMDGPU] Remove obsolete hack from allowsMisalignedMemoryAccesses. NFCI.
Stanislav Mekhanoshin [Tue, 19 Apr 2022 19:44:40 +0000 (12:44 -0700)]
[AMDGPU] Remove obsolete hack from allowsMisalignedMemoryAccesses. NFCI.

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

2 years ago[VPlan] Initial modeling of middle block in VPlan.
Florian Hahn [Wed, 20 Apr 2022 18:34:41 +0000 (19:34 +0100)]
[VPlan] Initial modeling of middle block in VPlan.

This patch extends the scope of VPlan to also include the exit (aka
middle) block.

For now, the exit block remains empty, but handling of exit values will
subsequently be moved to VPlan, by adding recipes to model exit values
in the exit block.

As a first step, this will allow fixing #51366.

Reviewed By: Ayal

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

2 years agoLook through calls to std::addressof to compute pointer alignment.
Eli Friedman [Mon, 18 Apr 2022 17:19:57 +0000 (10:19 -0700)]
Look through calls to std::addressof to compute pointer alignment.

This is sort of a followup to D37310; that basically fixed the same
issue, but then the libstdc++ implementation of <atomic> changed. Re-fix
the the issue in essentially the same way: look through the addressof
operation to find the alignment of the underlying object.

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

2 years ago[safestack] Support safestack in stack size diagnostics
Paul Kirth [Tue, 19 Apr 2022 16:34:23 +0000 (16:34 +0000)]
[safestack] Support safestack in stack size diagnostics

Current stack size diagnostics ignore the size of the unsafe stack.
This patch attaches the size of the static portion of the unsafe stack
to the function as metadata, which can be used by the backend to emit
diagnostics regarding stack usage.

Reviewed By: phosek, mcgrathr

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

2 years agoRevert "[clang][lex] NFCI: Use DirectoryEntryRef in HeaderSearch::load*()"
Jan Svoboda [Wed, 20 Apr 2022 18:09:04 +0000 (20:09 +0200)]
Revert "[clang][lex] NFCI: Use DirectoryEntryRef in HeaderSearch::load*()"

This reverts commit 1d3ba05e4a288b49287fe997763e90234b8c62db which caused failures of the VFS/real-path-found-first.m test on Windows build bots.

2 years ago[clang][lex] NFCI: Use FileEntryRef in ModuleMap::diagnoseHeaderInclusion()
Jan Svoboda [Wed, 20 Apr 2022 17:02:03 +0000 (19:02 +0200)]
[clang][lex] NFCI: Use FileEntryRef in ModuleMap::diagnoseHeaderInclusion()

This patch removes uses of the deprecated `DirectoryEntry::getName()` from the `ModuleMap::diagnoseHeaderInclusion()` function by using `{File,Directory}EntryRef` instead.

Reviewed By: bnbarham

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

2 years ago[COFF, ARM64] Add __break intrinsic
Pengxuan Zheng [Fri, 15 Apr 2022 21:57:40 +0000 (14:57 -0700)]
[COFF, ARM64] Add __break intrinsic

https://docs.microsoft.com/en-us/cpp/intrinsics/arm64-intrinsics?view=msvc-170

Reviewed By: rnk, mstorsjo

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

2 years agoRevert D119136 "[clang] Implement Change scope of lambda trailing-return-type" and...
Fangrui Song [Wed, 20 Apr 2022 17:57:12 +0000 (10:57 -0700)]
Revert D119136 "[clang] Implement Change scope of lambda trailing-return-type" and its follow-up

This reverts commit 69dd89fdcbd846375a45e2fe3a88710887236d7a.
This reverts commit 04000c2f928a7adc32138a664d167f01b642bef3.

The current states breaks libstdc++ usage (https://reviews.llvm.org/D119136#3455423).
The fixup has been reverted as it caused other valid code to be disallowed.
I think we should start from the clean state by reverting all relevant commits.

2 years ago[NFC] Avoid unnecessary duplication of code generating diagnostic.
Dan Liew [Tue, 19 Apr 2022 23:28:33 +0000 (16:28 -0700)]
[NFC] Avoid unnecessary duplication of code generating diagnostic.

The previous code unneccessarily duplicated the creation of a diagnostic
where the only difference was the `AssignmentAction` being passed.

rdar://88664722

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

2 years ago[LICM] Add additional writeonly tests, check attributes.
Florian Hahn [Wed, 20 Apr 2022 17:49:37 +0000 (18:49 +0100)]
[LICM] Add additional writeonly tests, check attributes.

Add additional test coverage for D123473.

2 years ago[ELF] Shrink binding and type in Symbol
Shoaib Meenai [Tue, 19 Apr 2022 20:46:04 +0000 (13:46 -0700)]
[ELF] Shrink binding and type in Symbol

STB_HIPROC and STT_HIPROC are both 15, so we can fit the symbol binding
and type in 4 bits. This gives us an additional byte to use for Symbol
flags (without increasing the type's size), which I'll be making use of
in the next diff.

Reorder type and binding based on a suggestion from @MaskRay, to
optimize st_info computation on little-endian systems (see
https://godbolt.org/z/nMn8Yar43).

Reviewed By: MaskRay

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

2 years ago[ELF] Assert on invalid GOT or PLT relocations
Shoaib Meenai [Tue, 19 Apr 2022 06:24:46 +0000 (23:24 -0700)]
[ELF] Assert on invalid GOT or PLT relocations

Because of https://llvm.org/PR50675, we can end up producing a PLT
relocation referencing a symbol that's dropped from the dynamic symbol
table, which in turn causes a crash at runtime. We ran into this again
recently, resulting in crashes for our users. A subsequent diff will fix
that issue, but add an assert to catch it if it happens again.

Reviewed By: MaskRay

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

2 years agoSpeculatively fix build bot
Aaron Ballman [Wed, 20 Apr 2022 17:39:15 +0000 (13:39 -0400)]
Speculatively fix build bot

This should fix the issue found by:
https://lab.llvm.org/buildbot/#/builders/37/builds/12606

2 years ago[AMDGPU] Regenerate lit test pattern (NFC).
Christudasan Devadasan [Tue, 19 Apr 2022 14:42:05 +0000 (20:12 +0530)]
[AMDGPU] Regenerate lit test pattern (NFC).

2 years ago[LLDB][NativePDB] Fix the case when S_DEFRANGE_SUBFIELD_REGISTERs are out of order.
Zequan Wu [Wed, 20 Apr 2022 03:11:44 +0000 (20:11 -0700)]
[LLDB][NativePDB] Fix the case when S_DEFRANGE_SUBFIELD_REGISTERs are out of order.

Previously, I was assuming that S_DEFRANGE_SUBFIELD_REGISTERs are always in the
increasing order of offset_in_parent until I saw a counter example.

Using `std::map` so that they are sorted by offset_in_parent.

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

2 years agoRevert D123909 "[Clang] Use of decltype(capture) in parameter-declaration-clause"
Fangrui Song [Wed, 20 Apr 2022 17:32:41 +0000 (10:32 -0700)]
Revert D123909 "[Clang] Use of decltype(capture) in parameter-declaration-clause"

This reverts commit daa6d7b250edb81ffef7770a71049d7af211698b.

It breaks valid code like https://reviews.llvm.org/D123909#3461716

2 years ago[C2x] Disallow functions without prototypes/functions with identifier lists
Aaron Ballman [Wed, 20 Apr 2022 17:26:38 +0000 (13:26 -0400)]
[C2x] Disallow functions without prototypes/functions with identifier lists

WG14 has elected to remove support for K&R C functions in C2x. The
feature was introduced into C89 already deprecated, so after this long
of a deprecation period, the committee has made an empty parameter list
mean the same thing in C as it means in C++: the function accepts no
arguments exactly as if the function were written with (void) as the
parameter list.

This patch implements WG14 N2841 No function declarators without
prototypes (http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2841.htm)
and WG14 N2432 Remove support for function definitions with identifier
lists (http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2432.pdf).

It also adds The -fno-knr-functions command line option to opt into
this behavior in other language modes.

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

2 years agoReland "[Clang][Sema] Fix invalid redefinition error in if/switch/for statement"
Jun Zhang [Wed, 20 Apr 2022 17:17:47 +0000 (01:17 +0800)]
Reland "[Clang][Sema] Fix invalid redefinition error in if/switch/for statement"

This reverts commit 9f075c3d84fb359efb6496535ab397a6f09609e2.
The broken build has alreasy been fixed in D124012, so reland it now.
Signed-off-by: Jun Zhang <jun@junz.org>
2 years ago[flang] Set LBOUND() folding for (x) expression as ones
Mike Kashkarov [Wed, 20 Apr 2022 16:53:09 +0000 (19:53 +0300)]
[flang] Set LBOUND() folding for (x) expression as ones

Set LBOUND() constant folding for parentheses expr. as ones

Array bounds should not propagate throught omitted bounds specifications or
temporary variables - fix constant folding in case of Parentheses<T> expression
by explicitly returning array of ones (or scalar in case of DIM=).

Add set of tests for (x) bounds checks (w/ and w/o 'parameter' arrays)

Reviewed By: jeanPerier

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

2 years ago[flang] Fix LBOUND() folding for constant arrays
Mike Kashkarov [Wed, 20 Apr 2022 16:47:21 +0000 (19:47 +0300)]
[flang] Fix LBOUND() folding for constant arrays

Previously constant folding uses 'dim' without checks which leads to ICE if we
do not have DIM= parameter. And for inputs without DIM= we need to form an
array of rank size with computed bounds instead of single value.

Add additional PackageConstant function to simplify 'if (dim)' handling since we
need to distinguish between scalar initialization in case of DIM= argument and
rank=1 array.

Also add a few more tests with 'parameter' type to verify folding for constant
arrays.

Reviewed By: jeanPerier

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

2 years ago[clang][dataflow] Ensure well-formed flow conditions.
Yitzhak Mandelbaum [Mon, 11 Apr 2022 19:41:42 +0000 (19:41 +0000)]
[clang][dataflow] Ensure well-formed flow conditions.

Ensure that the expressions associated with terminators are associated with a
value. Otherwise, we can generate degenerate flow conditions, where both
branches share the same condition.

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

2 years ago[clang][lex] NFCI: Use DirectoryEntryRef in FrameworkCacheEntry
Jan Svoboda [Wed, 20 Apr 2022 16:55:58 +0000 (18:55 +0200)]
[clang][lex] NFCI: Use DirectoryEntryRef in FrameworkCacheEntry

This patch changes the member of `FrameworkCacheEntry` from `const DirectoryEntry *` to `Optional<DirectoryEntryRef>` in order to remove uses of the deprecated `DirectoryEntry::getName()`.

Reviewed By: bnbarham

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

2 years ago[clang] NFCI: Use DirectoryEntryRef in FrontendAction::BeginSourceFile()
Jan Svoboda [Wed, 20 Apr 2022 16:54:36 +0000 (18:54 +0200)]
[clang] NFCI: Use DirectoryEntryRef in FrontendAction::BeginSourceFile()

This patch removes use of the deprecated `DirectoryEntry::getName()` from `FrontendAction::BeginSourceFile()`.

Reviewed By: bnbarham

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

2 years ago[clang][lex] NFCI: Use DirectoryEntryRef in HeaderSearch::load*()
Jan Svoboda [Wed, 20 Apr 2022 16:52:24 +0000 (18:52 +0200)]
[clang][lex] NFCI: Use DirectoryEntryRef in HeaderSearch::load*()

This patch removes uses of the deprecated `DirectoryEntry::getName()` from `HeaderSearch::load*()` functions by using `DirectoryEntryRef` instead.

Note that we bail out in one case and use the also deprecated `FileEntry::getLastRef()`. That's to prevent this patch from growing, and is addressed in a follow-up.

Reviewed By: bnbarham

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

2 years ago[DAG]Introduce llvm::processShuffleMasks and use it for shuffles in DAG Type Legalizer.
Alexey Bataev [Mon, 13 Dec 2021 18:38:28 +0000 (10:38 -0800)]
[DAG]Introduce llvm::processShuffleMasks and use it for shuffles in DAG Type Legalizer.

We can process the long shuffles (working across several actual
vector registers) in the best way if we take the actual register
represantion into account. We can build more correct representation of
register shuffles, improve number of recognised buildvector sequences.
Also, same function can be used to improve the cost model for the
shuffles. in future patches.

Part of D100486

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

2 years agoSpeculatively fix build bot
Aaron Ballman [Wed, 20 Apr 2022 16:32:14 +0000 (12:32 -0400)]
Speculatively fix build bot

This should address the issue in:
https://lab.llvm.org/buildbot/#/builders/77/builds/16683

2 years ago[InstCombine] Don't look through bitcast from vector in collectInsertionElements.
Craig Topper [Wed, 20 Apr 2022 16:05:35 +0000 (09:05 -0700)]
[InstCombine] Don't look through bitcast from vector in collectInsertionElements.

We're making a recursive call here and everything in the function
assumes we're looking at scalars. This would be violated if we
looked through a bitcast from vectors.

Reviewed By: spatel

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

2 years ago[InstCombine] Pre-commit test for D124015
Craig Topper [Wed, 20 Apr 2022 16:05:28 +0000 (09:05 -0700)]
[InstCombine] Pre-commit test for D124015

Reviewed By: spatel

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

2 years ago[InstCombine] Fold mul nuw+lshr to a single multiplication when the latter is a factor
chenglin.bi [Wed, 20 Apr 2022 15:51:34 +0000 (23:51 +0800)]
[InstCombine] Fold mul nuw+lshr to a single multiplication when the latter is a factor

if c is divisible by (1 << ShAmtC), we can fold this pattern:
lshr (mul nuw x, c), ShAmtC -> mul nuw x, (c >> ShAmtC)

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

Fix https://github.com/llvm/llvm-project/issues/54824

Reviewed By: spatel, lebedev.ri, craig.topper

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

2 years agoSpeculatively fix build bots
Aaron Ballman [Wed, 20 Apr 2022 16:05:33 +0000 (12:05 -0400)]
Speculatively fix build bots

This should address the issue found in:
https://lab.llvm.org/buildbot/#/builders/215/builds/4610

2 years agoSpeculatively fix build bots
Aaron Ballman [Wed, 20 Apr 2022 16:02:16 +0000 (12:02 -0400)]
Speculatively fix build bots

This should address the issues found by:
https://lab.llvm.org/buildbot/#/builders/105/builds/24292

2 years agoRemoving some ancient, unused testing functionality
Aaron Ballman [Wed, 20 Apr 2022 15:55:27 +0000 (11:55 -0400)]
Removing some ancient, unused testing functionality

This was last touched 13 years ago in
https://github.com/llvm/llvm-project/commit/7a1095f243e393d40ed9b9cee17fd091a13f2947
and is no longer being maintained.

2 years ago[PS5][NFC] Fix a test with a misplaced -x option
Paul Robinson [Wed, 20 Apr 2022 15:56:38 +0000 (08:56 -0700)]
[PS5][NFC] Fix a test with a misplaced -x option

2 years agoSpeculatively fix build bots
Aaron Ballman [Wed, 20 Apr 2022 15:46:35 +0000 (11:46 -0400)]
Speculatively fix build bots

This should address build failures found in:

https://lab.llvm.org/buildbot/#/builders/217/builds/3610
https://lab.llvm.org/buildbot/#/builders/215/builds/4609
https://lab.llvm.org/buildbot/#/builders/68/builds/31012

2 years agoRevert "[Clang][Sema] Fix invalid redefinition error in if/switch/for statement"
Jun Zhang [Wed, 20 Apr 2022 15:43:21 +0000 (23:43 +0800)]
Revert "[Clang][Sema] Fix invalid redefinition error in if/switch/for statement"

This reverts commit be0905a333d6f7c4d7f5c70c18211463e53473cd.
This patch broke build addressed in https://github.com/llvm/llvm-project/issues/54968
Signed-off-by: Jun Zhang <jun@junz.org>
2 years ago[clang-format] Don't skip PP lines if original line was a PP line when trying to...
Arthur Eubanks [Tue, 19 Apr 2022 20:02:54 +0000 (13:02 -0700)]
[clang-format] Don't skip PP lines if original line was a PP line when trying to merge lines

Fixes a crash introduced in D123737 where LastNonComment would be null.

Reviewed By: curdeius

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

2 years ago[libc] Add GNU extention functions fread_unlocked and fwrite_unlocked.
Siva Chandra Reddy [Tue, 19 Apr 2022 07:36:43 +0000 (07:36 +0000)]
[libc] Add GNU extention functions fread_unlocked and fwrite_unlocked.

POSIX locking and unlocking functions flockfile and funlockfile have
also been added. The locking is not recursive yet. A future patch will
make the underlying lock a recursive lock.

Reviewed By: lntue

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

2 years agoUpdate the developer policy to mention release notes
Aaron Ballman [Wed, 20 Apr 2022 15:34:05 +0000 (11:34 -0400)]
Update the developer policy to mention release notes

As a project, Clang has gotten negative public feedback about our lack
of communicating changes to users. There are comments on places like
Hacker News or Reddit where users have (rightfully) been confused as to
what changes happen in a given release, leading to misinformation like
Clang not adding support for C++20 features:
https://news.ycombinator.com/item?id=28761464.

This documents the expectation that changes which impact users should
have release notes, and it's normal for code reviewers to ask an author
to add a release note for a given change.

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

RFC: https://discourse.llvm.org/t/rfc-update-developer-policy-on-release-notes/61856

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

2 years ago[PS4][NFC] Rename classes to align with prevailing practice
Paul Robinson [Wed, 20 Apr 2022 15:35:17 +0000 (08:35 -0700)]
[PS4][NFC] Rename classes to align with prevailing practice

Rename classes Assemble -> Assembler, Link -> Linker,
for consistency with names other toolchains use.

2 years ago[libc][docs] Update the fuzzing doc to better reflect the current state.
Siva Chandra Reddy [Mon, 18 Apr 2022 07:29:17 +0000 (07:29 +0000)]
[libc][docs] Update the fuzzing doc to better reflect the current state.

Reviewed By: lntue

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

2 years ago[C11/C2x] Change the behavior of the implicit function declaration warning
Aaron Ballman [Wed, 20 Apr 2022 15:25:35 +0000 (11:25 -0400)]
[C11/C2x] Change the behavior of the implicit function declaration warning

C89 had a questionable feature where the compiler would implicitly
declare a function that the user called but was never previously
declared. The resulting function would be globally declared as
extern int func(); -- a function without a prototype which accepts zero
or more arguments.

C99 removed support for this questionable feature due to severe
security concerns. However, there was no deprecation period; C89 had
the feature, C99 didn't. So Clang (and GCC) both supported the
functionality as an extension in C99 and later modes.

C2x no longer supports that function signature as it now requires all
functions to have a prototype, and given the known security issues with
the feature, continuing to support it as an extension is not tenable.

This patch changes the diagnostic behavior for the
-Wimplicit-function-declaration warning group depending on the language
mode in effect. We continue to warn by default in C89 mode (due to the
feature being dangerous to use). However, because this feature will not
be supported in C2x mode, we've diagnosed it as being invalid for so
long, the security concerns with the feature, and the trivial
workaround for users (declare the function), we now default the
extension warning to an error in C99-C17 mode. This still gives users
an easy workaround if they are extensively using the extension in those
modes (they can disable the warning or use -Wno-error to downgrade the
error), but the new diagnostic makes it more clear that this feature is
not supported and should be avoided. In C2x mode, we no longer allow an
implicit function to be defined and treat the situation the same as any
other lookup failure.

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

2 years ago[InstCombine] remove likely redundant ValueTracking-based folds for shifts
Sanjay Patel [Wed, 20 Apr 2022 15:10:21 +0000 (11:10 -0400)]
[InstCombine] remove likely redundant ValueTracking-based folds for shifts

This is not expected to have a functional difference as discussed in the
post-commit comments for 8a9c70fc01e6. All of the motivating tests for
the older fold still optimize as expected because other code can infer
the 'nuw'.

2 years agoMachineModuleInfo: Move AddrLabelSymbols to AsmPrinter
Matt Arsenault [Sun, 17 Apr 2022 21:11:48 +0000 (17:11 -0400)]
MachineModuleInfo: Move AddrLabelSymbols to AsmPrinter

This was tracking global state only used by the AsmPrinter, which can
store its own module global state.

2 years ago[clang-tidy] Reduce false positives for `bugprone-infinite-loop` with dependent expre...
Fabian Wolff [Wed, 20 Apr 2022 15:15:19 +0000 (17:15 +0200)]
[clang-tidy] Reduce false positives for `bugprone-infinite-loop` with dependent expressions

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

Reviewed By: aaron.ballman

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

2 years agoMachineModuleInfo: Remove UsesMorestackAddr
Matt Arsenault [Sun, 17 Apr 2022 19:45:20 +0000 (15:45 -0400)]
MachineModuleInfo: Remove UsesMorestackAddr

This is x86 specific, and adds statefulness to
MachineModuleInfo. Instead of explicitly tracking this, infer if we
need to declare the symbol based on the reference previously inserted.

This produces a small change in the output due to the move from
AsmPrinter::doFinalization to X86's emitEndOfAsmFile. This will now be
moved relative to other end of file fields, which I'm assuming doesn't
matter (e.g. the __morestack_addr declaration is now after the
.note.GNU-split-stack part)

This also produces another small change in code if the module happened
to define/declare __morestack_addr, but I assume that's invalid and
doesn't really matter.

2 years ago[clang-tidy] Fix `readability-container-size-empty` check for smart pointers
Fabian Wolff [Wed, 20 Apr 2022 15:03:30 +0000 (17:03 +0200)]
[clang-tidy] Fix `readability-container-size-empty` check for smart pointers

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

Reviewed By: Sockke

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

2 years ago[clang-tidy] Fix `altera-struct-pack-align` check for empty structs
Fabian Wolff [Wed, 20 Apr 2022 14:52:23 +0000 (16:52 +0200)]
[clang-tidy] Fix `altera-struct-pack-align` check for empty structs

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

Reviewed By: whisperity, aaron.ballman

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