533833 Commits

Author SHA1 Message Date
PeterChou1
6d98d45c9c
reland [clang-doc][NFC] refactor out file helpers (#135164)
Split from https://github.com/llvm/llvm-project/pull/133161

refactor the code to extract file helpers used in HTML generators for
use in other generators for clang-doc

This patch fixes the error where compiling with
-DLLVM_LINK_LLVM_DYLIB=ON broke the buildbot
2025-04-10 07:58:29 -04:00
Nico Weber
dcb2ae126d [gn] port e10f67a8270c774 2025-04-10 07:50:13 -04:00
Benjamin Maxwell
c7745b0bab
[AArch64][test] Regenerate arm64-st1.ll using update_llc_test_checks.py (NFC) (#134919)
This is a fairly large test file which can be annoying to manually
update. Using --filter-out gets pretty close to the original checks.
2025-04-10 12:48:42 +01:00
Han-Kuan Chen
d02a704ec9
[SLP][REVEC] Make getExtractWithExtendCost support FixedVectorType as Dst. (#134822) 2025-04-10 18:54:45 +08:00
Simon Pilgrim
64b5e8f2b7 [X86] masked_gather_scatter.ll - clean up check prefixes
Share X86/X64 common prefixes as much as possible to reduce duplication
2025-04-10 11:34:11 +01:00
Nikita Popov
20507a9e95
[Verifier][CGP] Allow integer argument to dbg_declare (#134803)
Relaxes the newly added verifier rule to also allow an integer argument
to dbg_declare, which is interpreted as a pointer. Adjust CGP to deal with
it gracefully.

Fixes https://github.com/llvm/llvm-project/issues/134523.
Alternative to https://github.com/llvm/llvm-project/pull/134601.
2025-04-10 12:29:56 +02:00
Dominik Adamski
716b02d8c5
[LLVM][MemCpyOpt] Unify alias tags if we optimize allocas (#129537)
Optimization of alloca instructions may lead to invalid alias tags.
Incorrect alias tags can result in incorrect optimization outcomes for
Fortran source code compiled by Flang with flags: `-O3 -mmlir
-local-alloc-tbaa -flto`.

This commit removes alias tags when memcpy optimization replaces two
arrays with one array, thus ensuring correct compilation of Fortran
source code using flags: `-O3 -mmlir -local-alloc-tbaa -flto`.

This commit is also a proposal to fix the reported issue:
https://github.com/llvm/llvm-project/issues/133984

---------

Co-authored-by: Shilei Tian <i@tianshilei.me>
2025-04-10 12:23:53 +02:00
Michael Kruse
2fe123a119 Revert "Remember LLVM_ENABLE_LIBCXX setting in installed configuration (#134990)"
This reverts commit 785e7f06ddb1ba36aa679d23436726dcf61f8afb.

It did not solve the problem with flang-aarch64-libcxx and caused
another failure with openmp-offload-amdgpu-runtime-2.
2025-04-10 11:57:06 +02:00
Jay Foad
e3350a6263
[AMDGPU] InstCombine llvm.amdgcn.ds.bpermute with uniform arguments (#130133)
Reland #129895 with a fix to avoid trying to combine bpermute of
bitcast.
2025-04-10 10:36:38 +01:00
Pavel Labath
cdb9c6190f
[lldb] Support negative function offsets in UnwindPlans (#134662)
These are needed for functions whose entry point is not their lowest
address.
2025-04-10 11:31:44 +02:00
Philip Reames
d34437e9e1
[RISCV] Recognize a zipeven/zipodd requiring larger SEW (#134923)
This is a follow up to f8ee58a3c, and improves code generation for the
XRivosVizip extension.

If we have a slide pair which could be a zipeven or zipodd if the
shuffle was widened, widen the shuffle and then mask the zipeven or
zipodd.

This is basically working around an order of matching issue; we match
the slide pair variants before trying widening. I considered whether we
should just widen slide pairs without any consideration of the zip
idioms, but the resulting codegen changes look mostly like churn, and
have no clear evidence of profitability.
2025-04-10 02:29:04 -07:00
David Spickett
d9cfd90524 [ci] Improve wording in CI test reports
We weren't saying where to click, make it clear you click on a
test name.
2025-04-10 09:20:13 +00:00
Michael Kruse
785e7f06dd
Remember LLVM_ENABLE_LIBCXX setting in installed configuration (#134990)
The buidbot
[flang-aarch64-libcxx](https://lab.llvm.org/buildbot/#/builders/89) is
currently failing with an ABI issue. The suspected reason is that
LLVMSupport.a is built using libc++, but the unittests are using the
default C++ standard library, libstdc++ in this case. This predefined
`llvm_gtest` target uses the LLVMSupport from `find_package(LLVM)`,
which finds the libc++-built LLVMSupport.

To fix, store the `LLVM_ENABLE_LIBCXX` setting in the LLVMConfig.cmake
such that everything that links to LLVM libraries use the same standard
library. In this case discussed in
https://github.com/llvm/llvm-zorg/pull/387 it was the flang-rt
unittests, but other runtimes with GTest unittests should have the same
issue (e.g. offload), and any external project that uses
`find_package(LLVM)`.
2025-04-10 11:18:51 +02:00
Abhishek Kaushik
5543d9ded7
[RegAlloc][NFC] Use std::move to avoid copy (#134533) 2025-04-10 14:45:02 +05:30
Fraser Cormack
7d32d72f10 [libclc][NFC] Remove blank line at end of file 2025-04-10 10:02:51 +01:00
Romaric Jodin
135a7874dc
libclc: clspv: fma: remove fp16 implementation (#135002)
clspv is already handling generation of fp16. This implementation is
preventing clspv from making the best choice to use an emulation on top
of fp32-fma, or the native fp16-fma, depending on the command-line
arguments.
2025-04-10 10:01:57 +01:00
Nathan Gauër
a625bc60e2
[HLSL][SPIR-V] Add hlsl_private address space for SPIR-V (#133464)
This is an alternative to
https://github.com/llvm/llvm-project/pull/122103

In SPIR-V, private global variables have the Private storage class. This
PR adds a new address space which allows frontend to emit variable with
this storage class when targeting this backend.

This is covered in this proposal: llvm/wg-hlsl@4c9e11a

This PR will cause addrspacecast to show up in several cases, like class
member functions or assignment. Those will have to be handled in the
backend later on, particularly to fixup pointer storage classes in some
functions.

Before this change, global variable were emitted with the 'Function'
storage class, which was wrong.
2025-04-10 10:55:10 +02:00
Jay Foad
344a491dad
[CodeGen] Simplify expandRoundInexactToOdd (#134988)
FP_ROUND and FP_EXTEND the input value before FABSing it. This avoids
some bit twiddling to copy the sign bit from the input to the result. It
does introduce one extra FABS, but that is folded into another
instruction for free on AMDGPU, which is the only target currently
affected by this change.
2025-04-10 09:45:38 +01:00
Michael Buch
f030f6f3c5
[lldb][FormatEntity][NFCI] Refactor FunctionNameWithArgs into helper functions and use LLVM style (#135031)
I've always found this hard to read. Some upcoming changes make similar
computations, so I thought it's a good time to factor out this logic
into re-usable helpers and clean it up using LLVM's preferred
early-return style.
2025-04-10 09:39:58 +01:00
Matthias Springer
85742f7642
[mlir][LLVM] Delete getFixedVectorType and getScalableVectorType (#135051)
The LLVM dialect no longer has its own vector types. It uses
`mlir::VectorType` everywhere. Remove
`LLVM::getFixedVectorType/getScalableVectorType` and use
`VectorType::get` instead. This commit addresses a
[comment](https://github.com/llvm/llvm-project/pull/133286#discussion_r2022192500)
on the PR that deleted the LLVM vector types.
2025-04-10 10:36:21 +02:00
Wenju He
923da2b843
[clang-format] Add 'cl' to enable OpenCL kernel file formatting (#134529)
There are many .cl files in llvm repo. It would be great that
clang-format can support it.
2025-04-10 01:23:46 -07:00
Dominik Adamski
adfc577895
[OpenMP][CodeExtractor]Add align metadata to load instructions (#131131)
Moving code to another function can lead to missed optimization
opportunities, because function passes operate on smaller chunks of
code, and they cannot figure out all details.

One example of missed optimization opportunities after code extraction
is information about pointer alignment. The instruction combine pass
adds information about pointer alignment to LLVM intrinsic memcpy calls
if it can deduce it from the code or if align metadata is added. If this
information is not present, then further optimization passes can
generate inefficient code.

If we add align metadata to extracted pointers, then the instruction
combine pass can add the align attribute to the LLVM intrinsic memcpy
call and unblock further optimization.

Scope of changes:
1. Analyze MLIR map operations. Add information about the alignment of
objects that are passed by reference to OpenMP GPU kernels.
2. Propagate alignment information to the outlined by `CodeExtractor`
helper functions.
2025-04-10 09:45:30 +02:00
Hua Tian
b122956390
[llvm][CodeGen] update live intervals for ModuloScheduleExpanderMVE (#132677)
ModuloScheduleExpanderMVE and ModuloScheduleExpander are used sequentially in 
certain use cases. It is necessary to update live intervals for ModuloScheduleExpanderMVE; 
otherwise, crashes may occur.
2025-04-10 15:28:10 +08:00
tangaac
7818e5ab67
[LoongArch] lower vector shuffle to shift if possible (#132866) 2025-04-10 15:26:00 +08:00
Piotr Fusik
807cc3791f
[DAGCombiner] Fold subtraction if above threshold to umin (#134235)
Folds patterns such as:

    unsigned foo(unsigned x, unsigned y) {
      return x >= y ? x - y : x;
    }

Before, on RISC-V:

    sltu    a2, a0, a1
    addi    a2, a2, -1
    and     a1, a1, a2
    subw    a0, a0, a1

Or, with Zicond:

    sltu    a2, a0, a1
    czero.nez a1, a1, a2
    subw    a0, a0, a1

After, with Zbb:

    subw    a1, a0, a1
    minu    a0, a0, a1

Only applies to unsigned comparisons.
If `x >= y` then `x - y` is less than or equal `x`.
Otherwise, `x - y` wraps and is greater than `x`.
2025-04-10 09:08:08 +02:00
Fangrui Song
3fd0d22d74 AArch64AsmParser: Restore Lsym@page-offset support
https://github.com/llvm/llvm-project/pull/134202 removed support for
`sym@page-offset` in instruction operands. This change is generally
reasonable since subtracting an offset from a symbol typically doesn’t
make sense for Mach-O due to its .subsections_via_symbols mechanism, which treats
them as separate atoms.

However, BoringSSL relies on a temporary symbol with a negative offset,
which can be meaningful when the symbol and the referenced location are
within the same atom.
```
../../third_party/boringssl/src/gen/bcm/p256-armv8-asm-apple.S:1160:25: error: unexpected token in argument list
 adrp x23,Lone_mont@PAGE-64
```

It's worth noting that expressions involving @ can be complex and
brittle in MCParser, and much of the Mach-O @ offsets remains
under-tested.

* Allow default argument for parsePrimaryExpr. The argument, used by the niche llvm-ml,
  should not require other targets to adapt.
2025-04-09 23:13:06 -07:00
Matt Arsenault
f819f46284
Reapply "Inline: Propagate callsite nofpclass attribute" (#135018)
This reverts commit 3f38cd07d820248fd2043efb1341fabaac2d84a6.

Fix case where inner callsite has nofpclass but callsite does not.
2025-04-10 07:15:58 +02:00
Yingwei Zheng
2257f51431
Revert "[Clang][CodeGen][UBSan] Add more precise attributes to recoverable ubsan handlers" (#135130)
Reverts llvm/llvm-project#130990

Breaks buildbot https://lab.llvm.org/buildbot/#/builders/186/builds/8072
2025-04-10 13:15:55 +08:00
Matt Arsenault
843fb7be38
llvm-reduce: Fix overly conservative operands-to-args user restriction (#133854)
I assume this was a leftover from typed pointers. It's easier to replace
the non-callee uses, they are just replacable pointer values.
2025-04-10 07:10:25 +02:00
donald chen
27ca4837ee
[EquivalenceClasses] Introduce erase member function (#134660)
Introduce 'erase(const ElemTy &V)' member function to allow the deletion
of a certain value from EquivClasses. This is essential for certain
scenarios that require modifying the contents of EquivClasses.

---------

Co-authored-by: Florian Hahn <flo@fhahn.com>
2025-04-10 12:42:10 +08:00
Timm Baeder
02f923f8e4
[clang][bytecode] Classify function pointers as PT_Ptr (#135026)
The Pointer class already has the capability to be a function pointer,
but we still classifed function pointers as PT_FnPtr/FunctionPointer.
This means when converting from a Pointer to a FunctionPointer, we lost
the information of what the original Pointer pointed to.
2025-04-10 06:40:54 +02:00
Matt Arsenault
5587932e20
llvm-reduce: Use simpleSimplifyCFG in block reduction (#135028) 2025-04-10 06:12:24 +02:00
Timm Baeder
98ea512f72
[clang][bytecode] Clear inactive union fields when copying (#134982)
When copying unions, we need to only copy the active field of the source
union, which we were already doing. However, we also need to zero out
the (now) inactive fields, so we don't end up with dangling pointers in
those inactive fields.
2025-04-10 06:12:00 +02:00
Matt Arsenault
2828328611
llvm-reduce: Link to command guide in help like bugpoint does (#134810) 2025-04-10 06:11:19 +02:00
Jonas Devlieghere
7f7f3d91a2
Revert "Replace bool operator== for VersionType in sanitizer_mac.h" (#135127)
Reverts llvm/llvm-project#135068 because it breaks building compiler-rt
on Darwin.

https://green.lab.llvm.org/job/clang-stage1-RA/
https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/
https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/lldb-cmake/
2025-04-09 21:09:27 -07:00
Yingwei Zheng
0283bb3afc
[Clang][CodeGen][UBSan] Add more precise attributes to recoverable ubsan handlers (#130990)
This patch adds `memory(argmem: read, inaccessiblemem: readwrite)
mustprogress` to **recoverable** ubsan handlers in order to unblock some
memory/loop optimizations. It provides an average of 3% performance
improvement on llvm-test-suite (except for 49 test failures due to ubsan
diagnostics).

Closes https://github.com/llvm/llvm-project/issues/130093.
2025-04-10 11:09:45 +08:00
Fangrui Song
2b8cc651dc :createMCStreamer: delete InstPrinter on error 2025-04-09 19:57:38 -07:00
Thurston Dang
d1badf5635
[cfi][NFCI] Precommit tests to show nomerge functionality (#135104)
https://github.com/llvm/llvm-project/pull/120464 (and earlier CLs) added -fsanitize-merge functionality, which is intended to work for all "sanitizers". It is nearly correct for CFI.

This patch precommits some tests for CFI, to track the progress of future -fsanitize-merge fixes for CFI.
2025-04-09 19:46:59 -07:00
Matheus Izvekov
98feb05825
[clang] fix unresolved dependent template specialization mangling (#135111)
This fixes a regression introduced in
https://github.com/llvm/llvm-project/pull/133610 which was reported here
https://github.com/llvm/llvm-project/pull/133610#issuecomment-2787332042

When mangling a dependent template specialization appearing within an
unresolved prefix, translate the dtst back to a dependent template name
including the prefix, and mangle following the nested unresolved-type
production.

There are no release notes, since this regression was never released.
2025-04-09 23:23:52 -03:00
Pranav Kant
02fde3a651
[bazel] Fix for #134298 (#135114) 2025-04-09 18:54:48 -07:00
Deric C.
747d4a952b
[DirectX] Implement UseNativeLowPrecision shader flag analysis (#134288)
Fixes #112267 

Implement the shader flag analysis to set the UseNativeLowPrecision DXIL
module flag.

The flag is only able to be set when the command-line flag
`-enable-16bit-types` is passed to clang-dxc, or equivalently
`-fnative-half-type` is passed to clang.
When the command-line flag is passed, a module metadata flag called
"dx.nativelowprec" is set to 1.
The DXILShaderFlags shader flags analysis checks that the module
metadata flag "dx.nativelowprec" is set to 1 and the DXIL Version is 1.2
or greater before setting the UseNativeLowPrecision DXIL module flag.
2025-04-09 18:14:23 -07:00
Michael Berg
b88eef95e7
[DSE] Add predicated vector length store support for masked store elimination (#134175)
In isMaskedStoreOverwrite we process two stores that fully overwrite one
another, here we add support for predicated vector length stores so that
DSE will eliminate this variant of masked stores.

This is the follow up installment mentioned in:
https://reviews.llvm.org/D132700
2025-04-09 18:12:15 -07:00
Zequan Wu
78b21ddba7 Revert "Reland "Symbolize line zero as if no source info is available (#124846)" (#133798)"
This reverts commit 348374028970c956f2e49ab7553b495d7408ccd9 because #128619 doesn't handle the case when we have an empty frame from `getInliningInfoForAddress` because line num is 0 which makes it non-differentiable from missing debug info. So, we end up using the base filename from symtab again. Reverting for now until that issus is solved.
2025-04-09 18:09:31 -07:00
Owen Pan
f344838389
[clang-format] Keep the space between not and a unary operator (#135035)
Also keep the space between `not` and `::`.

Based on the
[documentation](https://releases.llvm.org/20.1.0/tools/clang/docs/ClangFormatStyleOptions.html#spaceafterlogicalnot),
it can be argued that SpaceAfterLogicalNot doesn't cover the alternative
operator `not`.

Closes #125465
2025-04-09 17:52:12 -07:00
Alan Li
2795abb2f8
[GISel][AMDGPU] Expand ShuffleVector (#124527)
This patch dismantles G_SHUFFLE_VECTOR before lowering. The original
lowering would emit extract vector element ops. We found that by using
unmerged values the build vector op combine could find ways to fold.

Only enabled on AMDGPU.

This resolves #123631
2025-04-09 17:51:24 -07:00
Owen Pan
75cbb1f0fa
[clang-format][NFC] Add FormatToken::is(tok::ObjCKeywordKind) (#134973)
This allows simplification of code that checks if a token is an
Objective-C keyword.

Also, delete the following in
UnwrappedLineParser::parseStructuralElement():
- an else-after-break in the tok::at case
- the copypasted code in the tok::objc_autoreleasepool case
2025-04-09 17:49:26 -07:00
Valentin Clement (バレンタイン クレメン)
56b792322a
[flang][cuda] Use the aysncId in device allocation (#135099)
Use `cudaMallocAsync` in the `CUFAllocDevice` allocator when asyncId is
provided.

More work is needed to be able to call `cudaFreeAsync` since the
allocated address and stream needs to be tracked.
2025-04-09 17:34:48 -07:00
Craig Topper
6a63abce7b [RISCV] Use GPRMemZeroOffset instead of GPRMem in RISCVInstrInfoVPseudos.td. NFC
The distinction between GPRMem and GPRMemZeroOffset only matters
for parsing which doesn't apply to pseudos.
2025-04-09 17:07:01 -07:00
Bangtian Liu
c359f7625f
[mlir][CAPI][python] expose the python bindings for linalg::isaContractionOpInterface and linalg::inferContractionDims (#134935)
This PR is mainly about exposing the python bindings for`
linalg::isaContractionOpInterface` and` linalg::inferContractionDims`.

---------

Signed-off-by: Bangtian Liu <liubangtian@gmail.com>
2025-04-09 20:01:38 -04:00
Maksim Levental
9b50167ed9
[mlir][python] add use_name_loc_as_prefix to value.get_name() (#135052)
Add `use_name_loc_as_prefix` to `value.get_name()`.
2025-04-09 19:28:59 -04:00