platform/upstream/llvm.git
15 months agoRevert "[CMake] Use COMPILER_RT_BUILD_CRT in the condition for test"
Petr Hosek [Wed, 12 Jul 2023 18:01:32 +0000 (18:01 +0000)]
Revert "[CMake] Use COMPILER_RT_BUILD_CRT in the condition for test"

This reverts commit 926f3759ec62a8f170e76a60316cc0bdd9dd2ec9.

15 months ago[ci] Make libc++ and Clang CI scripts independent
Louis Dionne [Wed, 12 Jul 2023 12:55:07 +0000 (08:55 -0400)]
[ci] Make libc++ and Clang CI scripts independent

This simply moves existing CI-related scripts for Clang outside of libc++
to make the two projects independent with respect to CI.

The reason for making this change is that libc++'s CI pipeline history
was full of Clang runs, making it a lot harder to figure out information
about libc++'s own jobs. I created a pipeline for Clang and this patch
will run pre-commit CI for Clang inside that pipeline instead.

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

15 months ago[PowerPC] Add DFP conversion instructions definitions and MC tests
Lei Huang [Tue, 4 Jul 2023 15:18:30 +0000 (11:18 -0400)]
[PowerPC] Add DFP conversion instructions definitions and MC tests

Add td definitions and asm/disasm tests for the quantum conversion
instructions in ISA 3.1 section 5.6.5

Reviewed By: stefanp

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

15 months ago[CMake] Use COMPILER_RT_BUILD_CRT in the condition for test
Petr Hosek [Wed, 12 Jul 2023 17:41:16 +0000 (17:41 +0000)]
[CMake] Use COMPILER_RT_BUILD_CRT in the condition for test

Unlike COMPILER_RT_HAS_CRT this handles the case where CRT is available
but has been disabled by setting COMPILER_RT_BUILD_CRT.

15 months ago[libLTO][AIX] Respect `-f[no]-integrated-as` on AIX
Qiongsi Wu [Wed, 12 Jul 2023 16:45:50 +0000 (12:45 -0400)]
[libLTO][AIX] Respect `-f[no]-integrated-as` on AIX

`libLTO` currently ignores the `-f[no-]integrated-as` flags. This patch teaches `libLTO` to respect them on AIX.

The implementation consists of two parts:

  # Migrate `llc`'s `-no-integrated-as` option to a codegen option so that the option is available to `libLTO`/`lld`/`gold`.
  # Teach `clang` to pass `-no-integrated-as` accordingly to `libLTO` depending on the `-f[no-]integrated-as` flags.

On platforms other than AIX, the `-f[no-]integrated-as` flags are ignored.

Reviewed By: MaskRay, steven_wu

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

15 months ago[libc++][hardening][NFC] Remove the `LIBCXX_DEBUG_BUILD` CMake variable.
varconst [Wed, 12 Jul 2023 03:18:20 +0000 (20:18 -0700)]
[libc++][hardening][NFC] Remove the `LIBCXX_DEBUG_BUILD` CMake variable.

It's no longer necessary to define `_DEBUG` because we use our own
internal assertion mechanism in libc++.

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

15 months agoValueTracking: Recognize fpclass clamping select patterns
Matt Arsenault [Thu, 15 Jun 2023 11:54:40 +0000 (07:54 -0400)]
ValueTracking: Recognize fpclass clamping select patterns

Improve computeKnownFPClass select handling to cover the case where
the condition performs a class test. This allows us to recognize
no-nans in cases like:

  %not.nan = fcmp ord float %x, 0.0
  %select = select i1 %not.nan, float %x, float 0.0

Math library code has similar edge case filtering on the inputs and
final results.

https://reviews.llvm.org/D153089

15 months agoValueTracking: Add base computeKnownFPClass select handling tests
Matt Arsenault [Thu, 15 Jun 2023 12:15:54 +0000 (08:15 -0400)]
ValueTracking: Add base computeKnownFPClass select handling tests

Prepare to handle class clamping patterns. Working around some kind of
select special casing bug in attributor where computeKnownFPClass is
never called on select.

15 months agoValueTracking: Replace CannotBeNegativeZero
Matt Arsenault [Thu, 13 Apr 2023 15:20:44 +0000 (11:20 -0400)]
ValueTracking: Replace CannotBeNegativeZero

This is now just a wrapper around computeKnownFPClass.

15 months ago[libc++][hardening][NFC] Add macros to enable hardened mode.
varconst [Wed, 12 Jul 2023 17:12:51 +0000 (10:12 -0700)]
[libc++][hardening][NFC] Add macros to enable hardened mode.

This patch only adds new configuration knobs -- the actual assertions
will be added in follow-up patches.

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

15 months ago[libc++] Fix an exception safety issue in `forward_list` and add tests.
varconst [Wed, 12 Jul 2023 17:11:09 +0000 (10:11 -0700)]
[libc++] Fix an exception safety issue in `forward_list` and add tests.

When inserting nodes into a forward list, each new node is allocated but
not constructed. The constructor was being called explicitly on the node
`value_` but the `next_` pointer remained uninitialized rather than
being set to null. This bug is only triggered in the cleanup code if an
exception is thrown -- upon successful creation of new nodes, the last
incorrect "next" value is overwritten to a correct pointer.

This issue was found due to new tests added in
https://reviews.llvm.org/D149830.

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

15 months ago[flang][HLFIR] allow hlfir.get_length with hlfir.associate
Tom Eccles [Tue, 11 Jul 2023 10:37:05 +0000 (10:37 +0000)]
[flang][HLFIR] allow hlfir.get_length with hlfir.associate

hlfir.get_length will not modify the buffer and so it is safe for a
hlfir.associate using the same expression buffer not to make its own
copy.

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

15 months ago[TOSA] Add level checks and remove Tensor1DTo4D
Tai Ly [Tue, 11 Jul 2023 20:38:27 +0000 (13:38 -0700)]
[TOSA] Add level checks and remove Tensor1DTo4D

Remove Tosa_Tensor1Dto4D and Tosa_TensorUpto4D in the Tosa Dialect
and added level checks to TosaValidation pass to validate per spec.

Signed-off-by: Tai Ly <tai.ly@arm.com>
Change-Id: Icd32137e9f8051f99994cee9f388f20c1a840f4b

Reviewed By: eric-k256

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

15 months ago[ConstantHoisting] simplify NumUses accounting NFC
Nick Desaulniers [Wed, 12 Jul 2023 16:51:21 +0000 (09:51 -0700)]
[ConstantHoisting] simplify NumUses accounting NFC

The `Uses` variable is unnecessary. Just use `UsesNum` instead.

Reviewed By: MaskRay

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

15 months ago[BPF][DebugInfo] Use .BPF.ext for line info when DWARF is not available
Eduard Zingerman [Wed, 12 Jul 2023 16:51:09 +0000 (09:51 -0700)]
[BPF][DebugInfo] Use .BPF.ext for line info when DWARF is not available

"BTF" is a debug information format used by LLVM's BPF backend.
The format is much smaller in scope than DWARF, the following info is
available:
- full set of C types used in the binary file;
- types for global values;
- line number / line source code information .

BTF information is embedded in ELF as .BTF and .BTF.ext sections.
Detailed format description could be found as a part of Linux Source
tree, e.g. here: [1].

This commit modifies `llvm-objdump` utility to use line number
information provided by BTF if DWARF information is not available.
E.g., the goal is to make the following to print source code lines,
interleaved with disassembly:

    $ clang --target=bpf -g test.c -o test.o
    $ llvm-strip --strip-debug test.o
    $ llvm-objdump -Sd test.o

    test.o: file format elf64-bpf

    Disassembly of section .text:

    <foo>:
    ; void foo(void) {
     r1 = 0x1
    ;   consume(1);
     call -0x1
     r1 = 0x2
    ;   consume(2);
     call -0x1
    ; }
     exit

A common production use case for BPF programs is to:
- compile separate object files using clang with `-g -c` flags;
- link these files as a final "static" binary using bpftool linker ([2]).
The bpftool linker discards most of the DWARF sections
(line information sections as well) but merges .BTF and .BTF.ext sections.
Hence, having `llvm-objdump` capable to print source code using .BTF.ext
is valuable.

The commit consists of the following modifications:

- llvm/lib/DebugInfo/BTF aka `DebugInfoBTF` component is added to host
  the code needed to process BTF (with assumption that BTF support
  would be added to some other tools as well, e.g. `llvm-readelf`):
  - `DebugInfoBTF` provides `llvm::BTFParser` class, that loads information
    from `.BTF` and `.BTF.ext` sections of a given `object::ObjectFile`
    instance and allows to query this information.
    Currently only line number information is loaded.

  - `DebugInfoBTF` also provides `llvm::BTFContext` class, which is an
    implementation of `DIContext` interface, used by `llvm-objdump` to
    query information about line numbers corresponding to specific
    instructions.

- Structure `DILineInfo` is modified with field `LineSource`.

  `DIContext` interface uses `DILineInfo` structure to communicate
  line number and source code information.
  Specifically, `DILineInfo::Source` field encodes full file source code,
  if available. BTF only stores source code for selected lines of the
  file, not a complete source file. Moreover, stored lines are not
  guaranteed to be sorted in a specific order.

  To avoid reconstruction of a file source code from a set of
  available lines, this commit adds `LineSource` field instead.

- `Symbolize` class is modified to use `BTFContext` instead of
  `DWARFContext` when DWARF sections are not available but BTF
  sections are present in the object file.
  (`Symbolize` is instantiated by `llvm-objdump`).

- Integration and unit tests.

Note, that DWARF has a notion of "instruction sequence".
DWARF implementation of `DIContext::getLineInfoForAddress()` provides
inexact responses if exact address information is not available but
address falls within "instruction sequence" with some known line
information (see `DWARFDebugLine::LineTable::findRowInSeq()`).

BTF does not provide instruction sequence groupings, thus
`getLineInfoForAddress()` queries only return exact matches.
This does not seem to be a big issue in practice, but output
of the `llvm-objdump -Sd` might differ slightly when BTF
is used instead of DWARF.

[1] https://www.kernel.org/doc/html/latest/bpf/btf.html
[2] https://github.com/libbpf/bpftool

Depends on https://reviews.llvm.org/D149501

Reviewed By: MaskRay, yonghong-song, nickdesaulniers, #debug-info

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

15 months ago[ConstantHoisting] use BasicBlock::getFirstInsertionPt NFC
Nick Desaulniers [Wed, 12 Jul 2023 16:40:43 +0000 (09:40 -0700)]
[ConstantHoisting] use BasicBlock::getFirstInsertionPt NFC

Rather than open coding the same implementation.

Reviewed By: MaskRay, void

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

15 months agoFix mixed disassembly showing source lines for "line 0"
Ted Woodward [Wed, 12 Jul 2023 16:04:14 +0000 (11:04 -0500)]
Fix mixed disassembly showing source lines for "line 0"

"line 0" in a DWARF linetable means something that doesn't have associated
source. The code for mixed disassembly has a comment indicating that
"line 0" should be skipped, but the wrong value was returned. Fix the return
value and add a test to check that we don't incorrectly show source lines
from the beginning of the file.

Reviewed By: jasonmolenda

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

15 months ago[ARM][AArch64] Add ARM specific builtin for clz that is not undefined for 0 in ubsan.
Craig Topper [Wed, 12 Jul 2023 16:29:18 +0000 (09:29 -0700)]
[ARM][AArch64] Add ARM specific builtin for clz that is not undefined for 0 in ubsan.

D152023 made ubsan consider __builtin_clz of 0 undefined regardless of
the target. This ensures portability and matches gcc.

This causes the ACLE intrinsics to also be considered to also be
considered to be undefined for 0 since they used the generic builtins
as their implementation.

This patch adds builtins for ARM that ubsan doesn't know about to make
the behavior defined for 0. Alternatively, I could have added a zero
check to the intrinsics, but the dedicated builtin will give better -O0
codegen.

Fixes #63113.

Reviewed By: tmatheson

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

15 months ago[mlir][DialectUtils] Generalize `extractFromI64ArrayAttr` helper
Matthias Springer [Wed, 12 Jul 2023 15:58:11 +0000 (17:58 +0200)]
[mlir][DialectUtils] Generalize `extractFromI64ArrayAttr` helper

Generalize `extractFromI64ArrayAttr` to `extractFromIntegerArrayAttr`, so that arbitrary integer/bool types can be extracted.

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

15 months ago[libc++][PSTL] Fix double-move in std::transform_reduce
Nikolas Klauser [Wed, 12 Jul 2023 15:55:02 +0000 (08:55 -0700)]
[libc++][PSTL] Fix double-move in std::transform_reduce

Reviewed By: #libc, ldionne

Spies: h-vetinari, libcxx-commits

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

15 months agoRevert "[Clang] Diagnose jumps into statement expressions"
Corentin Jabot [Wed, 12 Jul 2023 15:37:53 +0000 (17:37 +0200)]
Revert "[Clang] Diagnose jumps into statement expressions"

This reverts commit b0cc947b5d0a74f4ffe63c53b32978b21498e72e.

Breaks in presence of asm goto
https://reviews.llvm.org/D154696#4493805

15 months ago[ARM] Fix unused variable warning in ARMExpandPseudoInsts.cpp
John Brawn [Wed, 12 Jul 2023 15:47:47 +0000 (16:47 +0100)]
[ARM] Fix unused variable warning in ARMExpandPseudoInsts.cpp

When built without LLVM_ENABLE_ASSERTIONS we can get a warning in
ARMExpandPseudoInsts.cpp due to a variable only being used inside
of a LLVM_DEBUG statement. Fix this with a dummy use, like we do
elsewhere.

15 months ago[ODS] Extra Concrete Declarations and Definitions under Traits
Amanda Tang [Wed, 12 Jul 2023 15:14:16 +0000 (08:14 -0700)]
[ODS] Extra Concrete Declarations and Definitions under Traits

Support extra concrete class declarations and definitions under NativeTrait that get injected into the class that specifies the trait. Extra declarations and definitions can be passed in as template arguments for NativeOpTraitNativeAttrTrait and NativeTypeTrait.

Usage examples of this feature include:

- Creating a wrapper Trait for authoring inferReturnTypes with the OpAdaptor by specifying necessary Op specific declarations and definitions directly in the trait
- Refactoring the InferTensorType trait

Reviewed By: jpienaar

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

15 months ago[test] after REQUIRES after D154665
Fangrui Song [Wed, 12 Jul 2023 15:46:05 +0000 (08:46 -0700)]
[test] after REQUIRES after D154665

Disassembling needs LLVM_TARGETS_TO_BUILD.

15 months ago[flang][openacc] Add error for unsupported min/max reduction on complex type
Valentin Clement [Wed, 12 Jul 2023 15:41:51 +0000 (08:41 -0700)]
[flang][openacc] Add error for unsupported min/max reduction on complex type

reduction operator min and max are not supported with complex type.
Add a proper error so it fails correctly.

Reviewed By: razvanlupusoru

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

15 months ago[IR] Ignore globals with the `llvm.` prefix when calculating module hash
Paul Kirth [Wed, 28 Jun 2023 23:50:27 +0000 (23:50 +0000)]
[IR] Ignore globals with the `llvm.` prefix when calculating module hash

This came up in This came up in
https://reviews.llvm.org/D146776#inline-1489091 and is slightly related
to https://reviews.llvm.org/D153855. In both patches, there is the
observation that some modifications of the module should not invalidate
analysis, such as when adding a declaration or some metadata the won't
be used when compiling the current module.

This patch implements the suggestion that we should ignore globals that have
the `llvm.` prefix when calculating the module hash.

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

Reviewed By: aeubanks

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

15 months ago[MachineLICM] Handle Subloops
Jingu Kang [Fri, 30 Jun 2023 11:57:11 +0000 (12:57 +0100)]
[MachineLICM] Handle Subloops

MachineLICM pass handles inner loops only when outmost loop does not have unique
predecessor. If the loop has preheader and there is loop invariant code, the
invariant code can be hoisted to the preheader in general. This patch makes the
pass handle inner loops in general.

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

15 months ago[RISCV] Clear kill flags when forming FMA instructions in MachineCombiner.
Craig Topper [Wed, 12 Jul 2023 15:03:44 +0000 (08:03 -0700)]
[RISCV] Clear kill flags when forming FMA instructions in MachineCombiner.

If the operands to the mul have other uses we may be extending their
live range past a kill flag.

Reviewed By: asb, asi-sc

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

15 months ago[LegalizeDAG] Prevent LegalizeLoadOps from creating extloads that mix int and fp...
Craig Topper [Wed, 12 Jul 2023 15:03:09 +0000 (08:03 -0700)]
[LegalizeDAG] Prevent LegalizeLoadOps from creating extloads that mix int and fp types.

For RISC-V, getRegisterType for fp16 returns i16. i16->fp64 extload
is considered legal because the LoadExtActions defaults to Legal
for all entries. Only fp/fp and int/int entries are changed to
Expand fore RISC-V.

This patch detects the FP-ness has changed and won't try to call
isLoadExtLegal.

Alternatively, we could add Expand for int/fp and fp/int, but that
seemed a little silly.

Fixes #63816

Reviewed By: asb, wangpc

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

15 months ago[SCEVExpander] Remove GEP add rec splitting code (NFCI)
Nikita Popov [Wed, 12 Jul 2023 14:53:51 +0000 (16:53 +0200)]
[SCEVExpander] Remove GEP add rec splitting code (NFCI)

I don't believe this is relevant anymore with opaque pointers,
where we always expand the entire offset, without splitting it into
parts.

15 months ago[InstCombine] Enhance select icmp and folding
Peixin Qiao [Sun, 9 Jul 2023 09:14:13 +0000 (17:14 +0800)]
[InstCombine] Enhance select icmp and folding

This folds (a << k) ? 2^k * a : 0 to 2^k * a.

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

Fix #62155.

Reviewed By: nikic

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

15 months ago[mlir][linalg] Fix bug in vector transfer hoisting
Matthias Springer [Wed, 12 Jul 2023 10:36:55 +0000 (12:36 +0200)]
[mlir][linalg] Fix bug in vector transfer hoisting

Do not hoist vector transfers that do not match exactly. In particular, do not hoist transfers with different vector types. This has lead to invalid IR (yielded vector type is different from iter_arg type) in downstream projects.

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

15 months ago[Transforms] Remove FactorOutConstant to fix -Wunneeded-internal-declaration (NFC)
Jie Fu [Wed, 12 Jul 2023 13:55:24 +0000 (21:55 +0800)]
[Transforms] Remove FactorOutConstant to fix -Wunneeded-internal-declaration (NFC)

/Users/jiefu/llvm-project/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp:293:13: error: function 'FactorOutConstant' is not needed and will not be emitted [-Werror,-Wunneeded-internal-declaration]
static bool FactorOutConstant(const SCEV *&S, const SCEV *&Remainder,
            ^
1 error generated.

15 months ago[FPEnv][TableGen] Add strictfp attribute to constrained intrinsics by default.
Kevin P. Neal [Wed, 12 Jul 2023 13:52:57 +0000 (09:52 -0400)]
[FPEnv][TableGen] Add strictfp attribute to constrained intrinsics by default.

In D146869 @arsenm pointed out that the constrained intrinsics aren't
getting the strictfp attribute by default. They should be since they are
required to have it anyway.

TableGen did not know about this attribute until now. This patch adds
strictfp to TableGen, and it uses it on all of the constrained intrinsics.

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

15 months ago[IVDescriptors] Remove typed pointer support (NFC)
Nikita Popov [Wed, 12 Jul 2023 13:41:42 +0000 (15:41 +0200)]
[IVDescriptors] Remove typed pointer support (NFC)

This also removes the element type from the descriptor, as it is
always i8. The meaning of the step is now the same between
integers and pointers.

15 months agoFix warnings about unused varibles on builds without asserts.
Ivan Kosarev [Wed, 12 Jul 2023 13:35:42 +0000 (14:35 +0100)]
Fix warnings about unused varibles on builds without asserts.

15 months ago[SCEVExpander] Remove typed pointer support (NFC)
Nikita Popov [Wed, 12 Jul 2023 13:25:30 +0000 (15:25 +0200)]
[SCEVExpander] Remove typed pointer support (NFC)

15 months ago[mlir][linalg][transform] Fix printing of TileToForall in edge case.
Ingo Müller [Wed, 12 Jul 2023 09:55:06 +0000 (09:55 +0000)]
[mlir][linalg][transform] Fix printing of TileToForall in edge case.

The `static_(num_threads|tile_sizes)` attributes of this op are
`DefaultValuedOptionalAttr`s, so they can be constructed *without* such
an attribute. In other words, the following is a valid op (note the
absense of the `static_num_threads` attribute):

"builtin.module"() ({
  "transform.sequence"() <{failure_propagation_mode = 1 : i32, operand_segment_sizes = array<i32: 0, 0>}> ({
  ^bb0(%arg0: !pdl.operation, %arg1: !transform.op<"linalg.matmul">, %arg2: !transform.op<"linalg.elemwise_binary">):
    %0 = "transform.structured.match"(%arg0) <{ops = ["test.dummy"]}> : (!pdl.operation) -> !pdl.operation
    %1:2 = "transform.structured.tile_to_forall_op"(%arg1, %0) <{operand_segment_sizes = array<i32: 1, 0, 0, 0, 1>}> : (!transform.op<"linalg.matmul">, !pdl.operation) -> (!transform.op<"scf.forall">, !transform.op<"linalg.matmul">)
    "transform.yield"() : () -> ()
  }) : () -> ()
}) : () -> ()

However, the custom printing directive converted those to an `ArrayRef`,
which crashes if done on an empty `ArrayAttr`. This patch changes the
signature such that no automatic conversion takes place and extends the
test to test for existinnce of the attribute.

Reviewed By: nicolasvasilache

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

15 months ago[CodeGen] Store SP adjustment in MachineBasicBlock. NFCI.
Jay Foad [Fri, 30 Jun 2023 07:14:40 +0000 (08:14 +0100)]
[CodeGen] Store SP adjustment in MachineBasicBlock. NFCI.

Record the SP adjustment on entry to each basic block. This is almost
always zero except on targets like ARM which can split a basic block in
the middle of a call sequence.

This simplifies PEI::replaceFrameIndices which previously had to visit
basic blocks in a specific order and had special handling for
unreachable blocks. More importantly it paves the way for an equally
simple implementation of a backwards version of replaceFrameIndices,
which is required to fully convert PrologEpilogInserter to backwards
register scavenging, which is preferred because it does not rely on
accurate kill flags.

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

15 months ago[CodeGen][NFCI] Avoid calls to setTargetAttributes on definitions
Alex Gatea [Mon, 10 Jul 2023 19:39:35 +0000 (15:39 -0400)]
[CodeGen][NFCI] Avoid calls to setTargetAttributes on definitions

Avoid duplicate calls to setTargetAttributes on global variable definitions.

Differential: https://reviews.llvm.org/D153903

15 months ago[GlobalISel] Rename KnownBits field of InstructionSelector
pvanhout [Wed, 12 Jul 2023 13:21:53 +0000 (15:21 +0200)]
[GlobalISel] Rename KnownBits field of InstructionSelector

`KnownBits` is also a type name. Having a field with this name
prevents derived classes from using the `KnownBits` type unless they use `struct KnownBits`.

Reviewed By: foad

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

15 months ago[ConstantFold] Remove typed pointer specific folds (NFC)
Nikita Popov [Wed, 12 Jul 2023 13:20:29 +0000 (15:20 +0200)]
[ConstantFold] Remove typed pointer specific folds (NFC)

15 months ago[IR] Remove unit tests for typed pointers (NFC)
Nikita Popov [Wed, 12 Jul 2023 13:10:04 +0000 (15:10 +0200)]
[IR] Remove unit tests for typed pointers (NFC)

15 months ago[X86] Complete preservation of !pcsections in X86ISelLowering
Marco Elver [Wed, 12 Jul 2023 13:08:43 +0000 (15:08 +0200)]
[X86] Complete preservation of !pcsections in X86ISelLowering

https://reviews.llvm.org/D130883 introduced MIMetadata to simplify
metadata propagation (DebugLoc and PCSections).

However, we're currently still permitting implicit conversion of
DebugLoc to MIMetadata, to allow for a gradual transition and let the
old code work as-is.

This manifests in lost !pcsections metadata for X86-specific lowerings.
For example, 128-bit atomics.

Fix the situation for X86ISelLowering by converting all BuildMI() calls
to use an explicitly constructed MIMetadata.

Reviewed By: dvyukov

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

15 months ago[SVE2p1][SME2] Add scalar addressing mode for LD1
Matt Devereau [Wed, 12 Jul 2023 13:00:26 +0000 (13:00 +0000)]
[SVE2p1][SME2] Add scalar addressing mode for LD1

Add the scalar addressing mode for multi vector LD1 instructions.

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

15 months ago[mlir][nvvm] Change return type of std::string of getPtx of PtxBuilder
Guray Ozen [Wed, 12 Jul 2023 09:40:36 +0000 (11:40 +0200)]
[mlir][nvvm] Change return type of std::string of getPtx of PtxBuilder

getPtx used to return `const char*`. It is not flexible when one needs to build string in the function. This work changes return type.

Reviewed By: springerm

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

15 months ago[TLI][AArch64] Add mappings to vectorized functions from ArmPL
Maciej Gabka [Tue, 4 Jul 2023 08:43:07 +0000 (08:43 +0000)]
[TLI][AArch64] Add mappings to vectorized functions from ArmPL

Arm Performance Libraries contain math library which provides
vectorized versions of common math functions.
This patch allows to use it with clang and llvm via -fveclib=ArmPL or
-vector-library=ArmPL, so loops with such calls can be vectorized.
The executable needs to be linked with the amath library.

Arm Performance Libraries are available at:
https://developer.arm.com/Tools%20and%20Software/Arm%20Performance%20Libraries

Reviewed by: paulwalker-arm
Differential Revision: https://reviews.llvm.org/D154508

15 months ago[mlir][nvvm] Fix test (NFC)
Guray Ozen [Wed, 12 Jul 2023 09:41:47 +0000 (11:41 +0200)]
[mlir][nvvm] Fix test (NFC)

`ptxas` complains with . in the function name, so we delete. Also, it expects return i64.

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

15 months ago[llvm] Remove explicit -opaque-pointers flag from tests (NFC)
Nikita Popov [Wed, 12 Jul 2023 12:19:34 +0000 (14:19 +0200)]
[llvm] Remove explicit -opaque-pointers flag from tests (NFC)

Opaque pointers mode is enabled by default, no need to explicitly
enable it.

15 months ago[clang] Create a buildkite-pipeline.yml file for clang
Nikolas Klauser [Wed, 12 Jul 2023 12:30:31 +0000 (08:30 -0400)]
[clang] Create a buildkite-pipeline.yml file for clang

This moves the formatting job to a shell script, which should also fix
the clang pre-commit CI.

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

15 months agoRevert "Revert "IRBuilder: Fix not handling strictfp minnum/maxnum""
Krasimir Georgiev [Wed, 12 Jul 2023 12:10:09 +0000 (14:10 +0200)]
Revert "Revert "IRBuilder: Fix not handling strictfp minnum/maxnum""

This reverts commit 593797ab9bedca6e9b0b7a9ed0589cf76023ab00.

I didn't realize that there was already a fix for the broken tests fd2254b7358d0f78a79784688bd8012c1a52b9cf.

15 months ago[AArch64] Improve cost of umull from known bits
David Green [Wed, 12 Jul 2023 12:13:06 +0000 (13:13 +0100)]
[AArch64] Improve cost of umull from known bits

As in D140287, we can now generate umull from mul(zext(x), y) in cases where we
know that the top bits of y are zero. This teaches that to the cost model,
adjusting how isWideningInstruction detects mul operations that can extend both
operands. This helps for constants and other cases where the operands of the
mul are known to be extended, but not directly extends.

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

15 months ago[LSR] Convert test to opaque pointers (NFC)
Nikita Popov [Wed, 12 Jul 2023 12:06:40 +0000 (14:06 +0200)]
[LSR] Convert test to opaque pointers (NFC)

This regresses with opaque pointers. I'll submit a patch to recover
the regression.

15 months ago[DWARF] Allow op-index in line number programs
David Stenberg [Wed, 12 Jul 2023 10:14:46 +0000 (12:14 +0200)]
[DWARF] Allow op-index in line number programs

This extends DWARFDebugLine to properly parse line number programs with
maximum_operations_per_instruction > 1 for VLIW targets.

No functions that use that parsed output to retrieve line information
have been extended to support multiple op-indexes. This means that when
retrieving information for an address with multiple op-indexes, e.g.
when using llvm-addr2line, the penultimate row for that address will be
used, which in most cases is the row for the second largest op-index.
This will be addressed in further changes, but this patch at least
allows us to correctly parse such line number programs, with a warning
saying that the line number information may be incorrect (incomplete).

Reviewed By: StephenTozer

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

15 months agoRevert "IRBuilder: Fix not handling strictfp minnum/maxnum"
Krasimir Georgiev [Wed, 12 Jul 2023 11:16:20 +0000 (11:16 +0000)]
Revert "IRBuilder: Fix not handling strictfp minnum/maxnum"

This reverts commit 14c3ab945be9c49964dbf79f13d8ff8df1ff7b72.

Causes build bot failures.

15 months ago[AArch64] Split lowerVectorFCMP combine
pvanhout [Tue, 11 Jul 2023 10:53:50 +0000 (12:53 +0200)]
[AArch64] Split lowerVectorFCMP combine

It's the only combine (AFAIK) that didn't use an apply function.
There is no reason for it to mutate instructions in the matcher, so split it up.

Reviewed By: aemerson, arsenm

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

15 months ago[OpenMP] Migrate device code privatisation from Clang CodeGen to OMPIRBuilder
Akash Banerjee [Wed, 12 Jul 2023 11:03:15 +0000 (12:03 +0100)]
[OpenMP] Migrate device code privatisation from Clang CodeGen to OMPIRBuilder

This patch migrates the UseDevicePtr and UseDeviceAddr clause related code for handling privatisation from Clang codegen to the OMPIRBuilder

Depends on D150860

Reviewed By: jdoerfert

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

15 months ago[Codegen] Generate fast fp64-to-fp16 conversions in unsafe mode.
Ivan Kosarev [Wed, 12 Jul 2023 10:19:36 +0000 (11:19 +0100)]
[Codegen] Generate fast fp64-to-fp16 conversions in unsafe mode.

Reviewed By: arsenm

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

15 months ago[ARM] Correctly handle execute-only in EmitStructByval
John Brawn [Wed, 5 Jul 2023 15:21:51 +0000 (16:21 +0100)]
[ARM] Correctly handle execute-only in EmitStructByval

Currently when compiling for an execute-only target without movt then
EmitStructByval will generate a constant pool load which isn't
compatible with execute-only. Handle this by emitting tMOVi32imm,
and also simplify the existing movt handling by emitting t2MOVi32imm
or MOVi32imm.

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

15 months ago[ARM] Restructure MOVi32imm expansion to not do pointless instructions
John Brawn [Thu, 6 Jul 2023 09:43:40 +0000 (10:43 +0100)]
[ARM] Restructure MOVi32imm expansion to not do pointless instructions

The expansion of the various MOVi32imm pseudo-instructions works by
splitting the operand into components (either halfwords or bytes) and
emitting instructions to combine those components into the final
result. When the operand is an immediate with some components being
zero this can result in pointless instructions that just add zero.

Avoid this by restructuring things so that a separate function handles
splitting the operand into components, then don't emit the component
if it is a zero immediate. This is straightforward for movw/movt,
where we just don't emit the movt if it's zero, but the thumb1
expansion using mov/add/lsl is more complex, as even when we don't
emit a given byte we still need to get the shift correct.

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

15 months ago[InstCombine] Precommit a test
Peixin Qiao [Sun, 9 Jul 2023 09:13:01 +0000 (17:13 +0800)]
[InstCombine] Precommit a test

This patch precommits a test for:
https://reviews.llvm.org/D148420

Reviewed By: nikic

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

15 months ago[clang-format] Don't eat two semicolons after namespace
Björn Schäpers [Sun, 20 Nov 2022 04:15:05 +0000 (05:15 +0100)]
[clang-format] Don't eat two semicolons after namespace

Remove the double check, move the comment.

This changes behavior, but I think for the better. Despite the comment
my personal opinion would be to not even gracefully handle the one
semicolon, it shouldn't be there.

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

15 months ago[clang-format] Correctly count a tab's width in a comment
Björn Schäpers [Mon, 21 Nov 2022 07:10:50 +0000 (08:10 +0100)]
[clang-format] Correctly count a tab's width in a comment

It worked only correct for a tab as the first char.

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

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

15 months ago[DWARF] Add printout for op-index
David Stenberg [Wed, 12 Jul 2023 08:49:00 +0000 (10:49 +0200)]
[DWARF] Add printout for op-index

This is a preparatory patch for extending DWARFDebugLine to properly
parse line number programs with maximum_operations_per_instruction > 1
for VLIW targets.

Add some scaffolding for handling op-index in line number programs, and
add printouts for that in the table. As this affects a lot of tests,
this is done in a separate commit to get a cleaner review for the actual
op-index implementation.

Verbose printouts are not present in many tests, and adding op-index to
those will require a bit more code changes, so that is done in the
actual implementation patch.

Reviewed By: StephenTozer

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

15 months ago[LSR] Convert some tests to opaque pointers (NFC)
Nikita Popov [Wed, 12 Jul 2023 09:45:39 +0000 (11:45 +0200)]
[LSR] Convert some tests to opaque pointers (NFC)

These no longer show codegen regressions.

15 months ago[LSR] Move test to target specific directory (NFC)
Nikita Popov [Wed, 12 Jul 2023 09:44:09 +0000 (11:44 +0200)]
[LSR] Move test to target specific directory (NFC)

Uses an x86 triple.

15 months ago[SCEVExpander] Fix GEP IV inc reuse logic for opaque pointers
Nikita Popov [Wed, 12 Jul 2023 09:23:51 +0000 (11:23 +0200)]
[SCEVExpander] Fix GEP IV inc reuse logic for opaque pointers

Instead of checking the pointer type, check the element type of
the GEP.

Previously we ended up reusing GEP increments that were not in
expanded form, thus not respecting LSRs choice of representation.

The change in 2011-10-06-ReusePhi.ll recovers a regression that
appeared when converting that test to opaque pointers.

Changes in various Thumb tests now compute the step outside the
loop instead of using add.w inside the loop, which is LSR's
preferred representation for this target.

15 months ago[mlir] Apply ClangTidy fixes
Adrian Kuegel [Wed, 12 Jul 2023 09:31:05 +0000 (11:31 +0200)]
[mlir] Apply ClangTidy fixes

The get() call is redundant.

15 months ago[IRCE] Implement runtime overflow check for computed range's end
Aleksandr Popov [Wed, 12 Jul 2023 08:25:48 +0000 (10:25 +0200)]
[IRCE] Implement runtime overflow check for computed range's end

Here is activated check elimination which was parsed previously in
https://reviews.llvm.org/D154069

* Added runtime check that computed range's boundary doesn't overflow in
terms of range type.

* From the statement INT_MIN <= END <= INT_MAX is inferred check:
isNonNegative(INT_MAX - END) * isNonNegative(END - INT_MIN).

* If overflow happens, check will return 0 and the safe interval will be
empty.

Reviewed By: skatkov

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

15 months ago[NFC][AMDGPULowerModuleLDSPass] Fix buildbot santizier failed to compile
Juan Manuel MARTINEZ CAAMAÑO [Wed, 12 Jul 2023 09:00:16 +0000 (11:00 +0200)]
[NFC][AMDGPULowerModuleLDSPass] Fix buildbot santizier failed to compile

It seems that the sanitizer-x86_64-linux-android wasn't able to deduce
the template argument:

  AMDGPULowerModuleLDSPass.cpp:1192:53: error: no viable constructor or
  deduction guide for deduction of template arguments of 'vector'
        auto TableLookupVariablesOrdered = sortByName(std::vector(

This patch makes the template argument explicit.

15 months ago[MLIR][IR] Rewrite OperationVerifier using worklist
Alexander Shaposhnikov [Wed, 12 Jul 2023 08:52:21 +0000 (08:52 +0000)]
[MLIR][IR] Rewrite OperationVerifier using worklist

This diff switches OperationVerifier to using a worklist
rather than recursion. The exception is our handling of isolated regions,
it can still contain recursive calls, however, the parallel processing
of these regions is preserved. This fixes the crash of the "verifier"
on the input from https://github.com/llvm/circt/issues/5316
(but the IR printer would still crash with stack overflow).

Test plan: ninja check-mlir check-all

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

15 months ago[clangd] Fix builds with LLVM_LINK_LLVM_DYLIB=ON
Martin Storsjö [Wed, 12 Jul 2023 08:59:28 +0000 (11:59 +0300)]
[clangd] Fix builds with LLVM_LINK_LLVM_DYLIB=ON

This was broken by 56ac9d46a7c1468d587ccec02a781e52d0bb298a.

15 months ago[AArch64] Fix order of isReg and isDef checks in INSvi64 peephole.
David Green [Wed, 12 Jul 2023 08:51:28 +0000 (09:51 +0100)]
[AArch64] Fix order of isReg and isDef checks in INSvi64 peephole.

The isDef asserts that the operand isReg, so the checks need to happen in the
other order.

15 months ago[InstCombine][NFC] Rename check run label
Piotr Sobczak [Mon, 10 Jul 2023 09:36:46 +0000 (11:36 +0200)]
[InstCombine][NFC] Rename check run label

The existing check run label "DEFAULT" may clash with
the label from switch "DEFAULT", so renaming it for clarity.

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

15 months ago[clang][Bazel] Add dependency to the right target.
Adrian Kuegel [Wed, 12 Jul 2023 08:19:06 +0000 (10:19 +0200)]
[clang][Bazel] Add dependency to the right target.

15 months ago[clang][Bazel] Add missing dependency.
Adrian Kuegel [Wed, 12 Jul 2023 08:13:40 +0000 (10:13 +0200)]
[clang][Bazel] Add missing dependency.

15 months ago[LSR] Move test to target-specific directory (NFC)
Nikita Popov [Wed, 12 Jul 2023 08:10:29 +0000 (10:10 +0200)]
[LSR] Move test to target-specific directory (NFC)

15 months ago[mlir][nvvm] fix potential bug (NFC)
Guray Ozen [Wed, 12 Jul 2023 08:02:13 +0000 (10:02 +0200)]
[mlir][nvvm] fix potential bug (NFC)

Reviewed By: nicolasvasilache

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

15 months ago[clang][clangd] Don't crash/assert on -gsplit-dwarf=single without output
Dmitry Polukhin [Thu, 6 Jul 2023 12:41:58 +0000 (05:41 -0700)]
[clang][clangd] Don't crash/assert on -gsplit-dwarf=single without output

The crash happens in clang::driver::tools::SplitDebugName when Output is
InputInfo::Nothing. It doesn't happen with standalone clang driver because
output is created in Driver::BuildJobsForActionNoCache.

Example backtrace:
```
* thread #1, name = 'clangd', stop reason = hit program assert
  * frame #0: 0x00007ffff5c4eacf libc.so.6`raise + 271
    frame #1: 0x00007ffff5c21ea5 libc.so.6`abort + 295
    frame #2: 0x00007ffff5c21d79 libc.so.6`__assert_fail_base.cold.0 + 15
    frame #3: 0x00007ffff5c47426 libc.so.6`__assert_fail + 70
    frame #4: 0x000055555dc0923c clangd`clang::driver::InputInfo::getFilename(this=0x00007fffffff9398) const at InputInfo.h:84:5
    frame #5: 0x000055555dcd0d8d clangd`clang::driver::tools::SplitDebugName(JA=0x000055555f6c6a50, Args=0x000055555f6d0b80, Input=0x00007fffffff9678, Output=0x00007fffffff9398) at CommonArgs.cpp:1275:40
    frame #6: 0x000055555dc955a5 clangd`clang::driver::tools::Clang::ConstructJob(this=0x000055555f6c69d0, C=0x000055555f6c64a0, JA=0x000055555f6c6a50, Output=0x00007fffffff9398, Inputs=0x00007fffffff9668, Args=0x000055555f6d0b80, LinkingOutput=0x0000000000000000) const at Clang.cpp:5690:33
    frame #7: 0x000055555dbf6b54 clangd`clang::driver::Driver::BuildJobsForActionNoCache(this=0x00007fffffffb5e0, C=0x000055555f6c64a0, A=0x000055555f6c6a50, TC=0x000055555f6c4be0, BoundArch=(Data = 0x0000000000000000, Length = 0), AtTopLevel=true, MultipleArchs=false, LinkingOutput=0x0000000000000000, CachedResults=size=1, TargetDeviceOffloadKind=OFK_None) const at Driver.cpp:5618:10
    frame #8: 0x000055555dbf4ef0 clangd`clang::driver::Driver::BuildJobsForAction(this=0x00007fffffffb5e0, C=0x000055555f6c64a0, A=0x000055555f6c6a50, TC=0x000055555f6c4be0, BoundArch=(Data = 0x0000000000000000, Length = 0), AtTopLevel=true, MultipleArchs=false, LinkingOutput=0x0000000000000000, CachedResults=size=1, TargetDeviceOffloadKind=OFK_None) const at Driver.cpp:5306:26
    frame #9: 0x000055555dbeb590 clangd`clang::driver::Driver::BuildJobs(this=0x00007fffffffb5e0, C=0x000055555f6c64a0) const at Driver.cpp:4844:5
    frame #10: 0x000055555dbe6b0f clangd`clang::driver::Driver::BuildCompilation(this=0x00007fffffffb5e0, ArgList=ArrayRef<const char *> @ 0x00007fffffffb268) at Driver.cpp:1496:3
    frame #11: 0x000055555b0cc0d9 clangd`clang::createInvocation(ArgList=ArrayRef<const char *> @ 0x00007fffffffbb38, Opts=CreateInvocationOptions @ 0x00007fffffffbb90) at CreateInvocationFromCommandLine.cpp:53:52
    frame #12: 0x000055555b378e7b clangd`clang::clangd::buildCompilerInvocation(Inputs=0x00007fffffffca58, D=0x00007fffffffc158, CC1Args=size=0) at Compiler.cpp:116:44
    frame #13: 0x000055555895a6c8 clangd`clang::clangd::(anonymous namespace)::Checker::buildInvocation(this=0x00007fffffffc760, TFS=0x00007fffffffe570, Contents= Has Value=false ) at Check.cpp:212:9
    frame #14: 0x0000555558959cec clangd`clang::clangd::check(File=(Data = "build/test.cpp", Length = 64), TFS=0x00007fffffffe570, Opts=0x00007fffffffe600) at Check.cpp:486:34
    frame #15: 0x000055555892164a clangd`main(argc=4, argv=0x00007fffffffecd8) at ClangdMain.cpp:993:12
    frame #16: 0x00007ffff5c3ad85 libc.so.6`__libc_start_main + 229
    frame #17: 0x00005555585bbe9e clangd`_start + 46
```

Test Plan: ninja ClangDriverTests && tools/clang/unittests/Driver/ClangDriverTests

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

15 months ago[LSR] Convert some tests to opaque pointers (NFC)
Nikita Popov [Wed, 12 Jul 2023 07:40:44 +0000 (09:40 +0200)]
[LSR] Convert some tests to opaque pointers (NFC)

15 months ago[LSR] Regenerate test checks (NFC)
Nikita Popov [Wed, 12 Jul 2023 07:34:43 +0000 (09:34 +0200)]
[LSR] Regenerate test checks (NFC)

15 months ago[libc][math] Fix floating-point test support on x86_64 Apple machines
Dominic Chen [Tue, 27 Jun 2023 00:19:00 +0000 (17:19 -0700)]
[libc][math] Fix floating-point test support on x86_64 Apple machines

Provide platform-specific x87 FPU definitions and operations

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

15 months agoReland "[NFC][AMDGPULowerModuleLDSPass] Factorize repetead sort code"
Juan Manuel MARTINEZ CAAMAÑO [Wed, 12 Jul 2023 07:16:24 +0000 (09:16 +0200)]
Reland "[NFC][AMDGPULowerModuleLDSPass] Factorize repetead sort code"

Fixed compilation error and reudndant copy warning

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

15 months ago[DAG] Use legal shift amount type in DAGTypeLegalizer::JoinIntegers
Jay Foad [Tue, 11 Jul 2023 13:26:54 +0000 (14:26 +0100)]
[DAG] Use legal shift amount type in DAGTypeLegalizer::JoinIntegers

Documentation for TargetLowering::getShiftAmountTy says that LegalTypes
should generally be true during type legalization, so this patch does
that.

On AMDGPU the effect is that we use i32 (a sane type) instead of i64
(pointer sized type) for more shift amounts, which in turn allows more
formation of rotates and funnel shifts pre-legalization.

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

15 months ago[gn build] Port da61c865e734
LLVM GN Syncbot [Wed, 12 Jul 2023 07:03:11 +0000 (07:03 +0000)]
[gn build] Port da61c865e734

15 months ago[RFC] Introduce convergence control intrinsics
Sameer Sahasrabuddhe [Wed, 12 Jul 2023 07:01:42 +0000 (12:31 +0530)]
[RFC] Introduce convergence control intrinsics

This is a reboot of the original design and implementation by
Nicolai Haehnle <nicolai.haehnle@amd.com>:
https://reviews.llvm.org/D85603

This change also obsoletes an earlier attempt at restarting the work on
convergence tokens:
https://reviews.llvm.org/D104504

Changes relative to D85603:

 1. Clean up the definition of a "convergent operation", a convergent
    call and convergent function.
 2. Clean up the relationship between dynamic instances, sets of threads and
    convergence tokens.
 3. Redistribute the formal rules into the definitions of the convergence
    intrinsics.
 4. Expand on the semantics of entering a function from outside LLVM,
    and the environment-defined outcome of the entry intrinsic.
 5. Replace the term "cycle" with "closed path". The static rules are defined
    in terms of closed paths, and then a relation is established with cycles.
 6. Specify that if a function contains a controlled convergent operation, then
    all convergent operations in that function must be controlled.
 7. Describe an optional procedure to infer tokens for uncontrolled convergent
    operations.
 8. Introduce controlled maximal convergence-before and controlled m-converged
    property as an update to the original properties in UniformityAnalysis.
 9. Additional constraint that a cycle heart can only occur in the header of a
    reducible cycle (natural loop).

Reviewed By: nhaehnle

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

15 months ago[AArch64] Fix cost modelling for SVE Min/Max Intrinsics
Tuan Chuong Goh [Wed, 12 Jul 2023 06:46:12 +0000 (07:46 +0100)]
[AArch64] Fix cost modelling for SVE Min/Max Intrinsics

Add more legal types for SMIN, SMAX, UMIN, UMAX in cost modelling for AArch64

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

15 months ago[mlir][emitc] Add div, mul and rem operators
Marius Brehler [Mon, 10 Jul 2023 12:04:13 +0000 (12:04 +0000)]
[mlir][emitc] Add div, mul and rem operators

This adds operations for binary multiplicative arithmetic operators to
EmitC. The input and output arguments for the remainder operator are
restricted to index (emitted as size_t), integers and the EmitC opaque
types (as the operator can be overloaded for a custom type). The
multiplication and division operator further support floating point
numbers.

Reviewed By: jpienaar

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

15 months ago[mlir][vector] Refine diagnostic messages
Andrzej Warzynski [Tue, 11 Jul 2023 18:50:32 +0000 (19:50 +0100)]
[mlir][vector] Refine diagnostic messages

Clarify a few diagnostics so that they are more consistent with the
corresponding condition. For example:

```
  if (positionAttr.size() >
      static_cast<unsigned>(getSourceVectorType().getRank()))
```

should lead to ("no greater than"):

```
    return emitOpError(
        "expected position attribute of rank no greater than vector rank");

```

as opposed to ("smaller"):

```
    return emitOpError(
        "expected position attribute of rank smaller than vector rank");
```

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

15 months ago[gn build] Port 7d935d083659
LLVM GN Syncbot [Wed, 12 Jul 2023 06:09:47 +0000 (06:09 +0000)]
[gn build] Port 7d935d083659

15 months ago[dataflow] improve determinism of generated SAT system
Sam McCall [Tue, 11 Jul 2023 10:48:30 +0000 (12:48 +0200)]
[dataflow] improve determinism of generated SAT system

Fixes two places where we relied on map iteration order when processing
values, which leaked nondeterminism into the generated SAT formulas.
Adds a couple of tests that directly assert that the SAT system is
equivalent on each run.

It's desirable that the formulas are deterministic based on the input:

 - our SAT solver is naive and perfermance is sensitive to even simple
   semantics-preserving transformations like A|B to B|A.
   (e.g. it's likely to choose a different variable to split on).
   Timeout failures are bad, but *flaky* ones are terrible to debug.
 - similarly when debugging, it's important to have a consistent
   understanding of what e.g. "V23" means across runs.

---

Both changes in this patch were isolated from a nullability analysis of
real-world code which was extremely slow, spending ages in the SAT
solver at "random" points that varied on each run.
I've included a reduced version of the code as a regression test.

One of the changes shows up directly as flow-condition nondeterminism
with a no-op analysis, the other relied on bits of the nullability
analysis but I found a synthetic example to show the problem.

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

15 months ago[Clang] Correctly handle $, @, and ` when represented as UCN
Corentin Jabot [Fri, 23 Jun 2023 11:02:37 +0000 (13:02 +0200)]
[Clang] Correctly handle $, @, and ` when represented as UCN

This covers
 * P2558R2 (C++, wg21.link/P2558)
 * N2701 (C, https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2701.htm)
 * N3124 (C, https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3124.pdf)

This patch
 * Disallow representing $ as a UCN in all language mode, which did not
   properly work (see GH62133), and which in made ill-formed in
   C++ and C by P2558 and N3124 respectively
 * Allow a UCN for any character in C2X, in string and character
   literals

Fixes #62133

Reviewed By: #clang-language-wg, tahonermann

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

15 months ago[InstCombine] Generalize foldAndOrOfICmpEqZeroAndICmp
Dhruv Chawla [Mon, 10 Jul 2023 18:12:30 +0000 (23:42 +0530)]
[InstCombine] Generalize foldAndOrOfICmpEqZeroAndICmp

This patch generalizes the fold implemented by foldAndOrOfICmpEqZeroAndICmp,
which are:

(icmp eq X, 0) | (icmp ult Other, X) -> (icmp ule Other, X-1)
(icmp ne X, 0) & (icmp uge Other, X) -> (icmp ugt Other, X-1)

to the following:

(icmp eq X, C) | (icmp ult Other, (X - C)) -> (icmp ule Other, (X - (C + 1)))
(icmp ne X, C) & (icmp uge Other, (X - C)) -> (icmp ugt Other, (X - (C + 1)))

The function foldAndOrOfICmpEqZeroAndICmp is also renamed to
foldAndOrOfICmpEqConstantAndICmp to reflect the changes.

Proofs: https://alive2.llvm.org/ce/z/yXGv6q

Fixes #63749.

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

15 months ago[InstCombine] Test cases for D154937
Dhruv Chawla [Tue, 11 Jul 2023 10:06:51 +0000 (15:36 +0530)]
[InstCombine] Test cases for D154937

Create test cases for the following two folds:

(icmp eq X, C) | (icmp ult Other, (X - C)) -> (icmp ule Other, (X - (C + 1)))
(icmp ne X, C) & (icmp uge Other, (X - C)) -> (icmp ugt Other, (X - (C + 1)))

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

15 months ago[CodeGen] Part II of "Fine tune MachineFunctionSplitPass (MFS) for FSAFDO".
Han Shen [Fri, 30 Jun 2023 20:02:48 +0000 (13:02 -0700)]
[CodeGen] Part II of "Fine tune MachineFunctionSplitPass (MFS) for FSAFDO".

This CL adds a new discriminator pass. Also adds a new sample profile
loading pass when MFS is enabled.

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

15 months ago[dataflow] document flow condition
Sam McCall [Tue, 11 Jul 2023 14:23:55 +0000 (16:23 +0200)]
[dataflow] document flow condition

There's some documentation of this concept at
https://clang.llvm.org/docs/DataFlowAnalysisIntro.html
but it would be nice to have it closer to the code.

I also was laboring under an obvious but wrong mental model that
the flow condition token represented "execution reached this point",
I'd like to explicitly call that out as wrong.

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

15 months ago[PowerPC] remove XXSWAPD after vector splat immediate
Ting Wang [Wed, 12 Jul 2023 04:58:36 +0000 (00:58 -0400)]
[PowerPC] remove XXSWAPD after vector splat immediate

Redundant XXSWAPD has been observed on little-endian in D138883 test
case. Remove those associated with vector splat instructions.

Reviewed By: shchenz

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

15 months ago[clang][dataflow] Fix initializing a reference field with an `InitListExpr`.
Martin Braenne [Wed, 12 Jul 2023 04:42:48 +0000 (04:42 +0000)]
[clang][dataflow] Fix initializing a reference field with an `InitListExpr`.

I added a test for this as the ongoing migration to strict handling of value categories (see https://discourse.llvm.org/t/70086) will change the code that handles this case. It turns out we already didn't handle this correctly, so I fixed the existing implementation.

Depends On D154961

Reviewed By: xazax.hun

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

15 months ago[clang][dataflow] Include fields initialized in an `InitListExpr` in `getModeledField...
Martin Braenne [Wed, 12 Jul 2023 04:42:32 +0000 (04:42 +0000)]
[clang][dataflow] Include fields initialized in an `InitListExpr` in `getModeledFields()`.

Previously, we were including these fields only in the specific instance that was initialized by the `InitListExpr`, but not in other instances of the same type. This is inconsistent and error-prone.

Depends On D154952

Reviewed By: xazax.hun, gribozavr2

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

15 months ago[clang][dataflow] Various refactorings in TypeErasedDataflowAnalysisTest.cpp
Martin Braenne [Wed, 12 Jul 2023 04:42:15 +0000 (04:42 +0000)]
[clang][dataflow] Various refactorings in TypeErasedDataflowAnalysisTest.cpp

These simplify the code in their own right, but they are also useful in that they minimize the number of changes that will need to be made when then API of `AggregateStorageLocation` and `StructValue` changes as part of the migration to strict handling of value categories (see https://discourse.llvm.org/t/70086).

Depends On D154949

Reviewed By: xazax.hun, gribozavr2

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