61612 Commits

Author SHA1 Message Date
Nikita Popov
a22d1b5d43
[ConstantInt] Add ImplicitTrunc parameter to getSigned() (NFC) (#172875)
For consistency with `ConstantInt::get()`, add an ImplicitTrunc
parameter to `ConstantInt::getSigned()` as well. It currently defaults
to true and will be flipped to false in the future (by #171456).
2025-12-19 09:48:26 +01:00
Alex MacLean
a40f444265
[NVPTX] Add support for barrier.cta.red.* instructions (#172541)
This change adds full support for the ptx `barrier.cta.red` instruction,
following the same conventions as are already used for
`barrier.cta.sync` and `barrier.cta.arrive`.

In addition this MR removes the following intrinsics which are no longer
needed:
* llvm.nvvm.barrier0.popc -->
  llvm.nvvm.barrier.cta.red.popc.aligned.all(0, c)
* llvm.nvvm.barrier0.and -->
  llvm.nvvm.barrier.cta.red.and.aligned.all(0, z)
* llvm.nvvm.barrier0.or -->
  llvm.nvvm.barrier.cta.red.or.aligned.all(0, z)
2025-12-18 18:06:27 -08:00
Matt Arsenault
bb993a89a8
RuntimeLibcalls: Add entries for stack probe functions (#167453) 2025-12-19 01:17:20 +01:00
Harald van Dijk
a9b62e8324
[AArch64] Make IFUNC opt-in rather than opt-out. (#171648)
IFUNCs require loader support, so for arbitrary environments, the safe
assumption is to assume that they are not supported. In particular,
aarch64-linux-pauthtest may be used with musl, and was wrongly detected
as supporting IFUNCs.

With IFUNC support now being detected more reliably, this also removes
the check for PAuth support. If both are supported, either would work.
2025-12-18 22:17:07 +00:00
Krzysztof Parzyszek
755f298ddc
[flang][OpenMP] Implement COMBINER clause (#172036)
This adds parsing and lowering of the COMBINER clause. It utilizes the
existing lowering code for combiner-expression to lower the COMBINER
clause as well.
2025-12-18 08:04:28 -06:00
Frederik Harwath
5c05824d2b
[CodeGen] Rename expand-fp to expand-ir-insts (#172681)
The pass now contains a non-fp expansion and should
be used for any similar expansions regardless of the
types involved. Hence a generic name seems apt.

Rename the source files, pass, and adjust the pass
description. Move all tests for the expansions
that have previously been merged into the pass
to a single directory.
2025-12-18 11:15:04 +00:00
Nathan Gauër
8cfda79105
[HLSL][SPIR-V] Implement vk::push_constant (#166793)
Implements initial support for vk::push_constant.
As is, this allows handling simple push constants, but has one
main issue: layout can be incorrect (See #168401). The layout
issue being not only push-constant related, it's ignored for this PR.

The frontend part of the implementation is straightforward:
 - adding a new attribute
 - when targeting vulkan/spirv, we process it
 - global variables with this attribute gets a new AS:
   hlsl_push_constant

The IR has nothing specific, only some RO globals in this new AS.

On the SPIR-V side, we not convert this AS into a PushConstant storage
class. But this creates some issues: the variables in this storage class
must have a specific set of decoration to define their layout.

Current infra to create the SPIR-V types lacks the context required to
make this decision: no indication on the AS or context around the type
being created. Refactoring this would be a heavy task as it would
require getting this information in every place using the GR for type
creation.

Instead, we do something similar to CBuffers:
 - find all globals with this address space, and change their type to
   a target-specific type.
 - insert a new intrinsic in place of every reference to this global
   variable.

This allow the backend to handle both layout variables loads and type
lowering independently.

Type lowering has nothing specific: when we encounter a target extension
type with spirv.PushConstant, we lower this to the correct SPIR-V type
with the proper offset & block decorations.

As for the intrinsic, it's mostly a no-op, but required since we have
this target-specific type.

Note: this implementation prevents the static declaration of multiple
push constants in a single shader module. The actual specification is
more relaxed: there can be only one **used** push constant block per
entrypoint. To correctly implement this, we'd require to keep some
additional state to determine the list of statically used resources per
entrypoint. This shall be addressed as a follow-up (see #170310)
2025-12-18 11:01:11 +01:00
Frederik Harwath
71760f324f
[CodeGen] Merge ExpandLargeDivRem into ExpandFp (#172680)
Both passes expand instructions at the IR level.
They use the same kind of instruction visitation
logic and contain significant code duplication e.g.
for scalarization.
2025-12-18 09:22:47 +01:00
Lang Hames
48c8c45475
[ORC] Fix typo in method name. NFCI. (#172787)
"reigsterRuntimeFunctions" should be "registerRuntimeFunctions".
2025-12-18 16:14:01 +11:00
Michael Smith
35b2b24e62
Implement reserveAllocationSpace for SectionMemoryManager (#71968)
Implements `reserveAllocationSpace` and provides an option to enable
`needsToReserveAllocationSpace` for large-memory environments with
AArch64.

The [AArch64
ABI](https://github.com/ARM-software/abi-aa/blob/main/sysvabi64/sysvabi64.rst#7code-models)
has restrictions on the distance between TEXT and GOT sections as the
instructions to reference them are limited to 2 or 4GB. Allocating
sections in multiple blocks can result in distances greater than that on
systems with lots of memory. In those environments several projects
using SectionMemoryManager with MCJIT have run across assertion failures
for the R_AARCH64_ADR_PREL_PG_HI21 instruction as it attempts to address
across distances greater than 2GB (an int32).

Fixes #71963 by allocating all sections in a single contiguous memory
allocation, limiting the distance required for instruction offsets
similar to how pre-compiled binaries would be loaded into memory.

Co-authored-by: Lang Hames <lhames@gmail.com>
2025-12-18 13:19:45 +11:00
Rahman Lavaee
53005fd435
Use the Propeller CFG profile in the PGO analysis map if it is available. (#163252)
This PR implements the emitting of the post-link CFG information in PGO
analysis map, as explained in the
[RFC](https://discourse.llvm.org/t/rfc-extending-the-pgo-analysis-map-with-propeller-cfg-frequencies/88617).
This is enabled by a flag `pgo-analysis-map-emit-bb-sections-cfg`.

This PR bumps the SHT_LLVM_BB_ADDR_MAP version to 5.
Also includes some refactoring changes related to storing the CFG in the
Basic block sections profile reader.
2025-12-17 14:19:18 -08:00
Jiachen Yuan
21fd8cc2a5
Make STLExtras's (all|any|none)_of() Utility Functions Constexpr-Friendly (#172536)
This patch replaces the implementation of `llvm::all_of`,
`llvm::any_of`, and `llvm::none_of` with simple loops instead of their
corresponding `std` versions. This makes them possible to be evaluated
at compile time for the time being. We can revisit once the C++ version
of LLVM is promoted to C++20.
https://en.cppreference.com/w/cpp/algorithm/all_any_none_of.html

This refactor was brought up in the context of this PR:
https://github.com/llvm/llvm-project/pull/172062#discussion_r2615331513
2025-12-17 16:21:16 -05:00
Lang Hames
558760009c
[ORC] Rename WrapperFunctionResult to WrapperFunctionBuffer. NFCI. (#172633)
Also renames CWrapperFunctionResult to CWrapperFunctionBuffer.

These types are used as argument buffers, as well as result buffers. The
new name better reflects their purpose, and is consistent with naming in
the new ORC runtime (llvm-project/orc-rt).
2025-12-18 07:57:06 +11:00
Pan Tao
b6bfa85686
[aarch64] Mix the frame pointer with the stack cookie when protecting the stack (#161114)
This strengthens the guard and matches MSVC.

Fixes #156573 .
2025-12-17 12:52:28 -08:00
Ivan Butygin
ce553ab69f
Revert "[mlir][amdgpu] Expose waitcnt bitpacking infra (#172313)" (#172636)
This reverts commit 93013817afabe23a07073528481856b3507b6faf.

Revert https://github.com/llvm/llvm-project/pull/172313

Missing libraries, again
2025-12-17 12:13:44 +00:00
Mingjie Xu
159f1c048e
[IR] Optimize PHINode::removeIncomingValue() by swapping removed incoming value with the last incoming value. (#171963)
Current implementation uses `std::copy` to shift all incoming values
after the removed index. This patch optimizes
`PHINode::removeIncomingValue()` by replacing the linear shift of
incoming values with a swap-with-last strategy.

After this change, the relative order of incoming values after removal
is not preserved.

This improves compile-time for PHI nodes with many predecessors.

Depends:
https://github.com/llvm/llvm-project/pull/171955
https://github.com/llvm/llvm-project/pull/171956
https://github.com/llvm/llvm-project/pull/171960
https://github.com/llvm/llvm-project/pull/171962
2025-12-17 19:44:01 +08:00
Ivan Butygin
93013817af
[mlir][amdgpu] Expose waitcnt bitpacking infra (#172313)
So we can get rid of our copy in `AMDGPUToROCDL`.
2025-12-17 14:32:30 +03:00
Jim Lin
fcf762c6ec
[RISCV] Implement Clang Builtins for XAndesPerf Extension (#147018)
This patch adds the Clang builtins for byte comparision instructions in
XAndesPerf Extension. These instructions are hardly generated by
compiler. So we provide the Clang builtins for the user.

Please refer to:
https://github.com/andestech/andes-intrinsic-doc/blob/main/andes-scalar-intrinsic.md
2025-12-17 08:43:37 +00:00
Lang Hames
dec5d66374
[ORC] Make WrapperFunctionResult constructor explicit. (#172602)
The WrapperFunctionBuffer(CWrapperFunctionBuffer) constructor takes
ownership of the underlying buffer (if one exists). Making the
constructor explicit makes this clearer at the call site.
2025-12-17 18:38:28 +11:00
Aiden Grossman
6b183f4cfd
[Codegen][NewPM] Explicitly Nest Passes in CodegenPassBuilder (#169867)
This implements the major piece of

https://discourse.llvm.org/t/rfc-codegen-new-pass-manager-pipeline-construction-design/84659,
making it explicit when we break the function pipeline up.

We essentially get rid of the AddPass and AddMachinePass helpers and
replace them with explicit functions for the pass types. The user then
needs to explicitly call flushFPMstoMPM before breaking.

This is sort of a hybrid of the current construction and what the RFC
proposed. The alternative would be passing around FunctionPassManagers
and having the pipeline actually explicitly constructed. I think this
compromises ergonomics slightly (needing to pass a FPM in many more
places). It is also nice to assert that the function pass manager is
empty when adding a module pass, which is easier when CodegenPassBuilder
owns the FPM and MFPM.
2025-12-16 15:42:28 -08:00
Min-Yih Hsu
9c9b6931d9
[TableGen][SchedModel] Add logical combiners for SchedPredicates (#172106)
Sometimes we want to create a SchedPredicate out of different types of
SchedPredicate: composing a `FeatureSchedPredicate` with a
`MCSchedPredicate`, for example. For those cases, this patch creates
several new TableGen constructions so that users can create a
SchedPredicate like
```
AllOfSchedPreds<[FeatureFooPred,
                 MCSchedPredicate<CheckZeroOperand<1>>]>
```
which evaluates to true only when both `FeatureFooPred` and
`MCSchedPredicate<CheckZeroOperand<1>>` hold.
2025-12-16 13:43:45 -08:00
Zachary Yedidia
2c05ae4b8f
[LFI] Introduce AArch64 LFI Target (#167061)
This PR is the first step towards introducing LFI into LLVM as a new
sub-architecture backend of AArch64. For details, please see the
[RFC](https://discourse.llvm.org/t/rfc-lightweight-fault-isolation-lfi-efficient-native-code-sandboxing-upstream-lfi-target-and-compiler-changes/88380),
which has been approved for AArch64.

This patch creates the `aarch64_lfi` architecture, and marks the
appropriate registers as reserved when it is targeted (`x25`, `x26`,
`x27`, `x28`). It also adds a Clang driver toolchain for targeting LFI,
and updates the compiler-rt CMake to allow builds for the `aarch64_lfi`
target. The patch also includes documentation for LFI and the rewrites
that will be implemented in future patches.

I am planning to split the relevant modifications for LFI into a series
of patches, organized as described below (after this one). Please let me
know if you'd like me to split the changes in a different way, or
provide one big patch.

1. The next patch will introduce the `MCLFIExpander` mechanism for
applying the MC-level rewrites needed by LFI, along with the
`.lfi_expand` and `.lfi_no_expand` assembly directives when targeting
LFI. A preview can be seen on the `lfi-project`
[fork](https://github.com/llvm/llvm-project/compare/main...lfi-project:llvm-project:lfi-patchset/aarch64-pr-2).

2. The following patch will create an `MCLFIExpander` for the AArch64
backend that performs LFI expansions. This patch will contain the
majority of the LFI-specific logic.

3. The final patch will add an optimization to the rewriter that can
eliminate redundant guard instructions that occur within the same basic
block.

We plan to introduce x86-64 support after further discussion and once
the `MCLFIExpander` infrastructure is in place.

Please let me know your feedback, and thank you very much for your help
and guidance in the review process.
2025-12-16 12:51:02 -08:00
Thibault Monnier
39f68f737d
[ADT][NFC] Move FoldingSetBase definition lower in the file (#172503)
This is required for #172371, where
`FoldingSetBase::FindNodeOrInsertPos` needs full definition of
`FoldingSetNodeID`.
2025-12-16 19:19:46 +01:00
Frederik Harwath
6ad41bcc49
[CodeGen] expand-fp: Change frem expansion criterion (#158285)
The existing condition for checking whether or not to expand an frem
instruction in expand-fp is not sufficiently precise.
The expansion on other targets than AMDGPU - which is the only intended
user right now - is only prevented due to the interaction with the
MaxLegalFpConvertBitWidth check.  Relying on this is conceptually wrong
and limits the use of the pass for other targets and further expansions
(e.g. merging with the similar ExpandLargeDivRem pass).

Change the expansion criterion to always expand frem of a given type
for targets that use "Expand" as the legalization action for the 
underlying scalar type and use this to exit the pass early for targets 
which do not require any expansions. This requires to change the
frem legalization action for all targets which do not want frem to 
be expanded in this pass from "Expand" to "LibCall".

---------

Co-authored-by: Matt Arsenault <arsenm2@gmail.com>
2025-12-16 17:31:26 +01:00
Alexis Engelke
cd806d7e76
[LLVM] Add plugin hook for back-ends
Add a mechanism to permit plugins running code between optimizations and
the back-end passes. Implement this through the LLVM plug-in mechanism
to make permit plugins to be written independently of the front-end.

The primary motivation for this point is TPDE-LLVM, which substitutes
the LLVM back-end (optionally falling back to it for unsupported IR). We
have been distributing a Clang patch; but requiring a custom-build
toolchain is impracticable for many users.

Front-end adjustments will follow as separate patches.

Pull Request: https://github.com/llvm/llvm-project/pull/170846
2025-12-16 16:33:39 +01:00
Stefan Gränitz
d2a097d6a3
Reland: [ORC] Tailor ELF debugger support plugin to load-address patching only (#169482)
In 4 years the ELF debugger support plugin wasn't adapted to other
object formats or debugging approaches. After the renaming NFC in
https://github.com/llvm/llvm-project/pull/168343, this patch tailors the
plugin to ELF and section load-address patching. It allows removal of
abstractions and consolidate processing steps with the newly enabled
AllocActions from https://github.com/llvm/llvm-project/pull/168343.

The key change is to process debug sections in one place in a
post-allocation pass. Since we can handle the endianness of the ELF file
the single `visitSectionLoadAddresses()` visitor function now, we don't
need to track debug objects and sections in template classes anymore. We
keep using the `DebugObject` class and drop `DebugObjectSection`,
`ELFDebugObjectSection<ELFT>` and `ELFDebugObject`.

Furthermore, we now use the allocation's working memory for load-address
fixups directly. We can drop the `WritableMemoryBuffer` from the debug
object and most of the `finalizeWorkingMemory()` step, which saves one
copy of the entire debug object buffer. Inlining `finalizeAsync()` into
the pre-fixup pass simplifies quite some logic.

The original patch broke compiler-rt checks: db5eeddbd3
Reverted with: 0182a76970
2025-12-16 12:04:00 +01:00
Lukacma
1ba23fff26
[AArch64] Add intrinsics support for SVE2p2 instructions (#163575)
This patch add intrinsics for SVE2p2 instructions defined in
[this](https://github.com/ARM-software/acle/pull/412) ACLE proposal.
Intrinsics added:

```
  // Variants are available for:
  // _s8, _s16, _u16, _mf8, _bf16, _f16
  svuint8_t svcompact[_u8](svbool_t pg, svuint8_t zn);

  // Variants are available for:
  // _s8, _s16, _u16, _s32, _u32, _s64, _u64
  // _mf8, _bf16, _f16, _f32, _f64
  svuint8_t svexpand[_u8](svbool_t pg, svuint8_t zn);

  // Variants are available for:
  // _b16, _b32, _b64
  int64_t svfirstp_b8(svbool_t pg, svbool_t pn);

  // Variants are available for:
  // _b16, _b32, _b64
  int64_t svlastp_b8(svbool_t pg, svbool_t pn);
```

It also generates Sema tests using aarch64_builtins_test_generator
script for some previously merged intrinsics patches, which were merged
without regenerating.

---------

Co-authored-by: Kerry McLaughlin <kerry.mclaughlin@arm.com>
2025-12-16 11:21:16 +01:00
Usman Nadeem
1ea201d73b
[WoA] Remove extra barriers after ARM LSE instructions with MSVC (#169596)
c9821abfc0
added extra fences after sequentially consistent stores for
compatibility with MSVC's seq_cst loads (ldr+dmb). These extra fences
should not be needed for ARM LSE instructions that have both
acquire+release semantics, which results in a two way barrier, and
should be enough for sequential consistency.

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

Change-Id: I9148c73d0dcf3bf1b18a0915f96cac71ac1800f2
2025-12-15 17:19:40 -08:00
Scott Linder
8fa29f8457
Reapply "[MC] Use a variant to hold MCCFIInstruction state (NFC)" (#170342)
This reverts commit 8217c6415ab76c2a0f06705100c76207cd1e6bc0.

I asked Claude Sonnet 4.5 to hazard a guess at what was causing the
buildbot failure, and it seems to have correctly pinned it on a bug in
GCC7, although it didn't give a working fix.

I worked out of a `gcc:7.4` docker container and moved code around until
`MCDwarf.cpp.o` compiled without errors or warnings, so hopefully that's
sufficient to fix the bot.
2025-12-15 14:42:58 -05:00
Teresa Johnson
e3c621c50b
[ThinLTO][MemProf] Add option to override max ICP with larger number (#171652)
Adds an option -module-summary-max-indirect-edges, and wiring into the
ICP logic that collects promotion candidates from VP metadata, to
support a larger number of promotion candidates for use in building the
ThinLTO summary. Also use this in the MemProf ThinLTO backend handling
where we perform memprof ICP during cloning.

The new option, essentially off by default, can be used to override the
value of -icp-max-prom, which is checked internally in ICP, with a
larger max value when collecting candidates from the VP metadata.

For MemProf in particular, where we synthesize new VP metadata targets
from allocation contexts, which may not be all that frequent, we need to
be able to include a larger set of these targets in the summary in order
to correctly handle indirect calls in the contexts. Otherwise we will
not set up the callsite graph edges correctly.
2025-12-15 10:16:06 -08:00
Mehdi Amini
efd9dc83f2
Revert "[APFloat] Add exp function for APFloat::IEEESsingle using expf implementation from LLVM libc. (#143959)" (#172325)
This reverts commit 4190d576823c18f45ee0632baee7d798448178ac.

See https://lab.llvm.org/buildbot/#/builders/181/builds/33524

```
                 from /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/llvm/lib/Support/APFloat.cpp:32:
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/llvm/../libc/src/__support/math/asin_utils.h:548:1:   in ‘constexpr’ expansion of ‘__llvm_libc::fputil::DyadicFloat<128>(__llvm_libc::Sign::POS, -127, __llvm_libc::BigInt<128, false, long unsigned int>(__llvm_libc::operator""_u128(((const char*)"0x80000000\'00000000\'00000000\'00000000"))))’
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/llvm/../libc/src/__support/FPUtil/dyadic_float.h:109:5:   in ‘constexpr’ expansion of ‘((__llvm_libc::fputil::DyadicFloat<128>*)this)->__llvm_libc::fputil::DyadicFloat<128>::normalize()’
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/llvm/../libc/src/__support/FPUtil/dyadic_float.h:118:16:   in ‘constexpr’ expansion of ‘((__llvm_libc::fputil::DyadicFloat<128>*)this)->__llvm_libc::fputil::DyadicFloat<128>::mantissa.__llvm_libc::BigInt<128, false, long unsigned int>::operator<<=(((size_t)shift_length))’
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/llvm/../libc/src/__support/big_int.h:829:52:   in ‘constexpr’ expansion of ‘__llvm_libc::multiword::shift<__llvm_libc::multiword::LEFT, false, long unsigned int, 2>(((__llvm_libc::BigInt<128, false, long unsigned int>*)this)->__llvm_libc::BigInt<128, false, long unsigned int>::val, s)’
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/llvm/../libc/src/__support/big_int.h:264:35: error: ‘constexpr __llvm_libc::cpp::enable_if_t<((((sizeof (To) == sizeof (From)) && __llvm_libc::cpp::is_trivially_constructible<To>::value) && __llvm_libc::cpp::is_trivially_copyable<T>::value) && __llvm_libc::cpp::is_trivially_copyable<From>::value), To> __llvm_libc::cpp::bit_cast(const From&) [with To = __int128 unsigned; From = __llvm_libc::cpp::array<long unsigned int, 2>; __llvm_libc::cpp::enable_if_t<((((sizeof (To) == sizeof (From)) && __llvm_libc::cpp::is_trivially_constructible<To>::value) && __llvm_libc::cpp::is_trivially_copyable<T>::value) && __llvm_libc::cpp::is_trivially_copyable<From>::value), To> = __int128 unsigned]’ called in a constant expression
  264 |     auto tmp = cpp::bit_cast<type>(array);
      |                ~~~~~~~~~~~~~~~~~~~^~~~~~~
                 from /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/llvm/lib/Support/APFloat.cpp:32:
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/llvm/../libc/src/__support/CPP/bit.h:48:1: note: ‘constexpr __llvm_libc::cpp::enable_if_t<((((sizeof (To) == sizeof (From)) && __llvm_libc::cpp::is_trivially_constructible<To>::value) && __llvm_libc::cpp::is_trivially_copyable<T>::value) && __llvm_libc::cpp::is_trivially_copyable<From>::value), To> __llvm_libc::cpp::bit_cast(const From&) [with To = __int128 unsigned; From = __llvm_libc::cpp::array<long unsigned int, 2>; __llvm_libc::cpp::enable_if_t<((((sizeof (To) == sizeof (From)) && __llvm_libc::cpp::is_trivially_constructible<To>::value) && __llvm_libc::cpp::is_trivially_copyable<T>::value) && __llvm_libc::cpp::is_trivially_copyable<From>::value), To> = __int128 unsigned]’ is not usable as a ‘constexpr’ function because:
   48 | bit_cast(const From &from) {
      | ^~~~~~~~
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/llvm/../libc/src/__support/CPP/bit.h:56:28: error: call to non-‘constexpr’ function ‘void __llvm_libc::cpp::inline_copy(const char*, char*) [with unsigned int N = 16]’
   56 |   inline_copy<sizeof(From)>(src, dst);
```
2025-12-15 16:57:37 +01:00
lntue
4190d57682
[APFloat] Add exp function for APFloat::IEEESsingle using expf implementation from LLVM libc. (#143959)
Discourse RFC:
https://discourse.llvm.org/t/rfc-make-clang-builtin-math-functions-constexpr-with-llvm-libc-to-support-c-23-constexpr-math-functions/86450

- The implementation in LLVM libc is header-only.
- expf implementation in LLVM libc is correctly rounded for all rounding
modes.
- LLVM libc implementation will round to the floating point
environment's rounding mode.
- No cmake build dependency between LLVM and LLVM libc, only requires
LLVM libc source presents in llvm-project/libc folder.
2025-12-15 10:21:45 -05:00
Midhunesh
ee5b9cd59d
[llvm-symbolizer] Recognize and symbolize archive members (#150401)
This PR adds support for selecting specific archive members in
llvm-symbolizer using the `archive.a(member.o)` syntax, with
architecture-aware member selection.

  **Key features:**
1. **Archive member selection syntax**: Specify archive members using
`archive.a(member.o)` format
2. **Architecture selection via `--default-arch` flag**: Select the
appropriate member when multiple members have the same name but
different architectures
3. **Architecture selection via `:arch` suffix**: Alternative syntax
`archive.a(member.o):arch` for specifying architecture

This functionality is primarily designed for AIX big archives, which can
contain multiple members with the same name but different architectures
(32-bit and 64-bit). However, the implementation works with all archive
formats (GNU, BSD, Darwin, big archive) and handles same-named members
created with llvm-ar q.

---------

Co-authored-by: Midhunesh <midhuensh.p@ibm.com>
2025-12-15 18:55:36 +05:30
Nathan Corbyn
2f9bf3f292
[GlobalISel](NFC) Refactor construction of LLTs in LegalizerHelper (#170664)
I spotted a number of places where we're duplicating logic provided by
the `LLT` class inline in `LegalizerHelper`. This PR tidies up these
spots.
2025-12-15 12:26:27 +00:00
Srinivasa Ravi
7d0865122e
[clang][NVPTX] Add support for mixed-precision FP arithmetic (#168359)
This change adds support for mixed precision floating point 
arithmetic for `f16` and `bf16` where the following patterns:
```
%fh = fpext half %h to float
%resfh = fp-operation(%fh, ...)
...
%fb = fpext bfloat %b to float
%resfb = fp-operation(%fb, ...)

where the fp-operation can be any of:
- fadd
- fsub
- llvm.fma.f32
- llvm.nvvm.add(/fma).*
```
are lowered to the corresponding mixed precision instructions which 
combine the conversion and operation into one instruction from 
`sm_100` onwards.

This also adds the following intrinsics to complete support for 
all variants of the floating point `add/fma` operations in order 
to support the corresponding mixed-precision instructions:
- `llvm.nvvm.add.(rn/rz/rm/rp){.ftz}.sat.f`
- `llvm.nvvm.fma.(rn/rz/rm/rp){.ftz}.sat.f`

We lower `fneg` followed by one of the above addition
intrinsics to the corresponding `sub` instruction.

Tests are added in `fp-arith-sat.ll` , `fp-fold-sub.ll`, and
`bultins-nvptx.c`
for the newly added intrinsics and builtins, and in
`mixed-precision-fp.ll`
for the mixed precision instructions.

PTX spec reference for mixed precision instructions:
https://docs.nvidia.com/cuda/parallel-thread-execution/#mixed-precision-floating-point-instructions
2025-12-15 16:28:23 +05:30
Fabrice de Gans
96881c1226
llvm: Export IndexedCodeGenDataLazyLoading (#169563)
This is needed so the llvm-cgdata tool properly builds with
`LLVM_BUILD_LLVM_DYLIB` so LLVM can be built as a DLL on Windows.

This effort is tracked in #109483.
2025-12-15 04:25:30 -05:00
Craig Topper
c878cf4580
[SelectionDAG] Consistently use doxygen comments in the NodeType enum. NFC (#172178) 2025-12-14 22:31:47 -08:00
David Green
1a1c5df7f9
[ARM] Introduce intrinsics for MVE fp-converts under strict-fp. (#170686)
This is the last of the generic instructions created from MVE
intrinsics. It was a little more awkward than the others due to it
taking a Type as one of the arguments. This creates a new function to
create the intrinsic we need.
2025-12-14 12:12:45 +00:00
David Green
b97d24796c
[ARM] Introduce intrinsics for MVE vcmp under strict-fp. (#169798)
Similar to #169156 again, this adds intrinsics for strict-fp compare nodes to
make sure they end up as the original instruction.
2025-12-14 11:27:48 +00:00
David Green
1b93f8b48f
[ARM] Introduce intrinsics for MVE vrnd under strict-fp. (#169797)
Similar to #169156 again, this adds intrinsics for strict-fp vrnd nodes to make
sure they end up as the original instruction.
2025-12-14 11:19:53 +00:00
Artur Bermond Torres
755a693299
[DAG] SDPatternMatch - Replace runtime data structures with lengths known at compile time (#172064)
Following the suggestions in #170061, I replaced `SmallVector<SDValue>`
with `std::array<SDValue, NumPatterns>` and `SmallBitVector` with
`Bitset<NumPatterns>`.

I had to make some changes to the `collectLeaves` and
`reassociatableMatchHelper` functions. In `collectLeaves` specifically,
I changed the return type so I could propagate a failure in case the
number of found leaves is greater than the number of expected patterns.
I also added a new unit test that, together with the one already present
in the previous line, checks if the matching fails in the cases where
the number of patterns is less or more than the number of leaves.

I don't think this is going to completely address the increased compile
time reported in #169644, but hopefully it leads to an improvement.
2025-12-14 10:48:08 +00:00
Matt Arsenault
b2d9356719
DAG: Make more use of the LibcallImpl overload of getExternalSymbol (#172171)
Also add a new copy for TargetExternalSymbol that AArch64 needs.
2025-12-13 19:16:47 +00:00
Jakub Kuderski
2490bb7e4b
[ADT] Only call reserve on empty containers in append_values (#172109)
Calling reserve in a loop can prevent amortized constant time appends
when the container doesn't round up the capacity.
2025-12-13 13:50:08 -05:00
Craig Topper
9483353ba2
[SelectionDAG] Remove single quote around GET_ROUNDING in doxygen comment in ISDOPcode.h. NFC (#172114)
This style isn't used elsewhere in this file.

Hoping this fixes the strange rendering of the enum here.
https://llvm.org/doxygen/namespacellvm_1_1ISD.html#a22ea9cec080dd5f4f47ba234c2f59110
2025-12-12 20:22:29 -08:00
Alireza Torabian
9bc38df587
[LoopFusion] Simplifying the legality checks (#171889)
Considering that the current loop fusion only supports adjacent loops,
we are able to simplify the checks in this pass. By removing
`isControlFlowEquivalent` check, this patch fixes multiple issues
including #166560, #166535, #165031, #80301 and #168263.

Now only the sequential/adjacent candidates are collected in the same
list. This patch is the implementation of approach 2 discussed in post
#171207.
2025-12-12 15:09:34 -05:00
Ryotaro Kasuga
5cdb757cc3
[Delinearization] Remove isKnownNonNegative (#171817)
Delinearization has its own `isKnownNonNegative` function, which wraps
`ScalarEvolution::isKnownNonNegative` and adds additional logic. The
additional logic is that, for a pointer addrec `{a,+,b}`, if the pointer
has `inbounds` and both `a` and `b` are known to be non-negative, then
the addrec is also known non-negative (i.e., it doesn't wrap). This
reasoning is incorrect. If the GEP and/or load/store using the pointer
are not unconditionally executed in the loop, then the addrec can still
wrap. Even though no actual example has been found where this causes a
miscompilation (probably because the subsequent checks fail so the
validation also fails), simply replacing it with
`ScalarEvolution::isKnownNonNegative` is safer, especially it doesn't
cause any regressions in the existing tests.

Resolve #169811
2025-12-12 18:15:18 +00:00
Alexander Johnston
4ca2caeab6
[HLSL] Implement ddx/ddy_fine intrinsics (#168874)
Implements the HLSL ddx_fine and ddy_fine intrinsics.
For the SPIRV backend the intrinsics are ensured to be unavailable in
opencl (as they require fragment execution stage).

Closes https://github.com/llvm/llvm-project/issues/99098
Closes https://github.com/llvm/llvm-project/issues/99101
2025-12-12 09:34:41 -08:00
Krzysztof Parzyszek
1451f3d9b0
[flang][OpenMP] Use StylizedInstance in converted clauses (#171907)
Invent `StylizedInstance` class to store special variables together with
the instantiated expression in omp::clause::Initializer. This will
eliminate the need for visiting the original AST nodes in lowering to
MLIR.
2025-12-12 08:09:25 -06:00
Mikołaj Piróg
81a75b1af9
[X86] Remove rest of AMX-TRANSPOSE (#171906)
This is a followup to https://github.com/llvm/llvm-project/pull/165556

I've missed some parts of amx-transpose during initial removal
2025-12-12 13:12:18 +01:00
Paul Walker
54744bc0a6
[LLVM][AArch64] Add "u" variants of sve.[s,u]hsub intrinsics (#170894) 2025-12-12 11:22:34 +00:00