platform/upstream/llvm.git
22 months agollvm-reduce: Add reduction for function personalities
Matt Arsenault [Mon, 2 Jan 2023 13:25:26 +0000 (08:25 -0500)]
llvm-reduce: Add reduction for function personalities

Fixes second piece of #58815

22 months agoAMDGPU: Use cast instead of unchecked dyn_cast
Matt Arsenault [Tue, 3 Jan 2023 15:03:58 +0000 (10:03 -0500)]
AMDGPU: Use cast instead of unchecked dyn_cast

22 months agoOpenMPOpt: Fix introducing empty nvvm.annotations into module
Matt Arsenault [Sun, 1 Jan 2023 19:33:15 +0000 (14:33 -0500)]
OpenMPOpt: Fix introducing empty nvvm.annotations into module

22 months ago[LoopFusion] Exit early if one of fusion candidate has guarded branch but the another...
luxufan [Tue, 3 Jan 2023 15:05:18 +0000 (23:05 +0800)]
[LoopFusion] Exit early if one of fusion candidate has guarded branch but the another has not

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

Reviewed By: nikic

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

22 months agollvm-reduce: Avoid push_back for constant array
Matt Arsenault [Mon, 2 Jan 2023 21:47:08 +0000 (16:47 -0500)]
llvm-reduce: Avoid push_back for constant array

22 months agollvm-reduce: Remove unused class
Matt Arsenault [Mon, 2 Jan 2023 19:11:47 +0000 (14:11 -0500)]
llvm-reduce: Remove unused class

22 months agollvm-reduce: Restrict set of run delta passes in invoke test
Matt Arsenault [Sun, 1 Jan 2023 23:06:33 +0000 (18:06 -0500)]
llvm-reduce: Restrict set of run delta passes in invoke test

Also stop using cat

22 months agoUtils: Fix comment typos
Matt Arsenault [Mon, 2 Jan 2023 03:39:08 +0000 (22:39 -0500)]
Utils: Fix comment typos

22 months ago[TypePromotion] NewPM support.
Samuel Parker [Tue, 3 Jan 2023 14:42:25 +0000 (14:42 +0000)]
[TypePromotion] NewPM support.

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

22 months ago[NFC] Formatting
Samuel Parker [Tue, 3 Jan 2023 15:03:41 +0000 (15:03 +0000)]
[NFC] Formatting

Format opt PassNameExact vector to make diffs, that remove strings,
cleaner.

22 months agoReapply "[NFC] Update CXXSTatus to show we implement CWG 2061""
Erich Keane [Tue, 3 Jan 2023 14:27:07 +0000 (06:27 -0800)]
Reapply "[NFC] Update CXXSTatus to show we implement CWG 2061""

This reverts commit a5ae5afa521f75e87f9018d8361aa5a1cadc7a86.

FIx the test that didn't consider the test was running in pre-C++11
mode.

22 months agollvm-reduce: Try to fix error message test on windows
Matt Arsenault [Tue, 3 Jan 2023 14:56:19 +0000 (09:56 -0500)]
llvm-reduce: Try to fix error message test on windows

It seems the execute implementations have gone out of their way to
produce inconsistent error messages. The unix version explicitly
checks if the file exists before trying to execute. The windows
version checks if it's executable. I don't understand why they
wouldn't just try the execution and check the error code.

22 months ago[CVP] Simplify SRem when constantrange abs(lhs) < abs(rhs)
luxufan [Tue, 20 Dec 2022 15:03:04 +0000 (23:03 +0800)]
[CVP] Simplify SRem when constantrange abs(lhs) < abs(rhs)

For `srem x, y`, if abs(constant range of x) less than abs(constant
range of y), we can simplify it as:
`srem x, y => x` if y is guaranteed to be positive.
'srem x, y => -x' if y is guaranteed to be negative.

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

22 months ago[NFC][AArch64] Adjust comments in tablegen file
Lucas Prates [Tue, 20 Dec 2022 14:23:28 +0000 (14:23 +0000)]
[NFC][AArch64] Adjust comments in tablegen file

22 months ago[LLDB] Skip python exception unit test on AArch64/Windows
Muhammad Omair Javaid [Tue, 3 Jan 2023 14:40:57 +0000 (18:40 +0400)]
[LLDB] Skip python exception unit test on AArch64/Windows

This patch marks python exception test as skipped for AArch64/Windows
platform. This is temporary to make LLDB WoA buildbot happy until a proper
fix is found.

22 months ago[LLDB] Skip TestThreadSpecificBreakpoint.py on AArch64/Windows
Muhammad Omair Javaid [Tue, 3 Jan 2023 14:38:30 +0000 (18:38 +0400)]
[LLDB] Skip TestThreadSpecificBreakpoint.py on AArch64/Windows

TestThreadSpecificBreakpoint.py is flaky on AArch64/Windows buildbot
and results in timeout randomly. This patch marks the test skipped.

22 months ago[CVP] Add baseline tests of abs(lhs) < abs(rhs) in srem
luxufan [Tue, 20 Dec 2022 16:04:18 +0000 (00:04 +0800)]
[CVP] Add baseline tests of abs(lhs) < abs(rhs) in srem

22 months agoAMDGPU: Diagnose which LDS global failed to lower
Matt Arsenault [Tue, 3 Jan 2023 14:21:56 +0000 (09:21 -0500)]
AMDGPU: Diagnose which LDS global failed to lower

Also lowercase the message to start since that seems to be the
prevailing convention for error messages.

22 months ago[TLI] Fix signature for fprintf (PR59757)
Nikita Popov [Tue, 3 Jan 2023 14:26:31 +0000 (15:26 +0100)]
[TLI] Fix signature for fprintf (PR59757)

fprintf() requires two pointer arguments.

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

22 months agoRevert "[NFC] Update CXXSTatus to show we implement CWG 2061"
Erich Keane [Tue, 3 Jan 2023 14:26:29 +0000 (06:26 -0800)]
Revert "[NFC] Update CXXSTatus to show we implement CWG 2061"

This reverts commit 80a78033cf5f21c082aa30bfc692df76d296573c.

Fails thanks to an inline-ns warning

22 months ago[NFC] Update CXXSTatus to show we implement CWG 2061
Erich Keane [Tue, 3 Jan 2023 14:18:08 +0000 (06:18 -0800)]
[NFC] Update CXXSTatus to show we implement CWG 2061

Looking through the list, I discovered this was implemented and has been
for as long as Clang shows up on godbolt, so this patch updates the
  CXXStatus list and adds a test.

22 months agollvm-reduce: Fix missing newline after error message
Matt Arsenault [Sun, 1 Jan 2023 15:01:21 +0000 (10:01 -0500)]
llvm-reduce: Fix missing newline after error message

Fixes missing test coverage for the failed to execute case. However,
this test fails to verify the newline is printed. I can't figure out
how to get FileCheck to match the trailing newline.

22 months ago[OpenMP] Convert some tests to opaque pointers (NFC)
Nikita Popov [Tue, 3 Jan 2023 14:00:22 +0000 (15:00 +0100)]
[OpenMP] Convert some tests to opaque pointers (NFC)

22 months ago[CGP] Avoid branch on poison UB in test (NFC)
Nikita Popov [Tue, 3 Jan 2023 13:52:15 +0000 (14:52 +0100)]
[CGP] Avoid branch on poison UB in test (NFC)

22 months ago[SimplifyCFG] Add test for branch on undef/poison (NFC)
Nikita Popov [Tue, 3 Jan 2023 13:51:13 +0000 (14:51 +0100)]
[SimplifyCFG] Add test for branch on undef/poison (NFC)

22 months ago[mlir][llvm] Make the import of LLVM IR metadata extensible.
Tobias Gysi [Tue, 3 Jan 2023 12:46:08 +0000 (13:46 +0100)]
[mlir][llvm] Make the import of LLVM IR metadata extensible.

This revision extends the LLVMImportDialectInterface to make the import
of LLVM IR instruction-level metadata extensible. It extends the
signature of the existing dialect interface to provide a method to
import specific metadata kinds and attach them to the imported
operation. The conversion function can rely on the ModuleImport class
to perform support tasks.

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

The interface method names changed a bit compared to the suggested
design. The hook to set the instruction level metadata is now called
setMetadataAttrs and takes the metadata kind as an additional parameter.
We do not hand in the original LLVM IR instruction since it is not used
at this point. Importing named module-level meta data can be added in a
later stage after gaining some experience with this extension mechanism.

Depends on D140374

Reviewed By: ftynse, Dinistro

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

22 months ago[LSR] Convert test to check IR (NFC)
Nikita Popov [Tue, 3 Jan 2023 13:35:10 +0000 (14:35 +0100)]
[LSR] Convert test to check IR (NFC)

Convert this llc -O3 test to instead check the IR after -loop-reduce.

22 months ago[RewriteStatepointsForGC] Avoid branch on undef UB in tests (NFC)
Nikita Popov [Tue, 3 Jan 2023 13:28:22 +0000 (14:28 +0100)]
[RewriteStatepointsForGC] Avoid branch on undef UB in tests (NFC)

22 months ago[RewriteStatepointsForGC] Convert some tests to opaque pointers (NFC)
Nikita Popov [Tue, 3 Jan 2023 13:24:54 +0000 (14:24 +0100)]
[RewriteStatepointsForGC] Convert some tests to opaque pointers (NFC)

22 months ago[ConstraintElim] Move after first instcombine run.
Florian Hahn [Tue, 3 Jan 2023 13:25:00 +0000 (13:25 +0000)]
[ConstraintElim] Move after first instcombine run.

Running ConstraintEliminiation after the first InstCombine run results
in slightly more simplifications on average.

There are is a tiny number of regressions, mostly due to CVP eliminating
a condition that ConstraintElimination would use, but in most cases
there's a slight improvement or no change.

Reviewed By: nikic

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

22 months ago[SampleProfile] Avoid branch on undef UB in tests (NFC)
Nikita Popov [Tue, 3 Jan 2023 13:23:25 +0000 (14:23 +0100)]
[SampleProfile] Avoid branch on undef UB in tests (NFC)

22 months ago[SafepointIRVerifier] Convert tests to opaque pointers (NFC)
Nikita Popov [Tue, 3 Jan 2023 13:14:16 +0000 (14:14 +0100)]
[SafepointIRVerifier] Convert tests to opaque pointers (NFC)

22 months ago[lldb][Test] TestDataFormatterLibcxxRangesRefView.py: skip on old compiler versions
Michael Buch [Tue, 3 Jan 2023 13:11:16 +0000 (13:11 +0000)]
[lldb][Test] TestDataFormatterLibcxxRangesRefView.py: skip on old compiler versions

`std::ranges` are only available in libcxx shipped with Clang > 15.0

22 months ago[PlaceSafepoints] Avoid branch on undef UB in test (NFC)
Nikita Popov [Tue, 3 Jan 2023 13:08:35 +0000 (14:08 +0100)]
[PlaceSafepoints] Avoid branch on undef UB in test (NFC)

22 months ago[HotColdSplit] Avoid branch on undef UB in test (NFC)
Nikita Popov [Tue, 3 Jan 2023 13:07:07 +0000 (14:07 +0100)]
[HotColdSplit] Avoid branch on undef UB in test (NFC)

22 months ago[Coroutines] Convert some tests to opaque pointers (NFC)
Nikita Popov [Tue, 3 Jan 2023 12:54:06 +0000 (13:54 +0100)]
[Coroutines] Convert some tests to opaque pointers (NFC)

22 months ago[Coroutines] Avoid branch on undef UB in test (NFC)
Nikita Popov [Tue, 3 Jan 2023 12:53:10 +0000 (13:53 +0100)]
[Coroutines] Avoid branch on undef UB in test (NFC)

22 months ago[llvm] XFAIL X86 tests failing on AArch64/Windows
Muhammad Omair Javaid [Tue, 3 Jan 2023 12:42:03 +0000 (16:42 +0400)]
[llvm] XFAIL X86 tests failing on AArch64/Windows

coff-alignment.ll and merge-equivalent-ranges.ll depend on X86 target.
This patch marks them as XFAIL for AArch64/Windows target.

22 months ago[CodeGenPrepare] Avoid branch on undef UB in tests (NFC)
Nikita Popov [Tue, 3 Jan 2023 12:45:52 +0000 (13:45 +0100)]
[CodeGenPrepare] Avoid branch on undef UB in tests (NFC)

22 months agoFix MSVC "result of 32-bit shift implicitly converted to 64 bits" warning.
Simon Pilgrim [Tue, 3 Jan 2023 12:23:06 +0000 (12:23 +0000)]
Fix MSVC "result of 32-bit shift implicitly converted to 64 bits" warning.

22 months ago[CodeExtractor] Avoid branch on undef UB in tests (NFC)
Nikita Popov [Tue, 3 Jan 2023 12:01:44 +0000 (13:01 +0100)]
[CodeExtractor] Avoid branch on undef UB in tests (NFC)

22 months ago[CodeExtractor] Convert some tests to opaque pointers (NFC)
Nikita Popov [Tue, 3 Jan 2023 11:52:47 +0000 (12:52 +0100)]
[CodeExtractor] Convert some tests to opaque pointers (NFC)

22 months ago[CallSiteSplitting] Avoid branch on undef UB in test (NFC)
Nikita Popov [Tue, 3 Jan 2023 11:51:01 +0000 (12:51 +0100)]
[CallSiteSplitting] Avoid branch on undef UB in test (NFC)

22 months ago[Inline] Avoid branch on undef UB in tests (NFC)
Nikita Popov [Tue, 3 Jan 2023 11:44:01 +0000 (12:44 +0100)]
[Inline] Avoid branch on undef UB in tests (NFC)

22 months ago[mlir][transforms][NFC] Expand CanonicalizerPass documentation
Matthias Springer [Tue, 3 Jan 2023 10:48:38 +0000 (11:48 +0100)]
[mlir][transforms][NFC] Expand CanonicalizerPass documentation

Mention that canonicalization is best-effort and that pass pipelines should not rely on it for correctness.

RFC: https://discourse.llvm.org/t/rfc-canonicalizerpass-convergence-error-handling/67333

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

22 months ago[SimplifyCFG] Avoid branch on undef UB in test (NFC)
Nikita Popov [Tue, 3 Jan 2023 11:38:05 +0000 (12:38 +0100)]
[SimplifyCFG] Avoid branch on undef UB in test (NFC)

22 months ago[SLP][AArch64] Add fmuladd test coverage
Dinar Temirbulatov [Tue, 3 Jan 2023 11:28:18 +0000 (11:28 +0000)]
[SLP][AArch64] Add fmuladd test coverage

22 months ago[compiler-rt] XFAIL builtins unit tests on WoA
Muhammad Omair Javaid [Mon, 2 Jan 2023 19:26:18 +0000 (23:26 +0400)]
[compiler-rt] XFAIL builtins unit tests on WoA

Following tests are marked XFAIl because they are dependent on native
C complex numbers but they are not a native type for Microsoft ABI [1].

Builtins-aarch64-windows :: divmodti4_test.c
Builtins-aarch64-windows :: fixunstfdi_test.c
Builtins-aarch64-windows :: multc3_test.c

Also trampoline_setup_test.c as it runs with only non-clang compiler while
WoA LLVM buildbots use clang.

[1] https://learn.microsoft.com/en-us/cpp/c-runtime-library/complex-math-support?view=msvc-170

22 months ago[TypePromotion] Add truncate in ConvertTruncs when the original truncate type is...
chenglin.bi [Tue, 3 Jan 2023 10:12:15 +0000 (18:12 +0800)]
[TypePromotion] Add truncate in ConvertTruncs when the original truncate type is not extend type

If the src type is not extend type, after convert the truncate to and we need to truncate the and also to make sure the all user is legal.

The old fix D137613 doesn't work when the truncate convert to and have the other users. So this time I try to add the truncate after and to avoid all these potential issues.

Fix: #59554

Reviewed By: samparker

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

22 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)

22 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)

22 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.

22 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

22 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

22 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.

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

22 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

22 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.

22 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

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

22 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

22 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

22 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

22 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

22 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

22 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

22 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

22 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

22 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

22 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).

22 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.

22 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

22 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

22 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

22 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

22 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

22 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>
22 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

22 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

22 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

22 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

22 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

22 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.

22 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.

22 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.

22 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

22 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)

22 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.

22 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)

22 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)

22 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

22 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.

22 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.

22 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.

22 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

22 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.

22 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

22 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.

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

22 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.