platform/upstream/llvm.git
18 months agoApply clang-tidy fixes for llvm-else-after-return in TestBackwardDataFlowAnalysis...
Mehdi Amini [Thu, 22 Dec 2022 22:29:41 +0000 (22:29 +0000)]
Apply clang-tidy fixes for llvm-else-after-return in TestBackwardDataFlowAnalysis.cpp (NFC)

18 months agoApply clang-tidy fixes for performance-move-const-arg in Utils.cpp (NFC)
Mehdi Amini [Thu, 22 Dec 2022 21:23:47 +0000 (21:23 +0000)]
Apply clang-tidy fixes for performance-move-const-arg in Utils.cpp (NFC)

18 months ago[clang-tidy] Fix all broken links in the comment.
Haojian Wu [Mon, 2 Jan 2023 22:51:35 +0000 (23:51 +0100)]
[clang-tidy] Fix all broken links in the comment.

18 months agoLink the default GC strategies everywhere getGCStrategy is used.
Campbell Suter [Thu, 22 Dec 2022 14:29:58 +0000 (21:29 +0700)]
Link the default GC strategies everywhere getGCStrategy is used.

GC strategies are registered using a system of global constructors: any
object can include a GCRegistry::Add stataic variable to register a
strategy, and that will generate a static constructor which registers
this strategy into a global list.

This allows shared libraries to easily register their own strategies,
but poses a problem related to linking: the default GC strategies
(defined and registered in their own file) must obviously be included in
LLVM binaries.

The previous solution was to define an empty functon in BuiltinGCs.cpp,
and call it from LinkAllCodegenComponents.h - this is the solution used
for many other codegen components. This header is then included into the
llc and lli main source files, ensuring everything gets linked into
those binaries.

This isn't great for GCStrategy, which we'd like [1] to use in other
binaries, notably opt for the RS4GC [2] pass. Instead of doing something
specific to opt (for example, adding a call in LinkAllIR), this patch
links to the registry function from getGCStrategy, in the assumption
that anything that might look up a GC strategy probably also expects
the default strategies to exist.

[1] https://reviews.llvm.org/D140458
[2] RewriteStatepointsForGC

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

18 months agoAdd a math.cbrt instruction and lowering to libm.
Johannes Reifferscheid [Mon, 2 Jan 2023 14:23:12 +0000 (15:23 +0100)]
Add a math.cbrt instruction and lowering to libm.

There's currently no way to get accurate cube roots in the math dialect.
powf(x, 1/3.0) is too inaccurate in some cases.

Reviewed By: akuegel

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

18 months ago[C++20] [Modules] Emit full specialization of variable template as available external...
Chuanqi Xu [Tue, 3 Jan 2023 06:37:56 +0000 (14:37 +0800)]
[C++20] [Modules] Emit full specialization of variable template as available externally in importers

Closes https://github.com/llvm/llvm-project/issues/59780.

In this issue report, when we use full specialization of variable
templates in modules, we will meet the multiple definition errors.

The root cause of the problem is that when we see the full
specialization of the variable template in the importers, we will find
if it is already defined in the external sources and we failed to find
such definitions from external sources. So we generate the definition in
the current TU. We failed to find the definition in the external sources
because we restricted to not write it during writing. However, we don't
know why we restricted it and it doesn't make a lot sense to do such
restriction. Then no test fails after we remove such limitations. So
let's remove it now and add it back later if we found it is necessary
then we can add the corresponding test that time.

Note that the code is only applied to named modules and
PCHWithObjectFiles. So it won't affect the normal clang modules and
header units.

18 months ago[gn build] Port c570287fbf4d
LLVM GN Syncbot [Tue, 3 Jan 2023 05:56:22 +0000 (05:56 +0000)]
[gn build] Port c570287fbf4d

18 months ago[RISCV][NFC] Move RISCVISAInfo back to Support
wangpc [Tue, 3 Jan 2023 05:55:12 +0000 (13:55 +0800)]
[RISCV][NFC] Move RISCVISAInfo back to Support

So that there is no cyclic dependency if we want to use it in
tablegen.

Reviewed By: fpetrogalli

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

18 months ago[C++20] [Modules] Fix a crash when instantiate hidden friends
Chuanqi Xu [Tue, 3 Jan 2023 05:35:45 +0000 (13:35 +0800)]
[C++20] [Modules] Fix a crash when instantiate hidden friends

Closes https://github.com/llvm/llvm-project/issues/54457.

This removes a FIXME we found previously. But we didn't remove the FIXME
that time due to the lack of the corresponding test. And now we found
the corresponding test so we can remove it.

18 months ago[llvm] Use std::optional instead of llvm::Optional (NFC)
Kazu Hirata [Tue, 3 Jan 2023 05:17:15 +0000 (21:17 -0800)]
[llvm] Use std::optional instead of llvm::Optional (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

18 months ago[RISCV] Fix compile warning.
jacquesguan [Tue, 3 Jan 2023 03:58:18 +0000 (11:58 +0800)]
[RISCV] Fix compile warning.

18 months ago[RISCV] Use vfirst.m to extract the first element from mask vector.
jacquesguan [Wed, 7 Dec 2022 07:41:27 +0000 (15:41 +0800)]
[RISCV] Use vfirst.m to extract the first element from mask vector.

This patch uses vfirst.m to extract the first bit of mask.

Reviewed By: craig.topper

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

18 months ago[polly] Use std::optional instead of llvm::Optional (NFC)
Kazu Hirata [Tue, 3 Jan 2023 03:18:46 +0000 (19:18 -0800)]
[polly] Use std::optional instead of llvm::Optional (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

18 months ago[clang-format][NFC] Remove CRs at EOLs introduced in 617277e7cbda
Owen Pan [Tue, 3 Jan 2023 03:06:00 +0000 (19:06 -0800)]
[clang-format][NFC] Remove CRs at EOLs introduced in 617277e7cbda

18 months ago[flang] Use std::optional instead of llvm::Optional (NFC)
Kazu Hirata [Tue, 3 Jan 2023 03:13:11 +0000 (19:13 -0800)]
[flang] Use std::optional instead of llvm::Optional (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

18 months ago[mlir] Use std::optional instead of llvm::Optional (NFC)
Kazu Hirata [Tue, 3 Jan 2023 02:56:09 +0000 (18:56 -0800)]
[mlir] Use std::optional instead of llvm::Optional (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

18 months ago[clang-format][NFC] Remove a superfluous semicolon after \version
Owen Pan [Tue, 3 Jan 2023 02:49:25 +0000 (18:49 -0800)]
[clang-format][NFC] Remove a superfluous semicolon after \version

18 months ago[NFC][Clang][RISCV] Reduce boilerplate when determining prototype for segment loads
eopXD [Thu, 29 Dec 2022 09:05:54 +0000 (01:05 -0800)]
[NFC][Clang][RISCV] Reduce boilerplate when determining prototype for segment loads

No functionality change of the RVV builtin and compiler intrinsics is intended
in this patch.

This patch gathers scattered comments for the segment load builtin/intrinsics
and its variants (e.g. segment unit-stride load, segment strided load) into a
single paragraph under riscv_vector.td.

This patch also tries to reduce one level of the if-statements as the push_back
are essentially the same actions but differs in index based on the the value
of the policy attributes and whether the intrinsic is masked.

Reviewed By: kito-cheng

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

18 months ago[BOLT] Use std::optional instead of llvm::Optional (NFC)
Kazu Hirata [Tue, 3 Jan 2023 02:40:21 +0000 (18:40 -0800)]
[BOLT] Use std::optional instead of llvm::Optional (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

18 months ago[lld] Use std::optional instead of llvm::Optional (NFC)
Kazu Hirata [Tue, 3 Jan 2023 02:29:04 +0000 (18:29 -0800)]
[lld] Use std::optional instead of llvm::Optional (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

18 months ago[ORC] Rename ThreadSafeModule::takingModuleDo to consumingModuleDo.
Lang Hames [Tue, 3 Jan 2023 01:48:55 +0000 (17:48 -0800)]
[ORC] Rename ThreadSafeModule::takingModuleDo to consumingModuleDo.

Renamed to emphasize intent: this method allows the module to be consumed by the
callback (while protected by the context lock), but we don't want to imply that
the Module could be taken out of the ThreadSafeModule (where it would no longer
be protected by that lock).

18 months ago[ORC] Add ThreadSafeModule::takingModuleDo for consuming operations on TSMs.
Lang Hames [Tue, 3 Jan 2023 01:33:13 +0000 (17:33 -0800)]
[ORC] Add ThreadSafeModule::takingModuleDo for consuming operations on TSMs.

ThreadSafeModule::takingModuleDo passes ownership of the contained llvm::Module
into the callback, allowing ThreadSafeModules to be used with consuming
operations like Linker::link.

18 months ago[clang-tools-extra] Use std::optional instead of llvm::Optional (NFC)
Kazu Hirata [Tue, 3 Jan 2023 00:17:40 +0000 (16:17 -0800)]
[clang-tools-extra] Use std::optional instead of llvm::Optional (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

18 months ago[clang] Use std::optional instead of llvm::Optional (NFC)
Kazu Hirata [Mon, 2 Jan 2023 23:54:57 +0000 (15:54 -0800)]
[clang] Use std::optional instead of llvm::Optional (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

18 months agoFix the broken bazel build for f6076bd81fce06bb29f83d370b8298110ecc2f99
Haojian Wu [Mon, 2 Jan 2023 23:02:15 +0000 (00:02 +0100)]
Fix the broken bazel build for f6076bd81fce06bb29f83d370b8298110ecc2f99

18 months ago[clang][dataflow] Remove unused includes
Dmitri Gribenko [Mon, 2 Jan 2023 22:34:24 +0000 (23:34 +0100)]
[clang][dataflow] Remove unused includes

18 months ago[mlir][ROCDL] Translate known block size attributes to ROCDL
Krzysztof Drewniak [Mon, 5 Dec 2022 22:17:34 +0000 (22:17 +0000)]
[mlir][ROCDL] Translate known block size attributes to ROCDL

1. When converting from the GPU dialect to the ROCDL dialect, if the
function that contains a gpu.thread_id or gpu.block_id op is annotated
with gpu.known_{block,grid}_size, use that size to set a "range"
attribute on the corresponding rocdl intrinsic so that the LLVM
frontend can optimize based on that range information.
1b. When translating from the rocdl dialect to LLVM IR, use the
"range" attribute, if present, to set !range metadata on the relevant
function call.
2. Deprecate the old rocdl.max_flat_work_group_size attribute, which
was used in a tensorflow backend. Instead, use
rocdl.flat_work_group_size going forward to allow kernel generators to
specify the minimum and maximum work group sizes a kernel may be
launched with in one attribute, thus more closely matching the backend.
3. When translating from gpu.func to llvm.func within gpu-to-rocdl,
copy the known_block_size attribute as rocdl.reqd_work_group_size to
enable further translations to set the corresponding metadata on the
LLVM IR function. Also, set the rocdl.flat_work_group_size attribute
to ensure that the reqd_work_group_size metadata and the
amdgpu-flat-work-group-size metadata are consistent.
3b. Extend the ROCDL to LLVM IR translation to set the
!reqd_work_group_size metadata on LLVM functions

Also update tests and add functions to the ROCDL dialect to ensure
attribute names are used consistently.

Depends on D139865

Reviewed By: antiagainst

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

18 months agoprecommit formatting of LowerSwitch.cpp for D140747
Peter Rong [Mon, 2 Jan 2023 20:57:35 +0000 (12:57 -0800)]
precommit formatting of LowerSwitch.cpp for D140747

Signed-off-by: Peter Rong <PeterRong96@gmail.com>
18 months ago[InstCombine] fold mask with not-of-sext-bool to select
Sanjay Patel [Mon, 2 Jan 2023 18:31:01 +0000 (13:31 -0500)]
[InstCombine] fold mask with not-of-sext-bool to select

~sext(A) & Op1 --> A ? 0 : Op1

With no extra uses, this pattern is already reduced,
but we would miss it in examples such as issue #59773.

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

18 months ago[InstCombine] add tests for not-sext-bool+mask; NFC
Sanjay Patel [Mon, 2 Jan 2023 17:42:43 +0000 (12:42 -0500)]
[InstCombine] add tests for not-sext-bool+mask; NFC

18 months ago[InstCombine] early exit to reduce indents in foldSelectIntoOp(); NFC
Sanjay Patel [Fri, 30 Dec 2022 15:31:10 +0000 (10:31 -0500)]
[InstCombine] early exit to reduce indents in foldSelectIntoOp(); NFC

18 months ago[InstCombine] Canonicalize math-y conditional negation into a `select`
Roman Lebedev [Mon, 2 Jan 2023 18:15:31 +0000 (21:15 +0300)]
[InstCombine] Canonicalize math-y conditional negation into a `select`

https://alive2.llvm.org/ce/z/vPs-gZ

This is a larger pattern than would seem necessary, with minimal being:
* `and` https://alive2.llvm.org/ce/z/q9-MqK
* `or`  https://alive2.llvm.org/ce/z/AUUEMZ
* `xor` https://alive2.llvm.org/ce/z/dm3Ume
.. so for all others, we canonicalize away from math to `select`,
but there we canonicalize in the opposite direction.

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

18 months ago[NFC][InstCombine] Add tests for conditional negation via math
Roman Lebedev [Mon, 2 Jan 2023 17:51:51 +0000 (20:51 +0300)]
[NFC][InstCombine] Add tests for conditional negation via math

https://github.com/llvm/llvm-project/issues/59791

18 months ago[VPlan] Use VP_CLASSOF_IMPL for VPWidenCanonicalIVRecipe(NFC).
Florian Hahn [Mon, 2 Jan 2023 17:52:12 +0000 (17:52 +0000)]
[VPlan] Use VP_CLASSOF_IMPL for VPWidenCanonicalIVRecipe(NFC).

Replace VPWidenCanonicalIVRecipe::classof implementation with general
VP_CLASSOF_IMPL.

18 months ago[VPlan] Use VP_CLASSOF_IMPL for VPWidenMemoryInstructionRecipe (NFC).
Florian Hahn [Mon, 2 Jan 2023 17:32:31 +0000 (17:32 +0000)]
[VPlan] Use VP_CLASSOF_IMPL for VPWidenMemoryInstructionRecipe (NFC).

Replace VPWidenMemoryInstructionRecipe ::classof implementation with general
VP_CLASSOF_IMPL.

18 months ago[VPlan] Use VP_CLASSOF_IMPL for VPPredInstPHI (NFC).
Florian Hahn [Mon, 2 Jan 2023 17:22:34 +0000 (17:22 +0000)]
[VPlan] Use VP_CLASSOF_IMPL for VPPredInstPHI (NFC).

Replace VPPredInstPHI::classof implementation with general
VP_CLASSOF_IMPL.

18 months agoRe-land D139865 "Add known_block_size and known_grid_size to gpu.func"
Krzysztof Drewniak [Thu, 29 Dec 2022 21:36:12 +0000 (21:36 +0000)]
Re-land D139865 "Add known_block_size and known_grid_size to gpu.func"

This should fix the MSVC warning that caused the previous revert.

Reviewed By: antiagainst

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

18 months ago[LoopRotate] Convert tests to opaque pointers (NFC)
Nikita Popov [Mon, 2 Jan 2023 15:53:31 +0000 (16:53 +0100)]
[LoopRotate] Convert tests to opaque pointers (NFC)

18 months ago[LoopRotate] Make test more robust (NFC)
Nikita Popov [Mon, 2 Jan 2023 15:58:57 +0000 (16:58 +0100)]
[LoopRotate] Make test more robust (NFC)

Use a non-zero GEP index, so it does not get dropped during opaque
pointer conversion.

18 months ago[LoopRotate] Name instructions in test (NFC)
Nikita Popov [Mon, 2 Jan 2023 15:57:13 +0000 (16:57 +0100)]
[LoopRotate] Name instructions in test (NFC)

18 months ago[LoopPredication] Convert tests to opaque pointers (NFC)
Nikita Popov [Mon, 2 Jan 2023 15:51:41 +0000 (16:51 +0100)]
[LoopPredication] Convert tests to opaque pointers (NFC)

18 months ago[DAGCombiner] `convertBuildVecZextToBuildVecWithZeros()`: rework split factor calculation
Roman Lebedev [Mon, 2 Jan 2023 15:22:54 +0000 (18:22 +0300)]
[DAGCombiner] `convertBuildVecZextToBuildVecWithZeros()`: rework split factor calculation

The original computation was both making assumptions that do not hold
in practice, and being overly pessimistic. We should just check
every possible split factor, and pick the best one.

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

18 months ago[LLDB] Enable TestSignedTypes.py for AArch64/Windows
Muhammad Omair Javaid [Mon, 2 Jan 2023 15:30:18 +0000 (19:30 +0400)]
[LLDB] Enable TestSignedTypes.py for AArch64/Windows

TestSignedTypes.py passes on AArch64 Windows. This patch disables this
test only for i[3-6]86 and x86_64 Windows platform.

18 months ago[InstCombine] Support vectors in icmp of GEP fold
Nikita Popov [Mon, 2 Jan 2023 14:28:10 +0000 (15:28 +0100)]
[InstCombine] Support vectors in icmp of GEP fold

EmitGEPOffset() supports vector GEPs nowadays, so we don't need
any further code changes.

compare_gep_with_base_vector1 shows a weakness in folding the
resulting comparison if an index splat has to be performed.

18 months ago[InstCombine] Add tests for icmp of vector GEP (NFC)
Nikita Popov [Mon, 2 Jan 2023 14:17:34 +0000 (15:17 +0100)]
[InstCombine] Add tests for icmp of vector GEP (NFC)

These show up as regressions with opaque pointers.

18 months ago[JITLink][RISCV] Order EdgeKind_riscv the same way as relocations
Jonas Hahnfeld [Sat, 31 Dec 2022 12:41:51 +0000 (13:41 +0100)]
[JITLink][RISCV] Order EdgeKind_riscv the same way as relocations

There were basically four different orderings: one defined by the
relocations, one by the enum definition of EdgeKind_riscv, one for
mapping the enum values to their names, and one when mapping the
relocations to edge kinds and finally processing them. Chose the
ordering defined by the relocations in the riscv-elf-psabi-doc as
the canonical one.

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

18 months ago[ValueTracking] Use SmallVector for non-undef/poison ops
Nikita Popov [Mon, 2 Jan 2023 13:37:02 +0000 (14:37 +0100)]
[ValueTracking] Use SmallVector for non-undef/poison ops

The way these APIs are used, there isn't really a benefit to
deduplicating the ops as part of the API. The only place that
benefits from this is PoisonChecking, and for that particular
use the assertion emission was potentially non-deterministic.
We should populate a vector for deterministic order and then
deduplicate via a separate set.

18 months ago[mlir] NFC use the correct markdown header in BufferizationTransformOps.td
Oleksandr "Alex" Zinenko [Mon, 2 Jan 2023 13:14:40 +0000 (14:14 +0100)]
[mlir] NFC use the correct markdown header in BufferizationTransformOps.td

18 months ago[llvm-objcopy] Use getNumberOfSymbols() instead of getRawNumberOfSymbols()
Daan De Meyer [Mon, 19 Dec 2022 11:53:02 +0000 (11:53 +0000)]
[llvm-objcopy] Use getNumberOfSymbols() instead of getRawNumberOfSymbols()

getRawNumberOfSymbols() assumes that a symbol table exists, which isn't
always guaranteed, while getNumberOfSymbols() handles and tolerates objects
without a symbol table. When there is a symbol table, both methods return
the same value.

Also add a test to ensure we don't regress in this regard. The test
generates a basic COFF object with symbols and overrides the symbol table
pointer with zeros to craft the input required to verify llvm-objcopy works
as expected in this scenario.

18 months ago[mlir][Bazel] Port cf487cce6f64
Adrian Kuegel [Mon, 2 Jan 2023 12:05:26 +0000 (13:05 +0100)]
[mlir][Bazel] Port cf487cce6f64

18 months ago[ValueTracking] Treat branch on undef as UB as well
Nikita Popov [Mon, 2 Jan 2023 10:16:09 +0000 (11:16 +0100)]
[ValueTracking] Treat branch on undef as UB as well

We were already treating branch on poison as UB, but branch on
undef is also UB. Move the checks into the correct function.

From LangRef for br:

> If ‘cond’ is poison or undef, this instruction has undefined behavior.

From LangRef for switch:

> If ‘value’ is poison or undef, this instruction has undefined behavior.

There is a minor regression in dont-distribute-phi.ll, apparently
we handle that pattern in logical but not bitwise form.

18 months ago[SimpleLoopUnswitch] Perform poison query before transform
Nikita Popov [Mon, 2 Jan 2023 11:19:39 +0000 (12:19 +0100)]
[SimpleLoopUnswitch] Perform poison query before transform

I think this doesn't make any difference right now, but once
we take into account that branch on undef is UB in
programUndefinedIfUndefOrPoison() the new position of the branch
would imply that the condition can't be poison, which would
defeat the purpose of the freeze insertion here. We need to
perform the check before the branch is moved.

18 months ago[clang-tidy] Support std::string_view in readability-redundant-string-cstr
Tamas Berghammer [Mon, 2 Jan 2023 11:24:00 +0000 (06:24 -0500)]
[clang-tidy] Support std::string_view in readability-redundant-string-cstr

Previously we were matching constructor calls for std::string and
llvm::StringRef and this change extends this set with including
std::string_view as well.

Reviewed By: njames93, carlosgalvezp

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

18 months ago[mlir][llvm] Make the import of LLVM IR intrinsics extensible.
Tobias Gysi [Mon, 2 Jan 2023 10:34:51 +0000 (11:34 +0100)]
[mlir][llvm] Make the import of LLVM IR intrinsics extensible.

The revision introduces the LLVMImportDialectInterface to make the
import of LLVM IR intrinsics extensible. It uses a dialect interface
that enables external projects to provide their own conversion functions
for custom intrinsics. These conversion functions can rely on the
ModuleImport class to perform support tasks such as mapping LLVM
values to MLIR values or for converting types between the two worlds.

The implementation largely mirrors the export implementation. One major
difference is the dispatch to the appropriate dialect interface, since
LLVM IR intrinsics have no direct association to an MLIR dialect. The
dialect interfaces thus have to publish the supported intrinsics to
ensure incoming conversion calls are dispatched to the right dialect
interface.

The revision implements the extensible intrinsic import discussed as
part of the "extensible llvm ir import" rfc:
https://discourse.llvm.org/t/rfc-extensible-llvm-ir-import/67256/6

Reviewed By: ftynse

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

18 months ago[ValueTracking] Remove branch-on-poison-as-ub flag (NFC)
Nikita Popov [Mon, 2 Jan 2023 10:02:27 +0000 (11:02 +0100)]
[ValueTracking] Remove branch-on-poison-as-ub flag (NFC)

This has been enabled by default without issue for a while now,
remove the flag.

18 months ago[LLD][Windows]Feature "checksum" for Windows PE
Qfrost [Mon, 2 Jan 2023 09:20:15 +0000 (17:20 +0800)]
[LLD][Windows]Feature "checksum" for Windows PE

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

18 months ago[mlir][MemRef] Apply ClangTidy performance fix (NFC).
Adrian Kuegel [Mon, 2 Jan 2023 07:41:31 +0000 (08:41 +0100)]
[mlir][MemRef] Apply ClangTidy performance fix (NFC).

18 months ago[JITLink][RISCV] Fix incorrectly use of uint32_t
luxufan [Mon, 2 Jan 2023 05:48:39 +0000 (13:48 +0800)]
[JITLink][RISCV] Fix incorrectly use of uint32_t

18 months ago[clang-format][docs] Fix indentation for the Sphinx build
Owen Pan [Sun, 1 Jan 2023 23:13:36 +0000 (15:13 -0800)]
[clang-format][docs] Fix indentation for the Sphinx build

See https://reviews.llvm.org/D140543#4021209.

18 months ago[clang-format][NFC] Clean up IntegerLiteralSeparatorFixer::process
Owen Pan [Sun, 1 Jan 2023 06:06:28 +0000 (22:06 -0800)]
[clang-format][NFC] Clean up IntegerLiteralSeparatorFixer::process

18 months ago[libc] [nfc] Fix heading underline.
Jeff Bailey [Sun, 1 Jan 2023 20:48:24 +0000 (20:48 +0000)]
[libc] [nfc] Fix heading underline.

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

18 months ago[DAGCombiner][X86] Fold a CONCAT_VECTORS of SHUFFLE_VECTOR and it's operand into...
Roman Lebedev [Sun, 1 Jan 2023 19:36:49 +0000 (22:36 +0300)]
[DAGCombiner][X86] Fold a CONCAT_VECTORS of SHUFFLE_VECTOR and it's operand into wider SHUFFLE_VECTOR

This was showing as a source of *many* regressions
with more aggressive ZERO_EXTEND_VECTOR_INREG recognition.

18 months ago[NFC][X86] Add tests for concatenation of shuffle's operand to the shuffle
Roman Lebedev [Sun, 1 Jan 2023 18:34:02 +0000 (21:34 +0300)]
[NFC][X86] Add tests for concatenation of shuffle's operand to the shuffle

18 months ago[VPlan] Adjust mergeReplicateRegions to be in line with mergeBlock (NFC)
Florian Hahn [Sun, 1 Jan 2023 19:48:48 +0000 (19:48 +0000)]
[VPlan] Adjust mergeReplicateRegions to be in line with mergeBlock (NFC)

Adjust mergeReplicateRegions to be in line with
mergeBlocksIntoPredecessors added in 36d70a6aea6b by collecting only the
valid candidates first.

Also rename to mergeReplicateRegionsIntoSuccessors and add missing
doc-comment.

This addresses post-commit suggestions by @Ayal.

18 months ago[clangd] Add extension for adding context (enclosing function or class) in references...
Tom Praschan [Sat, 31 Dec 2022 15:24:55 +0000 (16:24 +0100)]
[clangd] Add extension for adding context (enclosing function or class) in references results

Relevant issue: https://github.com/clangd/clangd/issues/177

Reviewed By: nridge

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

18 months ago[OpenMP][libomptarget] Add TargetParser as dependency in NextGen's JIT
Kevin Sala [Sat, 31 Dec 2022 20:07:56 +0000 (21:07 +0100)]
[OpenMP][libomptarget] Add TargetParser as dependency in NextGen's JIT

This patch fixes an undefined reference to llvm::Triple::Triple(llvm::Twine const&).

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

18 months ago[lld][ELF] Support relocation R_AVR_LDS_STS_16 on AVRTiny devices
Ben Shi [Mon, 12 Dec 2022 03:40:57 +0000 (11:40 +0800)]
[lld][ELF] Support relocation R_AVR_LDS_STS_16 on AVRTiny devices

The relocation 'R_AVR_LDS_STS_16' is introduced for the compact
16-bit LDS/STS instructions on AVRTiny devices.

Reviewed By: MaskRay, aykevl

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

18 months ago[X86] Revert -fno-plt __tls_get_addr workaround for old GNU ld
Fangrui Song [Sun, 1 Jan 2023 06:39:20 +0000 (22:39 -0800)]
[X86] Revert -fno-plt __tls_get_addr workaround for old GNU ld

ENABLE_X86_RELAX_RELOCATIONS has defaulted to on in 2020.
This workaround is not exercised for a long time.

18 months ago[clang] Change CodeGenOptions::RelaxELFRelocations/assembler defaults to match MC...
Fangrui Song [Sun, 1 Jan 2023 06:24:37 +0000 (22:24 -0800)]
[clang] Change CodeGenOptions::RelaxELFRelocations/assembler defaults to match MC default

MC default was flipped in 2016.
CMake ENABLE_X86_RELAX_RELOCATIONS defaults to on in 2020 (c41a18cf61790fc898dcda1055c3efbf442c14c0).
It makes sense for the CodeGenOptions::RelaxELFRelocations to match, so
that most -cc1/-cc1as command lines won't have this option.

This also fixes a minor issue: -fno-plt -S will now use GOT for
__tls_get_addr calls, matching -fno-plt -c.

18 months ago[ELF] Support TLS GD/LD relaxations for x86-32 -fno-plt
Fangrui Song [Sun, 1 Jan 2023 04:50:54 +0000 (20:50 -0800)]
[ELF] Support TLS GD/LD relaxations for x86-32 -fno-plt

For x86-32, {clang,gcc} -fno-plt uses `call *___tls_get_addr@GOT(%reg)` instead
of `call ___tls_get_addr@PLT`. GD to IE/LE relaxations need to shift the offset
by one while LD to LE relaxation needs to use a different code sequence.

While here, fix some comments.

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

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

18 months ago[gn build] Port 89aad1e6a397
LLVM GN Syncbot [Sun, 1 Jan 2023 01:57:45 +0000 (01:57 +0000)]
[gn build] Port 89aad1e6a397

18 months agoReland [clang-format] Add an option to format integer literal separators
Owen Pan [Thu, 22 Dec 2022 09:21:17 +0000 (01:21 -0800)]
Reland [clang-format] Add an option to format integer literal separators

Previously committed in 46c94e5067b5 which was reverted in f0756e086010
due to a memory bug.

Closes #58949.

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

18 months ago[clang][NFC] Fix warning due to initializing a pointer with `false`
Markus Böck [Sat, 31 Dec 2022 14:04:31 +0000 (15:04 +0100)]
[clang][NFC] Fix warning due to initializing a pointer with `false`

18 months ago[VPlan] Move GraphTraits definitions to separate header (NFC).
Florian Hahn [Sat, 31 Dec 2022 15:14:57 +0000 (15:14 +0000)]
[VPlan] Move GraphTraits definitions to separate header (NFC).

This reduces the size of VPlan.h and avoids future growth of the file
when the graph traits are extended in future patches.

Reviewed By: Ayal

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

18 months ago[MLIR] Fix affine LICM pass for unknown region holding ops
Uday Bondhugula [Sat, 31 Dec 2022 14:56:40 +0000 (20:26 +0530)]
[MLIR] Fix affine LICM pass for unknown region holding ops

Fix affine LICM pass for unknown region-holding ops. The logic was
completely ignoring regions of unknown ops leading to generation of
invalid IR on hoisting. Handle affine.parallel op among those with
regions that are supported.

Reviewed By: ftynse

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

18 months agoNFC. Fix/improve style in affine-licm pass
Uday Bondhugula [Sat, 24 Dec 2022 10:23:36 +0000 (15:53 +0530)]
NFC. Fix/improve style in affine-licm pass

The code here appears to be out of line with proper style and
guidelines. Fix this.

18 months ago[NFC][libc++] Removes concepts tests.
Mark de Wever [Fri, 23 Dec 2022 17:10:00 +0000 (18:10 +0100)]
[NFC][libc++] Removes concepts tests.

Concepts should be supported by all supported compilers. This is
probably a left over from an older version of the expected patch.

Reviewed By: #libc, philnik

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

18 months ago[docs] TestingGuide.rst: Fix incorrect description
Jie Fu [Sat, 31 Dec 2022 07:31:33 +0000 (23:31 -0800)]
[docs] TestingGuide.rst: Fix incorrect description

This patch fixes two incorrect descriptions in TestingGuide.rst.

1. test/lit.site.cfg --> test/lit.site.cfg.py
   After https://reviews.llvm.org/D37838 , the `test/lit.site.cfg` had been added a .py extension.
   So it should be `test/lit.site.cfg.py`.

2. $(LLVM_OBJ_ROOT)/$(BuildMode)/bin --> $(LLVM_OBJ_ROOT)/bin
   The current build system doesn't create a $(BuildMode) directory any more.
   So it should be removed.

Reviewed By: mehdi_amini, MaskRay

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

18 months ago[test] Opaquify cgprofile.ll
Fangrui Song [Sat, 31 Dec 2022 04:33:27 +0000 (20:33 -0800)]
[test] Opaquify cgprofile.ll

18 months agollvm-readobj COFFDumper print PEHeader CheckSum
Qfrost [Sat, 31 Dec 2022 03:48:58 +0000 (11:48 +0800)]
llvm-readobj COFFDumper print PEHeader CheckSum
Differential Revision:https://reviews.llvm.org/D140555

18 months ago[msan] Remove non-working MSAN_LINUX_X86_64_OLD_MAPPING
Fangrui Song [Sat, 31 Dec 2022 03:43:19 +0000 (19:43 -0800)]
[msan] Remove non-working MSAN_LINUX_X86_64_OLD_MAPPING

r249754 (2015) added this macro (not set anywhere) for an escape hatch.
This old layout has been non-working for many years (Linux
arch/x86/include/asm/elf.h ELF_ET_DYN_BASE is outside the APP range):

    FATAL: Code 0x558547327980 is out of application range. Non-PIE build?
    FATAL: MemorySanitizer can not mmap the shadow memory.
    FATAL: Make sure to compile with -fPIE and to link with -pie.
    FATAL: Disabling ASLR is known to cause this error.
    FATAL: If running under GDB, try 'set disable-randomization off'.

Non-pie doesn't work either.

18 months ago[RISCV] Use tail agnostic if inserting subvector/element at the end of a vector.
Yeting Kuo [Mon, 26 Dec 2022 09:52:56 +0000 (17:52 +0800)]
[RISCV] Use tail agnostic if inserting subvector/element at the end of a vector.

The patch tries to make more vslidup nodes use tail agnostic. The idea comes
from D125546 authored by Zack Chen.

Reviewed By: craig.topper

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

18 months ago[CMake] Remove unused ALL_SCUDO_SUPPORTED_ARCH after D138157
Fangrui Song [Sat, 31 Dec 2022 02:23:54 +0000 (18:23 -0800)]
[CMake] Remove unused ALL_SCUDO_SUPPORTED_ARCH after D138157

18 months ago[CVP] When expanding `urem`, always freeze the nominator
Roman Lebedev [Sat, 31 Dec 2022 01:58:22 +0000 (04:58 +0300)]
[CVP] When expanding `urem`, always freeze the nominator

As per the post-commit feedback - that was not the correct precondition
to avoid it here. I think we should generally start changing mentality
about `freeze`, the fact that we have been conditioned to be afraid of it
(or of anything in LLVM in general) is the key problem here.

18 months ago[NFC][CVP] Add more tests for urem expansion
Roman Lebedev [Sat, 31 Dec 2022 01:43:29 +0000 (04:43 +0300)]
[NFC][CVP] Add more tests for urem expansion

As mentioned in post-commit feedback.

18 months ago[DAGCombiner][TLI] Do not fuse bitcast to <1 x ?> into a load/store of a vector
Roman Lebedev [Sat, 31 Dec 2022 00:23:54 +0000 (03:23 +0300)]
[DAGCombiner][TLI] Do not fuse bitcast to <1 x ?> into a load/store of a vector

Single-element vectors are legalized by splitting,
so the the memory operations would also get scalarized.
While we do have some support to reconstruct scalarized loads,
we clearly don't catch everything.

The comment for the affected AArch64 store suggests that
having two stores was the desired outcome in the first place.

This was showing as a source of *many* regressions
with more aggressive ZERO_EXTEND_VECTOR_INREG recognition.

18 months ago[NFC][Codegen][x86] Add tests for load/store of a single-element vectors
Roman Lebedev [Sat, 31 Dec 2022 00:10:43 +0000 (03:10 +0300)]
[NFC][Codegen][x86] Add tests for load/store of a single-element vectors

18 months ago[NFC][TLI] Move `isLoadBitCastBeneficial()` implementation into source file
Roman Lebedev [Fri, 30 Dec 2022 23:07:50 +0000 (02:07 +0300)]
[NFC][TLI] Move `isLoadBitCastBeneficial()` implementation into source file

... so any change to it does not cause 700 source files to be recompiled.

18 months ago[DAG] BUILD_VECTOR: absorb ZERO_EXTEND of a single first operand if all other ops...
Roman Lebedev [Fri, 30 Dec 2022 00:49:48 +0000 (03:49 +0300)]
[DAG] BUILD_VECTOR: absorb ZERO_EXTEND of a single first operand if all other ops are zeros

This kind of pattern seems to come up as regressions
with better ZERO_EXTEND_VECTOR_INREG recognition.

For initial implementation, this is quite restricted
to the minimal viable transform, otherwise there are
too many regressions to be dealt with.

18 months ago[NFC] Test case intended to cover SLP cost for chain with masked gather loads.
Valery N Dmitriev [Fri, 30 Dec 2022 19:07:04 +0000 (11:07 -0800)]
[NFC] Test case intended to cover SLP cost for chain with masked gather loads.

SLP produces two gather loads (one feeds another).
For the first set of scalar loads GEP indices are all constant.
The result of the second load is then fed into reduction (as a seed).

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

18 months ago[mlir] Add a test for default valued dictionary attributes
Eugene Zhulenev [Thu, 29 Dec 2022 21:24:45 +0000 (13:24 -0800)]
[mlir] Add a test for default valued dictionary attributes

+ Replace special placeholders ($_builder, etc...) in default attribute string

Reviewed By: ftynse

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

18 months ago[NFC][X86] Add exhaustive-ish coverage for broadcast of implicitly aext/zext element
Roman Lebedev [Fri, 30 Dec 2022 18:25:14 +0000 (21:25 +0300)]
[NFC][X86] Add exhaustive-ish coverage for broadcast of implicitly aext/zext element

Some of these even crash instruction selection for AVX512.
This is one of the patterns that comes up as regressions
with more aggressive ZERO_EXTEND_VECTOR_INREG recognition.

https://godbolt.org/z/x88aqfrT5

18 months agoRevert "[CodeGen] Temporarily disable-lsr in HWASAN build"
Vitaly Buka [Fri, 30 Dec 2022 18:57:12 +0000 (10:57 -0800)]
Revert "[CodeGen] Temporarily disable-lsr in HWASAN build"

We can do the same with cmake on the bot.

This reverts commit 8f70b848d339cabfaa8f1379d41dae11b9b75014.

18 months ago[Sema] Avoid double hash lookup. NFCI
Benjamin Kramer [Fri, 30 Dec 2022 18:07:19 +0000 (19:07 +0100)]
[Sema] Avoid double hash lookup. NFCI

18 months ago[VPlan] Also consider operands of sink candidates in same block.
Florian Hahn [Fri, 30 Dec 2022 18:24:34 +0000 (18:24 +0000)]
[VPlan] Also consider operands of sink candidates in same block.

Even if the the sink candidate is already in the target block, its
operands can be candidates for sinking. Queue them up as well. Also
moves the queuing logic to a helper.

18 months ago[NFC][AMDGPU] Make method declarations in SIInstrInfo equivalent to their definitions.
Thomas Symalla [Fri, 30 Dec 2022 13:25:51 +0000 (14:25 +0100)]
[NFC][AMDGPU] Make method declarations in SIInstrInfo equivalent to their definitions.

Some functions from SIInstrInfo have their operands named different in
their declarations vs. their defs. This was caught by cppcheck.

Reviewed By: arsenm

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

18 months ago[AArch64] Stringref'ize AArch64Subtarget constructor. NFCI
Benjamin Kramer [Fri, 30 Dec 2022 17:02:26 +0000 (18:02 +0100)]
[AArch64] Stringref'ize AArch64Subtarget constructor. NFCI

18 months ago[mlir][gpu][spirv] Lower gpu reduction ops to spirv
Ivan Butygin [Thu, 22 Dec 2022 19:50:52 +0000 (20:50 +0100)]
[mlir][gpu][spirv] Lower gpu reduction ops to spirv

Supports only "add" and "mul" ops for now. More ops will be added later.

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

18 months ago[CVP] Expand bound `urem`s
Roman Lebedev [Fri, 30 Dec 2022 16:06:59 +0000 (19:06 +0300)]
[CVP] Expand bound `urem`s

This kind of thing happens really frequently in LLVM's very own
shuffle combining methods, and it is even considered bad practice
to use `%` there, instead of using this expansion directly.
Though, many of the cases there have variable divisors,
so this won't help everything.

Simple case: https://alive2.llvm.org/ce/z/PjvYf-
There's alternative expansion via `umin`:
https://alive2.llvm.org/ce/z/hWCVPb

BUT while we can transform the first expansion
into the `umin` one (e.g. for SCEV):
https://alive2.llvm.org/ce/z/iNxKmJ
... we can't go in the opposite direction.

Also, the non-`umin` expansion seems somewhat more codegen-friendly:
https://godbolt.org/z/qzjx5bqWK
https://godbolt.org/z/a7bj1axbx

There's second variant of precondition:
https://alive2.llvm.org/ce/z/zE6cbM
but there the numerator must be non-undef / must be frozen.

18 months ago[NFC][CVP] `processURem()`: add statistic and increase readability
Roman Lebedev [Fri, 30 Dec 2022 16:15:43 +0000 (19:15 +0300)]
[NFC][CVP] `processURem()`: add statistic and increase readability