Commit Graph

465378 Commits

Author SHA1 Message Date
Hongtao Yu
09742be818 [llvm-profgen] Remove target triple check to allow for more targets
Llvm-profgen internally uses the llvm libraries and the MCDesc interface to do disassembling and symblization and it never checks against target-specific instruction operators. This makes it quite transparent to targets and a first attempt for an aarch64 binary just works. Therefore I'm removing the unnecessary triple check to unblock for new targets.

Reviewed By: wenlei

Differential Revision: https://reviews.llvm.org/D153449
2023-06-23 10:16:24 -07:00
Fangrui Song
620bff758d [llvm-addr2line] Replace checkFileExists with getOrCreateModuleInfo
GNU addr2line exits immediately if -e (default to a.out) specifies a file that
cannot be open or a directory. llvm-addr2line used to wait for input on if the
input file cannot be open and addresses are not specified in command line.
Replace the D147652 checkFileExists with getOrCreateModuleInfo to avoid
a separate `sys::fs::status` operation.

Reviewed By: sepavloff

Differential Revision: https://reviews.llvm.org/D153595
2023-06-23 10:04:13 -07:00
Wenlei He
9a868a902c [LoopSink] Allow sinking to PHI-use (2nd attempt)
This change allows sinking defs from loop preheader with PHI-use into loop body. Loop sink can now see through PHI-use and select incoming blocks of value being used as candidate sink destination.

It makes loop sink more effective so more LICM can be undone if proven unprofitable with profile info. It addresses the motivating case in D87551, without resorting to profile guided LICM which breaks canonicalization.

This is the 2nd attempt after D152772.
2023-06-23 09:52:03 -07:00
Valentin Clement
8015ea6a6d
[flang] Enhance getTypeAsString for RecordType
Add support for RecordType in getTypeAsString

Depends on D153461

Reviewed By: razvanlupusoru, jeanPerier

Differential Revision: https://reviews.llvm.org/D153467
2023-06-23 09:51:05 -07:00
Fangrui Song
f9fd0062b6 [XRay][AArch64] Suppport __xray_customevent/__xray_typedevent
`__xray_customevent` and `__xray_typedevent` are built-in functions in Clang.
With -fxray-instrument, they are lowered to intrinsics llvm.xray.customevent and
llvm.xray.typedevent, respectively. These intrinsics are then lowered to
TargetOpcode::{PATCHABLE_EVENT_CALL,PATCHABLE_TYPED_EVENT_CALL}. The target is
responsible for generating a code sequence that calls either
`__xray_CustomEvent` (with 2 arguments) or `__xray_TypedEvent` (with 3
arguments).

Before patching, the code sequence is prefixed by a branch instruction that
skips the rest of the code sequence. After patching
(compiler-rt/lib/xray/xray_AArch64.cpp), the branch instruction becomes a NOP
and the function call will take effects.

This patch implements the lowering process for
{PATCHABLE_EVENT_CALL,PATCHABLE_TYPED_EVENT_CALL} and implements the runtime.

```
// Lowering of PATCHABLE_EVENT_CALL
.Lxray_sled_N:
  b  #24
  stp x0, x1, [sp, #-16]!
  x0 = reg of op0
  x1 = reg of op1
  bl __xray_CustomEvent
  ldrp x0, x1, [sp], #16
```

As a result, two updated tests in compiler-rt/test/xray/TestCases/Posix/ now
pass on AArch64.

Reviewed By: peter.smith

Differential Revision: https://reviews.llvm.org/D153320
2023-06-23 09:24:18 -07:00
Piotr Zegar
b0f6fd24dc [clang-tidy] Document modernize-raw-string-literal check options
Add missing documentation for DelimiterStem and ReplaceShorterLiterals
options.

Fixes #54662

Reviewed By: Eugene.Zelenko

Differential Revision: https://reviews.llvm.org/D153639
2023-06-23 16:14:15 +00:00
Ties Stuij
5ddd561cb5 disable execute-only tests which are failing with expensive checks
Temporarily disabling the execute-only tests. We recently added codegen for
armv6-m, which is still in heavy development (D152795).

Disabling the tests while we're figuring out what's going on is probably the
least disruptive option, as a patch dependent on it also already landed.
2023-06-23 16:35:24 +01:00
Simon Pilgrim
1f006f5fb6 [DAG] mergeTruncStores - early out if we collect more than the maximum number of stores
If we have an excessive number of stores in a single chain then the candidate WideVT may exceed the maximum width of an EVT integer type (and will assert) - but since mergeTruncStores doesn't support anything wider than a i64 store we should just early-out if we've collected more than stores than that.

Fixes #63306
2023-06-23 16:22:11 +01:00
Nikita Popov
b51153792b [LSR] Convert some tests to opaque pointers (NFC) 2023-06-23 17:13:57 +02:00
Nikita Popov
2c9aba9352 [LSR] Regenerate test checks (NFC) 2023-06-23 17:06:51 +02:00
Nikita Popov
6b83c06aab [ArgPromotion] Remove code for handling typed pointers (NFC) 2023-06-23 16:57:07 +02:00
eopXD
703c1c7e78 [RISCV] Add a policy operand to VPseudoBinaryNoMaskTURoundingMode [NFC]
The template was created in D151396 but was not aware of the change in
D153067. This commit adds the operand and keep similar templates
aligned.

Reviewed By: reames, craig.topper

Differential Revision: https://reviews.llvm.org/D153506
2023-06-23 07:39:27 -07:00
Emilia Kond
7a38b3bfeb
[clang-format] Respect ColumnLimit 0 line breaks in inline asm
Previously, using ColumnLimit: 0 with extended inline asm with the
BreakBeforeInlineASMColon: OnlyMultiline option (the default style),
the formatter would act as if in Always mode, meaning a line break was
added before every colon in an extended inline assembly block.

This patch respects the already existing line breaks, and doesn't add
any new ones, if in ColumnLimit 0 mode.

Behaviour with Always stays as expected, with a break before every colon
regardless of any existing line breaks.

Behaviour with Never was broken before, and remains broken with this patch,
it is just never respected in ColumnLimit 0 mode.

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

Reviewed By: HazardyKnusperkeks, owenpan

Differential Revision: https://reviews.llvm.org/D150848
2023-06-23 17:30:24 +03:00
Nikita Popov
ab94c1bad3 [InstCombine] Add created extracts to worklist
Use InstCombine's insertion helper for the created extracts, so
they become part of the worklist and will be revisited.
2023-06-23 16:11:47 +02:00
David Green
589c940eb3 [DAG] Fix and expand fmin/fmax reassociation fold.
This call to reassociateReduction is used by both fminnum/fmaxnum and
fminimum/fmaximum. In adding support for fminimum/fmaximum we appear to be
fixing the use of an incorrect reduction type, which should have only applied
to minnum/maxnum.

I also believe that it doesn't need nsz and reassoc to perform the
reassociation. For float min/max it should always be valid.

Differential Revision: https://reviews.llvm.org/D153247
2023-06-23 14:45:14 +01:00
Nikita Popov
8762f4c748 [InstCombine] Track inserted instructions when lowering objectsize
The inserted instructions can usually be simplified. Make sure this
happens in the same InstCombine iteration by adding them to the
worklist.

We happen to get some better optimization in two cases, but this is
just a lucky accident. https://github.com/llvm/llvm-project/issues/63472
tracks implementing a fold for that case.

This doesn't track all inserted instructions yet, for that we would
also have to include those created by ObjectSizeOffsetEvaluator.
2023-06-23 15:36:23 +02:00
Takuya Shimizu
940c94e1c1 [clang][Sema] Fix comments to conform to bugprone-argument-comment (NFC)
Makes some comments conform to bugprone-argument-comment (https://clang.llvm.org/extra/clang-tidy/checks/bugprone/argument-comment.html)
2023-06-23 22:25:04 +09:00
Alex Bradbury
65de5a16c4 [RISCV][doc] Document support for zvfbfmin and zvfbfwma
My MC layer support patches missed adding these to RISCVUsage. Also
update the link to the most recent spec PDF (including the recently
committed encoding fix for vfwmaccbf16.
2023-06-23 14:22:25 +01:00
Alex Bradbury
690b1c847f [RISCV] Implement support for bf16 truncate/extend on hard FP targets
For the same reasons as D151284, this requires custom lowering of the
truncate libcall on hard float ABIs (the normal libcall code path is
used on soft ABIs).

The extend operation is implemented by a shift just as in the standard
legalisation, but needs to be custom lowered because i32 isn't a legal
type on RV64.

This patch aims to make the minimal changes that result in correct
codegen for the bfloat.ll tests.

Differential Revision: https://reviews.llvm.org/D151663
2023-06-23 14:18:59 +01:00
Matt Arsenault
d7feba74b6 HIP: Directly call trunc builtins 2023-06-23 09:11:06 -04:00
Matt Arsenault
2449931b01 AMDGPU: Don't use old form of fneg in some tests 2023-06-23 09:11:06 -04:00
Matt Arsenault
c56e4a8c42 AMDGPU: Modernize exp codegen tests
Find and replace on the new log tests (plus <3 x half> which was
missing). Apparently exp10 never worked.
2023-06-23 09:11:06 -04:00
Alex Bradbury
d532484468 [RISCV][MC] Fix encoding for vfwmaccbf16
The encoding matched the one given in the bf16 extension specification
PDF, but per https://github.com/riscv/riscv-bfloat16/issues/45 it seems
this encoding was not the one that is intended and was incorrectly
modified due to an issue in the PDF generation process. This patch
corrects the opcode to 111011 from 100011.

The correct encoding is shown in the new spec PDF
<https://github.com/riscv/riscv-bfloat16/releases/tag/20230614>.

Differential Revision: https://reviews.llvm.org/D152894
2023-06-23 14:01:52 +01:00
Aaron Ballman
82e29c65e3 Fixed failed assertion w/attribute on anon unions
This amends 304d1304b7 to process the
declaration attributes rather than assert on them; nothing prevents an
attribute from being written on an anonymous union.

Fixes https://github.com/llvm/llvm-project/issues/48512
2023-06-23 08:58:37 -04:00
John Brawn
5421ab4625 [lld][ARM] Add support for 16-bit thumb group relocations
This adds support for the following relocations:
 * R_ARM_THM_ALU_ABS_G0_NC
 * R_ARM_THM_ALU_ABS_G1_NC
 * R_ARM_THM_ALU_ABS_G2_NC
 * R_ARM_THM_ALU_ABS_G3
as defined in:
https://github.com/ARM-software/abi-aa/blob/main/aaelf32/aaelf32.rst#5615static-thumb16-relocations

Differential Revision: https://reviews.llvm.org/D153407
2023-06-23 13:43:04 +01:00
Matt Arsenault
89ccfa1b39 AMDGPU: Use correct lowering for llvm.log2.f32
We previously directly codegened to v_log_f32, which is broken for
denormals. The lowering isn't complicated, you simply need to scale
denormal inputs and adjust the result. Note log and log10 are still
not accurate enough, and will be fixed separately.
2023-06-23 08:37:37 -04:00
Ivan Kosarev
813f6a495b [AMDGPU][GFX11] Add test coverage for 16-bit conversions, part 12.
Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D152905
2023-06-23 13:33:06 +01:00
Matt Arsenault
089f652f17 AMDGPU: Add more log vector tests 2023-06-23 08:28:42 -04:00
Marius Brehler
0f1ac5e110 [mlir][emitc] Add add and sub operations
This adds operations for binary additive operators to EmitC. The input
arguments to these ops can be EmitC pointers and thus the operations can
be used for pointer arithmetic.

Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D149963
2023-06-23 12:15:06 +00:00
Haojian Wu
6585dd3b83 [clangd] Replace the hacky include-cleaner macro-reference implementation.
Now MainFileMacros preserves enough information, we perform a just-in-time
convertion to interop with include-cleaner::Macro for include-cleaer features.

Differential Revision: https://reviews.llvm.org/D147034
2023-06-23 14:08:55 +02:00
Nikita Popov
407ff50eca [SCEV] Add test for alloca ranges (NFC) 2023-06-23 14:08:39 +02:00
Ivan Kosarev
5183ca8779 [AMDGPU][AsmParser] Eliminate cvtMtbuf().
Now that we have proper support for optional operands, the standard LLVM
machinery can take care of converting parsed instructions to MCInsts.
There are likely more cases where the conversion can be done
automatically, probably with some additional treatment. The plan is to
address them separately.

Part of <https://github.com/llvm/llvm-project/issues/62629>.

Reviewed By: arsenm, foad

Differential Revision: https://reviews.llvm.org/D153565
2023-06-23 12:43:52 +01:00
Ivan Kosarev
9435942447 [AMDGPU][GFX11] Add test coverage for 16-bit conversions, part 10.
Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D152903
2023-06-23 12:24:52 +01:00
Nikita Popov
a68c968755 [ValueTracking] Correctly check addrspace of alloca
The DataLayout alloca address space is the address space that should
be used when creating new allocas. However, not all allocas are
required to be in this address space. The isKnownNonZero() check
should work on the actual address space of the alloca, not the
default alloca address space.
2023-06-23 13:11:28 +02:00
Aaron Ballman
63342ae4b8 Fix a failing assertion with implicit function definitions
When implicitly defining a function in C, we would try to find an
appropriate declaration context for the function to be declared within.
However, we did not account for GNU statement expressions, which
masquerade as a compound statement and can be used in other contexts
such as within structure member declarations.

Fixes https://github.com/llvm/llvm-project/issues/48579
2023-06-23 07:02:21 -04:00
Michael Platings
041ffc155f [Clang][Driver] Warn on invalid Arm or AArch64 baremetal target triple
A common user mistake is specifying a target of aarch64-none-eabi or
arm-none-elf whereas the correct names are aarch64-none-elf &
arm-none-eabi. Currently if a target of aarch64-none-eabi is specified
then the Generic_ELF toolchain is used, unlike aarch64-none-elf which
will use the BareMetal toolchain. This is unlikely to be intended by the
user so issue a warning that the target is invalid.

The target parser is liberal in what input it accepts so invalid triples
may yield behaviour that's sufficiently close to what the user intended.
Therefore invalid triples were used in many tests. This change updates
those tests to use valid triples.
One test (gnu-mcount.c) relies on the Generic_ELF toolchain behaviour so
change it to explicitly specify aarch64-unknown-none-gnu as the target.

Reviewed By: peter.smith, DavidSpickett

Differential Revision: https://reviews.llvm.org/D153430
2023-06-23 11:54:29 +01:00
Luke Lau
1c70c2bc2c [CostModel] Use operands argument in getInstructionCost in more places
The current instruction's pointer operand may be different from the one
specified in the Operands argument. We should use the pointer operand
from here instead in case the user has transformed it.

This manifested itself somewhere down the line in
https://reviews.llvm.org/D149889, but I haven't been able to create a
test case on its own yet unfortunately.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D153574
2023-06-23 11:52:27 +01:00
Nikita Popov
406e9c9372 [SCEV] Use object size for allocas as well
The object size and alignment based restriction on the possible
allocation range also applies to allocas, not just globals, so
handle them as well.

We shouldn't really need any type restriction here at all, but
for now stay conservative.
2023-06-23 12:38:12 +02:00
Nikita Popov
6555b5dc99 [SCEV] Store getValue() result in variable (NFC) 2023-06-23 12:31:36 +02:00
David Green
71ac2a8e23 [AArch64] Add tests for double reducts of vector.reduce.fmaximum/fminimum. NFC
Including some tests with mixed minnum/minimum reductions and removing the fast
from fmin/fmax reductions as those should not be needed.
2023-06-23 11:28:09 +01:00
Serge Pavlov
1099208b99 [symbolizer] Check existence of input file in GNU mode
GNU addr2line exits immediately if it cannot open the file specified as
executable/relocatable. In contrast llvm-addr2line does not exit and, if
addresses are not specified in command line, waits for input on stdin. This
causes the test compiler-rt/test/asan/TestCases/Posix/asan-symbolize-bad-path.cc to block
forever on Gentoo (see https://reviews.llvm.org/rG27c4777f41d2ab204c1cf84ff1cccd5ba41354da#1190273).
To fix this issue the behavior llvm-addr2line now exits if
executable/relocatable file cannot be found.

It fixes https://github.com/llvm/llvm-project/issues/42099 (llvm-addr2line
does not exit when passed a non-existent file).

Differential Revision: https://reviews.llvm.org/D147652
2023-06-23 17:20:15 +07:00
Nikita Popov
7cf567d461 [ConstantRange] Calculate precise range for multiply by -1
These are pretty common in SCEV, so make sure we get a precise
result by mapping to the sub() operation.
2023-06-23 12:17:48 +02:00
Igor Kirillov
04a8070b46 Revert "Revert "[CodeGen] Extend reduction support in ComplexDeinterleaving pass to support predication""
Adds the capability to recognize SelectInst that appear in the IR.
These instructions are generated during scalable vectorization for reduction
and when the code contains conditions inside the loop body or when
"-prefer-predicate-over-epilogue=predicate-dont-vectorize" is set.

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

This reverts commit ab09654832.

Reason: Reapplying after removing unnecessary default case in switch expression.
2023-06-23 10:13:22 +00:00
Ties Stuij
2273741ea2 [ARM] generate armv6m eXecute Only (XO) code
[ARM] generate armv6m eXecute Only (XO) code for immediates, globals

Previously eXecute Only (XO) support was implemented for targets that support
MOVW/MOVT (~armv7+). See: https://reviews.llvm.org/D27449

XO prevents the compiler from generating data accesses to code sections. This
patch implements XO codegen for armv6-M, which does not support MOVW/MOVT, and
must resort to the following general pattern to avoid loads:

    movs    r3, :upper8_15:foo
    lsls    r3, #8
    adds    r3, :upper0_7:foo
    lsls    r3, #8
    adds    r3, :lower8_15:foo
    lsls    r3, #8
    adds    r3, :lower0_7:foo
    ldr     r3, [r3]

This is equivalent to the code pattern generated by GCC.

The above relocations are new to LLVM and have been implemented in a parent
patch: https://reviews.llvm.org/D149443.

This patch limits itself to implementing codegen for this pattern and enabling
XO for armv6-M in the backend.

Separate patches will follow for:
- switch tables
- replacing specific loads from constant islands which are spread out over the
  ARM backend codebase. Amongst others: FastISel, call lowering, stack frames.

Reviewed By: john.brawn

Differential Revision: https://reviews.llvm.org/D152795
2023-06-23 10:50:47 +01:00
pvanhout
2f7ab29624 [NFC] clang-format GlobalISelEmitter.cpp
It was overdue for a clang-format run, and it avoids unrelated formatting changes sneaking into diffs.
2023-06-23 11:42:51 +02:00
pvanhout
fd33821650 [NFC] Remove leftover inline on some RuleMatcher functions
Accidentally copy-pasted them into the .cpp while refactoring the file in D151432
Those functions are currently only used in the .cpp so it didn't cause an issue, but it causes an undefined reference if another file attempts to use them.
2023-06-23 11:39:56 +02:00
Jolanta Jensen
c5ed93f975 [SVE ACLE] Remove DAG combines that are no longer relevant.
This patch removes DAG combines that are no longer relevant
because equivalent IR combines have been added.

Differential Revision: https://reviews.llvm.org/D153445
2023-06-23 09:09:07 +00:00
Jeremy Furtek
55c2211a23 [APFloat] Add APFloat semantic support for TF32
This diff adds APFloat support for a semantic that matches the TF32 data type
used by some accelerators (most notably GPUs from both NVIDIA and AMD).

For more information on the TF32 data type, see https://blogs.nvidia.com/blog/2020/05/14/tensorfloat-32-precision-format/.
Some intrinsics that support the TF32 data type were added in https://reviews.llvm.org/D122044.

For some discussion on supporting common semantics in `APFloat`, see similar
efforts for 8-bit formats at https://reviews.llvm.org/D146441, as well as
https://discourse.llvm.org/t/rfc-adding-the-amd-graphcore-maybe-others-float8-formats-to-apfloat/67969.

A subsequent diff will extend MLIR to use this data type. (Those changes are
not part of this diff to simplify the review process.)

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D151923
2023-06-23 10:54:49 +02:00
Kazu Hirata
2764322912 [LegacyPM] Remove LowerMatrixIntrinsicsLegacyPass and LowerMatrixIntrinsicsMinimalLegacyPass
Differential Revision: https://reviews.llvm.org/D153615
2023-06-23 01:32:38 -07:00
Kazu Hirata
0fd1e93bd7 [LegacyPM] Remove unused declaration initializeAnnotation2MetadataLegacyPass
The corresponding function definition was removed by:

  commit 773d663e47
  Author: Arthur Eubanks <aeubanks@google.com>
  Date:   Mon Feb 27 19:00:37 2023 -0800
2023-06-23 01:32:36 -07:00