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
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
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
LLVM GN Syncbot [Tue, 4 Jan 2022 14:32:08 +0000 (14:32 +0000)]
[gn build] Port
4dcc47aaeaf0
LLVM GN Syncbot [Tue, 4 Jan 2022 14:32:07 +0000 (14:32 +0000)]
[gn build] Port
4950198116a5
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
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
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.
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
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.
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.
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>
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
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
Simon Pilgrim [Fri, 31 Dec 2021 23:15:53 +0000 (23:15 +0000)]
[DAG] TargetLowering::SimplifySetCC - use APInt::getMinSignedBits() helper. NFC.
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.
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.
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
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;
};
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
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
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
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
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
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.
Sam McCall [Tue, 4 Jan 2022 11:36:08 +0000 (12:36 +0100)]
[CodeComplete] drop unused Scope param. 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.
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.
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.
Haojian Wu [Tue, 4 Jan 2022 11:19:49 +0000 (12:19 +0100)]
Remove an unused variable, NFC.
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
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
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
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
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
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
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
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
LLVM GN Syncbot [Tue, 4 Jan 2022 09:23:00 +0000 (09:23 +0000)]
[gn build] Port
af7bc39ba17d
Stanislav Gatev [Wed, 29 Dec 2021 11:31:02 +0000 (11:31 +0000)]
[clang][dataflow] Add transfer function for VarDecl statements
This is part of the implementation of the dataflow analysis framework.
See "[RFC] A dataflow analysis framework for Clang AST" on cfe-dev.
Reviewed-by: xazax.hun
Differential Revision: https://reviews.llvm.org/D116368
Nikita Popov [Mon, 3 Jan 2022 10:44:39 +0000 (11:44 +0100)]
[LangRef] Require elementtype attribute for indirect inline asm operands
Indirect inline asm operands may require the materialization of a
memory access according to the pointer element type. As this will
no longer be available with opaque pointers, we require it to be
explicitly annotated using the elementtype attribute, for example:
define void @test(i32* %p, i32 %x) {
call void asm "addl $1, $0", "=*rm,r"(i32* elementtype(i32) %p, i32 %x)
ret void
}
This patch only includes the LangRef change and Verifier updates to
allow adding the elementtype attribute in this position. It does not
yet enforce this, as this will require changes on the clang side
(and test updates) first.
Something I'm a bit unsure about is whether we really need the
elementtype for all indirect constraints, rather than only indirect
register constraints. I think indirect memory constraints might not
strictly need it (though the backend code is written in a way that
does require it). I think it's okay to just make this a general
requirement though, as this means we don't need to carefully deal
with multiple or alternative constraints. In addition, I believe
that MemorySanitizer benefits from having the element type even in
cases where it may not be strictly necessary for normal lowering
(https://github.com/llvm/llvm-project/blob/
cd2b050fa4995b75b9c36fae16c0d9f105b67585/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp#L4066).
Differential Revision: https://reviews.llvm.org/D116531
Nikita Popov [Tue, 4 Jan 2022 08:46:33 +0000 (09:46 +0100)]
[Evaluator] Make forward declaration consistent (NFC)
Fix a build warning.
Nikita Popov [Mon, 3 Jan 2022 10:21:05 +0000 (11:21 +0100)]
[ELF] Handle .init_array prefix consistently
Currently, the code in TargetLoweringObjectFile only assigns
@init_array section type to plain .init_array sections, but not
prioritized sections like .init_array.00001.
This is inconsistent with the interpretation in the AsmParser
(see https://github.com/llvm/llvm-project/blob/
791523bae6153b13bb41ba05c9fc89e502cc4a1a/llvm/lib/MC/MCParser/ELFAsmParser.cpp#L621-L632)
and upcoming expectations in LLD
(see https://github.com/rust-lang/rust/issues/92181 for context).
This patch assigns @init_array section type to all sections with an
.init_array prefix. The same is done for .fini_array and
.preinit_array as well. With that, the logic matches the AsmParser.
Differential Revision: https://reviews.llvm.org/D116528
Nikita Popov [Thu, 9 Dec 2021 15:57:33 +0000 (16:57 +0100)]
[GlobalOpt][Evaluator] Rewrite global ctor evaluation (fixes PR51879)
Global ctor evaluation currently models memory as a map from Constant*
to Constant*. For this to be correct, it is required that there is
only a single Constant* referencing a given memory location. The
Evaluator tries to ensure this by imposing certain limitations that
could result in ambiguities (by limiting types, casts and GEP formats),
but ultimately still fails, as can be seen in PR51879. The approach
is fundamentally fragile and will get more so with opaque pointers.
My original thought was to instead store memory for each global as an
offset => value representation. However, we also need to make sure
that we can actually rematerialize the modified global initializer
into a Constant in the end, which may not be possible if we allow
arbitrary writes.
What this patch does instead is to represent globals as a MutableValue,
which is either a Constant* or a MutableAggregate*. The mutable
aggregate exists to allow efficient mutation of individual aggregate
elements, as mutating an element on a Constant would require interning
a new constant. When a write to the Constant* is made, it is converted
into a MutableAggregate* as needed.
I believe this should make the evaluator more robust, compatible
with opaque pointers, and a bit simpler as well.
Fixes https://github.com/llvm/llvm-project/issues/51221.
Differential Revision: https://reviews.llvm.org/D115530
Marek Kurdej [Mon, 3 Jan 2022 16:32:20 +0000 (17:32 +0100)]
[clang-format] Fix incorrect formatting of lambdas inside brace initialisation
Fixes https://github.com/llvm/llvm-project/issues/27146.
Fixes https://github.com/llvm/llvm-project/issues/52943.
Before:
```
namespace ns {
void foo() {
std::variant<int, double> v;
std::visit(overloaded{[](auto &&) -> int (*)[] { return nullptr; }}, v);
}
} // namespace ns
int break_me() {
int x = 42;
return int{[x = x]() {
return x;
}()};
}
```
got formatted as:
```
namespace ns {
void foo() {
std::variant<int, double> v;
std::visit(overloaded{[](auto &&) -> int (*)[] { return nullptr;
}
} // namespace ns
, v);
}
} // namespace ns
int break_me() {
int x = 42;
return int{[x = x](){return x;
}
()
}
;
}
```
Reviewed By: HazardyKnusperkeks, owenpan
Differential Revision: https://reviews.llvm.org/D116553
Markus Böck [Mon, 3 Jan 2022 22:52:13 +0000 (23:52 +0100)]
[mlir][LLVM] Set cleanup flag on `llvm.landingpad` when exporting to LLVM IR
Exporting a llvm.landingpad operation with the cleanup flag set is currently ignored by the export code.
Differential Revision: https://reviews.llvm.org/D116565
Nicolas Vasilache [Mon, 3 Jan 2022 16:38:59 +0000 (11:38 -0500)]
[mlir] Add CMake flags to properly enable Jit event listeners.
By default, the listeners do nothing unless linked in.
This revision allows the "Perf" and "Intel" Jit event listeners to be used.
The "OProfile" event listener is not enabled at this time,
the associated library structure is not well-isolated.
Differential Revision: https://reviews.llvm.org/D116552
Jim Lin [Tue, 4 Jan 2022 06:40:31 +0000 (14:40 +0800)]
[M68k][NFC] Fix unused argument warnings in M68kInstrArithmetic.td
Alexander Belyaev [Tue, 4 Jan 2022 06:59:16 +0000 (07:59 +0100)]
Mikael Holmen [Tue, 4 Jan 2022 06:28:16 +0000 (07:28 +0100)]
[clang] Fix warning about unused variable [NFC]
Ben Shi [Tue, 4 Jan 2022 04:14:15 +0000 (04:14 +0000)]
Revert "[AVR] Optimize int8 arithmetic right shift 6 bits"
This reverts commit
5723261370b45fa4d0d295845c6ef9e223f2ff4a.
There are failures as reported in
https://lab.llvm.org/buildbot#builders/16/builds/21638
https://lab.llvm.org/buildbot#builders/104/builds/5394
Freddy Ye [Tue, 4 Jan 2022 01:34:45 +0000 (09:34 +0800)]
[X86] Add missing CET intrinsics support
These two intrinsics are documented o SDM and intrinsic guide.
Reviewed By: pengfei
Differential Revision: https://reviews.llvm.org/D116325
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
Jim Lin [Tue, 4 Jan 2022 03:11:00 +0000 (11:11 +0800)]
[M68k][NFC] Fix typo in comment. PCD->PCI.
Chuanqi Xu [Tue, 4 Jan 2022 03:12:17 +0000 (11:12 +0800)]
[NFC] [Coroutines] Fix incorrect use of coroutine intrinsics
The inlined llvm.coro.id should contain the function it refers to.
The modifed test would caused the compiler crash under O2. See
issue52912 for example.
Uday Bondhugula [Tue, 4 Jan 2022 02:54:14 +0000 (08:24 +0530)]
[MLIR[PDL] NFC. Fix unused variable warning in PDLToPDLInterp.cpp
NFC. Fix unused variable warning in PDLToPDLInterp.cpp.
Differential Revision: https://reviews.llvm.org/D116571
Stanislav Funiak [Tue, 4 Jan 2022 02:42:51 +0000 (08:12 +0530)]
[MLIR] Printing a null Value.
This diff adds support to printing a Value when it is null. We encounter this situation when debugging the PDL bytcode execution (where a null Value is perfectly valid). Currently, the AsmPrinter crashes (with an assert in a cast) when it encounters such Value.
We follow the same format used in other printed entities (e.g., null attribute).
Reviewed By: mehdi_amini, bondhugula
Differential Revision: https://reviews.llvm.org/D116084
Stanislav Funiak [Tue, 4 Jan 2022 02:41:35 +0000 (08:11 +0530)]
[MLIR][PDL] Generalize result type verification
Presently the result type verification checks if the type is used by a `pdl::OperationOp` inside the matcher. This is unnecessarily restrictive; the type could come from a `pdl::OperandOp or `pdl::OperandsOp` and still be inferrable.
Reviewed By: rriddle, Mogball
Differential Revision: https://reviews.llvm.org/D116083
Stanislav Funiak [Tue, 4 Jan 2022 02:33:29 +0000 (08:03 +0530)]
[MLIR][PDL] Integration test of multi-root matching and related fixes.
This diff adds an integration test to multi-root PDL matching. It consists of two subtests:
1) A 1-layer perceptron with split forward / backward operations.
2) A 2-layer perceptron with fused forward / backward operations.
These tests use a collection of hand-written patterns and TensorFlow operations to be matched. The first test has a DAG / SSA dominant resulting match; the second does not and is therefore stored in a graph region.
This diff also includes two bug fixes:
1) Mark the pdl_interp dialect as a dependent in the TestPDLByteCodePass. This is needed, because we create ops from that dialect as a part of the PDL-to-PDLInterp lowering.
2) Fix of the starting index in the liveness range for the ForEach operations (bug exposed by the integration test).
Reviewed By: Mogball
Differential Revision: https://reviews.llvm.org/D116082
Stanislav Funiak [Tue, 4 Jan 2022 02:33:26 +0000 (08:03 +0530)]
[MLIR][PDL] Make predicate order deterministic.
The tree merging of pattern predicates places the predicates in an unordered set. When the predicates are sorted, they are taken in the set order, not the insertion order. This results in nondeterministic behavior.
One solution to this problem would be to use `SetVector`. However, the value `SetVector` does not provide a `find` function for fast O(1) lookups and stores the predicates twice -- once in the set and once in the vector, which is undesirable, because we store patternToAnswer in each predicate. A simpler solution is to store the tie breaking ID (which follows the insertion order), and use this ID to break any ties when comparing predicates.
Reviewed By: Mogball
Differential Revision: https://reviews.llvm.org/D116081
Stanislav Funiak [Tue, 4 Jan 2022 02:33:18 +0000 (08:03 +0530)]
[MLIR][PDL] Refactor the positions for multi-root patterns.
When the original version of multi-root patterns was reviewed, several improvements were made to the pdl_interp operations during the review process. Specifically, the "get users of a value at the specified operand index" was split up into "get users" and "compare the users' operands with that value". The iterative execution was also cleaned up to `pdl_interp.foreach`. However, the positions in the pdl-to-pdl_interp lowering were not similarly refactored. This introduced several problems, including hard-to-detect bugs in the lowering and duplicate evaluation of `pdl_interp.get_users`.
This diff cleans up the positions. The "upward" `OperationPosition` was split-out into `UsersPosition` and `ForEachPosition`, and the operand comparison was replaced with a simple predicate. In the process, I fixed three bugs:
1. When multiple roots were had the same connector (i.e., a node that they shared with a subtree at the previously visited root), we would generate a single foreach loop rather than one foreach loop for each such root. The reason for this is that such connectors shared the position. The solution for this is to add root index as an id to the newly introduced `ForEachPosition`.
2. Previously, we would use `pdl_interp.get_operands` indiscriminately, whether or not the operand was variadic. We now correctly detect variadic operands and insert `pdl_interp.get_operand` when needed.
3. In certain corner cases, we would trigger the "connector has not been traversed yet" assertion. This was caused by not inserting the values during the upward traversal correctly. This has now been fixed.
Reviewed By: Mogball
Differential Revision: https://reviews.llvm.org/D116080
Jim Lin [Tue, 4 Jan 2022 02:14:01 +0000 (10:14 +0800)]
[M68k][NFC] Fix file header
Let all file header have the same style. NFC.
Fangrui Song [Tue, 4 Jan 2022 01:24:54 +0000 (17:24 -0800)]
[llvm-readobj][test] Rename ELF/reloc-types-elf-*.test to avoid redundant "elf-" infix
Dave Lee [Sun, 2 Jan 2022 22:35:52 +0000 (14:35 -0800)]
[lldb] Use std::move in StringList (NFC)
Markus Böck [Mon, 3 Jan 2022 22:45:26 +0000 (23:45 +0100)]
[mlir][LLVM] Fix mapping of result values of `llvm.invoke` during export
The result value of a llvm.invoke operation is currently not mapped to the corresponding llvm::Value* when exporting to LLVM IR. This leads to any later operations using the result to crash as it receives a nullptr.
Differential Revision: https://reviews.llvm.org/D116564
Nicolas Vasilache [Mon, 3 Jan 2022 22:17:11 +0000 (17:17 -0500)]
[mlir] NFC - Format ExecutionEngine.cpp
Björn Schäpers [Sun, 5 Dec 2021 11:31:56 +0000 (12:31 +0100)]
Revert "[clang-format][NFC] Prefer pass by reference"
This reverts commit
25f637913fe31b6d23e78ff07c725bb537dd3b97.
Differential Revision: https://reviews.llvm.org/D115061
Björn Schäpers [Fri, 3 Dec 2021 15:37:02 +0000 (16:37 +0100)]
[clang-format][NFC] Merge another two calls to isOneOf
Differential Revision: https://reviews.llvm.org/D115069
Björn Schäpers [Fri, 3 Dec 2021 07:13:57 +0000 (08:13 +0100)]
[clang-format][NFC] Code Tidies in UnwrappedLineFormatter
* Give I[1] and I[-1] a name:
- Easier to understand
- Easier to debug (since you don't go through operator[] everytime)
* TheLine->First != TheLine->Last follows since last is a l brace and
first isn't.
* Factor the check for is(tok::l_brace) out.
* Drop else after return.
Differential Revision: https://reviews.llvm.org/D115060
Markus Böck [Mon, 3 Jan 2022 22:00:39 +0000 (23:00 +0100)]
[lld][MinGW] Remove `--no-as-needed` from ignored flags
In the post commit discussion of https://reviews.llvm.org/D116484 it was concluded that `--no-as-needed` should not be ignored. `--as-needed` stays ignored as it is already the default behaviour on COFF, which cannot be changed.
Kazu Hirata [Mon, 3 Jan 2022 21:41:32 +0000 (13:41 -0800)]
Add IgnoreBaseInCopyConstructors to .clang-tidy
gcc issues warnings on copy constructors that do not explicitly
initialize the base class.
Louis Dionne [Mon, 3 Jan 2022 20:44:36 +0000 (15:44 -0500)]
[libc++][CI] Don't install libc6-dev-i386 in the Docker image
We don't cross-compile to 32 bits in the CI anymore.
Louis Dionne [Mon, 3 Jan 2022 20:08:05 +0000 (15:08 -0500)]
[libc++][NFC] Fix comment for running Docker container
John Ericson [Sat, 1 Jan 2022 07:03:31 +0000 (07:03 +0000)]
[CMake] Use `LLVM_COMMON_CMAKE_UTILS` in runtimes just for clarity
In D116472 we created conditionally defined variables for the tools to
unbreak the legacy build where they are in `llvm/tools`.
The runtimes are not tools, so that flexibility doesn't matter. Still,
it might be nice to define (unconditionally) and use the variable for
the runtimes simply to make the code a bit clearer and document what is
going on.
Also, consistently put project dirs at the beginning, not end of `CMAKE_MODULE_PATH`. This ensures they will properly shadow similarly named stuff that happens to be later on the path.
Reviewed By: mstorsjo, #libunwind, #libc, #libc_abi, ldionne
Differential Revision: https://reviews.llvm.org/D116477
LLVM GN Syncbot [Mon, 3 Jan 2022 20:50:31 +0000 (20:50 +0000)]
[gn build] Port
6f6f88ffdae1
ksyx [Tue, 28 Dec 2021 15:01:26 +0000 (10:01 -0500)]
[clang-format] Style to separate definition blocks
This commit resolves GitHub issue #45895 (Bugzilla #46550), to
add or remove empty line between definition blocks including
namespaces, classes, structs, enums and functions.
Reviewed By: MyDeveloperDay, curdeius, HazardyKnusperkeks
Differential Revision: https://reviews.llvm.org/D116314
G. Pery [Mon, 3 Jan 2022 19:55:13 +0000 (20:55 +0100)]
[clang-format] Add penalty for breaking after '('
My team has a vendetta against lines ending with an open parenthesis, thought it might be useful for others too 😊
Reviewed By: HazardyKnusperkeks, curdeius
Differential Revision: https://reviews.llvm.org/D116170
Philip Reames [Mon, 3 Jan 2022 19:56:02 +0000 (11:56 -0800)]
Revert "[unroll] Prune all but first copy of invariant exit"
This reverts commit
9bd22595bad36cd19f5e7ae18ccd9f41cba29dc5.
Seeing some bot failures which look plausibly connected. Revert while investigating/waiting for bots to stablize.
e.g. https://lab.llvm.org/buildbot#builders/36/builds/15933
Craig Topper [Mon, 3 Jan 2022 19:13:25 +0000 (11:13 -0800)]
[ValueTracking][SelectionDAG] Rename ComputeMinSignedBits->ComputeMaxSignificantBits. NFC
This function returns an upper bound on the number of bits needed
to represent the signed value. Use "Max" to match similar functions
in KnownBits like countMaxActiveBits.
Rename APInt::getMinSignedBits->getSignificantBits. Keeping the old
name around to keep this patch size down. Will do a bulk rename as
follow up.
Rename KnownBits::countMaxSignedBits->countMaxSignificantBits.
Reviewed By: lebedev.ri, RKSimon, spatel
Differential Revision: https://reviews.llvm.org/D116522
Kazu Hirata [Mon, 3 Jan 2022 19:28:47 +0000 (11:28 -0800)]
Revert "[llvm] Remove redundant member initialization (NFC)"
This reverts commit
fd4808887ee47f3ec8a030e9211169ef4fb094c3.
This patch causes gcc to issue a lot of warnings like:
warning: base class ‘class llvm::MCParsedAsmOperand’ should be
explicitly initialized in the copy constructor [-Wextra]
Aaron Ballman [Mon, 3 Jan 2022 19:18:45 +0000 (14:18 -0500)]
Silence a "not all control paths return a value" warning; NFC
Sam McCall [Mon, 3 Jan 2022 19:17:20 +0000 (20:17 +0100)]
[clangd] Fix windows build after
478863ef58c7f7314e06
http://45.33.8.238/win/51774/step_4.txt
MS extension causes the wrong class to be friended.
Sam McCall [Mon, 27 Dec 2021 19:42:11 +0000 (20:42 +0100)]
[CodeCompletion] Signature help for braced constructor calls
Implementation is based on the "expected type" as used for
designated-initializers in braced init lists. This means it can deduce the type
in some cases where it's not written:
void foo(Widget);
foo({ /*help here*/ });
Only basic constructor calls are in scope of this patch, excluded are:
- aggregate initialization (no help is offered for aggregates)
- initializer_list initialization (no help is offered for these constructors)
Fixes https://github.com/clangd/clangd/issues/306
Differential Revision: https://reviews.llvm.org/D116317
Erik Desjardins [Mon, 3 Jan 2022 19:09:50 +0000 (11:09 -0800)]
[X86] Improve selection of the mov instruction in FrameLowering
MOV64ri results in a significantly longer encoding, and use of this
operator is fairly avoidable as we can always check the size of the
immediate we're using.
This is an updated version of D99045.
Co-authored-by: Simonas Kazlauskas <git@kazlauskas.me>
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D116458
Erik Desjardins [Mon, 3 Jan 2022 18:58:26 +0000 (10:58 -0800)]
[X86] autogen segmented stacks tests (NFC)
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D116420
Michael Zimmermann [Mon, 3 Jan 2022 11:16:11 +0000 (12:16 +0100)]
[clang-format] respect AfterEnum for enums
There is some similar looking code in `TokenAnnotator.cpp` but given that I've
never worked on clang-format before I don't know what the purpose of that code
is and how it's related to `UnwrappedLineParser.cpp`.
Either way, it fixes clang-format with `BraceWrapping.AfterEnum=true` and
`AllowShortEnumsOnASingleLine=false` to behave like the documentation says.
Before this patch:
```
enum
{
A,
B
} myEnum;
```
After this patch:
```
enum {
A,
B
} myEnum;
```
According to the unittests which I had to modify this would change the LLVM
style. Please evaluate if you want to change the defaults or if you consider
the current style a bug.
Reviewed By: curdeius, HazardyKnusperkeks
Differential Revision: https://reviews.llvm.org/D106349
Alexandre Ganea [Sun, 2 Jan 2022 19:19:12 +0000 (14:19 -0500)]
[CodeView] Remove unnecessary property that was commited by accident.
Alexandre Ganea [Mon, 3 Jan 2022 18:22:26 +0000 (13:22 -0500)]
[MSVC] Silence -Wnon-virtual-dtor on DIA APIs
Differential Revision: https://reviews.llvm.org/D116313
John Ericson [Sun, 2 Jan 2022 06:29:26 +0000 (06:29 +0000)]
[clang][cmake] Rearrange top-level CMakeLists.txt for D116492
In that revision, I make LLD match Clang in deprecating `llvm-config`.
This patch isn't to worthwhile on its own --- there isn't a sense in
which the new order is "better" in isolation --- but by putting the
steps that LLD also neeeds to do first, I make the diff between LLD and
Clang's top-level `CMakeLists.txt` very legible.
Longer term I hope:
1. We can remove calling `llvm-config` altogether, and just go strait to
finding the CMake config file. This is what Flang does, at least.
2. Hopefully the diffable part is smaller then --- i.e. there is less
duplicated boilerplate.
3. Any duplicate boilerplate that remains can be factored out.
I didn't both trying to factor anything out in e.g. the top level common
CMake Utility modules because this deprecated-but-not-removed state is a
merely transitional.
Reviewed By: beanz
Differential Revision: https://reviews.llvm.org/D116548
Chris Bieneman [Mon, 3 Jan 2022 17:52:44 +0000 (11:52 -0600)]
[NFC][CMake] Add FOLDER to utility targets
As Visual Studio's CMake support is getting better and better the line
between IDE generator and non-IDE generators is blurring. Visual Studio
2019 and later have a very useful UI that can handle all of the various
targets we create, but if they are unsorted it is wildly unwieldy.
This change sorts the lit testsuite targets and per-component install
targets into folders, which are not generated for IDE generators but
are generated by default under Visual Studio's CMake + Ninja
integration.
Craig Topper [Mon, 3 Jan 2022 18:09:50 +0000 (10:09 -0800)]
[AMDGPU] Use ComputeMinSignedBits and KnownBits::countMaxActiveBits to simplify some code. NFC
Reviewed By: RKSimon
Differential Revision: https://reviews.llvm.org/D116516
Craig Topper [Mon, 3 Jan 2022 18:07:37 +0000 (10:07 -0800)]
[SimplifyCFG] Make use of ComputeMinSignedBits and KnownBits::getBitWidth. NFC
Philip Reames [Mon, 3 Jan 2022 17:55:19 +0000 (09:55 -0800)]
[unroll] Prune all but first copy of invariant exit
If we have an exit which is controlled by a loop invariant condition and which dominates the latch, we know only the copy in the first unrolled iteration can be taken. All other copies are dead.
The change itself is pretty straight forward, but let me add two points of context:
* I'd have expected other transform passes to catch this after unrolling, but I'm seeing multiple examples where we get to the end of O2/O3 without simplifying.
* I'd like to do a stronger change which did CSE during unroll and accounted for invariant expressions (as defined by SCEV instead of trivial ones from LoopInfo), but that doesn't fit cleanly into the current code structure.
Differential Revision: https://reviews.llvm.org/D116496
Philip Reames [Mon, 3 Jan 2022 17:39:26 +0000 (09:39 -0800)]
Remove loop invariant exit conditions from tests in advance of D116496
Reviewer suggested this was more in spirit of the original tests.
Louis Dionne [Mon, 3 Jan 2022 17:27:04 +0000 (12:27 -0500)]
[libc++][CI] Temporarily disable several Linux jobs
There is an ongoing CI outage with our Linux nodes, so I temporarily
set up a couple of nodes. These nodes will be much slower than the
usual ones and there's only a few of them, so I am temporarily disabling
most of our CI to keep things working.
RitanyaB [Mon, 3 Jan 2022 17:22:50 +0000 (11:22 -0600)]
SIGSEGV in ompt_tsan_dependences with for-ordered
Segmentation fault in ompt_tsan_dependences function due to an unchecked NULL pointer dereference is as follows:
```
ThreadSanitizer:DEADLYSIGNAL
==140865==ERROR: ThreadSanitizer: SEGV on unknown address 0x000000000050 (pc 0x7f217c2d3652 bp 0x7ffe8cfc7e00 sp 0x7ffe8cfc7d90 T140865)
==140865==The signal is caused by a READ memory access.
==140865==Hint: address points to the zero page.
/usr/bin/addr2line: DWARF error: could not find variable specification at offset 1012a
/usr/bin/addr2line: DWARF error: could not find variable specification at offset 133b5
/usr/bin/addr2line: DWARF error: could not find variable specification at offset 1371a
/usr/bin/addr2line: DWARF error: could not find variable specification at offset 13a58
#0 ompt_tsan_dependences(ompt_data_t*, ompt_dependence_t const*, int) /ptmp/bhararit/llvm-project/openmp/tools/archer/ompt-tsan.cpp:1004 (libarcher.so+0x15652)
#1 __kmpc_doacross_post /ptmp/bhararit/llvm-project/openmp/runtime/src/kmp_csupport.cpp:4280 (libomp.so+0x74d98)
#2 .omp_outlined. for_ordered_01.c:? (for_ordered_01.exe+0x5186cb)
#3 __kmp_invoke_microtask /ptmp/bhararit/llvm-project/openmp/runtime/src/z_Linux_asm.S:1166 (libomp.so+0x14e592)
#4 __kmp_invoke_task_func /ptmp/bhararit/llvm-project/openmp/runtime/src/kmp_runtime.cpp:7556 (libomp.so+0x909ad)
#5 __kmp_fork_call /ptmp/bhararit/llvm-project/openmp/runtime/src/kmp_runtime.cpp:2284 (libomp.so+0x8461a)
#6 __kmpc_fork_call /ptmp/bhararit/llvm-project/openmp/runtime/src/kmp_csupport.cpp:308 (libomp.so+0x6db55)
#7 main ??:? (for_ordered_01.exe+0x51828f)
#8 __libc_start_main ??:? (libc.so.6+0x24349)
#9 _start /home/abuild/rpmbuild/BUILD/glibc-2.26/csu/../sysdeps/x86_64/start.S:120 (for_ordered_01.exe+0x4214e9)
ThreadSanitizer can not provide additional info.
SUMMARY: ThreadSanitizer: SEGV /ptmp/bhararit/llvm-project/openmp/tools/archer/ompt-tsan.cpp:1004 in ompt_tsan_dependences(ompt_data_t*, ompt_dependence_t const*, int)
==140865==ABORTING
```
To reproduce the error, use the following openmp code snippet:
```
/* initialise testMatrixInt Matrix, cols, r and c */
#pragma omp parallel private(r,c) shared(testMatrixInt)
{
#pragma omp for ordered(2)
for (r=1; r < rows; r++) {
for (c=1; c < cols; c++) {
#pragma omp ordered depend(sink:r-1, c+1) depend(sink:r-1,c-1)
testMatrixInt[r][c] = (testMatrixInt[r-1][c] + testMatrixInt[r-1][c-1]) % cols ;
#pragma omp ordered depend (source)
}
}
}
```
Compilation:
```
clang -g -stdlib=libc++ -fsanitize=thread -fopenmp -larcher test_case.c
```
It seems like the changes introduced by the commit https://reviews.llvm.org/D114005 causes this particular SEGV while using Archer.
Reviewed By: protze.joachim
Differential Revision: https://reviews.llvm.org/D115328
Sam McCall [Wed, 17 Nov 2021 12:27:58 +0000 (13:27 +0100)]
[clangd] Basic IncludeCleaner support for c/c++ standard library
There are some limitations here, so this is behind a flag for now (in addition
to the config setting for the overall feature).
- symbols without exactly one associated header aren't handled right
- no macro support
- referencing std::size_t usually doesn't leave any trace in the AST that the
alias in std was used, so we associate with stddef.h instead of cstddef.
(An AST issue not specific to stdlib, but much worse there)
Differential Revision: https://reviews.llvm.org/D114077
LLVM GN Syncbot [Mon, 3 Jan 2022 17:01:27 +0000 (17:01 +0000)]
[gn build] Port
fe68088d44f7
Sam McCall [Sun, 2 Jan 2022 22:22:18 +0000 (23:22 +0100)]
[clangd] Helper for determining member insertion point.
To be used in D116490 and D116385, and an upcoming patch to generate C++
constructors.
Differential Revision: https://reviews.llvm.org/D116502
Sam McCall [Wed, 22 Dec 2021 10:07:50 +0000 (11:07 +0100)]
[clangd] Respect .clang-tidy ExtraArgs (-Wfoo only) when producing diagnostics
This mechanism is used almost exclusively to enable extra warnings in clang-tidy
using ExtraArgs=-Wfoo, Checks="clang-diagnostic-foo".
Its presence is a strong signal that these flags are useful.
We choose not to actually emit them as clang-tidy diagnostics, but under their
"main" name - this ensures we show the same diagnostic in a consistent way.
We don't add the ExtraArgs to the compile command in general, but rather just
handle the -W<group> flags, which is the common case and avoids unexpected
side-effects.
And we only do this for the main file parse, when producing diagnostics.
Differential Revision: https://reviews.llvm.org/D116147