platform/upstream/llvm.git
2 years agoRestrict lvalue-to-rvalue conversions in CGExprConstant.
Eli Friedman [Wed, 13 Apr 2022 00:13:06 +0000 (17:13 -0700)]
Restrict lvalue-to-rvalue conversions in CGExprConstant.

We were generating wrong code for cxx20-consteval-crash.cpp: instead of
loading a value of a variable, we were using its address as the
initializer.

Found while adding code to verify the size of constant initializers.

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

2 years agoRegAllocGreedy: Remove redundant check for virtual registers
Matt Arsenault [Sat, 26 Mar 2022 21:25:34 +0000 (17:25 -0400)]
RegAllocGreedy: Remove redundant check for virtual registers

The set of interfering virtual registers obviously only includes
virtual registers.

2 years agoAMDGPU: Relax test check on tablegen debug output
Matt Arsenault [Wed, 13 Apr 2022 18:31:39 +0000 (14:31 -0400)]
AMDGPU: Relax test check on tablegen debug output

Try to match tN and pointer for asserts and non-assert builds.

2 years ago[iwyu] Handle regressions in libLLVM header include
serge-sans-paille [Wed, 13 Apr 2022 16:39:26 +0000 (12:39 -0400)]
[iwyu] Handle regressions in libLLVM header include

Running iwyu-diff on LLVM codebase since a96638e50ef5 detected a few
regressions, fixing them.

2 years ago[DA] Refactor with a better API
Congzhe Cao [Wed, 13 Apr 2022 18:45:48 +0000 (14:45 -0400)]
[DA] Refactor with a better API

Refactor from iteratively using BitCastInst::getOperand()
to using stripPointerCasts() instead. This is an improvement
since now we are able to analyze more cases, please refer
to test cases added in this patch.

Reviewed By: Meinersbur, #loopoptwg

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

2 years ago[BOLT][TEST] Add -no-pie to two tests
Amir Ayupov [Wed, 13 Apr 2022 18:46:59 +0000 (11:46 -0700)]
[BOLT][TEST] Add -no-pie to two tests

Missed these two tests in D123329 in a rebase.

2 years ago[sanitizer] Don't run malloc hooks for stacktraces
Vitaly Buka [Sat, 9 Apr 2022 02:53:41 +0000 (19:53 -0700)]
[sanitizer] Don't run malloc hooks for stacktraces

Usually when we generated stacktraces the process is in error state, so
running hooks may crash the process and prevent meaningfull error report.

Symbolizer, unwinder and pthread are potential source of mallocs.

https://b.corp.google.com/issues/228110771

Reviewed By: kda

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

2 years agoFix a typo with this test function name
Aaron Ballman [Wed, 13 Apr 2022 18:42:52 +0000 (14:42 -0400)]
Fix a typo with this test function name

The call and the function name don't line up correctly, so this was
accidentally using an implicit function declaration when it didn't
intend to.

2 years ago[BOLT][TEST] Remove -no-pie from cflags/cxxflags
Amir Ayupov [Thu, 7 Apr 2022 18:23:20 +0000 (11:23 -0700)]
[BOLT][TEST] Remove -no-pie from cflags/cxxflags

Align with an upstream change D120305 to make PIE the default on linux-gnu.

Add `-no-pie` to tests that require it.

Reviewed By: maksfb, yota9

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

2 years ago[Clang] Fix html error in cxx_status.html [NFC]
Corentin Jabot [Wed, 13 Apr 2022 18:26:40 +0000 (20:26 +0200)]
[Clang] Fix html error in cxx_status.html [NFC]

2 years agoRevert "[LICM] Only create load in pre-header when promoting load."
Florian Hahn [Wed, 13 Apr 2022 18:24:28 +0000 (20:24 +0200)]
Revert "[LICM] Only create load in pre-header when promoting load."

This reverts commit 4bf3b7dc929c8288e9e5631978ef060d9140b251.

This might be causing another buildbot failure.

2 years ago[BOLT] Ignore PC-relative relocations from data to data
Maksim Panchenko [Wed, 13 Apr 2022 01:42:19 +0000 (18:42 -0700)]
[BOLT] Ignore PC-relative relocations from data to data

BOLT expects PC-relative relocations in data sections to reference code
and the relocated data to form a jump table. However, there are cases
where PC-relative addressing is used for data-to-data references
(e.g. clang-15 can generate such code). BOLT should recognize and ignore
such relocations. Otherwise, they will be considered relocations not
claimed by any jump table and cause a failure in the strict mode.

Reviewed By: yota9, Amir

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

2 years ago[BOLT] Fix data race in shortenInstructions
Amir Ayupov [Wed, 13 Apr 2022 18:09:25 +0000 (11:09 -0700)]
[BOLT] Fix data race in shortenInstructions

Address ThreadSanitizer warning

Reviewed By: maksfb

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

2 years agoFix Werror build issue from 6f20744b7ff875
Erich Keane [Wed, 13 Apr 2022 17:57:05 +0000 (10:57 -0700)]
Fix Werror build issue from 6f20744b7ff875

2 years ago[clang] Implement Change scope of lambda trailing-return-type
Corentin Jabot [Sun, 6 Feb 2022 21:58:43 +0000 (22:58 +0100)]
[clang] Implement Change scope of lambda trailing-return-type

Implement P2036R3.

Captured variables by copy (explicitely or not), are deduced
correctly at the point we know whether the lambda is mutable,
and ill-formed before that.

Up until now, the entire lambda declaration up to the start of the body would be parsed in the parent scope, such that capture would not be available to look up.

The scoping is changed to have an outer lambda scope, followed by the lambda prototype and body.

The lambda scope is necessary because there may be a template scope between the start of the lambda (to which we want to attach the captured variable) and the prototype scope.

We also need to introduce a declaration context to attach the captured variable to (and several parts of clang assume captures are handled from the call operator context), before we know the type of the call operator.

The order of operations is as follow:

* Parse the init capture in the lambda's parent scope

* Introduce a lambda scope

* Create the lambda class and call operator

* Add the init captures to the call operator context and the lambda scope. But the variables are not capured yet (because we don't know their type).
Instead, explicit  captures are stored in a temporary map that conserves the order of capture (for the purpose of having a stable order in the ast dumps).

* A flag is set on LambdaScopeInfo to indicate that we have not yet injected the captures.

* The parameters are parsed (in the parent context, as lambda mangling recurses in the parent context, we couldn't mangle a lambda that is attached to the context of a lambda whose type is not yet known).

* The lambda qualifiers are parsed, at this point We can switch (for the second time) inside the lambda context, unset the flag indicating that we have not parsed the lambda qualifiers,
record the lambda is mutable and capture the explicit variables.

* We can parse the rest of the lambda type, transform the lambda and call operator's types and also transform the call operator to a template function decl where necessary.

At this point, both captures and parameters can be injected in the body's scope. When trying to capture an implicit variable, if we are before the qualifiers of a lambda, we need to remember that the variables are still in the parent's context (rather than in the call operator's).

Reviewed By: aaron.ballman, #clang-language-wg, ChuanqiXu

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

2 years ago[mlir][ods] Remove StrEnumAttr
Mogball [Wed, 2 Mar 2022 18:00:05 +0000 (18:00 +0000)]
[mlir][ods] Remove StrEnumAttr

StrEnumAttr has been deprecated in favour of EnumAttr, a solution based on AttrDef (https://reviews.llvm.org/D115181). This patch removes StrEnumAttr, along with all the custom ODS logic required to handle it.

See https://discourse.llvm.org/t/psa-stop-using-strenumattr-do-use-enumattr/5710 on how to transition to EnumAttr. In short,

```
// Before
def MyEnumAttr : StrEnumAttr<"MyEnum", "", [
  StrEnumAttrCase<"A">,
  StrEnumAttrCase<"B">
]>;

// After (pick an integer enum of your choice)
def MyEnum : I32EnumAttr<"MyEnum", "", [
  I32EnumAttrCase<"A", 0>,
  I32EnumAttrCase<"B", 1>
]> {
  // Don't generate a C++ class! We want to use the AttrDef
  let genSpecializedAttr = 0;
}
// Define the AttrDef
def MyEnum : EnumAttr<MyDialect, MyEnum, "my_enum">;
```

Reviewed By: rriddle, jpienaar

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

2 years ago[Sema] Don't check bounds for function pointer
Aleksandr Platonov [Wed, 13 Apr 2022 17:38:59 +0000 (20:38 +0300)]
[Sema] Don't check bounds for function pointer

Currently, clang crashes with i386 target on the following code:
```
void f() {
  f + 0xdead000000000000UL;
}
```
This problem is similar to the problem fixed in D104424, but that fix can't handle function pointer case, because `getTypeSizeInCharsIfKnown()` says that size is known and equal to 0 for function type.

This patch prevents bounds checking for function pointer, thus fixes the crash.

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

Reviewed By: erichkeane

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

2 years agoAdd support for ignored bitfield conditional codegen.
Erich Keane [Wed, 13 Apr 2022 13:46:42 +0000 (06:46 -0700)]
Add support for ignored bitfield conditional codegen.

Currently we emit an error in just about every case of conditionals
with a 'non simple' branch if treated as an LValue.  This patch adds
support for the special case where this is an 'ignored' lvalue, which
permits the side effects from happening.

It also splits up the emit for conditional LValue in a way that should
be usable to handle simple assignment expressions in similar situations.

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

2 years ago[mlir][pdll] Include string in PDLLServer.h
Jacques Pienaar [Wed, 13 Apr 2022 17:31:06 +0000 (10:31 -0700)]
[mlir][pdll] Include string in PDLLServer.h

2 years ago[libunwind][AIX] implementation of the unwinder for AIX
Xing Xue [Wed, 13 Apr 2022 17:18:10 +0000 (13:18 -0400)]
[libunwind][AIX] implementation of the unwinder for AIX

NFC - revert identation changes in AddressSpace.hpp from the previous commit

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

2 years agoRevert "[ValueTracking] Make getStringLenth aware of strdup"
serge-sans-paille [Wed, 13 Apr 2022 08:31:44 +0000 (10:31 +0200)]
Revert "[ValueTracking] Make getStringLenth aware of strdup"

This reverts commit e810d558093cff40caaa1aff24d289c76c59916d.

The commit was not taken into account the fact that strduped string could be
modified. Checking if such modification happens would make the function very
costly, without a test case in mind it's not worth the effort.

2 years ago[AArch64] Add new shuffles tests, and regenerate aarch64-wide-shuffle.ll and neon...
David Green [Wed, 13 Apr 2022 17:10:49 +0000 (18:10 +0100)]
[AArch64] Add new shuffles tests, and regenerate aarch64-wide-shuffle.ll and neon-wide-splat.ll. NFC

2 years ago[mlir][pdll] Rename extra dir flag
Jacques Pienaar [Wed, 13 Apr 2022 17:00:10 +0000 (10:00 -0700)]
[mlir][pdll] Rename extra dir flag

Not sure why this is overlapping, need to repro locally, but just rename
to something more explicit instead.

2 years ago[AArch64][SelectionDAG] stick all the power-of-two tests in a separate file; NFC
chenglin.bi [Wed, 13 Apr 2022 16:48:28 +0000 (00:48 +0800)]
[AArch64][SelectionDAG] stick all the power-of-two tests in a separate file; NFC

Baseline tests for D122968 (issue #54649).

2 years ago[NFC] Fix build failure with GCC 11 in C++20 mode
Evgeny Mandrikov [Wed, 13 Apr 2022 16:42:29 +0000 (09:42 -0700)]
[NFC] Fix build failure with GCC 11 in C++20 mode

This was already fixed in
https://github.com/llvm/llvm-project/commit/2ccf0b76bcaf0895e04f14e3ff53c59dd96f9f0f
but then regressed in
https://github.com/llvm/llvm-project/commit/79a1f3e7c6d338b953b4dfe8cd7cb13ba60fe4e7

Reviewed By: aeubanks

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

2 years ago[mlir][pdll] Add extra-dirs for LSP includes.
Jacques Pienaar [Wed, 13 Apr 2022 16:41:45 +0000 (09:41 -0700)]
[mlir][pdll] Add extra-dirs for LSP includes.

Enable specifying additional include directories to search. This is
consistent with what one can do with clangd (although there it is more
general compilation options) and Python LSP. We would in general expect
these to be provided by compilation database equivalent.

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

2 years agoCheck users of instrinsics instead of traversing entire function.NFC
Anna Thomas [Wed, 13 Apr 2022 16:08:53 +0000 (12:08 -0400)]
Check users of instrinsics instead of traversing entire function.NFC

Updated LowerGuardIntrinsic and LowerWidenableCondition to check for
users of the respective intrinsic, instead of checking for guards and
widenable conditions by traversing the entire function.

This is an NFC. Should save some compile time.

2 years ago[NFC] Add CMake cache file for HLSL
Chris Bieneman [Wed, 13 Apr 2022 16:25:08 +0000 (11:25 -0500)]
[NFC] Add CMake cache file for HLSL

This just adds a trivial CMake cache file (which will grow over time)
to handle the common build configuration for the HLSL compiler.

2 years ago[AArch64] Async unwind - Adjust unwind info in AArch64LoadStoreOptimizer
Momchil Velikov [Wed, 13 Apr 2022 15:21:33 +0000 (16:21 +0100)]
[AArch64] Async unwind - Adjust unwind info in AArch64LoadStoreOptimizer

The AArch64LoadStoreOptimnizer pass may merge a register
increment/decrement with a following memory operation. In doing so, it
may break CFI by moving a stack pointer adjustment past the CFI
instruction that described *that* adjustment.

This patch fixes this issue by moving said CFI instruction after the
merged instruction, where the SP increment/decrement actually takes
place.

Reviewed By: efriedma

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

2 years ago[demangler] Rust demangler buffer return
Nathan Sidwell [Fri, 8 Apr 2022 17:13:41 +0000 (10:13 -0700)]
[demangler] Rust demangler buffer return

The rust demangler has some odd buffer handling code, which will copy
the demangled string into the provided buffer, if it will fit.
Otherwise it uses the allocated buffer it made.  But the length of the
incoming buffer will have come from a previous call, which was the
length of the demangled string -- not the buffer size.  And of course,
we're unconditionally allocating a temporary buffer in the first
place.  So we don't actually get buffer reuse, and we get a memcpy in
somecases.

However, nothing in LLVM ever passes in a non-null pointer.  Neither
does anything pass in a status pointer that is then made use of.  The
only exercise these have is in the test suite.

So let's just make the rust demangler have the same API as the dlang
demangler.

Reviewed By: tmiasko

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

2 years ago[AMDGPU] Initialize a couple more Subtarget fields
Jay Foad [Wed, 13 Apr 2022 15:24:31 +0000 (16:24 +0100)]
[AMDGPU] Initialize a couple more Subtarget fields

This is just for consistency. The fields are never actually used
so it is NFC.

2 years ago[libunwind][AIX] implementation of the unwinder for AIX
Xing Xue [Wed, 13 Apr 2022 15:29:37 +0000 (11:29 -0400)]
[libunwind][AIX] implementation of the unwinder for AIX

Summary:
This is an add-on patch to address comments.
- Replace #elif in file <assembly.h> with #else as suggested;
- Reversed the indentation changes in the main patch.

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

2 years agoRecommit "[LICM] Only create load in pre-header when promoting load."
Florian Hahn [Wed, 13 Apr 2022 15:20:39 +0000 (17:20 +0200)]
Recommit "[LICM] Only create load in pre-header when promoting load."

This reverts the revert commit 1ddc719680c21f3.

This version of the patch sets the initial available value to poison,
which resolves an issue with the SSAUpdater breaking LCSSA form.

2 years ago[gn build] Port a85da649b9ac
LLVM GN Syncbot [Wed, 13 Apr 2022 15:05:20 +0000 (15:05 +0000)]
[gn build] Port a85da649b9ac

2 years ago[libunwind][AIX] implementation of the unwinder for AIX
Xing Xue [Wed, 13 Apr 2022 15:01:59 +0000 (11:01 -0400)]
[libunwind][AIX] implementation of the unwinder for AIX

Summary:
This patch contains the implementation of the unwinder for IBM AIX.

AIX does not support the eh_frame section. Instead, the traceback table located at the end of each function provides the information for stack unwinding and EH. In this patch macro _LIBUNWIND_SUPPORT_TBTAB_UNWIND is used to guard code for AIX traceback table based unwinding. Function getInfoFromTBTable() and stepWithTBTable() are added to get the EH information from the traceback table and to step up the stack respectively.

There are two kinds of LSDA information for EH on AIX, the state table and the range table. The state table is used by the previous version of the IBM XL compiler, i.e., xlC and xlclang++. The DWARF based range table is used by AIX clang++. The traceback table has flags to differentiate these cases. For the range table, relative addresses are calculated using a base of DW_EH_PE_datarel, which is the TOC base of the module where the function of the current frame belongs.

Two personality routines are employed to handle these two different LSDAs, __xlcxx_personality_v0() for the state table and __xlcxx_personality_v1() for the range table. Since the traceback table does not have the information of the personality for the state table approach, its personality __xlcxx_personality_v0() is dynamically resolved as the handler for the state table. For the range table, the locations of the LSDA and its associated personality routine are found in the traceback table.

Assembly code for 32- and 64-bit PowerPC in UnwindRegistersRestore.S and UnwindRegistersSave.S are modified so that it can be consumed by the GNU flavor assembler and the AIX assembler. The restoration of vector registers does not check VRSAVE on AIX because VRSAVE is not used in the AIX ABI.

Reviewed by: MaskRay, compnerd, cebowleratibm, sfertile, libunwind

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

2 years ago[CUDA][HIP] Fix host used external kernel in archive
Yaxun (Sam) Liu [Sat, 9 Apr 2022 03:56:07 +0000 (23:56 -0400)]
[CUDA][HIP] Fix host used external kernel in archive

For -fgpu-rdc, a host function may call an external kernel
which is defined in an archive of bitcode. Since this external
kernel is only referenced in host function, the device
bitcode does not contain reference to this external
kernel, then the linker will not try to resolve this external
kernel in the archive.

To fix this issue, host-used external kernels and device
variables are tracked. A global array containing pointers
to these external kernels and variables is emitted which
serves as an artificial references to the external kernels
and variables used by host.

Reviewed by: Artem Belevich

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

2 years ago[SimplifyLibCalls] Don't mark memchr() memory as fully dereferenceable
Nikita Popov [Wed, 13 Apr 2022 09:28:45 +0000 (11:28 +0200)]
[SimplifyLibCalls] Don't mark memchr() memory as fully dereferenceable

C11 specifies memchr() as follows:

> The memchr function locates the first occurrence of c (converted
> to an unsigned char) in the initial n characters (each interpreted
> as unsigned char) of the object pointed to by s. The implementation
> shall behave as if it reads the characters sequentially and stops
> as soon as a matching character is found.

In particular, it is well-defined to specify a memchr size larger
than the underlying object, as long as the character is found before
the end of the object.

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

2 years ago[clang-format] Fix SeparateDefinitionBlocks breaking up function-try-block.
Marek Kurdej [Fri, 25 Mar 2022 10:01:40 +0000 (11:01 +0100)]
[clang-format] Fix SeparateDefinitionBlocks breaking up function-try-block.

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

Reviewed By: HazardyKnusperkeks, owenpan

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

2 years ago[NFC] Simplify /noimplib argument logic
Tobias Hieta [Wed, 13 Apr 2022 14:39:22 +0000 (16:39 +0200)]
[NFC] Simplify /noimplib argument logic

2 years ago[LLD][COFF] Add support for /noimplib
Tobias Hieta [Tue, 12 Apr 2022 11:59:45 +0000 (13:59 +0200)]
[LLD][COFF] Add support for /noimplib

Mostly for compatibility reasons with link.exe this flag
makes sure we don't write a implib - not even when /implib
is also passed, that's how link.exe works.

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

2 years ago[SimplifyCFG] add tests for switch to select; NFC
chenglin.bi [Wed, 13 Apr 2022 14:34:30 +0000 (22:34 +0800)]
[SimplifyCFG] add tests for switch to select; NFC

Baseline tests for D122485 (issue #39957)

2 years agoRevert "[SimplifyCFG] add tests for switch to select; NFC"
chenglin.bi [Wed, 13 Apr 2022 14:32:22 +0000 (22:32 +0800)]
Revert "[SimplifyCFG] add tests for switch to select; NFC"

This reverts commit e2d77a160c5b8141eca3db1fca6dafd97e78288d.

2 years ago[OpenMP] Lowering to MLIR of ordered threads directive
PeixinQiao [Wed, 13 Apr 2022 14:30:52 +0000 (22:30 +0800)]
[OpenMP] Lowering to MLIR of ordered threads directive

This patch supports lowering parse-tree to MLIR of ordered threads
directive following Section 2.19.9 of the OpenMP 5.1 standard.

This is part of the upstreaming effort from the fir-dev branch in [1].
[1] https://github.com/flang-compiler/f18-llvm-project

Reviewed By: shraiysh

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

2 years ago[flang][OpenMP] Add semantic checks of nesting of region about ordered construct
PeixinQiao [Wed, 13 Apr 2022 14:27:58 +0000 (22:27 +0800)]
[flang][OpenMP] Add semantic checks of nesting of region about ordered construct

This patch supports the following checks for ORDERED construct:

```
[5.1] 2.19.9 ORDERED Construct
The worksharing-loop or worksharing-loop SIMD region to which an ordered
region corresponding to an ordered construct without a depend clause
binds must have an ordered clause without the parameter specified on the
corresponding worksharing-loop or worksharing-loop SIMD directive.
The worksharing-loop region to which an ordered region that corresponds
to an ordered construct with any depend clauses binds must have an
ordered clause with the parameter specified on the corresponding
worksharing-loop directive.
An ordered construct with the depend clause specified must be closely
nested inside a worksharing-loop (or parallel worksharing-loop)
construct.
An ordered region that corresponds to an ordered construct with the simd
clause specified must be closely nested inside a simd or
worksharing-loop SIMD region.
```

Reviewed By: kiranchandramohan, shraiysh, NimishMishra

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

2 years ago[mlir][docs] Fix broken links
Marius Brehler [Wed, 13 Apr 2022 14:17:52 +0000 (16:17 +0200)]
[mlir][docs] Fix broken links

2 years ago[libc++] Mark completed paper as complete
Louis Dionne [Wed, 13 Apr 2022 14:16:39 +0000 (10:16 -0400)]
[libc++] Mark completed paper as complete

2 years ago[gn build] Port 2fb026ee4d1a
LLVM GN Syncbot [Wed, 13 Apr 2022 13:52:22 +0000 (13:52 +0000)]
[gn build] Port 2fb026ee4d1a

2 years ago[libc++] Post-commit adjustments after rebasing D117656
Louis Dionne [Tue, 12 Apr 2022 22:56:40 +0000 (18:56 -0400)]
[libc++] Post-commit adjustments after rebasing D117656

2 years agoImplement move_sentinel and C++20 move_iterator.
Arthur O'Dwyer [Wed, 19 Jan 2022 11:26:52 +0000 (06:26 -0500)]
Implement move_sentinel and C++20 move_iterator.

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

2 years ago[lldb] Fixup af921006d3792f for non-linux platforms
Pavel Labath [Wed, 13 Apr 2022 13:37:44 +0000 (15:37 +0200)]
[lldb] Fixup af921006d3792f for non-linux platforms

2 years ago[SimplifyCFG] add tests for switch to select; NFC
chenglin.bi [Wed, 13 Apr 2022 13:27:06 +0000 (21:27 +0800)]
[SimplifyCFG] add tests for switch to select; NFC

Baseline tests for D122968(issue #54649)

2 years ago[gn build] Port 2b424f4ea82e
LLVM GN Syncbot [Wed, 13 Apr 2022 13:04:50 +0000 (13:04 +0000)]
[gn build] Port 2b424f4ea82e

2 years ago[libc++] Implement ranges::filter_view
Louis Dionne [Wed, 14 Jul 2021 21:01:25 +0000 (17:01 -0400)]
[libc++] Implement ranges::filter_view

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

2 years ago[SystemZ] Implement adjustInliningThreshold().
Jonas Paulsson [Fri, 14 Jan 2022 00:52:16 +0000 (18:52 -0600)]
[SystemZ] Implement adjustInliningThreshold().

This patch boosts the inlining threshold for a particular type of functions
that are using an incoming argument only as a memcpy source.

Review: Ulrich Weigand

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

2 years ago[clangd] Export preamble AST and serialized size as metrics
Sam McCall [Wed, 13 Apr 2022 12:02:19 +0000 (14:02 +0200)]
[clangd] Export preamble AST and serialized size as metrics

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

2 years ago[lldb] Remove the global platform list
Pavel Labath [Fri, 25 Feb 2022 13:47:27 +0000 (14:47 +0100)]
[lldb] Remove the global platform list

This patch moves the platform creation and selection logic into the
per-debugger platform lists. I've tried to keep functional changes to a
minimum -- the main (only) observable difference in this change is that
APIs, which select a platform by name (e.g.,
Debugger::SetCurrentPlatform) will not automatically pick up a platform
associated with another debugger (or no debugger at all).

I've also added several tests for this functionality -- one of the
pleasant consequences of the debugger isolation is that it is now
possible to test the platform selection and creation logic.

This is a product of the discussion at
<https://discourse.llvm.org/t/multiple-platforms-with-the-same-name/59594>.

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

2 years ago[compiler-rt] Don't explictly ad-hoc sign dylibs on APPLE if ld is new enough
Nico Weber [Mon, 11 Apr 2022 01:28:29 +0000 (21:28 -0400)]
[compiler-rt] Don't explictly ad-hoc sign dylibs on APPLE if ld is new enough

ld64 implicitly ad-hoc code-signs as of Xcode 12, and `strip` and friends know
how keep this special ad-hoc signature valid.

So this should have no effective behavior change, except that you can now strip
libclang_rt.asan_osx_dynamic.dylib and it'll still have a valid ad-hoc
signature, instead of strip printing "warning: changes being made to the file
will invalidate the code signature in:" and making the ad-hoc code signature
invalid.

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

2 years ago[mlir][Tensor] Fix wrong comment (NFC)
Adrian Kuegel [Wed, 13 Apr 2022 12:30:01 +0000 (14:30 +0200)]
[mlir][Tensor] Fix wrong comment (NFC)

2 years agoCorrectly diagnose prototype redeclaration errors in C
Aaron Ballman [Wed, 13 Apr 2022 12:20:19 +0000 (08:20 -0400)]
Correctly diagnose prototype redeclaration errors in C

We did not implement C99 6.7.5.3p15 fully in that we missed the rule
for compatible function types where a prior declaration has a prototype
and a subsequent definition (not just declaration) has an empty
identifier list or an identifier list with a mismatch in parameter
arity. This addresses that situation by issuing an error on code like:

void f(int);
void f() {} // type conflicts with previous declaration

(Note: we already diagnose the other type conflict situations
appropriately, this was the only situation we hadn't covered that I
could find.)

2 years ago[X86] Covert unsigned int 0 to float-point with FILD instruction.
Liu, Chen3 [Wed, 13 Apr 2022 07:25:12 +0000 (15:25 +0800)]
[X86] Covert unsigned int 0 to float-point with FILD instruction.

unsinged int 0 will be convert to float/double -0.0 when the rounding
mode is set to 'FE_DOWNWARD'. Using FILD instruction instead of SSE
instructions on 32-bit target if the strictfp is enabled.

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

2 years ago[DAG] Enable SimplifyVBinOp folds on add/sub sat intrinsics
Simon Pilgrim [Wed, 13 Apr 2022 11:53:15 +0000 (12:53 +0100)]
[DAG] Enable SimplifyVBinOp folds on add/sub sat intrinsics

2 years ago[AMDGPU][MC][GFX10] Removed unsupported 64bit DPP opcodes
Dmitry Preobrazhensky [Wed, 13 Apr 2022 11:16:40 +0000 (14:16 +0300)]
[AMDGPU][MC][GFX10] Removed unsupported 64bit DPP opcodes

Removed 64bit DPP opcodes from asm matcher tables.

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

2 years ago[X86] Add tests showing failure to pull common shuffles through add/sub sat intrinsics
Simon Pilgrim [Wed, 13 Apr 2022 11:35:38 +0000 (12:35 +0100)]
[X86] Add tests showing failure to pull common shuffles through add/sub sat intrinsics

2 years ago[SimplifyCFG] make a debug option for case max when converting switch to select
Sanjay Patel [Wed, 13 Apr 2022 10:54:08 +0000 (06:54 -0400)]
[SimplifyCFG] make a debug option for case max when converting switch to select

This should be "NFC" as written, but it will make D122485 smaller
and give us more flexibility to experiment with optimization level
vs. compile-time.

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

2 years ago[InlineAsm] Add support for address operands ("p").
Jonas Paulsson [Tue, 22 Mar 2022 09:39:07 +0000 (10:39 +0100)]
[InlineAsm] Add support for address operands ("p").

This patch adds support for inline assembly address operands using the "p"
constraint on X86 and SystemZ.

This was in fact broken on X86 (see example at
https://reviews.llvm.org/D110267, Nov 23).

These operands should probably be treated the same as memory operands by
CodeGenPrepare, which have been commented with "TODO" there.

Review: Xiang Zhang and Ulrich Weigand

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

2 years ago[flang][nfc] Simplify TargetMachine initialisation
Andrzej Warzynski [Wed, 13 Apr 2022 10:28:49 +0000 (10:28 +0000)]
[flang][nfc] Simplify TargetMachine initialisation

2 years ago[AMDGPU][GFX10] Enabled op_sel for v_add_nc_u16 and v_sub_nc_u16
Dmitry Preobrazhensky [Wed, 13 Apr 2022 10:09:11 +0000 (13:09 +0300)]
[AMDGPU][GFX10] Enabled op_sel for v_add_nc_u16 and v_sub_nc_u16

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

2 years ago[BOLT] Fix two aarch64 tests
Vladislav Khmelevsky [Thu, 7 Apr 2022 18:56:05 +0000 (21:56 +0300)]
[BOLT] Fix two aarch64 tests

tls-lld test might be broken since compiler might optimize plt function
call and use address directly from got table. The test is removed since
plt-gnu-ld checks the same functionality + versioning symbol matching,
no need to keep both of the tests.
The toolchain might optimize relocations in runtime-relocs test, replace
the test compilation with yaml files.

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

2 years ago[DAG] Add non-uniform vector support to (shl (srl x, c1), c2) -> (and (shift x, c3))
Simon Pilgrim [Wed, 13 Apr 2022 10:37:24 +0000 (11:37 +0100)]
[DAG] Add non-uniform vector support to (shl (srl x, c1), c2) -> (and (shift x, c3))

Another part of D77804 yak shaving

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

2 years ago[flang][driver] Add support for generating LLVM bytecode files
Andrzej Warzynski [Wed, 6 Apr 2022 11:59:28 +0000 (11:59 +0000)]
[flang][driver] Add support for generating LLVM bytecode files

Support for generating LLVM BC files is added in Flang's compiler and
frontend drivers. This requires the `BitcodeWriterPass` pass to be run
on the input LLVM IR module and is implemented as a dedicated frontend
aciton. The new functionality as seen by the user (compiler driver):
```
flang-new -c -emit-llvm file.90
```
or (frontend driver):
```
flang-new -fc1 -emit-llvm-bc file.f90
```

The new behaviour is consistent with `clang` and `clang -cc1`.

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

2 years ago[RISCV][NFC] Reorganize check prefixes in some tests to reduce redundant lines
Ping Deng [Wed, 13 Apr 2022 09:55:07 +0000 (09:55 +0000)]
[RISCV][NFC] Reorganize check prefixes in some tests to reduce redundant lines

Reviewed By: benshi001, craig.topper, frasercrmck

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

2 years ago[AArch64] Add missing HasNEON predicate in scalar FABD patterns
Alex Richardson [Tue, 12 Apr 2022 20:59:41 +0000 (20:59 +0000)]
[AArch64] Add missing HasNEON predicate in scalar FABD patterns

I was trying to compile with -march=+nosimd and hit the following assertion:
`Attempting to emit FABD64 instruction but the Feature_HasNEON predicate(s) are not met`.
This adds a HasNEON predicate to the patterns which was omitted in commit
21d9b33d62772c58267cc0aa725e35ac9a4661db for some reason.
The new code generation matches GCC with -mcpu=<cpu>+nosimd:
https://godbolt.org/z/n1Y7xh5jo

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

2 years ago[AArch64] Baseline test for D123491
Alex Richardson [Mon, 11 Apr 2022 08:01:05 +0000 (08:01 +0000)]
[AArch64] Baseline test for D123491

2 years ago[AutoUpgrade] Don't lose attributes when upgrading mem intrinsics
Alex Richardson [Thu, 17 Mar 2022 23:28:11 +0000 (23:28 +0000)]
[AutoUpgrade] Don't lose attributes when upgrading mem intrinsics

The original AutoUpgrade code from 1e68724d24ba38de7c7cdb2e1939d78c8b37cc0d
did not retain existing attributes. I noticed this in some downstream test
cases, but it turns out there are also two affected testcase upstream.

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

2 years ago[AArch64][SVE] Fix lowering of "fcmp ueq/one" when using SVE
David Sherwood [Thu, 17 Mar 2022 11:51:59 +0000 (11:51 +0000)]
[AArch64][SVE] Fix lowering of "fcmp ueq/one" when using SVE

We were previously lowering to the incorrect instructions for the
setcc DAG node when using the SETUEQ and SETONE floating point
condition codes. I have fixed this by marking the SETONE code
as Expand and letting the SETUNE code be legal. I have also
fixed up the patterns for FCMNE_PPzZZ and FCMNE_PPzZ0 to use
the correct opcode.

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

2 years ago[RISCV][NFC] Refactor the type promotion of fsl/fsr/becompress/bdecompress/bfp
Liqin Weng [Wed, 13 Apr 2022 02:45:28 +0000 (02:45 +0000)]
[RISCV][NFC] Refactor the type promotion of fsl/fsr/becompress/bdecompress/bfp

Reviewed By: asb, jrtc27, craig.topper, frasercrmck

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

2 years ago[Test] Add tests showing duplicate PHIs generated by RS4GC (NFC)
Dmitry Makogon [Wed, 13 Apr 2022 08:46:12 +0000 (15:46 +0700)]
[Test] Add tests showing duplicate PHIs generated by RS4GC (NFC)

2 years ago[LTO] Remove legacy PM support
Nikita Popov [Wed, 13 Apr 2022 08:35:42 +0000 (10:35 +0200)]
[LTO] Remove legacy PM support

We don't have any places setting NewPM=false anymore, so drop the
support code in LTOBackend.

2 years agoRevert "[ubsan] Simplify ubsan_GetStackTrace"
Nikita Popov [Wed, 13 Apr 2022 08:36:11 +0000 (10:36 +0200)]
Revert "[ubsan] Simplify ubsan_GetStackTrace"

This reverts commit 63f2d1f4d4b8ee284b4ab977242e322a9458a168.

I don't quite understand why, but this causes a linker error for
me and a number of buildbots:

/home/npopov/repos/llvm-project/compiler-rt/lib/ubsan/../sanitizer_common/sanitizer_stacktrace.h:130: error: undefined reference to '__sanitizer::BufferedStackTrace::UnwindImpl(unsigned long, unsigned long, void*, bool, unsigned int)'

2 years ago[LLD][COFF] Add support for /noimplib
Tobias Hieta [Tue, 12 Apr 2022 14:06:46 +0000 (16:06 +0200)]
[LLD][COFF] Add support for /noimplib

Mostly for compatibility reasons with link.exe this flag
makes sure we don't write a implib - not even when /implib
is also passed, that's how link.exe works.

Reviewed By: mstorsjo

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

2 years ago[Clang] Remove support for legacy pass manager
Nikita Popov [Mon, 11 Apr 2022 10:52:31 +0000 (12:52 +0200)]
[Clang] Remove support for legacy pass manager

This removes the -flegacy-pass-manager and
-fno-experimental-new-pass-manager options, and the corresponding
support code in BackendUtil. The -fno-legacy-pass-manager and
-fexperimental-new-pass-manager options are retained as no-ops.

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

2 years ago[clang][ASTImporter] Fix an import error handling related bug.
Balázs Kéri [Wed, 13 Apr 2022 07:41:40 +0000 (09:41 +0200)]
[clang][ASTImporter] Fix an import error handling related bug.

This bug can cause that more import errors are generated than necessary
and many objects fail to import. Chance of an invalid AST after these
imports increases.

Reviewed By: martong

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

2 years ago[clang] NFC, move CompilerInvocation::setLangDefaults to LangOptions.h
Haojian Wu [Fri, 8 Apr 2022 11:23:12 +0000 (13:23 +0200)]
[clang] NFC, move CompilerInvocation::setLangDefaults to LangOptions.h

The function is moved from clangFrontend to clangBasic, which allows tools
(e.g. clang pseudoparser) which don't depend on clangFrontend to use.

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

2 years ago[ubsan] Simplify ubsan_GetStackTrace
Fangrui Song [Wed, 13 Apr 2022 07:32:10 +0000 (00:32 -0700)]
[ubsan] Simplify ubsan_GetStackTrace

Suggested by Vitaly Buka

2 years agoSupport the min of module flags when linking, use for AArch64 BTI/PAC-RET
Daniel Kiss [Wed, 13 Apr 2022 07:31:25 +0000 (09:31 +0200)]
Support the min of module flags when linking, use for AArch64 BTI/PAC-RET

LTO objects might compiled with different `mbranch-protection` flags which will cause an error in the linker.
Such a setup is allowed in the normal build with this change that is possible.

Reviewed By: pcc

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

2 years ago[clangd] Fix incorrect operator< impl for HighlightingToken
Nathan Ridge [Wed, 13 Apr 2022 06:54:12 +0000 (02:54 -0400)]
[clangd] Fix incorrect operator< impl for HighlightingToken

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

2 years ago[gn build] Port e53c461bf3f0
LLVM GN Syncbot [Wed, 13 Apr 2022 05:30:23 +0000 (05:30 +0000)]
[gn build] Port e53c461bf3f0

2 years ago[libc++][ranges] Implement `lazy_split_view`.
Konstantin Varlamov [Wed, 13 Apr 2022 05:27:07 +0000 (22:27 -0700)]
[libc++][ranges] Implement `lazy_split_view`.

Note that this class was called just `split_view` in the original One
Ranges Proposal and was renamed to `lazy_split_view` by
[P2210](https://wg21.link/p2210).

Co-authored-by: zoecarver <z.zoelec2@gmail.com>
Differential Revision: https://reviews.llvm.org/D107500

2 years ago[clang][preprocessor] Allow calling DumpToken() on annotation tokens
Timm Bäder [Tue, 29 Mar 2022 14:58:45 +0000 (16:58 +0200)]
[clang][preprocessor] Allow calling DumpToken() on annotation tokens

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

2 years ago[X86][test] Add encoding/decoding tests for VEX instruction w/ address-size prefix
Shengchen Kan [Wed, 13 Apr 2022 04:49:51 +0000 (12:49 +0800)]
[X86][test] Add encoding/decoding tests for VEX instruction w/ address-size prefix

This patch also contains a regression test for D122448

Reviewed By: hvdijk, RKSimon

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

2 years ago[clang-format] Allow empty .clang-format file
owenca [Wed, 13 Apr 2022 00:51:28 +0000 (17:51 -0700)]
[clang-format] Allow empty .clang-format file

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

2 years ago[libomptarget][amdgpu] Add hidden_heap_v1 kernarg metadata
Saiyedul Islam [Mon, 11 Apr 2022 17:28:07 +0000 (17:28 +0000)]
[libomptarget][amdgpu] Add hidden_heap_v1 kernarg metadata

Code object version 5 adds support of hidden_heap_v1 kernarg
metadata field [1]. It is a global address space pointer to an
initialized memory buffer that conforms to the requirements of the
malloc/free device library V1 version implementation.

[1] https://llvm.org/docs/AMDGPUUsage.html#amdgpu-amdhsa-code-object-kernel-argument-metadata-map-table-v5

Reviewed By: carlo.bertolli

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

2 years ago[lldb] Re-enable TestStepNoDebug.py on AS
Jonas Devlieghere [Wed, 13 Apr 2022 03:27:10 +0000 (20:27 -0700)]
[lldb] Re-enable TestStepNoDebug.py on AS

This test showed up as an unexpected pass and is now consistently
passing on Apple Silicon.

2 years ago[lldb] Print diagnostic prefixes (error, warning) in color
Jonas Devlieghere [Wed, 13 Apr 2022 03:26:37 +0000 (20:26 -0700)]
[lldb] Print diagnostic prefixes (error, warning) in color

Print diagnostic prefixes (error, warning) in their respective colors
when colors are enabled.

2 years ago[NFC][sanitizer] Consolidate malloc hook invocations
Vitaly Buka [Wed, 13 Apr 2022 03:07:34 +0000 (20:07 -0700)]
[NFC][sanitizer] Consolidate malloc hook invocations

2 years ago[mlir][LLVM-IR] Added support for global variable attributes
Shraiysh Vaishay [Wed, 13 Apr 2022 02:50:56 +0000 (08:20 +0530)]
[mlir][LLVM-IR] Added support for global variable attributes

This patch adds thread_local to llvm.mlir.global and adds translation for dso_local and addr_space to and from LLVM IR.

Reviewed By: Mogball

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

2 years ago[NFC] [AST] Reduce the size of TemplateParmPosition
Chuanqi Xu [Thu, 7 Apr 2022 10:53:55 +0000 (18:53 +0800)]
[NFC] [AST] Reduce the size of TemplateParmPosition

I found this when reading the codes. I think it makes sense to reduce
the space for TemplateParmPosition. It is hard to image the depth of
template parameter is larger than 2^20 and the index is larger than
2^12. So I think the patch might be reasonable.

Reviewed By: aaron.ballman

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

2 years ago[NFC][sanitizer] Remove unnececary HOOK macros
Vitaly Buka [Wed, 13 Apr 2022 02:19:44 +0000 (19:19 -0700)]
[NFC][sanitizer] Remove unnececary HOOK macros

2 years ago[InstCombine] [NFC] Add a test for fneg.ll
Chenbing Zheng [Wed, 13 Apr 2022 02:33:54 +0000 (10:33 +0800)]
[InstCombine] [NFC] Add a test for fneg.ll

2 years ago[clang][test] Disable opaque pointers in test
Arthur Eubanks [Wed, 13 Apr 2022 02:14:52 +0000 (19:14 -0700)]
[clang][test] Disable opaque pointers in test

Was missed in opaque pointer switch due to not being run on x86.