Commit Graph

473767 Commits

Author SHA1 Message Date
Amara Emerson
f51b7992c9 [GlobalISel] Precommit a ptradd combine test. 2023-09-04 08:27:20 -07:00
David Green
233fb987fc [ARM] Improve bitwise reduction costs
This adds some basic and/or/xor reduction costs for NEON/MVE, handling them
like other reductions where vector operations are used to reduce to legal
sizes, followed by an optional VREV+VAND/VORR/VEOR step and scalarization from
there.
2023-09-04 16:22:52 +01:00
David Spickett
48987fb8cc [llvm][MC] Remove [[nodiscard]] from WithMarkup constructor
This is causing a lot of warnings with older compilers and
errors for -Werror builders downstream.

I'm removing it until we can decide a good way to do this,
as it does seem important that this class not be discarded
given it controls formatting.
2023-09-04 15:05:07 +00:00
Nicolas Vasilache
5d2bbe9c92 [mlir][Func] Extract datalayout string attribute setting as a separate module pass
FuncToLLVM uses the data layout string attribute in 3 different ways:
1. LowerToLLVMOptions options(&getContext(), getAnalysis<DataLayoutAnalysis>().getAtOrAbove(m));
2. options.dataLayout = llvm::DataLayout(this->dataLayout);
3. m->setAttr(..., this->dataLayout));

The 3rd way is unrelated to the other 2 and occurs after conversion, making it confusing.
This revision separates this post-hoc module annotation functionality into its own pass.
The convert-func-to-llvm pass loses its `data-layout` option and instead recovers it from
the `llvm.data_layout` attribute attached to the module, when present.

In the future, `LowerToLLVMOptions options(&getContext(), getAnalysis<DataLayoutAnalysis>().getAtOrAbove(m))` and
`options.dataLayout = llvm::DataLayout(dataLayout);` should be unified.

Reviewed By: ftynse, mehdi_amini

Differential Revision: https://reviews.llvm.org/D157604
2023-09-04 17:03:19 +02:00
Richard Dzenis
e6d305e64f Add support of Windows Trace Logging macros
Consider the following code:

    #include <windows.h>
    #include <TraceLoggingActivity.h>
    #include <TraceLoggingProvider.h>
    #include <winmeta.h>

    TRACELOGGING_DEFINE_PROVIDER(
        g_hMyComponentProvider,
        "SimpleTraceLoggingProvider",
        // {0205c616-cf97-5c11-9756-56a2cee02ca7}
        (0x0205c616,0xcf97,0x5c11,0x97,0x56,0x56,0xa2,0xce,0xe0,0x2c,0xa7));

    void test()
    {
        TraceLoggingFunction(g_hMyComponentProvider);
    }

    int main()
    {
        TraceLoggingRegister(g_hMyComponentProvider);
        test();
        TraceLoggingUnregister(g_hMyComponentProvider);
    }

It compiles with MSVC, but clang-cl reports an error:

    C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\shared/TraceLoggingActivity.h(377,30): note: expanded from macro '_tlgThisFunctionName'
    #define _tlgThisFunctionName __FUNCTION__
                                 ^
    .\tl.cpp(14,5): error: cannot initialize an array element of type 'char' with an lvalue of type 'const char[5]'
        TraceLoggingFunction(g_hMyComponentProvider);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The second commit is not needed to support above code, however, during isolated tests in ms_predefined_expr.cpp
I found that MSVC accepts code with constexpr, whereas clang-cl does not.
I see that in most places PredefinedExpr is supported in constant evaluation, so I didn't wrap my code with ``if(MicrosoftExt)``.

Reviewed By: cor3ntin

Differential Revision: https://reviews.llvm.org/D158591
2023-09-04 16:54:42 +02:00
David Green
4cef24a886 [ARM] Improve reduction integer min/max costs
This adds some basic smin/smax/umin/umax reduction costs for MVE/NEON, similar
to the existing Add reduction costs. They follow the same style as Add
reductions, but include a higher cost as the costs tend to be dependant on the
element size for vminv/vmaxv. These costs may not be precise, but will be more
inline than the default that extracts each element.
2023-09-04 15:47:06 +01:00
Nicolas Vasilache
62e90db21b [mlir][Transform] Add an example of a preloaded reference lowering to LLVM
Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D159364
2023-09-04 16:20:24 +02:00
Vladislav Dzhidzhoev
a15144f2ba [AArch64][GlobalISel] Lower G_EXTRACT_VECTOR_ELT with variable indices
G_EXTRACT_VECTOR_ELT instructions with non-constant indices are not
selected, so they need to be lowered.

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

Reviewed By: Peter

Differential Revision: https://reviews.llvm.org/D159096
2023-09-04 16:19:16 +02:00
Timm Bäder
bb94817ecf [clang][NFC] Remove stray slash 2023-09-04 16:12:30 +02:00
Nicolas Vasilache
92f088d335 [mlir][gpu][transform] Provide better error messages and avoid crashing in MapForallToBlocks.
This revision addresses issues surfaced in https://reviews.llvm.org/D159093
2023-09-04 14:11:38 +00:00
sdesmalen-arm
dbf9b93f25
[AArch64][SME] Disable tail-call optimization for __arm_locally_streaming functions. (#65258)
When calling a function which requires no streaming-mode change from an
__arm_locally_streaming function, LLVM would otherwise emit:

  // function prologue
  smstart
  b streaming_compatible_function   // tail call
  // never an smstop
2023-09-04 15:11:22 +01:00
Timm Bäder
ac56556047 [clang][Interp][NFC] Rename a parameter
We always call the expression parameter E.
2023-09-04 15:44:09 +02:00
Timm Bäder
1900721ae7 [clang][Interp][NFC] Check some emit* calls for errors
This doesn't make a difference right now but makes future commits
easier.
2023-09-04 15:42:33 +02:00
Timm Bäder
84643bfa87 [clang][Sema] Fix a copy/paste bug in ~Sema()
Differential Revision: https://reviews.llvm.org/D158361
2023-09-04 15:32:35 +02:00
Matthias Springer
2f8690b1e2 [mlir][transform] ApplyRegisteredPassOp: Support pass pipelines
The same transform op can now be used to apply registered pass pipelines.

This revision also adds a helper function for querying `PassPipelineInfo` objects and moves the corresponding `lookup` function for `PassInfo` objects to the `PassInfo` class.

Differential Revision: https://reviews.llvm.org/D159211
2023-09-04 15:11:24 +02:00
Sam McCall
a8c9b9f140 [clangd] Support ConceptReference in generic AST wrangling code
Now we can store it in DynTypedNode, we can target these nodes
(SelectionTree) and resolve them (FindTarget).
This makes Hover, go-to-def etc work in all(?) cases.

Also support it in DumpAST.

Differential Revision: https://reviews.llvm.org/D159299
2023-09-04 14:58:25 +02:00
John Brawn
fae3f9ec4f [ARM] Fix prologue/epilogue for pacbti-m leaf functions
R12 is callee-saved in functions with pacbti-m enabled, but this is
done in assignCalleeSavedSpillSlots, meaning that in
determineCalleeSaves we have to manually set CanEliminateFrame.

This fixes a bug where in leaf functions with no other callee-saved
registers the aut instruction wouldn't be emitted and stack offsets
of arguments passed on the stack would be incorrect.

Differential Revision: https://reviews.llvm.org/D157865
2023-09-04 13:46:01 +01:00
Mel Chen
26aed5b9a8 [VPlan][LoopUtils] Remove unused parameter TTI
This patch removes the member TTI from VPReductionRecipe, as the
generation of reduction operations no longer requires TTI.

Reviewed By: fhahn

Differential Revision: https://reviews.llvm.org/D158148
2023-09-04 05:30:37 -07:00
Adrian Kuegel
ba6af8f63c [mlir][Bazel] Adapt to 2ae5d1c790 2023-09-04 14:08:37 +02:00
Adrian Kuegel
baf2d13519 [mlir][GPUToROCDL] Lower arith.remf to GPU intrinsic.
Differential Revision: https://reviews.llvm.org/D159423
2023-09-04 14:05:04 +02:00
TY-AMD
b1b6c06567
[AMDGPU] Erase ShaderFunctions in AMDGPUPALMetadata::reset() (#65247) 2023-09-04 08:03:01 -04:00
Sam McCall
da5e11cd1c [AST] Support ConceptReference in DynTypedNode, add dump().
The dump() is not actually included recursively in any other nodes' dump,
as this is too verbose (similar to NNS) but useful in its own right.

It's unfortunate to not have the actual tests yet, but the DynTypedNode
tests are matcher-based and adding matchers is a larger task than
DynTypedNode support (but can't be done first).

(I've got a clangd change stacked on this that uses DynTypedNode and
dump(), and both work. I'll send a change for matchers next).

Differential Revision: https://reviews.llvm.org/D159300
2023-09-04 13:56:15 +02:00
David Green
2955cc15ff [ARM] Improve costs for FMin/Max reductions
Similar to the other reductions, this changes the cost of fmin/fmax reductions
under MVE/NEON to perform vector operations until the types need to be
scalarized. The fp16 vectors can perform a VREV+FMIN/FMAX to skip a step of the
reduction, and otherwise need lanewise extract fro the top lanes.
2023-09-04 12:49:13 +01:00
Sam McCall
3dcf3cbc42 [ASTMatchers] Bring comments & docs back in sync
415d9e8ca3 edited the generated html
directly without updating the source of truth.
2023-09-04 13:42:29 +02:00
Adrian Kuegel
640b95da80 [mlir][GPU] Lower arith.remf to GPU intrinsic.
Differential Revision: https://reviews.llvm.org/D159422
2023-09-04 13:38:45 +02:00
Florian Hahn
3fa1b254b7
[VPlan] Print blend recipe as operand directly, instead of IR PHI.
Update VPBlendRecipe::print() to print the result directly, instead of
relying on the stored Phi pointer. This brings the recipe in line with
how other recipes are printed.
2023-09-04 12:35:58 +01:00
Matthias Springer
f25217fb9e [mlir][linalg] Add matmul -> tiling -> GPU -> vectorization lowering example
Differential Revision: https://reviews.llvm.org/D156371
2023-09-04 13:33:21 +02:00
Ingo Müller
33278321e6 [mlir][linalg][transform][python] Make divisor arg to Multitile optional
The mix-in of the `MultiTileSizesOp` set the default value of its
`divisor` argument. This repeats information from the tablegen
defintion, is not necessary (since the generic code deals with `None`
and default values), and has the risk of running out of sync without
people noticing. This patch removes the setting of the value and forward
`None` to the generic constructor instead.

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D159416
2023-09-04 11:32:56 +00:00
Ingo Müller
ea4a5127c4 [mlir][linalg][transform][python] Refactor TileOp mix-in.
This patch simplifies and improves the mix-in of the `TileOp`. In
particular:

* Accept all types of sizes (static, dynamic, scalable) in a single
  argument `sizes`.
* Use the existing convenience function to dispatch different types of
  sizes instead of repeating the implementation in the mix-in.
* Pass on `None` values as is of optional arguments to the init function
  of the super class.
* Reformat with default indentation width (4 spaces vs 2 spaces).
* Add a a test for providing scalable sizes.

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D159417
2023-09-04 11:32:14 +00:00
Ingo Müller
d5946fd3ed [mlir][linalg][transform][python] Simplify mix-in of PadOp.
This patch removes some manual conversion of mixed Python/attribute
arguments to `I64ArrayAttr`s, which turned out to be unnecessary.
Interestingly, this change does not depend on the additional attribute
builders added in the (currently pending)
https://reviews.llvm.org/D159403 patch.

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D159419
2023-09-04 11:30:50 +00:00
Matthias Springer
b76a180d3b [mlir][linalg] Fix bufferize_to_allocation error checking
`bufferize_to_allocation` does not supports ops with regions, unless `bufferize_destination_only` is set. In that case, only the operand is replaced with an allocation and wrapped in a `to_tensor` op. The error checking was too strict.

Differential Revision: https://reviews.llvm.org/D159420
2023-09-04 13:13:35 +02:00
Florian Hahn
cb54522853
[LV] Add test coverage for adding DebugLoc to vector select.
Add missing test coverage for selects with !dbg info.
2023-09-04 12:01:14 +01:00
Egor Zhdan
86c31c1406
[APINotes] Remove unused OS-availability feature
iOS/OSX-specific availability is a legacy of compiled API Notes which
are not supported and were removed from Apple Clang in 2019 (see
30fc70f349).
2023-09-04 11:59:11 +01:00
Tom Eccles
ad9af7de90 [flang][LoopVersioning] support fir.array_coor
This is the last piece required for the loop versioning patch to work on
code lowered via HLFIR. With this patch, HLFIR performance on spec2017
roms is now similar to the FIR lowering.

Adding support for fir.array_coor means that many more loops will be
versioned, even in the FIR lowering. So far as I have seen, these do not
seem to have an impact on performance for the benchmarks I tried, but I
expect it would speed up some programs, if the loop being versioned
happened to be the hot code.

The main difference between fir.array_coor and fir.coordinate_of is
that fir.coordinate_of uses zero-based indices, whereas fir.array_coor
uses the indices as specified in the Fortran program (starting from 1 by
default, but also supporting non default lower bounds). I opted to
transform fir.array_coor operations into fir.coordinate_of operations
because this allows both to share the same offset calculation logic.

The tricky bit of this patch is getting the correct lower bounds for the
array operand to subtract from the fir.array_coor indices to get a
zero-based indices. So far as I can tell, the FIR lowering will always
provide lower bounds (shift) information in the shape operand to the
fir.array_coor when non-default lower bounds are used. If none is given,
I originally tried falling back to reading lower bounds from the box,
but this led to misscompilation in SPEC2017 cam4. Therefore the pass
instead assumes that if it can't already find an SSA value for the shift
information, the default lower bound (1) should be used.

A suspect the incorrect lower bounds in the box for the FIR lowering was
already a known issue (see https://reviews.llvm.org/D158119).

Differential Revision: https://reviews.llvm.org/D158597
2023-09-04 10:40:40 +00:00
David Green
4530f02916 [ARM] Improve reduction fadd/fmul costs
This adds some basic fadd/fmul reduction costs for MVE/NEON. It reduces by
halving the vector size until it it gets scalarized, with some additional costs
for fp16 which may require extracting the top lanes.

Differential Revision: https://reviews.llvm.org/D159367
2023-09-04 11:37:14 +01:00
Sergio Afonso
2ae5d1c790
Revert "Revert "[MLIR] Move builtin.module LLVM IR translation to before nested operations""
This reverts commit 823151f0cf.
2023-09-04 11:35:59 +01:00
Sander de Smalen
916415b837 [AArch64][SME] Make the overloaded svreinterpret_* functions streaming-compatible.
Otherwise these functions are not inlined when invoked from streaming
functions.

Reviewed By: paulwalker-arm

Differential Revision: https://reviews.llvm.org/D159188
2023-09-04 10:15:26 +00:00
Sander de Smalen
702c3f56d3 [SME] Don't scavenge a spillslot in callee-save area in presence of streaming-mode changes.
If no frame-pointer is available and the compiler has scavenged a
spill-slot in the callee-save area, the compiler may be forced to emit an
'addvl' inside the streaming-mode-changing call sequence when it needs to
fill (reload) an FP register being passed to the call.

We can avoid this entirely by disabling stack-slot scavenging when there
are streaming-mode-changing call-sequences in the function.

Reviewed By: david-arm

Differential Revision: https://reviews.llvm.org/D159196
2023-09-04 10:14:44 +00:00
Biplob Mishra
a4318a2566 Precommit tests for gep has phi ptr 2023-09-04 11:11:58 +01:00
Sjoerd Meijer
a5a6008988 [AArch64] Fix schedmodel pre/post-index loads and stores for Neoverse V2
Fix the operand description: the update was in the wrong place. As a result the
latency of the update was modelled incorrectly, it wasn't available as early as
it should. This was visible in llvm-mca timeline views.

This fixes the problem for the Neoverse V2, but the problem also affects the
other Neoverse cores.

Patch by: Ricardo Jesus

Differential Revision: https://reviews.llvm.org/D159254
2023-09-04 11:09:06 +01:00
David Green
5afb161ed5 [ARM] Add various vector reduce costmodel tests. NFC
See D159367 and the followups.
2023-09-04 10:50:58 +01:00
Tejas Joshi
0609b65aaf
[SCEV] Fix potentially empty set for unsigned ranges
The following commit enabled the analysis of ranges for heap allocations:
22ca38da25

The range turns out to be empty in cases such as the one in test (which
is [1,1)), leading to an assertion failure. This patch fixes for the
same case.

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

Reviewed By: fhahn

Differential Revision: https://reviews.llvm.org/D159160
2023-09-04 10:46:53 +01:00
Carlos Galvez
fdb6e8b792
[clang-tidy][NFC][doc] Improve documentation for modernize-use-equals… (#65231)
…-delete

So the purpose of the check is more clear. Update examples code to show
compliant code.

Fixes #65221

---------

Co-authored-by: Carlos Gálvez <carlos.galvez@zenseact.com>
2023-09-04 11:45:04 +02:00
Luke Lau
6098d7d5f6 [RISCV] Lower shuffles as rotates without zvbb
Now that the codegen for the expanded ISD::ROTL sequence has been improved,
it's probably profitable to lower a shuffle that's a rotate to the
vsll+vsrl+vor sequence to avoid a vrgather where possible, even if we don't
have the vror instruction.

This patch relaxes the restriction on ISD::ROTL being legal in
lowerVECTOR_SHUFFLEAsRotate. It also attempts to do the lowering twice: Once
if zvbb is enabled before any of the interleave/deinterleave/vmerge lowerings,
and a second time unconditionally just before it falls back to the vrgather.
This way it doesn't interfere with any of the above patterns that may be more
profitable than the expanded ISD::ROTL sequence.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D159353
2023-09-04 09:35:12 +01:00
Martin Braenne
bf46b0b551 [clang][dataflow] Eliminate deprecated ControlFlowContext::build() overload.
Reviewed By: ymandel, xazax.hun

Differential Revision: https://reviews.llvm.org/D159262
2023-09-04 08:30:54 +00:00
Martin Braenne
d948d9121f [clang][dataflow] Remove deprecated synonyms related to RecordStorageLocation and RecordValue
Reviewed By: ymandel, xazax.hun

Differential Revision: https://reviews.llvm.org/D159264
2023-09-04 08:18:43 +00:00
Nuno Lopes
66a652ab08 recommit test for #65212 2023-09-04 09:17:18 +01:00
Ingo Müller
9b91ae13f4 [mlir][python][linalg][transform] Forward missing params in mix-ins. 2023-09-04 07:59:12 +00:00
Muhammad Omair Javaid
42a46730bb Revert "fix test for #65212"
This reverts commit a0b0d7493d.

It has broken following buildbots:

https://lab.llvm.org/buildbot/#/builders/188/builds/34873
https://lab.llvm.org/buildbot/#/builders/245/builds/13538
https://lab.llvm.org/buildbot/#/builders/65/builds/11074
2023-09-04 12:53:12 +05:00
Martin Braenne
266c12a1bd [clang][dataflow] When dumping ExprToVal, dump the Value, not just its location.
This makes `ExprToVal` dumping consistent with `LocToVal` dumping.

Reviewed By: ymandel, xazax.hun

Differential Revision: https://reviews.llvm.org/D159274
2023-09-04 07:38:33 +00:00