platform/upstream/llvm.git
18 months ago[GlobalISel] New combine to commute constant operands to the RHS
Jay Foad [Tue, 3 Jan 2023 17:06:59 +0000 (17:06 +0000)]
[GlobalISel] New combine to commute constant operands to the RHS

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

18 months ago[LinkModulesTest] Convert to opaque pointers (NFC)
Nikita Popov [Thu, 5 Jan 2023 11:11:12 +0000 (12:11 +0100)]
[LinkModulesTest] Convert to opaque pointers (NFC)

This requires switching to the ssa.copy intrinsic, otherwise
we don't preserve test intent.

18 months agoUse --pass-pipeline syntax for mlir/test/Dialect/LLVMIR/canonicalize.mlir (NFC)
Mehdi Amini [Wed, 4 Jan 2023 21:52:39 +0000 (21:52 +0000)]
Use --pass-pipeline syntax for mlir/test/Dialect/LLVMIR/canonicalize.mlir (NFC)

This is just a cleanup to make the scheduling of the pass pipeline
explicit.

18 months ago[OperationsTest] Convert to opaque pointers (NFC)
Nikita Popov [Thu, 5 Jan 2023 10:14:31 +0000 (11:14 +0100)]
[OperationsTest] Convert to opaque pointers (NFC)

18 months ago[RandomIRBuilderTest] Convert to opaque pointers (NFC)
Nikita Popov [Thu, 5 Jan 2023 10:08:23 +0000 (11:08 +0100)]
[RandomIRBuilderTest] Convert to opaque pointers (NFC)

The FirstClassTypes test is no longer relevant with opaque pointers,
or at least not in that form.

18 months ago[CodeGenOpenCLCXX] Convert tests to opaque pointers (NFC)
Nikita Popov [Thu, 5 Jan 2023 09:59:37 +0000 (10:59 +0100)]
[CodeGenOpenCLCXX] Convert tests to opaque pointers (NFC)

18 months ago[libc][NFC] Use a function instead of templated static member functions for TYPE_DESC
Guillaume Chatelet [Wed, 4 Jan 2023 12:48:01 +0000 (12:48 +0000)]
[libc][NFC] Use a function instead of templated static member functions for TYPE_DESC

I'm surprised that clang accepts the current code.
It seems odd to me to specialize templated static member variables.

GCC rejects them: https://godbolt.org/z/3ecE9Ps7T

This patch is in the context of https://github.com/llvm/llvm-project/issues/59368

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

18 months agoApply clang-tidy fixes for performance-unnecessary-value-param in AffineCanonicalizat...
Mehdi Amini [Thu, 5 Jan 2023 00:58:52 +0000 (00:58 +0000)]
Apply clang-tidy fixes for performance-unnecessary-value-param in AffineCanonicalizationUtils.cpp (NFC)

18 months ago[CodeGenOpenCL] Convert some tests to opaque pointers (NFC)
Nikita Popov [Thu, 5 Jan 2023 09:57:30 +0000 (10:57 +0100)]
[CodeGenOpenCL] Convert some tests to opaque pointers (NFC)

18 months ago[AsmParserTest] Convert to opaque pointers (NFC)
Nikita Popov [Thu, 5 Jan 2023 09:53:37 +0000 (10:53 +0100)]
[AsmParserTest] Convert to opaque pointers (NFC)

18 months ago[IVDescriptorsTest] Convert to opaque pointers (NFC)
Nikita Popov [Thu, 5 Jan 2023 09:48:29 +0000 (10:48 +0100)]
[IVDescriptorsTest] Convert to opaque pointers (NFC)

The LoopWithScalableTypes test is removed, because it is testing
a situation that cannot occur with opaque pointers. If we convert
this test to opaque pointers, it will not contain any scalable
types at all.

18 months ago[Hexagon][VE][WebAssembly] Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros
Brad Smith [Thu, 5 Jan 2023 09:39:46 +0000 (04:39 -0500)]
[Hexagon][VE][WebAssembly] Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros

Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros

Reviewed By: kparzysz, aheejin, MaskRay

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

18 months ago[NFC][Coroutines] Build DominatorTree only once before collecting frame allocas ...
Dawid Jurczak [Sun, 1 Jan 2023 12:18:58 +0000 (13:18 +0100)]
[NFC][Coroutines] Build DominatorTree only once before collecting frame allocas (PR58650)

Assuming that collecting frame allocas doesn't modify CFG we can safely
move DominatorTree construction outside loop and avoid expensive computations.

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

18 months ago[GlobalISel] Add G_BUILD_VECTOR[_TRUNC] to CSE
Diana Picus [Wed, 4 Jan 2023 10:58:58 +0000 (11:58 +0100)]
[GlobalISel] Add G_BUILD_VECTOR[_TRUNC] to CSE

Add G_BUILD_VECTOR and G_BUILD_VECTOR_TRUNC to the list of opcodes in
`shouldCSEOpc`. This simplifies the code generated for vector splats.

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

18 months ago[GlobalISel] Don't switch opcodes in MIRBuilder::buildInstr
Diana Picus [Wed, 4 Jan 2023 10:59:49 +0000 (11:59 +0100)]
[GlobalISel] Don't switch opcodes in MIRBuilder::buildInstr

At the moment, `MachineIRBuilder::buildInstr` may build an instruction
with a different opcode than the one passed in as parameter. This may
cause confusion for its consumers, such as `CSEMIRBuilder`, which will
memoize the instruction based on the new opcode, but will search
through the memoized instructions based on the original one (resulting
in missed CSE opportunities). This is all the more unpleasant since
buildInstr is virtual and may call itself recursively both directly
and via buildCast, so it's not always easy to follow what's going on.

This patch simplifies the API of `MachineIRBuilder` so that the `buildInstr`
method does the least surprising thing (i.e. builds an instruction with
the specified opcode) and only the convenience `buildX` methods
(`buildMerge` etc) are allowed freedom over which opcode to use. This can
still be confusing (e.g. one might write a unit test using
`buildBuildVectorTrunc` but instead get a plain `G_BUILD_VECTOR`), but at
least it's explained in the comments.

In practice, this boils down to 3 changes:
* `buildInstr(G_MERGE_VALUES)` will no longer call itself with
`G_BUILD_VECTOR` or `G_CONCAT_VECTORS`; this functionality is moved to
`buildMerge` and replaced with an assert;
* `buildInstr(G_BUILD_VECTOR_TRUNC)` will no longer call itself with
`G_BUILD_VECTOR`; this functionality is moved to `buildBuildVectorTrunc`
and replaced with an assert;
* `buildInstr(G_MERGE_VALUES)` will no longer call `buildCast` and will
instead assert if we're trying to merge a single value; no change is
needed in `buildMerge` since it was already asserting more than one
source operand.

This change is NFC for users of the `buildX` methods, but users that
call `buildInstr` with relaxed parameters will have to update their code
(such instances will hopefully be easy to find thanks to the asserts).

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

18 months ago[GlobalISel] Precommit a test for D140965
Diana Picus [Wed, 4 Jan 2023 13:15:31 +0000 (14:15 +0100)]
[GlobalISel] Precommit a test for D140965

Add a test for CSE-ing G_BUILD_VECTOR. This will be enabled in D140965.

18 months ago[NVPTX] Fix NVPTX lowering of frem when denominator is infinite.
Benjamin Chetioui [Thu, 5 Jan 2023 08:26:13 +0000 (09:26 +0100)]
[NVPTX] Fix NVPTX lowering of frem when denominator is infinite.

`frem x, {+,-}inf` must return x to match the specification of LLVM's frem.

Reviewed By: tra

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

18 months agoIntroduce environment variables to deal with JIT IR
Johannes Doerfert [Wed, 28 Dec 2022 07:50:42 +0000 (23:50 -0800)]
Introduce environment variables to deal with JIT IR

We can now dump the IR before and after JIT optimizations into the
files passed via `LIBOMPTARGET_JIT_PRE_OPT_IR_MODULE` and
`LIBOMPTARGET_JIT_POST_OPT_IR_MODULE`, respectively.

Similarly, users can set `LIBOMPTARGET_JIT_REPLACEMENT_MODULE` to
replace the IR in the image with a custom IR module in a file.
All options take file paths, documentation was added.

Reviewed by: tianshilei1992

Differential revision: https://reviews.llvm.org/D140945

18 months ago[LoopUnrollAndJam] Visit phi operand dependencies in post-order
Joshua Cao [Fri, 16 Dec 2022 09:00:56 +0000 (04:00 -0500)]
[LoopUnrollAndJam] Visit phi operand dependencies in post-order

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

The previous implementation visits operands in pre-order, but this does
not guarantee an instruction is visited before its uses. This can cause
instructions to be copied in the incorrect order. For example:

```
a = ...
b = add a, 1
c = add a, b
d = add b, a
```

Pre-order visits does not guarantee the order in which `a` and `b` are
visited. LoopUnrollAndJam may incorrectly insert `b` before `a`.

This patch implements post-order visits. By visiting dependencies first,
we guarantee that an instruction's dependencies are visited first.

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

18 months ago1: use class instead of MVT
Chen Zheng [Thu, 5 Jan 2023 07:53:59 +0000 (07:53 +0000)]
1: use class instead of MVT
2: minor fix for the comments

18 months ago[PowerPC][GISel]fcmp support
Chen Zheng [Tue, 3 Jan 2023 09:44:03 +0000 (09:44 +0000)]
[PowerPC][GISel]fcmp support

This patch also includes:
1: CRRegBank support
2: Some workarounds in PPC table gen for anyext/setcc patterns
   selection.

Reviewed By: arsenm

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

18 months ago[InstCombine][NFC] Regenerate test cases by update_test_checks.py
luxufan [Thu, 5 Jan 2023 06:38:08 +0000 (14:38 +0800)]
[InstCombine][NFC] Regenerate test cases by update_test_checks.py

18 months ago[InstCombine][NFC] Regenerate test cases by update_test_checks.py
luxufan [Thu, 5 Jan 2023 06:20:41 +0000 (14:20 +0800)]
[InstCombine][NFC] Regenerate test cases by update_test_checks.py

18 months ago[lldb] Remove unneeded .get() NFC
Fangrui Song [Thu, 5 Jan 2023 06:05:40 +0000 (22:05 -0800)]
[lldb] Remove unneeded .get() NFC

18 months ago[ObjC][ARC] Fix non-deterministic behavior in ProvenanceAnalysis
Akira Hatanaka [Thu, 5 Jan 2023 02:29:39 +0000 (18:29 -0800)]
[ObjC][ARC] Fix non-deterministic behavior in ProvenanceAnalysis

If the second value passed to relatedSelect is a select, check whether
neither arm of the select is related to the first value.

18 months ago[Instcombine] fold logic ops to select
chenglin.bi [Thu, 5 Jan 2023 03:03:42 +0000 (11:03 +0800)]
[Instcombine] fold logic ops to select

(C & X) | ~(C | Y) -> C ? X : ~Y

https://alive2.llvm.org/ce/z/4yLh_i

Reviewed By: spatel

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

18 months ago[LoopUnrollAndJam] Forget scalar evolution dispositions. Do no explicitly forget...
Joshua Cao [Wed, 4 Jan 2023 06:37:36 +0000 (22:37 -0800)]
[LoopUnrollAndJam] Forget scalar evolution dispositions. Do no explicitly forget subloop.

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

Scalar evolution dispositions need to be forgotten to pass verification.

We do not need to forget the subloop since it is automatically forgotten
when forgetting the parent loop.

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

18 months ago[RISCV][NFC] Update RISCVUsage.rst for Svnapot extension
Piyou Chen [Thu, 5 Jan 2023 02:44:18 +0000 (18:44 -0800)]
[RISCV][NFC] Update RISCVUsage.rst for Svnapot extension

Note: Support Svnapot extension in https://reviews.llvm.org/D136570

Reviewed By: kito-cheng

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

18 months ago[TargetLowering] Remove stale FIXME. NFC
Craig Topper [Thu, 5 Jan 2023 02:40:30 +0000 (18:40 -0800)]
[TargetLowering] Remove stale FIXME. NFC

This was implemented for scalars in D140750.

18 months ago[mlir][sparse] Add AOS optimization.
bixia1 [Wed, 4 Jan 2023 21:08:06 +0000 (13:08 -0800)]
[mlir][sparse] Add AOS optimization.

Use an array of structures to represent the indices for the tailing COO region
of a sparse tensor.

Reviewed By: aartbik

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

18 months agoRevert "[gn] port f29cfab55d1f"
Nico Weber [Thu, 5 Jan 2023 02:01:30 +0000 (21:01 -0500)]
Revert "[gn] port f29cfab55d1f"

This reverts commit 199563534a2fc38f72fa93c4fdd03221afe06996.
f29cfab55d1fd80 was reverted in c6c54132b76.

18 months agoamdgpu-arch: Prefer hsa/hsa.h over hsa.h
Matt Arsenault [Wed, 4 Jan 2023 21:35:59 +0000 (16:35 -0500)]
amdgpu-arch: Prefer hsa/hsa.h over hsa.h

The header now prints a warning if you include hsa.h telling you to
include hsa/hsa.h

18 months agoAMDGPU: Set scratch_en if there is dynamic stack but no fixed stack
Matt Arsenault [Wed, 4 Jan 2023 20:17:54 +0000 (15:17 -0500)]
AMDGPU: Set scratch_en if there is dynamic stack but no fixed stack

18 months agoRevert "[InlineAdvisor] Restructure advisor plugin unittest cmake"
Jake Egan [Thu, 5 Jan 2023 01:39:19 +0000 (20:39 -0500)]
Revert "[InlineAdvisor] Restructure advisor plugin unittest cmake"

This reverts commit f29cfab55d1fd806f827b832832b196c10558680.

18 months ago[NFC][Clang][ASTTests] Use ASSERT instead of EXPECT for nullptr checks
Michael Spencer [Thu, 5 Jan 2023 01:32:12 +0000 (17:32 -0800)]
[NFC][Clang][ASTTests] Use ASSERT instead of EXPECT for nullptr checks

This avoids basically guaranteed crashes when the check fails.

18 months agoRevert "[-Wunsafe-buffer-usage] Add a new `forEachDescendant` matcher that skips...
Ziqing Luo [Thu, 5 Jan 2023 01:16:21 +0000 (17:16 -0800)]
Revert "[-Wunsafe-buffer-usage] Add a new `forEachDescendant` matcher that skips callable declarations"

This reverts commit b2ac5fd724c44cf662caed84bd8f84af574b981d.

18 months ago[-Wunsafe-buffer-usage] Add an unsafe gadget for pointer-arithmetic operations
Ziqing Luo [Thu, 5 Jan 2023 00:48:55 +0000 (16:48 -0800)]
[-Wunsafe-buffer-usage] Add an unsafe gadget for pointer-arithmetic operations

For -Wunsafe-buffer-usage diagnostics, we want to warn about pointer
arithmetics since resulting pointers can be used to access buffers.
Therefore, I add an `UnsafeGadget` representing general pointer
arithmetic operations.

Reviewed by: NoQ
Differential revision: https://reviews.llvm.org/D139233

18 months agoFix typeo in LoadBinariesViaExhaustiveSearch when looking for kernel
Jason Molenda [Thu, 5 Jan 2023 00:08:58 +0000 (16:08 -0800)]
Fix typeo in LoadBinariesViaExhaustiveSearch when looking for kernel

As a last resort, with a Mach-O corefile, lldb will iterate through
all memory segments looking for a dyld binary (for a userland process
core dump) or an xnu kernel binary (kernel coredump).  We often
have metadata via LC_NOTEs so this final search mechanism is not
needed.  During the rewrite in https://reviews.llvm.org/D133680 I
did not handle the case of finding the xnu kernel by exhaustive
search correctly.

rdar://103813200

18 months ago[-Wunsafe-buffer-usage] Add a new `forEachDescendant` matcher that skips callable...
Ziqing Luo [Wed, 4 Jan 2023 23:51:56 +0000 (15:51 -0800)]
[-Wunsafe-buffer-usage] Add a new `forEachDescendant` matcher that skips callable declarations

Note this is a change local to -Wunsafe-buffer-usage checks.

Add a new matcher `forEveryDescendant` that recursively matches
descendants of a `Stmt` but skips nested callable definitions.  This
matcher has same effect as using `forEachDescendant` and skipping
`forCallable` explicitly but does not require the AST construction to be
complete.

Reviewed by: NoQ, xazax.hun

Differential revision: https://reviews.llvm.org/D138329

18 months agoFix a phase-ordering problem in SimplifyCFG.
Owen Anderson [Mon, 2 Jan 2023 01:17:19 +0000 (18:17 -0700)]
Fix a phase-ordering problem in SimplifyCFG.

Switch simplification could sometimes fail to notice when an
intermediate case removal caused the switch condition to become
constant. This would cause the switch to be simplified into a
conditional branch rather than a direct branch.

Most of the time this didn't matter, except that occasionally
downstream parts of SimplifyCFG expect tautological branches to
already have been eliminated. The missed handling in switch
simplification would cause an assertion failure in the downstream
code.

Triggering the assertion failure is fairly sensitive to the exact
order of various simplifications.

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

Reviewed By: nikic

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

18 months ago[libcxx][test] fix allocator in allocator_propagation test
Casey Carter [Wed, 3 Aug 2022 16:44:18 +0000 (09:44 -0700)]
[libcxx][test] fix allocator in allocator_propagation test

The converting constructor is ill-formed, and `==` is missing. (I didn't implement `!=` since the test is C++20-and-later only; I'll let the compiler do it for us.)

Drive-by: change 4-space indent on line 27 to 2-space indent to be consistent with the rest of the test.
Differential Revision: https://reviews.llvm.org/D131079

18 months ago[Support][SelectionDAG][GlobalISel] Hoist PostShift adjustment for IsAdd into Unsigne...
Craig Topper [Wed, 4 Jan 2023 22:17:56 +0000 (14:17 -0800)]
[Support][SelectionDAG][GlobalISel] Hoist PostShift adjustment for IsAdd into UnsignedDivideUsingMagic.

Instead of doing the adjustment in 3 different places in the code
base, do it inside UnsignedDivideUsingMagic::get.

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

18 months ago[mlir][tosa] Remove clamping behavior in `tosa.cast` for integer truncation
mariecwhite [Wed, 4 Jan 2023 22:56:45 +0000 (14:56 -0800)]
[mlir][tosa] Remove clamping behavior in `tosa.cast` for integer truncation

Reviewed By: rsuderman

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

18 months ago[clang] Revert parentesized aggregate initalization patches
Alan Zhao [Wed, 4 Jan 2023 22:54:55 +0000 (14:54 -0800)]
[clang] Revert parentesized aggregate initalization patches

This feature causes clang to crash when compiling Chrome - see
https://crbug.com/1405031 and
https://github.com/llvm/llvm-project/issues/59675

Revert "[clang] Fix a clang crash on invalid code in C++20 mode."

This reverts commit 32d7aae04fdb58e65a952f281ff2f2c3f396d98f.

Revert "[clang] Remove overly restrictive aggregate paren init logic"

This reverts commit c77a91bb7ba793ec3a6a5da3743ed55056291658.

Revert "[clang][C++20] P0960R3 and P1975R0: Allow initializing aggregates from a parenthesized list of values"

This reverts commit 40c52159d3ee337dbed14e4c73b5616ea354c337.

18 months ago[dsymutil] Avoid invalid keep chains due to pruning
Jonas Devlieghere [Wed, 4 Jan 2023 23:01:19 +0000 (15:01 -0800)]
[dsymutil] Avoid invalid keep chains due to pruning

The pruning property that's part of the DIE info is fully computing
during the analyzeContextInfo phase, but can be updated during the
lookForDIEsToKeep phase.

  // Keep a module forward declaration if there is no definition.
  if (!(isODRAttribute(AttrSpec.Attr) && Info.Ctxt &&
        Info.Ctxt->hasCanonicalDIE()))
    Info.Prune = false;

When the pruning property is updated during the lookForDIEsToKeep phase,
it's not propagated to the parent, unlike during the analyzeContextInfo
phase. This can result in an invalid keep chain with the child DIE being
marked as kept while its parent is still marked as pruned and therefore
never kept, a situation that's now caught by 1b79bed8f532.

This patch fixes this issue by updating the pruning properties of the
parent DIE during the parent walk.

Differential revision: https://reviews.llvm.org/D140930

18 months ago[DWARFLinker] Clean up analyzeContextInfo signature (NFC)
Jonas Devlieghere [Tue, 3 Jan 2023 19:22:29 +0000 (11:22 -0800)]
[DWARFLinker] Clean up analyzeContextInfo signature (NFC)

 - Remove always-false flag.
 - Remove unused return value.

18 months ago[NFCI][DAGCombiner] `foldExtendVectorInregToExtendOfSubvector()`: just build new VT
Roman Lebedev [Wed, 4 Jan 2023 22:29:12 +0000 (01:29 +0300)]
[NFCI][DAGCombiner] `foldExtendVectorInregToExtendOfSubvector()`: just build new VT

Changing element type seems to not play well with non-simple types,
even though we are operating on EVT's here.

18 months ago[DAGCombiner] Do try to combine `ISD::ANY_EXTEND_VECTOR_INREG` nodes
Roman Lebedev [Wed, 4 Jan 2023 21:22:50 +0000 (00:22 +0300)]
[DAGCombiner] Do try to combine `ISD::ANY_EXTEND_VECTOR_INREG` nodes

These weren't previously getting combined at all here,
only in target-specific combines.

18 months ago[DAGCombiner] Fold *_EXTEND_INREG of one of CONCAT_VECTORS operands into *_EXTEND...
Roman Lebedev [Wed, 4 Jan 2023 21:07:38 +0000 (00:07 +0300)]
[DAGCombiner] Fold *_EXTEND_INREG of one of CONCAT_VECTORS operands into *_EXTEND of operand

This appears to be the root problematic pattern
for AArch64 regression in D140677.

We already do this, and many more, as target-specific X86 combines,
so this isn't causing much of an impact.

18 months ago[NFC][AArch64] Add some tests for upcoming patch
Roman Lebedev [Wed, 4 Jan 2023 21:51:28 +0000 (00:51 +0300)]
[NFC][AArch64] Add some tests for upcoming patch

18 months ago[NFC][DAG] Move `getOpcode_EXTEND*()` helpers from X86 into SelectionDAG
Roman Lebedev [Wed, 4 Jan 2023 21:06:41 +0000 (00:06 +0300)]
[NFC][DAG] Move `getOpcode_EXTEND*()` helpers from X86 into SelectionDAG

To be used in an upcoming patch.

18 months ago[NFC][X86] Make vec_anyext.ll test non-useless
Roman Lebedev [Wed, 4 Jan 2023 20:06:20 +0000 (23:06 +0300)]
[NFC][X86] Make vec_anyext.ll test non-useless

18 months ago[MLIR][TOSA] Switch Tosa_IntArrayAttr[N], Tosa_IntArrayAttrUpto[N] to DenseI64ArrayAttr
Alexander Shaposhnikov [Wed, 4 Jan 2023 21:50:46 +0000 (21:50 +0000)]
[MLIR][TOSA] Switch Tosa_IntArrayAttr[N], Tosa_IntArrayAttrUpto[N] to DenseI64ArrayAttr

Switch Tosa_IntArrayAttr[N], Tosa_IntArrayAttrUpto[N] to DenseI64ArrayAttr.

Test plan: ninja check-mlir check-all

Differential revision: https://reviews.llvm.org/D140748 https://reviews.llvm.org/D140829, https://reviews.llvm.org/D140832, https://reviews.llvm.org/D140833, https://reviews.llvm.org/D140834

18 months agoDon't read off end of GPR register array to access fp/sp/lr/pc
Jason Molenda [Wed, 4 Jan 2023 21:48:10 +0000 (13:48 -0800)]
Don't read off end of GPR register array to access fp/sp/lr/pc

The arm64 register context on Darwin has the 29 general purpose
registers, then pc/sp/lr/fp with different field names depending
on compile-time flags.  Instead of accessing beyond the end of
the uint64_t[29] array, and upsetting the sanitizers, access those
registers correctly with the correct name.

Fixes a test failure on the ASAN CI bot, currently being
skipped, in TestEarlyProcessLaunch.py.

Differential Revision: https://reviews.llvm.org/D140067
rdar://103359354

18 months ago[DWARF] Store CFA value on DW_CFA_remember_state
Alexis Engelke [Wed, 4 Jan 2023 21:51:14 +0000 (13:51 -0800)]
[DWARF] Store CFA value on DW_CFA_remember_state

Previously, CFA_remember_state stored only the register locations but ignored the CFA value. This needs also to be remembered and restored for correct behavior. The problem occurs, e.g., on functions with multiple epilogues, where the CFA value after the first epilogue is becomes wrong.

Reviewed By: #debug-info, MaskRay

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

18 months agoRevert "[VPlan] Also consider operands of sink candidates in same block."
Augie Fackler [Wed, 4 Jan 2023 21:17:13 +0000 (16:17 -0500)]
Revert "[VPlan] Also consider operands of sink candidates in same block."

This reverts commit aa2414729ebbcb2d8f162e9002a3a6aa768b1f9d.

Previously-valid IR from a tensorflow test case (as shown on the
Diffusion revision for aa2414729ebbcb2d8f162e9002a3a6aa768b1f9d) started
hanging in the loop-vectorize pass. Reverting to keep everyone working.

18 months ago[SLP]Fix incorrect shuffle results because of missing shuffle mask
Alexey Bataev [Wed, 4 Jan 2023 16:32:25 +0000 (08:32 -0800)]
[SLP]Fix incorrect shuffle results because of missing shuffle mask
analysis.

Missed the analysis of the shuffle mask when trying to analyze the
operands of the shuffle instruction during peeking through shuffle
instructions.

18 months ago[MLIR][Tensor] Canonicalize expand/collapse_shape of splat to splat
liqinweng [Wed, 4 Jan 2023 21:05:57 +0000 (13:05 -0800)]
[MLIR][Tensor] Canonicalize expand/collapse_shape of splat to splat

Collapsing / expanding a splatted value can be replaced with a single `tensor.splat` operation. Replace
these cases with a simple `tensor.splat` operation.

Reviewed By: rsuderman

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

18 months ago[mlir][sparse] Move some member functions from SparseTensorDescriptorImpl to MutSpars...
bixia1 [Wed, 4 Jan 2023 19:35:45 +0000 (11:35 -0800)]
[mlir][sparse] Move some member functions from SparseTensorDescriptorImpl to MutSparseTensorDescriptor.

This is to prepare for implementing AOS optimization.

Reviewed By: aartbik

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

18 months agoApply clang-tidy fixes for llvm-else-after-return in GPUToSPIRV.cpp (NFC)
Mehdi Amini [Tue, 3 Jan 2023 11:12:42 +0000 (11:12 +0000)]
Apply clang-tidy fixes for llvm-else-after-return in GPUToSPIRV.cpp (NFC)

18 months ago[mlir][tosa] Fix floating point offset for tosa.resize
Robert Walker [Wed, 4 Jan 2023 19:26:12 +0000 (11:26 -0800)]
[mlir][tosa] Fix floating point offset for tosa.resize

Offset is a signed value, so use `arith.sitofp`

See also https://github.com/llvm/llvm-project/issues/59585

Reviewed By: NatashaKnk, jpienaar

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

18 months agoRevert "[Sema] Don't mark deleted special member functions as non-trivial"
Roy Jacobson [Wed, 4 Jan 2023 20:39:04 +0000 (22:39 +0200)]
Revert "[Sema] Don't mark deleted special member functions as non-trivial"

This reverts commit d5dd37ac139a74701e16f084eb2609ff58893770.

Apparently there's some ABI difference in the Sony builder that fails a test.
Will hopefully investigate tomorrow. https://lab.llvm.org/buildbot/#/builders/139/builds/33769

18 months ago[LowerTypeTests] Add ENDBR to .cfi.jumptable for x86 Indirect Branch Tracking
Fangrui Song [Wed, 4 Jan 2023 20:28:07 +0000 (12:28 -0800)]
[LowerTypeTests] Add ENDBR to .cfi.jumptable for x86 Indirect Branch Tracking

Similar to D81251 for AArch64 BTI. This fixes `./a.out test` for

```
void foo(void) {}
void bar(void) {}
static void (*fptr)(void);
int main(int argc, char **argv) {
  if (argv[1]) fptr = foo;
  else fptr = bar;
  fptr();
}
```

`clang -flto=thin -fvisibility=hidden -fsanitize=cfi-icall -fcf-protection=branch -fuse-ld=lld a.cc`

Reviewed By: tejohnson

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

18 months ago[X86] Regen a couple tests so they are autogen clean [nfc]
Philip Reames [Wed, 4 Jan 2023 20:08:59 +0000 (12:08 -0800)]
[X86] Regen a couple tests so they are autogen clean [nfc]

These appear to have had 32 bit check lines manually deleted - presumably since the checks are verbose.  Please don't do this!  Split the test file if you want, but manually deleting test lines makes the diffs for later autogen changes really confusing.

18 months ago[mlir][sparse] add test that combines sparse codegen and lowering to llvm struct
Aart Bik [Wed, 4 Jan 2023 19:33:51 +0000 (11:33 -0800)]
[mlir][sparse] add test that combines sparse codegen and lowering to llvm struct

Reviewed By: bixia

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

18 months ago[sanitizer] Move {,__}pthread_mutex_{lock,unlock} interceptors to tsan
Fangrui Song [Wed, 4 Jan 2023 20:04:19 +0000 (12:04 -0800)]
[sanitizer] Move {,__}pthread_mutex_{lock,unlock} interceptors to tsan

These interceptors are pure forwarders for other sanitizers. Move them beside
tsan-specific pthread_mutex_{trylock,timedlock} interceptors.

While here, guard `__pthread_mutex_{lock,unlock}` (D46793) under `#if !__GLIBC_PREREQ(2, 34)`.

In glibc>=2.34 [1], `__pthread_mutex_{lock,unlock}` only have non-default-version definitions
(unversioned `__pthread_mutex_lock` causes a linker error. Program preloading is not expected).
In glibc>=2.36 [2], `dlsym(RTLD_NEXT, "__pthread_mutex_lock")` returns nullptr, so the interceptor won't work.

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

[1]: https://sourceware.org/git/?p=glibc.git;a=commit;h=99f841c441feeaa9a3d97fd91bb3d6ec8073c982
[2]: https://sourceware.org/git/?p=glibc.git;a=commit;h=efa7936e4c91b1c260d03614bb26858fbb8a0204

Reviewed By: melver, vitalybuka

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

18 months ago[llvm][CUDA] Allow NVVMREflect to process OpenCL-specific __nvvm_reflect_ocl()
Hugh Delaney [Wed, 4 Jan 2023 19:52:08 +0000 (11:52 -0800)]
[llvm][CUDA] Allow NVVMREflect to process OpenCL-specific __nvvm_reflect_ocl()

OpenCL requires constant string arguments to be in a particular address space,
so OpenCL sources can't use the regular `__nvvm_reflect()`.

Allow NVVMReflect pass to accept an Open_CL specific variant with a constant
string in a non-default address space.

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

18 months ago[X86] Autogen tests for ease of update in upcoming change [nfc]
Philip Reames [Wed, 4 Jan 2023 19:59:05 +0000 (11:59 -0800)]
[X86] Autogen tests for ease of update in upcoming change [nfc]

18 months agollvm-objdump: Fix --build-id documentation string
Roland McGrath [Wed, 4 Jan 2023 19:39:51 +0000 (11:39 -0800)]
llvm-objdump: Fix --build-id documentation string

The argument is hex digits, so <dir> doesn't make a lot of sense.

Reviewed By: phosek

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

18 months agoRevert "[clang] Add the check of membership in decltype for the issue #58674#"
Erich Keane [Wed, 4 Jan 2023 19:43:40 +0000 (11:43 -0800)]
Revert "[clang] Add the check of membership in decltype for the issue #58674#"

This reverts commit 85960043d594fc12d340ccb66a30861b023ab496.

The powerpc64le self-built buildbot had an assertion during self-build,
that seems like it is possibly related here, reverting so the author can
take a look.

18 months ago[DAG] `tryToFoldExtendOfConstant()`: `sext undef` is not `undef`
Roman Lebedev [Wed, 4 Jan 2023 19:31:33 +0000 (22:31 +0300)]
[DAG] `tryToFoldExtendOfConstant()`: `sext undef` is not `undef`

https://alive2.llvm.org/ce/z/cLGpWV, but https://alive2.llvm.org/ce/z/TGNH4P

18 months ago[X86] Autogen tests for ease of update in upcoming change [nfc]
Philip Reames [Wed, 4 Jan 2023 19:30:42 +0000 (11:30 -0800)]
[X86] Autogen tests for ease of update in upcoming change [nfc]

18 months ago[Sema] Don't mark deleted special member functions as non-trivial
Roy Jacobson [Sun, 25 Dec 2022 21:48:13 +0000 (23:48 +0200)]
[Sema] Don't mark deleted special member functions as non-trivial

As noted in https://github.com/llvm/llvm-project/issues/59624, we sometimes mark implicitly
deleted special member functions as non-trivial. This is unnecessary work and leads to some
weird type traits errors.

This fixes the problem by making the implicitly deleted special member functions always
trivial.

Reviewed By: #clang-language-wg, erichkeane

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

18 months ago[mlir][spirv] Relax instruction order checks in test
Jakub Kuderski [Wed, 4 Jan 2023 19:06:47 +0000 (14:06 -0500)]
[mlir][spirv] Relax instruction order checks in test

Fix a windows buildbot failure: https://lab.llvm.org/buildbot#builders/13/builds/30439.

18 months ago[PowerPC] Materialize floats in the range [-16.0, 15.0].
Stefan Pintilie [Wed, 21 Dec 2022 14:47:55 +0000 (08:47 -0600)]
[PowerPC] Materialize floats in the range [-16.0, 15.0].

Previous to this patch we only materialized 0.0 and all other floating point
values would be loaded from the TOC. This patch adds materialization for the
floating point values that can be represented as integers in [-16.0, 15.0].

For example we will now materialize 3.0 and -5.0 but not 4.7.

Reviewed By: nemanjai, lei, #powerpc

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

18 months ago[MachineCombine] Reorganize code for readability and tracing [nfc]
Philip Reames [Wed, 4 Jan 2023 18:45:56 +0000 (10:45 -0800)]
[MachineCombine] Reorganize code for readability and tracing [nfc]

18 months ago[SLP][NFC]Add a pass.
Alexey Bataev [Wed, 4 Jan 2023 18:26:53 +0000 (10:26 -0800)]
[SLP][NFC]Add a pass.

18 months ago[mlir][spirv] Add pattern to expand UMulExtended for WebGPU
Jakub Kuderski [Wed, 4 Jan 2023 18:29:46 +0000 (13:29 -0500)]
[mlir][spirv] Add pattern to expand UMulExtended for WebGPU

This is needed because WGSL does not yet support extended multiplication
ops.

Set up pattern/pass stuff and handle the first op: `UMulExtended`.
`SMulExtended` handling will go to a separate patch.

Issue: https://github.com/llvm/llvm-project/issues/59563

Reviewed By: antiagainst

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

18 months ago[SLP][NFC]Add a test for incorrect skipping of shuffle instruction at
Alexey Bataev [Wed, 4 Jan 2023 18:11:47 +0000 (10:11 -0800)]
[SLP][NFC]Add a test for incorrect skipping of shuffle instruction at
peek-through-shuffles, NFC.

18 months ago[exegesis] Analysis: filtering for benchmark results
Roman Lebedev [Wed, 4 Jan 2023 18:13:48 +0000 (21:13 +0300)]
[exegesis] Analysis: filtering for benchmark results

By default, all benchmark results are analysed, but sometimes it may be useful
to only look at those that to not involve memory, or vice versa. This option
allows to either keep all benchmarks, or filter out (ignore) either all the
ones that do involve memory (involve instructions that may read or write to
memory), or the opposite, to only keep such benchmarks.

Personally, so far i have found the benchmarks that do involve memory
to have dubious results. But the ones that do not involve memory,
are generally actionable. So i would like to have a toggle to declutter results.

Reviewed By: courbet

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

18 months ago[Codegen][X86] `LowerBUILD_VECTOR()`: improve lowering w/ multiple FREEZE-UNDEF ops
Roman Lebedev [Wed, 4 Jan 2023 17:43:42 +0000 (20:43 +0300)]
[Codegen][X86] `LowerBUILD_VECTOR()`: improve lowering w/ multiple FREEZE-UNDEF ops

While we have great handling for UNDEF operands,
FREEZE-UNDEF operands are effectively normal operands.

We are better off "interleaving" such BUILD_VECTORS into a blend
between a splat of FREEZE-UNDEF, and "thawed" source BUILD_VECTOR,
both of which are more natural for us to handle.

Refs. https://github.com/llvm/llvm-project/commit/f738ab9075f838dd4365adf3a92ca1acced114d7#r95017306

18 months ago[NFC][X86] Add few more tests for freezing BUILD_VECTOR
Roman Lebedev [Wed, 4 Jan 2023 17:34:24 +0000 (20:34 +0300)]
[NFC][X86] Add few more tests for freezing BUILD_VECTOR

18 months ago[OpenMP][JIT] Introduce support for AMDGPU
Johannes Doerfert [Wed, 28 Dec 2022 06:31:28 +0000 (22:31 -0800)]
[OpenMP][JIT] Introduce support for AMDGPU

To JIT kernels for AMDGPUs we need to provide the architecture, the
triple, and a post-link callback. The first two are simple, the last one
is a little more complicated since we need to invoke `lld`. There is
some library interface but for that we need the lld library, which is
not generally available, thus we go with the executable for now. In
either way we need to manifest the (amdgcn) object file and read the
output from another file. We should try to avoid that in the future.
The options for `lld` are copied from the way clang invokes it.

Reviewed By: tianshilei1992

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

18 months ago[InstCombine] don't let 'exact' inhibit demanded bits folds for udiv
Sanjay Patel [Wed, 4 Jan 2023 17:43:30 +0000 (12:43 -0500)]
[InstCombine] don't let 'exact' inhibit demanded bits folds for udiv

We shouldn't penalize instructions that have extra flags.

Drop the poison-generating flags if needed instead of bailing out.
This makes canonicalization/optimization more uniform.

There is a chance that dropping flags will cause some
other transform to not fire, but we added a preliminary
patch to avoid that with:
f0faea571403

See D140665 for more details.

18 months ago[SelectionDAG][GlobalISel] Don't use UnsignedDivisionByConstantInfo for divisor of 1.
Craig Topper [Wed, 4 Jan 2023 02:36:14 +0000 (18:36 -0800)]
[SelectionDAG][GlobalISel] Don't use UnsignedDivisionByConstantInfo for divisor of 1.

The magic algorithm sets IsAdd indication for division by 1 that
the caller had to ignore.

I considered folding the ignore into UnsignedDivisionByConstantInfo,
but we only allow 1 for vectors of mixed visiors. And really what we
want to end up with is undef. Currently, we get to undef via
DemandedElts optimizations using the select instruction. We could
directly emit undef.

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

18 months ago[ConstraintElim] Enable pass by default.
Florian Hahn [Wed, 4 Jan 2023 18:00:36 +0000 (18:00 +0000)]
[ConstraintElim] Enable pass by default.

The pass should help to close a functional gap when it comes to
reasoning about related conditions in a relatively general way.

It addresses multiple existing issues (linked below) and the need for a
more powerful reasoning system was also discussed recently in
https://discourse.llvm.org/t/rfc-alternative-approach-of-dealing-with-implications-from-comparisons-through-pos-analysis/65601/7

On AArch64, the new pass performs ~2000 simplifications on
MultiSource,SPEC2006,SPEC2017 with -O3.

Compile-time impact:

NewPM-O3: +0.20%
NewPM-ReleaseThinLTO: +0.32%
NewPM-ReleaseLTO-g: +0.28%

https://llvm-compile-time-tracker.com/compare.php?from=f01a3a893c147c1594b9a3fbd817456b209dabbf&to=577688758ef64fb044215ec3e497ea901bb2db28&stat=instructions:u

Fixes #49344.
Fixes #47888.
Fixes #48253.
Fixes #49229.
Fixes #58074.

Reviewed By: asbirlea

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

18 months ago[mlir][sparse] minor code layout edits
Aart Bik [Wed, 4 Jan 2023 02:06:54 +0000 (18:06 -0800)]
[mlir][sparse] minor code layout edits

Reviewed By: bixia

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

18 months ago[AMDGPU] Unify divergent nodes if the PostDom tree has one root
Anshil Gandhi [Wed, 4 Jan 2023 17:10:40 +0000 (10:10 -0700)]
[AMDGPU] Unify divergent nodes if the PostDom tree has one root

This patch allows AMDGPUUnifyDivergenceExitNodes pass
to transform a function whose PDT has exactly one root
and ends in a branch instruction. Fixes
https://github.com/llvm/llvm-project/issues/58861.

Reviewed By: ruiling, arsenm

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

18 months ago[lld-macho][nfc] Re-enable previously disabled test.
Vy Nguyen [Wed, 4 Jan 2023 14:43:34 +0000 (09:43 -0500)]
[lld-macho][nfc] Re-enable previously disabled test.

This check was previous disabled because the test kept failing on ARM64. The output from reported failure message
gave the impression that the bundle was created as an x86-64 bundle but upon further inspection, I believe that's
a bug in llvm-otool where it prints both -h and -f for both input files on ARM64.

So the "fix" here is to rewrite the test to run the two otool commands separately but concatenate the
output into one file for checking.

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

18 months ago[NFC] Update parseDimensionList comments for dynamic size from -1 to kDynamic
Kevin Gleason [Wed, 4 Jan 2023 17:09:27 +0000 (18:09 +0100)]
[NFC] Update parseDimensionList comments for dynamic size from -1 to kDynamic

Comment is stale now that kDynamic is defined as intmin instead of -1.

Confirmed that implementation in `parseDimensionListRanked` uses kDynamic.

Reviewed By: ftynse

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

18 months agoFix to D140567
Blue Gaston [Wed, 4 Jan 2023 16:49:34 +0000 (09:49 -0700)]
Fix to D140567

18 months ago[NFC] Autogenerate CodeGen/X86/sdiv-pow2.ll
Amaury Séchet [Wed, 4 Jan 2023 16:43:47 +0000 (16:43 +0000)]
[NFC] Autogenerate CodeGen/X86/sdiv-pow2.ll

18 months agoIROutliner: Fix assert with non-0 alloca addrspace
Matt Arsenault [Wed, 4 Jan 2023 16:07:34 +0000 (11:07 -0500)]
IROutliner: Fix assert with non-0 alloca addrspace

The arguments are passed as stored to new allocas so the address space
needs to match.

18 months ago[LoopVectorize] Convert some tests to opaque pointers (NFC)
Nikita Popov [Wed, 4 Jan 2023 16:18:17 +0000 (17:18 +0100)]
[LoopVectorize] Convert some tests to opaque pointers (NFC)

Check lines for some of these tests were regenerated. The difference
is that with opaque pointers SCEVExpander always emits i8 GEPs,
making the address calculation explicit. This is a known problem
that will be solved long term by making all address calculations
explicit.

18 months ago[LoopVersioningLICM] Convert tests to opaque pointers (NFC)
Nikita Popov [Wed, 4 Jan 2023 16:13:32 +0000 (17:13 +0100)]
[LoopVersioningLICM] Convert tests to opaque pointers (NFC)

18 months ago[mlir][llvm] Modernize the import of LLVM IR globals.
Tobias Gysi [Wed, 4 Jan 2023 16:04:14 +0000 (17:04 +0100)]
[mlir][llvm] Modernize the import of LLVM IR globals.

Return failure if the import of a global variable fails and add a
test case to check the emitted error message. Additionally, convert
the globals in iteration order and do not process them recursively
when translating a constant expression referencing it. Additionally,
use the module location rather unknown location.

Reviewed By: Dinistro

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

18 months ago[LowerTypeTests] Convert tests to opaque pointers (NFC)
Nikita Popov [Wed, 4 Jan 2023 16:09:46 +0000 (17:09 +0100)]
[LowerTypeTests] Convert tests to opaque pointers (NFC)

18 months ago[MakeGuardsExplicit] Convert test to opaque pointers (NFC)
Nikita Popov [Wed, 4 Jan 2023 16:09:13 +0000 (17:09 +0100)]
[MakeGuardsExplicit] Convert test to opaque pointers (NFC)

18 months ago[MergeFunc] Convert tests to opaque pointers (NFC)
Nikita Popov [Wed, 4 Jan 2023 16:05:13 +0000 (17:05 +0100)]
[MergeFunc] Convert tests to opaque pointers (NFC)

18 months ago[MergeICmps] Convert tests to opaque pointers (NFC)
Nikita Popov [Wed, 4 Jan 2023 16:03:43 +0000 (17:03 +0100)]
[MergeICmps] Convert tests to opaque pointers (NFC)