platform/upstream/llvm.git
2 years ago[lld-link] Replace LazyObjFile with lazy ObjFile/BitcodeFile
Fangrui Song [Tue, 4 Jan 2022 23:11:44 +0000 (15:11 -0800)]
[lld-link] Replace LazyObjFile with lazy ObjFile/BitcodeFile

Similar to ELF 3a5fb57393c3bc77be9e7afc2ec9d4ec3c9bbf70.

* previously when a LazyObjFile was extracted, a new ObjFile/BitcodeFile was created; now the file is reused, just with `lazy` cleared
* avoid the confusing transfer of `symbols` from LazyObjFile to the new file
* simpler code, smaller executable (5200+ bytes smaller on x86-64)
* make eager parsing feasible (for parallel section/symbol table initialization)

Reviewed By: aganea, rnk

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

2 years ago[libc++][test] Allow multiple tries in some thread tests
Nikolas Klauser [Tue, 4 Jan 2022 22:28:21 +0000 (23:28 +0100)]
[libc++][test] Allow multiple tries in some thread tests

2 years ago[gn build] Port 6d722801d1a2
LLVM GN Syncbot [Tue, 4 Jan 2022 22:44:20 +0000 (22:44 +0000)]
[gn build] Port 6d722801d1a2

2 years ago[libc++][ranges] Add indirectly_comparable concept
Nikolas Klauser [Tue, 4 Jan 2022 18:55:37 +0000 (19:55 +0100)]
[libc++][ranges] Add indirectly_comparable concept

Add `indirectly_comparable` concept

Reviewed By: Quuxplusone, Mordante, #libc

Spies: mgorny, libcxx-commits

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

2 years ago[Hexagon] Fix some issues with packetizing slot0-only instructions
Brendon Cahoon [Tue, 4 Jan 2022 22:34:15 +0000 (14:34 -0800)]
[Hexagon] Fix some issues with packetizing slot0-only instructions

2 years ago[flang] Modify an IO format error message
V Donaldson [Tue, 4 Jan 2022 20:54:45 +0000 (12:54 -0800)]
[flang] Modify an IO format error message

F18 constraint C1308 is:

  For the G edit descriptor, e shall not be specified if w is zero.

For an edit descriptor such as 'G0.2E4', change the error message from:

  error: Unexpected 'e' in 'G0' edit descriptor

To:

  error: A 'G0' edit descriptor must not have an 'e' value

2 years ago[libc++] [P0887] Add newest feature-test macros; mark `type_identity` as implemented.
Arthur O'Dwyer [Fri, 31 Dec 2021 04:28:12 +0000 (23:28 -0500)]
[libc++] [P0887] Add newest feature-test macros; mark `type_identity` as implemented.

`__cpp_lib_type_identity` was implemented way back in cf49ccd0 (Clang 8),
probably before the feature-test macro had been settled on.

`__cpp_lib_string_resize_and_overwrite` will be added by D113013 so I didn't add it here.

Fixes #46605.

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

2 years ago[libc++] [ranges] ADL-proof the [range.access] CPOs.
Arthur O'Dwyer [Thu, 23 Dec 2021 21:53:48 +0000 (16:53 -0500)]
[libc++] [ranges] ADL-proof the [range.access] CPOs.

For example, `std::ranges::range<Holder<Incomplete>*>` should be
well-formed false, not a hard error at compile time.

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

2 years ago[libc++] [test] More test coverage for ranges::{data,size}.
Arthur O'Dwyer [Thu, 23 Dec 2021 21:39:22 +0000 (16:39 -0500)]
[libc++] [test] More test coverage for ranges::{data,size}.

Reviewed as part of D116239.

2 years ago[Hexagon] Performance regression with b2b
Harsha Jagasia [Fri, 2 Oct 2020 16:26:45 +0000 (11:26 -0500)]
[Hexagon] Performance regression with b2b

For code below:
        {
                r7 = addasl(r3,r0,#2)
                r8 = addasl(r3,r2,#2)
                r5 = memw(r3+r0<<#2)
                r6 = memw(r3+r2<<#2)
        }
        {
                p1 = cmp.gtu(r6,r5)
                if (p1.new) memw(r8+#0) = r5
                if (p1.new) memw(r7+#0) = r6
        }
        {
                r0 = mux(p1,r2,r4)

        }

In packetizer, a new packet is created for the cmp instruction since
there arent enough resources in previous packet. Also it is determined
that the cmp stalls by 2 cycles since it depends on the prior load of r5.
In current packetizer implementation, the predicated store is evaluated
for whether it can go in the same packet as compare, and since the compare
stalls, the stall of the predicated store does not matter and it can go in
the same packet as the cmp. However the predicated store will stall for
more cycles because of its dependence on the addasl instruction and to
avoid that stall we can put it in a new packet.

Improve the packetizer to check if an instruction being added to packet
will stall longer than instruction already in packet and if so create a
new packet.

2 years ago[LLDB][Clang] add AccessSpecDecl for methods and fields in RecordType
Zequan Wu [Thu, 2 Dec 2021 22:58:23 +0000 (14:58 -0800)]
[LLDB][Clang] add AccessSpecDecl for methods and fields in RecordType

This allows access type be printed when running `lldb-test -dump-ast` and
`lldb-test -dump-clang-ast`.

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

2 years ago[Hexagon] HVX .new store uses different resources
SANTANU DAS [Tue, 3 Aug 2021 15:57:56 +0000 (21:27 +0530)]
[Hexagon] HVX .new store uses different resources

When checking resources in the post RA scheduler, see if a .new
vector store should be used instead of a regular vector store.

It may not be possible to schedule a regular vector store, but
it may be possible to schedule a .new version. If the correct one
isn't used, then the post RA scheduler may not generate the best
schedule.

2 years ago[libc++] Implement `ranges::{cbegin,cend}` per the spec.
Arthur O'Dwyer [Thu, 23 Dec 2021 03:36:42 +0000 (22:36 -0500)]
[libc++] Implement `ranges::{cbegin,cend}` per the spec.

The big change here is that they now work as intended for rvalues,
e.g. `ranges::cbegin(std::string_view("hello"))`.
Also, add tests verifying their return types.

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

2 years ago[Hexagon] Refactor updateLatency() function
Ikhlas Ajbar [Tue, 4 Jan 2022 20:58:04 +0000 (12:58 -0800)]
[Hexagon] Refactor updateLatency() function

Co-authored-by: Sumanth Gundapaneni <sgundapa@quicinc.com>
2 years ago[libc++] Fix whitespace in __partial_sort. NFC.
Arthur O'Dwyer [Tue, 4 Jan 2022 21:15:02 +0000 (16:15 -0500)]
[libc++] Fix whitespace in __partial_sort. NFC.

2 years ago[libc++] Add an early return for __partial_sort of an empty range.
Arthur O'Dwyer [Mon, 27 Dec 2021 03:57:46 +0000 (22:57 -0500)]
[libc++] Add an early return for __partial_sort of an empty range.

If `__first == __middle`, then `partial_sort` is a no-op; don't
bother to iterate all the way from `__middle` to `__end`.

Fixes #49431.

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

2 years ago[Sema] Fix the assertion in Sema::ActOnDependentMemberExpr
Yuanfang Chen [Tue, 4 Jan 2022 20:11:33 +0000 (12:11 -0800)]
[Sema] Fix the assertion in Sema::ActOnDependentMemberExpr

617007240cbfb97c introduced the use of ActOnDependentMemberExpr with
variable template specialization. The assertion inside
ActOnDependentMemberExpr should be adjusted accordingly.

Fixes https://bugs.llvm.org/show_bug.cgi?id=47211

Reviewed By: aaron.ballman

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

2 years ago[clang][ObjC] Add fix it for missing methods in impl
David Goldman [Thu, 30 Dec 2021 17:31:59 +0000 (12:31 -0500)]
[clang][ObjC] Add fix it for missing methods in impl

We suggest inserting the method with an empty body at the end
of the implementation decl.

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

2 years ago[flang][openacc] Remove unused variable. NFC.
Benjamin Kramer [Tue, 4 Jan 2022 20:47:28 +0000 (21:47 +0100)]
[flang][openacc] Remove unused variable. NFC.

2 years ago[LegalizeIntegerTypes][RISCV] Teach PromoteSetCCOperands to check sign bits of unsign...
Craig Topper [Tue, 4 Jan 2022 20:23:17 +0000 (12:23 -0800)]
[LegalizeIntegerTypes][RISCV] Teach PromoteSetCCOperands to check sign bits of unsigned compares.

Unsigned compares work with either zero extended or sign extended
inputs just like equality comparisons. I didn't allow this when
I refactored the code in D116421 due to lack of tests. But I've
since found a simple C test case that demonstrates when this can be
useful.

Reviewed By: efriedma

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

2 years ago[Hexagon] Update latencies on REG_SEQUENCE/COPY based on successors.
Sumanth Gundapaneni [Tue, 4 Jan 2022 20:26:34 +0000 (12:26 -0800)]
[Hexagon] Update latencies on REG_SEQUENCE/COPY based on successors.

If there are multiple uses of the def of COPY/REG_SEQUENCE, set the
latency only if the latencies on all the uses are equal, otherwise set
it to default.

2 years ago[DebugInfo] Avoid triggering global location assert for 2-byte pointer sizes.
Jack Andersen [Tue, 4 Jan 2022 20:16:36 +0000 (15:16 -0500)]
[DebugInfo] Avoid triggering global location assert for 2-byte pointer sizes.

D111404 moved a 4/8 byte check assert into a block taken by 2-byte platforms.
Since these platforms do not take the branches where the pointer size is used,
sink the assert accordingly.

Reviewed By: dblaikie

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

2 years ago[mlir] Make Value's constructor constexpr. NFCI.
Benjamin Kramer [Mon, 3 Jan 2022 15:45:08 +0000 (16:45 +0100)]
[mlir] Make Value's constructor constexpr. NFCI.

This allows clang to flag unused Values in more cases, so remove them.

2 years agoprecommit tests for a planned followon to D116200
Philip Reames [Tue, 4 Jan 2022 20:02:07 +0000 (12:02 -0800)]
precommit tests for a planned followon to D116200

2 years ago[PS4] Verify the default DWARF version is 4.
Paul Robinson [Tue, 4 Jan 2022 19:56:42 +0000 (11:56 -0800)]
[PS4] Verify the default DWARF version is 4.

Follow-up to b8e03be. Even if Clang's generic default DWARF version
bumps up, PS4 will stay on v4.

2 years agoprecommit additional tests for D116200
Philip Reames [Tue, 4 Jan 2022 19:44:56 +0000 (11:44 -0800)]
precommit additional tests for D116200

2 years ago[Hexagon] Fix an instruction move in HexagonVectorCombine
Brendon Cahoon [Tue, 4 Jan 2022 19:40:30 +0000 (11:40 -0800)]
[Hexagon] Fix an instruction move in HexagonVectorCombine

The HexagonVectorCombine pass was moving an instruction
incorrectly, which caused a use in a GEP that was not yet
defined.

HexagonVectorCombine removes a load from a group due to its
dependences, but in realignGroup, the load is processed anyways.
In realignGroup, when determining the maximum alignment, only
those instructions still in the group should be considered.

2 years ago[libc++] Remove incorrect default constructor in cpp17_input_iterator
Louis Dionne [Wed, 15 Dec 2021 16:26:47 +0000 (11:26 -0500)]
[libc++] Remove incorrect default constructor in cpp17_input_iterator

AFAICT, Cpp17InputIterators are not required to be default constructible,
since that requirement is added in Cpp17ForwardIterator. Hence, our
archetype for Cpp17InputIterator should not be default constructible.
Removing that constructor has a ripple effect on a couple of tests that
were making incorrect assumptions. Notably:

- Some tests were using cpp17_input_iterator as a sentinel for itself.
  That is not valid, because a cpp17_input_iterator is not semiregular
  anymore after the change (and hence it doesn't satisfy sentinel_for).

- Some tests were using a stride-counted cpp17_input_iterator as the
  sentinel for a range. This doesn't work anymore because of the problem
  above, so these tests were changed not to check stride counts for
  input iterators.

- Some tests were default constructing cpp17_input_iterator when a simple
  alternative was available -- those have been changed to use that alternative.

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

2 years ago[libc++] [test] Add tests for std::span construction from initializer lists.
Arthur O'Dwyer [Sun, 3 Oct 2021 04:54:18 +0000 (00:54 -0400)]
[libc++] [test] Add tests for std::span construction from initializer lists.

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

2 years ago[Hexagon] Fix buildVector32 for v4i8 constants
Tasmia Rahman [Tue, 4 Jan 2022 19:18:13 +0000 (11:18 -0800)]
[Hexagon] Fix buildVector32 for v4i8 constants

The code for constructing a 32-bit constant from 4 8-bit constants has
a typo and uses one of the constants twice

2 years ago[libc++] [test] Remove IFNDR uses of std::invocable.
Arthur O'Dwyer [Mon, 27 Dec 2021 02:36:33 +0000 (21:36 -0500)]
[libc++] [test] Remove IFNDR uses of std::invocable.

libstdc++'s implementation diagnoses these with hard errors.

Fixes #50059.

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

2 years ago[mlir][python] Add bindings for diagnostic handler.
Stella Laurenzo [Tue, 4 Jan 2022 00:39:58 +0000 (16:39 -0800)]
[mlir][python] Add bindings for diagnostic handler.

I considered multiple approaches for this but settled on this one because I could make the lifetime management work in a reasonably easy way (others had issues with not being able to cast to a Python reference from a C++ constructor). We could stand to have more formatting helpers, but best to get the core mechanism in first.

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

2 years ago[Hexagon] Conversions to/from FP types, HVX and scalar
Krzysztof Parzyszek [Tue, 4 Jan 2022 18:15:48 +0000 (10:15 -0800)]
[Hexagon] Conversions to/from FP types, HVX and scalar

Co-authored-by: Anirudh Sundar Subramaniam <quic_sanirudh@quicinc.com>
Co-authored-by: Sumanth Gundapaneni <sgundapa@quicinc.com>
2 years ago[libc++] Add the version header to all headers.
Mark de Wever [Wed, 22 Dec 2021 17:14:14 +0000 (18:14 +0100)]
[libc++] Add the version header to all headers.

Some headers which require the version header depend on other headers to
provide it. Include the version header in all top-level headers to make
sure a header cleanup can't remove the version header.

Note this doesn't add the version header to the c headers.

Reviewed By: #libc, Quuxplusone, ldionne

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

2 years ago[libcxx] Use Fuchsia-native CPRNG for std::random_device
Roland McGrath [Sun, 2 Jan 2022 19:53:53 +0000 (11:53 -0800)]
[libcxx] Use Fuchsia-native CPRNG for std::random_device

Use the zx_cprng_draw system call directly rather than going
through the libc getentropy function.  The libc function is a
trivial wrapper around the system call, and is not a standard C
function.  Avoiding it reduces the Fuchsia libc ABI surface that
libc++ depends on.

Reviewed By: #libc, ldionne

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

2 years ago[Analysis] fix swapped operands to computeConstantRange
Sanjay Patel [Tue, 4 Jan 2022 18:11:24 +0000 (13:11 -0500)]
[Analysis] fix swapped operands to computeConstantRange

This was noted in post-commit review for D116322 / 0edf99950e6 .

I am not seeing how to expose the bug in a test though because
we don't pass an assumption cache into this analysis from there.

2 years ago[RISCV] Teach RISCVGatherScatterLowering to handle more complex recurrence start...
Craig Topper [Tue, 4 Jan 2022 18:08:03 +0000 (10:08 -0800)]
[RISCV] Teach RISCVGatherScatterLowering to handle more complex recurrence start values.

Previously we only recognized strided loads/store when the initial
value for the phi was a strided constant vector.

This patch extends the support to a strided_constant added to a
splatted value. The rewritten loop will add the splat value to the
first element of the strided constant vector to use as the scalar
start value. The stride is unaffected.

Reviewed By: frasercrmck

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

2 years ago-Wmissing-prototypes: Don't warn in named namespaces nested in anonymous namespaces
David Blaikie [Tue, 4 Jan 2022 18:07:50 +0000 (10:07 -0800)]
-Wmissing-prototypes: Don't warn in named namespaces nested in anonymous namespaces

2 years agoFix altivec regression caused by D115670 in Vec Const Eval
Erich Keane [Tue, 4 Jan 2022 17:28:22 +0000 (09:28 -0800)]
Fix altivec regression caused by D115670 in Vec Const Eval

The Vector Constant Evaluator assumes that all the types of its
sub-expressions are going to be Vector APValues, which holds for most
situations.  However, in the 1 examples of Altivec C compilation of
operator ++ (not allowed for other vector types), the result is an
LValue.

Since the operator isn't supported for constant evaluation anyway, this
patch just fails-out of constant eval if we are in a situation where the
operand to the unary operator causes an LValue.

2 years ago[SCEV] Compute exit count from overflow check expressed w/ x.with.overflow intrinsics
Philip Reames [Tue, 4 Jan 2022 17:43:29 +0000 (09:43 -0800)]
[SCEV] Compute exit count from overflow check expressed w/ x.with.overflow intrinsics

This ports the logic we generate in instcombine for a single use x.with.overflow check for use in SCEV's analysis. The result is that we can prove trip counts for many checks, and (through existing logic) often discharge them.

Motivation comes from compiling a simple example with -ftrapv.

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

2 years agoAdd extra test for D116499 requested in review
Philip Reames [Tue, 4 Jan 2022 17:10:02 +0000 (09:10 -0800)]
Add extra test for D116499 requested in review

2 years ago[mlir] Fix incorrect top-level comment in DialectSparseTensor.cpp
Alex Zinenko [Tue, 4 Jan 2022 17:38:30 +0000 (18:38 +0100)]
[mlir] Fix incorrect top-level comment in DialectSparseTensor.cpp

2 years ago[llvm][cmake] never link llvm-config against llvm dylib
sternenseemann [Tue, 4 Jan 2022 17:33:29 +0000 (17:33 +0000)]
[llvm][cmake] never link llvm-config against llvm dylib

When cross-compiling, in order to make the output of the native and
cross-compiled llvm-config match, one needs to re-pass all cmake flags
relevant to BuildVariables.inc via `CROSS_TOOLCHAIN_FLAGS_NATIVE`. If
`LLVM_LINK_LLVM_DYLIB=ON` is among those, building a full `libLLVM` shared
object is required for the native llvm-config, otherwise `--shared-mode`
will be incorrect and `--link-shared` broken.

To avoid this, we can make llvm-config link statically against the
needed components for simplicity's sake in both the native and cross
case.

Reviewed By: beanz

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

2 years ago[libc++] Use std::addressof in std::function::target
Louis Dionne [Wed, 29 Dec 2021 17:24:45 +0000 (12:24 -0500)]
[libc++] Use std::addressof in std::function::target

This guards against hostile overloads of operator&. Thanks to Peter Dimov
for the report in https://github.com/boostorg/lambda/issues/24.

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

2 years ago[funcattrs] Infer writeonly argument attribute [part 2]
Philip Reames [Tue, 4 Jan 2022 16:39:51 +0000 (08:39 -0800)]
[funcattrs] Infer writeonly argument attribute [part 2]

This builds on the code from D114963, and extends it to handle calls both direct and indirect. With the revised code structure (from series of previously landed NFCs), this is pretty straight forward.

One thing to note is that we can not infer writeonly for arguments which might be captured. If the pointer can be read back by the caller, and then read through, we have no way to track that. This is the same restriction we have for readonly, except that we get no mileage out of the "callee can be readonly" exception since a writeonly param on a readonly function is either a) readnone or b) UB. This means we can't actually infer much unless nocapture has already been inferred.

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

2 years ago[regalloc] Fix GCC warning `-Wattributes`. NFC.
Michael Liao [Tue, 4 Jan 2022 17:01:21 +0000 (12:01 -0500)]
[regalloc] Fix GCC warning `-Wattributes`. NFC.

- Mark it with LLVM_LIBRARY_VISIBILITY to preserve the legacy
  visibility.

2 years ago[X86] combineSetCCMOVMSK - use APInt::getLowBitsSet to create bitmask. NFC.
Simon Pilgrim [Tue, 4 Jan 2022 16:56:33 +0000 (16:56 +0000)]
[X86] combineSetCCMOVMSK - use APInt::getLowBitsSet to create bitmask. NFC.

SelectionDAG::getConstant creates an APInt internally anyway, and getLowBitsSet helps assert for legal bitwidths. Plus it silences static analyzer out-of-bounds shift warnings.

2 years ago[mlir][ods] Handle DeclareOpInterfaceMethods in formatgen
Jacques Pienaar [Tue, 4 Jan 2022 16:28:59 +0000 (08:28 -0800)]
[mlir][ods] Handle DeclareOpInterfaceMethods in formatgen

Previously it would not consider ops with
DeclareOpInterfaceMethods<InferTypeOpInterface> as having the
InferTypeOpInterface interfaces added. The OpInterface nested inside
DeclareOpInterfaceMethods is not retained so that one could query it, so
check for the the C++ class directly (a bit raw/low level - will be
addressed in follow up).

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

2 years ago[clang-format] Add an option to add a space between operator overloading and opening...
Rajat Bajpai [Tue, 4 Jan 2022 16:19:24 +0000 (17:19 +0100)]
[clang-format] Add an option to add a space between operator overloading and opening parentheses

This change adds an option AfterOverloadedOperator in SpaceBeforeParensOptions to add a space between overloaded operator and opening parentheses in clang-format.

Reviewed By: MyDeveloperDay, curdeius, HazardyKnusperkeks

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

2 years ago[NFC] Expose isRematerializable and copyHint from CalcSpillWeights
Mircea Trofin [Tue, 21 Dec 2021 03:42:38 +0000 (19:42 -0800)]
[NFC] Expose isRematerializable and copyHint from CalcSpillWeights

We need to reuse them for the ML regalloc eviction advisor, as we
'explode' the weight calculation into sub-features.

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

2 years ago[AST] Produce ReturnStmt containing RecoveryExpr when type is wrong
Sam McCall [Thu, 30 Dec 2021 15:30:55 +0000 (16:30 +0100)]
[AST] Produce ReturnStmt containing RecoveryExpr when type is wrong

Previously we just drop the ReturnStmt and its argument from the AST,
which blocks analysis of broken code.

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

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

2 years ago[NFC][regalloc] Introduce RegAllocGreedy.h
Mircea Trofin [Tue, 21 Dec 2021 16:44:01 +0000 (08:44 -0800)]
[NFC][regalloc] Introduce RegAllocGreedy.h

This was suggested in D114831. It should simplify the relation between
eviction advisor and the allocator, and simplify ingesting more features
tied to the internals of the allocator, in the future.

This change simply pulls out RAGreedy, places it in the llvm namespace,
and cleans up a bit the includes in the new header file.

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

2 years agoRevert "[JITLink] Add fixup value range check"
luxufan [Tue, 4 Jan 2022 16:04:09 +0000 (00:04 +0800)]
Revert "[JITLink] Add fixup value range check"

This reverts commit 17af06ba8005d6d14b0ac79ece01ecb028de9f90.

2 years ago[InferAttrs] Add writeonly to all the math functions
Benjamin Kramer [Thu, 30 Dec 2021 22:57:21 +0000 (23:57 +0100)]
[InferAttrs] Add writeonly to all the math functions

All of these functions would be `readnone`, but can't be on platforms
where they can set `errno`. A `writeonly` function with no pointer
arguments can only write (but never read) global state.

Writeonly theoretically allows these calls to be CSE'd (a writeonly call
with the same arguments will always result in the same global stores) or
hoisted out of loops, but that's not implemented currently.

There are a few functions in this list that could be `readnone` instead
of `writeonly`, if someone is interested.

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

2 years ago[Arm] Remove duplicate CPU tests
Tomas Matheson [Thu, 30 Dec 2021 10:36:36 +0000 (10:36 +0000)]
[Arm] Remove duplicate CPU tests

There are some duplicate test lines in clang/test/Driver/arm-cortex-cpus.c.
Looks like these were duplicated from the corresponding v8.0a tests, which test
both "-target armv8" and "-target armv8a". "-target armv8.X" without the "a"
doesn't work for later versions though.

Several tests also specify the -mlittle-endian twice, which looks unintentional.

Remove duplicate test: -target arm -march=armv5 -mthumb

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

2 years ago[LAA] Remove overeager assertion for aggregate types.
Florian Hahn [Tue, 4 Jan 2022 14:34:38 +0000 (14:34 +0000)]
[LAA] Remove overeager assertion for aggregate types.

0a00d64 turned an early exit here into an assertion, but the assertion
can be triggered, as PR52920 shows.

The later code is agnostic to the accessed type, so just drop the
assert. The patch also adds tests for LAA directly and
loop-load-elimination to show the behavior is sane.

2 years agoDelete file erroneously added in 229c95ab661d89d
Sam McCall [Tue, 4 Jan 2022 15:17:24 +0000 (16:17 +0100)]
Delete file erroneously added in 229c95ab661d89d

This was committed by mistake.
The unusual filename caused problems for us downstream, apologies if it causes problems for you too!

2 years ago[clangd] Adjust compile flags so they work when applied to other file(type)s.
Sam McCall [Wed, 22 Dec 2021 15:57:59 +0000 (16:57 +0100)]
[clangd] Adjust compile flags so they work when applied to other file(type)s.

It's reasonable to want to use the command from one file to compile another.
In particular, the command from a translation unit to parse a related header:
  {"file": "foo.h", "command": "clang foo.cpp"}

This is largely what InterpolatingCompilationDatabase tries to do.
To do this correctly can require nontrivial changes to the argv, because the
file extension affects semantics.  e.g. here we must add "-x c++header".

When external tools compile commands for different files, we should apply the
same adjustments. This is better than telling people to "fix their tools":
 - simple e.g. python scripts shouldn't have to interpret clang argv
 - this is a good way to represent the intent "parse header X in the context of
   file Y", which can work even if X is not self-contained. clangd does not
   support this today, but some other tools do, and we may one day.

This issue is discussed in https://github.com/clangd/clangd/issues/519

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

2 years ago[ConstantFold] Remove another incorrect icmp of gep fold
Nikita Popov [Tue, 4 Jan 2022 15:04:25 +0000 (16:04 +0100)]
[ConstantFold] Remove another incorrect icmp of gep fold

This folded (null + X) == g to false, but of course this is
incorrect if X == g.

Possibly this got confused with the null == g case, which is
already handled elsewhere.

2 years ago[InstSimplify] Update test to make miscompile more obvious (NFC)
Nikita Popov [Tue, 4 Jan 2022 15:00:24 +0000 (16:00 +0100)]
[InstSimplify] Update test to make miscompile more obvious (NFC)

This is now testing (null + g3) != g3 and still coming up with
"true" as the answer. The original case was a less obvious
miscompile with index overflow involved.

2 years ago[libc++][NFC] Use _LIBCPP_DEBUG_ASSERT in <__hash_table>
Nikolas Klauser [Sun, 2 Jan 2022 00:26:43 +0000 (01:26 +0100)]
[libc++][NFC] Use _LIBCPP_DEBUG_ASSERT in <__hash_table>

Use `_LIBCPP_DEBUG_ASSERT` in `<__hash_table>`

Reviewed By: Quuxplusone, ldionne, Mordante, #libc

Spies: libcxx-commits

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

2 years ago[CodeCompletion] Signature help for aggregate initialization.
Sam McCall [Tue, 28 Dec 2021 02:58:13 +0000 (03:58 +0100)]
[CodeCompletion] Signature help for aggregate initialization.

The "parameter list" is the list of fields which should be initialized.
We introduce a new OverloadCandidate kind for this.
It starts to become harder for CC consumers to handle all the cases for
params, so I added some extra APIs on OverloadCandidate to abstract them.

Includes some basic support for designated initializers.
The same aggregate signature is shown, the current arg jumps after the
one you just initialized. This follows C99 semantics for mixed
designated/positional initializers (which clang supports in C++ as an extension)
and is also a useful prompt for C++ as C++ designated initializers must be
in order.

Related bugs:
 - https://github.com/clangd/clangd/issues/965
 - https://github.com/clangd/clangd/issues/306

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

2 years ago[JITLink] Add fixup value range check
luxufan [Tue, 4 Jan 2022 12:18:19 +0000 (20:18 +0800)]
[JITLink] Add fixup value range check

This patch makes jitlink to report an out of range error when the fixup value out of range

Reviewed By: lhames

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

2 years agoIntroduce the AttributeMask class
serge-sans-paille [Tue, 4 Jan 2022 08:44:47 +0000 (09:44 +0100)]
Introduce the AttributeMask class

This class is solely used as a lightweight and clean way to build a set of
attributes to be removed from an AttrBuilder. Previously AttrBuilder was used
both for building and removing, which introduced odd situation like creation of
Attribute with dummy value because the only relevant part was the attribute
kind.

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

2 years ago[gn build] Port 4dcc47aaeaf0
LLVM GN Syncbot [Tue, 4 Jan 2022 14:32:08 +0000 (14:32 +0000)]
[gn build] Port 4dcc47aaeaf0

2 years ago[gn build] Port 4950198116a5
LLVM GN Syncbot [Tue, 4 Jan 2022 14:32:07 +0000 (14:32 +0000)]
[gn build] Port 4950198116a5

2 years ago[clang][dataflow] Add multi-variable constant propagation example.
Yitzhak Mandelbaum [Tue, 28 Dec 2021 21:10:56 +0000 (21:10 +0000)]
[clang][dataflow] Add multi-variable constant propagation example.

Adds another constant-propagation analysis that covers all variables in
the scope (vs the existing single-variable demo). But, the analysis is still
unsuited to use, in that ignores issues of escaping variables.

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

2 years ago[clang][dataflow] Add parameterized map lattice.
Yitzhak Mandelbaum [Tue, 28 Dec 2021 19:34:26 +0000 (19:34 +0000)]
[clang][dataflow] Add parameterized map lattice.

This patchs adds a `MapLattice` template for lifting a lattice to a keyed map. A
typical use is for modeling variables in a scope with a partcular lattice.

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

2 years ago[CodeGen] Add target triple to test (NFC)
Nikita Popov [Tue, 4 Jan 2022 14:24:14 +0000 (15:24 +0100)]
[CodeGen] Add target triple to test (NFC)

Exact IR may depend on target.

2 years ago[ConstantFold] Remove unnecessary bounded index restriction
Nikita Popov [Tue, 4 Jan 2022 10:53:28 +0000 (11:53 +0100)]
[ConstantFold] Remove unnecessary bounded index restriction

The fold for merging a GEP of GEP into a single GEP currently bails
if doing so would result in notional overindexing. The justification
given in the comment above this check is dangerously incorrect: GEPs
with notional overindexing are perfectly fine, and if some code
treats them incorrectly, then that code is broken, not the GEP.
Such a GEP might legally appear in source IR, so only preventing
its creation cannot be sufficient. (The constant folder also ends
up canonicalizing the GEP to remove the notional overindexing, but
that's neither here nor there.)

This check dates back to
https://github.com/llvm/llvm-project/commit/bd4fef4a8939db18f39b108e19097b25e2c7c47a,
and as far as I can tell the original issue this was trying to
patch around has since been resolved.

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

2 years ago[libc++] Add `return 0` to some main() functions
Louis Dionne [Tue, 4 Jan 2022 14:17:37 +0000 (09:17 -0500)]
[libc++] Add `return 0` to some main() functions

This unbreaks the tests when running in freestanding mode.

2 years ago[CodeGen] Regenerate test checks (NFC)
Nikita Popov [Tue, 4 Jan 2022 13:55:32 +0000 (14:55 +0100)]
[CodeGen] Regenerate test checks (NFC)

Switch these tests to use update_cc_test_checks.py to simplify
future updates.

2 years ago[Flang] Enable support for conversion of recursive record types
Kiran Chandramohan [Tue, 4 Jan 2022 13:43:40 +0000 (13:43 +0000)]
[Flang] Enable support for conversion of recursive record types

Uses the recursive type conversion implemented in D113579, D113580.
Tests check for recursive and mutually recursive types.

Note: The downstream implementation for recursive types is a bit old
and is based on a static map. This was removed while upstreaming
(https://reviews.llvm.org/D112961) based on review comments. Since
the recursive type conversion is now available in MLIR we are using
that. If this patch is accepted we can use the same in the downstream
implementation.
Part of upstreaming flang from fir-dev branch of https://github.com/flang-compiler/f18-llvm-project.

Reviewed By: ftynse

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

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[VP][ISel] use LEGALPOS for legalization action
Simon Moll [Tue, 4 Jan 2022 13:50:37 +0000 (14:50 +0100)]
[VP][ISel] use LEGALPOS for legalization action

Use the VPIntrinsics.def's LEGALPOS that is specified with every VP
SDNode to determine which return or operand value type shall be used to
infer the legalization action.

Reviewed By: frasercrmck

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

2 years ago[lldb/python] Fix dangling Event and CommandReturnObject references
Pavel Labath [Mon, 20 Dec 2021 13:36:27 +0000 (14:36 +0100)]
[lldb/python] Fix dangling Event and CommandReturnObject references

Unlike the rest of our SB objects, SBEvent and SBCommandReturnObject
have the ability to hold non-owning pointers to their non-SB
counterparts. This makes it hard to ensure the SB objects do not become
dangling once their backing object goes away.

While we could make these two objects behave like others, that would
require plubming even more shared pointers through our internal code
(Event objects are mostly prepared for it, CommandReturnObject are not).
Doing so seems unnecessarily disruptive, given that (unlike for some of
the other objects) I don't see any good reason why would someone want to
hold onto these objects after the function terminates.

For that reason, this patch implements a different approach -- the SB
objects will still hold non-owning pointers, but they will be reset to
the empty/default state as soon as the function terminates. This python
code will not crash if the user decides to store these objects -- but
the objects themselves will be useless/empty.

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

2 years ago[DAG] TargetLowering::SimplifySetCC - use APInt::getMinSignedBits() helper. NFC.
Simon Pilgrim [Fri, 31 Dec 2021 23:15:53 +0000 (23:15 +0000)]
[DAG] TargetLowering::SimplifySetCC - use APInt::getMinSignedBits() helper. NFC.

2 years agoRecommit "[Clang] Extend emitUnaryBuiltin to avoid duplicate logic.""
Jun Zhang [Tue, 4 Jan 2022 13:46:16 +0000 (13:46 +0000)]
Recommit "[Clang] Extend emitUnaryBuiltin to avoid duplicate logic.""

This reverts the revert commit f552ba6e84057cad56e91e7c54170a60349d3330.

Recommit with fixed author name.

2 years agoRevert "[Clang] Extend emitUnaryBuiltin to avoid duplicate logic."
Florian Hahn [Tue, 4 Jan 2022 13:44:01 +0000 (13:44 +0000)]
Revert "[Clang] Extend emitUnaryBuiltin to avoid duplicate logic."

This reverts commit 5c57e6aa5777bddf9ddaca5d927f1b47a1a9d381.

Reverted due to a typo in the authors name. Will recommit soon with
fixed authorship.

2 years ago[OpenMP] Add nec and nvidia as compiler vendors for OpenMP
Saiyedul Islam [Mon, 3 Jan 2022 16:45:47 +0000 (16:45 +0000)]
[OpenMP] Add nec and nvidia as compiler vendors for OpenMP

OpenMP Specs 5.0[1] and 5.1[2] recognizes nec and nvidia as known
compiler vendors and their absence is causing compilation error in one
of the vendor based metadirective test of sollve_vv project[3].

[1] https://www.openmp.org/wp-content/uploads/Context-Definitions-5.0-v1.0.pdf
[2] https://www.openmp.org/wp-content/uploads/OpenMP-API-Additional-Definitions-2-0.pdf
[3] https://github.com/SOLLVE/sollve_vv/blob/master/tests/5.0/metadirective/test_metadirective_arch_nvidia_or_amd.c

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

2 years agoImprove the 'modernize-use-default-member-init'
Oleg Smolsky [Tue, 4 Jan 2022 12:27:02 +0000 (07:27 -0500)]
Improve the 'modernize-use-default-member-init'

We want to deal with non-default constructors that just happen to
contain constant initializers. There was already a negative test case,
it is now a positive one. We find and refactor this case:

struct PositiveNotDefaultInt {
  PositiveNotDefaultInt(int) : i(7) {}
  int i;
};

2 years ago[JITLink] Improve extractBits function
luxufan [Tue, 4 Jan 2022 11:39:07 +0000 (19:39 +0800)]
[JITLink] Improve extractBits function

Address the advice proposed at patch D105429 . Use [Low, Low+size) to represent bits.

Reviewed By: lhames

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

2 years ago[Clang][Sema] Adjust formatting (NFC)
Egor Zhdan [Tue, 4 Jan 2022 11:54:17 +0000 (12:54 +0100)]
[Clang][Sema] Adjust formatting (NFC)

This is a preparation for another change in the watchOS/tvOS availability logic. It is extracted into a separate commit to simplify reviewing and to keep the linter happy at the same time.

rdar://81491680

Reviewed By: aaron.ballman

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

2 years ago[Clang][NFC] Fix multiline comment prefixes in function headers
Saiyedul Islam [Mon, 3 Jan 2022 15:12:04 +0000 (15:12 +0000)]
[Clang][NFC] Fix multiline comment prefixes in function headers

Cleanup of D105191 after latest clang-format changes.

Reviewed By: MyDeveloperDay

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

2 years ago[AVR] Optimize int16 shift operation for shift amount greater than 8
Ben Shi [Tue, 4 Jan 2022 11:14:30 +0000 (11:14 +0000)]
[AVR] Optimize int16 shift operation for shift amount greater than 8

Skip operation on the lower byte in int16 logical left shift when
shift amount is greater than 8.

Skip operation on the higher byte in int16 logical & arithmetic
right shift when shift amount is greater than 8.

Reviewed By: aykevl

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

2 years ago[Clang] Extend emitUnaryBuiltin to avoid duplicate logic.
Jun Zhan [Tue, 4 Jan 2022 11:47:40 +0000 (11:47 +0000)]
[Clang] Extend emitUnaryBuiltin to avoid duplicate logic.

This patch extends `emitUnaryBuiltin` so that we can better emitting IR when
implement builtins specified in D111529.

Also contains some NFC, applying it to existing code.

Reviewed By: fhahn

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

2 years ago[ConstantFolding] Remove unused ConstantFoldLoadThroughGEPConstantExpr()
Nikita Popov [Tue, 4 Jan 2022 11:36:10 +0000 (12:36 +0100)]
[ConstantFolding] Remove unused ConstantFoldLoadThroughGEPConstantExpr()

This API is no longer used since bbeaf2aac678633749e7385466da10a1c0120b3b.

2 years ago[CodeComplete] drop unused Scope param. NFC
Sam McCall [Tue, 4 Jan 2022 11:36:08 +0000 (12:36 +0100)]
[CodeComplete] drop unused Scope param. NFC

2 years ago[ConstFold] Slightly clean up icmp of two geps fold (NFC)
Nikita Popov [Tue, 4 Jan 2022 11:33:38 +0000 (12:33 +0100)]
[ConstFold] Slightly clean up icmp of two geps fold (NFC)

As we're only dealing with one type of constant expression here,
try to directly cast to GEPOperator.

2 years ago[ConstantFold] Remove another incorrect icmp of GEP fold
Nikita Popov [Tue, 4 Jan 2022 11:23:06 +0000 (12:23 +0100)]
[ConstantFold] Remove another incorrect icmp of GEP fold

This fold is not correct, because indices might evaluate to zero
even if they are not a literal zero integer. Additionally, this
fold would be wrong (in the general case) for non-i8 types as well,
due to index overflow.

Drop this fold and instead let the target-dependent constant
folder compute the actual offset and fold the comparison based
on that.

2 years ago[InstSimplify] Use weak symbol in test to show miscompile (NFC)
Nikita Popov [Tue, 4 Jan 2022 11:10:45 +0000 (12:10 +0100)]
[InstSimplify] Use weak symbol in test to show miscompile (NFC)

This fold is incorrect, because it assumes that all indices are
non-zero. This happens to be true for the test as written, but
doesn't hold if we use an extern weak global instead, for which
ptrtoint might be zero.

Add separate tests for the simple constant int case.

2 years agoRemove an unused variable, NFC.
Haojian Wu [Tue, 4 Jan 2022 11:19:49 +0000 (12:19 +0100)]
Remove an unused variable, NFC.

2 years ago[Docs] Document C++ for OpenCL 2021 support in clang.
Anastasia Stulova [Tue, 4 Jan 2022 11:14:30 +0000 (11:14 +0000)]
[Docs] Document C++ for OpenCL 2021 support in clang.

Along with the new language mode this commit contains misc
small updates for OpenCL 3 and GitHub issues for OpenCL.

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

2 years ago[clangd] Move the selection decltype hack to getSourceRange.
Haojian Wu [Tue, 4 Jan 2022 11:07:37 +0000 (12:07 +0100)]
[clangd] Move the selection decltype hack to getSourceRange.

Previously, it was in canSafelySkipNode, which is only used to decide
whether we should descend into it and its children, and we still used
the incomplete Decltypeloc.getSourceRange() to claim tokens, which will
cause some tokens were not claimed correctly.

Separate a change of https://reviews.llvm.org/D116536

Reviewed By: sammccall

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

2 years agoRevert "[clang-format][NFC] Code Tidies in UnwrappedLineFormatter"
Alexander Belyaev [Tue, 4 Jan 2022 11:09:10 +0000 (12:09 +0100)]
Revert "[clang-format][NFC] Code Tidies in UnwrappedLineFormatter"

This reverts commit f014ab933f35805159021d2d0c856a3c9af21a85.

These tests are failing with asan:

clang/unittests:format_tests
clang/unittests:format_tests
clang-tools-extra/unittests:clang_move_tests
clang/unittests:tooling_tests
clang-tools-extra/test/clang-move:move-template-class.cpp.test
clang-tools-extra/test/clang-move:move-multiple-classes.cpp.test
clang-tools-extra/test/clang-move:move-used-helper-decls.cpp.test
clang-tools-extra/clangd/unittests:clangd_tests
clang/test/Format:access-modifiers.cpp.test
clang/unittests:rename_tests
clang/unittests:rename_tests

2 years ago[clangd] Fix selection on multi-dimensional array.
Haojian Wu [Tue, 4 Jan 2022 10:50:17 +0000 (11:50 +0100)]
[clangd] Fix selection on multi-dimensional array.

This involves separating out the concepts of "which tokens should we
descend into this node for" vs "which tokens should this node claim".

Reviewed By: sammccall

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

2 years ago[clangd] Add CompileFlags.Compiler option to override argv0
Sam McCall [Thu, 23 Dec 2021 00:26:49 +0000 (01:26 +0100)]
[clangd] Add CompileFlags.Compiler option to override argv0

This is separate from --query-driver but can combine with it.

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

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

2 years ago[AVR] Optimize int8 arithmetic right shift 6 bits
Ben Shi [Tue, 4 Jan 2022 03:20:29 +0000 (03:20 +0000)]
[AVR] Optimize int8 arithmetic right shift 6 bits

Reviewed By: aykevl

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

2 years ago[LoopVectorize][CostModel] Choose smaller VFs for in-loop reductions without loads...
Rosie Sumpter [Mon, 8 Nov 2021 13:15:45 +0000 (13:15 +0000)]
[LoopVectorize][CostModel] Choose smaller VFs for in-loop reductions without loads/stores

For loops that contain in-loop reductions but no loads or stores, large
VFs are chosen because LoopVectorizationCostModel::getSmallestAndWidestTypes
has no element types to check through and so returns the default widths
(-1U for the smallest and 8 for the widest). This results in the widest
VF being chosen for the following example,

float s = 0;
for (int i = 0; i < N; ++i)
  s += (float) i*i;

which, for more computationally intensive loops, leads to large loop
sizes when the operations end up being scalarized.

In this patch, for the case where ElementTypesInLoop is empty, the widest
type is determined by finding the smallest type used by recurrences in
the loop instead of falling back to a default value of 8 bits. This
results in the cost model choosing a more sensible VF for loops like
the one above.

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

2 years ago[libc++] Fix __wrap_iter copy-assignment in constexpr contexts
Nikolas Klauser [Sun, 2 Jan 2022 16:25:40 +0000 (17:25 +0100)]
[libc++] Fix __wrap_iter copy-assignment in constexpr contexts

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

In debug mode during constant evaluation the iterator was never assigend. There seem to be no other instances of this bug.

Reviewed By: Quuxplusone, Mordante, #libc, ldionne

Spies: ldionne, libcxx-commits

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

2 years ago[gn build] Port af7bc39ba17d
LLVM GN Syncbot [Tue, 4 Jan 2022 09:23:00 +0000 (09:23 +0000)]
[gn build] Port af7bc39ba17d