62088 Commits

Author SHA1 Message Date
Thibault Monnier
c322e374fe
[ADT][NFC] Remove else after return in APSInt.h (#180790)
Align with the LLVM coding standard:
https://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return
2026-02-10 21:27:32 +01:00
Sam Clegg
11c2613342
[WebAssembly] Add initial support for compact imports proposal (#176617)
This change adds initial support to libObject for reading compact
imports and support for writing compact imports in the linker.

There is minimal testing here since to tools like lllvm-readobj, and
obj2yaml don't currently report compact imports any differently.

See https://github.com/WebAssembly/compact-import-section
2026-02-10 10:57:45 -08:00
Marcos Maronas
ce94d63f0f
Make OpenCL an OSType rather than an EnvironmentType. (#170297)
OpenCL was added as an `EnvironmentType` in
https://github.com/llvm/llvm-project/pull/78655, but there is no
explanation as to why it was added as such, even after explicitly asking
in the PR
(https://github.com/llvm/llvm-project/pull/78655#issuecomment-2743162853).
This PR makes it an `OSType` instead, which feels more natural, and
updates tests accordingly.

---------

Co-authored-by: Marcos Maronas <marcos.maronas@intel.com>
2026-02-10 18:45:50 +00:00
Ben Dunbobbin
e6f5e4910d
[Windows][Support] Add helper to expand short 8.3 form paths (#178480)
Windows supports short 8.3 form filenames (for example,
`compile_commands.json` -> `COMPIL~1.JSO`) for legacy reasons. See:
https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#short-vs-long-names

Such paths are not unusual because, on Windows, the system temporary
directory is commonly derived from the `TMP`/`TEMP` environment
variables. For historical compatibility reasons, these variables are
often set to short 8.3 form paths on systems where user names exceed
eight characters.

Introduce `windows::makeLongFormPath()` to convert paths to their long
form by expanding any 8.3 components via `GetLongPathNameW`.

As part of this change:
- Extended-length path prefix handling is centralized by adding
`stripExtendedPrefix()` and reusing it in `realPathFromHandle()`.
- `widenPath()` is cleaned up to use shared prefix constants.

This was split out from #178303 at the request of the codeowner so that
the Windows support parts can be reviewed separately.
2026-02-10 16:44:02 +00:00
Rahul Joshi
d8b87934f0
[NFC][TableGen] Adopt CodeGenHelpers in GobalISel emitters (#180143)
Add specific emitters for `#ifdef` and `#ifndef` based guards and adopt
them and other CodeGenHelpers in Global ISel emitters.
2026-02-10 07:58:35 -08:00
Kerry McLaughlin
e043195ef4
[AArch64] Add support for intent to read prefetch intrinsic (#179709)
This patch adds support in Clang for the PRFM IR instruction, by adding
the following builtin:

  void __pldir(void const *addr);

This builtin is described in the following ACLE proposal:
https://github.com/ARM-software/acle/pull/406
2026-02-10 10:12:52 +00:00
Nikita Popov
59a8bd0a74
[SimplifyLibCalls] Directly canonicalize fminimum_num to intrinsic (#180555)
Same as https://github.com/llvm/llvm-project/pull/177988, but for
fminimum_num/fmaximum_num. Directly canonicalize these to the
corresponding intrinsics, and let the shrinking happen directly on the
intrinsics.
2026-02-10 10:07:14 +01:00
Diana Picus
24405f070f
[AMDGPU] Add intrinsic exposing s_alloc_vgpr (#163951)
Make it possible to use `s_alloc_vgpr` at the IR level. This is a huge
footgun and use for anything other than compiler internal purposes is
heavily discouraged. The calling code must make sure that it does not
allocate fewer VGPRs than necessary - the intrinsic is NOT a request to
the backend to limit the number of VGPRs it uses (in essence it's not so
different from what we do with the dynamic VGPR flags of the
`amdgcn.cs.chain` intrinsic, it just makes it possible to use this
functionality in other scenarios).
2026-02-10 09:28:31 +01:00
Peter Rong
9cd29a8ba1
[DebugInfo] Fix an assertion in DWARFTypePrinter (#178986)
A `DW_TAG_ptr_to_member_type` has no `RawName` and would trigger an
assertion.


7e48b14d1e/llvm/include/llvm/DebugInfo/DWARF/DWARFTypePrinter.h (L497-L502)

The assertion is mostly benign since it will be compared with other
strings and return false.


7e48b14d1e/llvm/include/llvm/DebugInfo/DWARF/DWARFTypePrinter.h (L505-L510)

But this is blocking our assertion builds.
We should escape `DW_TAG_ptr_to_member_type` as well when looking for
type names.

Adding a test to demonstrate how the assertion could be triggered, and
how we fixed it.

Depends on https://github.com/llvm/llvm-project/pull/180655

[Assisted-by](https://t.ly/Dkjjk): [Claude Opus
4.5](https://www.anthropic.com/news/claude-opus-4-5)
2026-02-10 04:59:53 +00:00
Steven Perron
e1d2ff6caf
[SPIRV] Implement lowering for HLSL Texture2D sampling intrinsics (#179312)
This patch implements the SPIR-V lowering for the following HLSL
intrinsics:
- SampleBias
- SampleGrad
- SampleLevel
- SampleCmp
- SampleCmpLevelZero

It defines the required LLVM intrinsics in 'IntrinsicsDirectX.td' and
'IntrinsicsSPIRV.td'.

It updates 'SPIRVInstructionSelector.cpp' to handle the new intrinsics
and
generates the correct 'OpImageSample*' instructions with the required
operands
(Bias, Grad, Lod, ConstOffset, MinLod, etc.).

CodeGen tests are added to verify the implementation for images with
dimension 1D, 2D, 3D, and Cube.

Assisted-by: Gemini
2026-02-09 17:28:58 -05:00
HighW4y2H3ll
37c3241d23
[SPGO] Use std::hash instead of MD5 to avoid run time regression in llvm-profgen (#180581)
https://github.com/llvm/llvm-project/pull/66164 changed the hashing in
`SampleContextFrame` from `std::hash` to `MD5` in a very hot function
(ContextTrieNode::getOrCrateChildContext()) in llvm-profgen. This
creates over 2x run time regression when running llvm-profgen with
csspgo preinliner enabled, since the MD5 computation is tripled
comparing to the Murmur hash in the std library. An llvm-profgen run
time comparison shows follows:

```
$ time llvm-profgen -binary $BINARY--perfscript $SAMPLES --populate-profile-symbol-list --show-density --output=XXX

# MD5 hash
real    105m31.644s
user    104m51.334s
sys     0m35.033s

# std::hash
real    46m0.340s
user    45m17.998s
sys     0m38.420s
```

Can confirm that this patch recovers the run time regression in
llvm-profgen, and the perf testing in our internal services shows
neutral.
2026-02-09 13:41:40 -08:00
Marina Taylor
cd47ae9f8f
[Profile] Enable binary profile correlation for Mach-O binaries (#179937)
The existing ELF/COFF correlation code mostly "just works" on Mach-O
files, with one gotcha: on disk, the pointers in `__llvm_covdata` are
stored in an encoded format due to dyld fixup chains. (In memory, they
would normally be fixed up at load time in a running binary, but the
correlator only looks at the on-disk values.)

LLVM's Mach-O reader knows how to decode the format, so this patch walks
the fixup table to create a set of mappings that the correlator can use
to resolve the values.

rdar://168259786
2026-02-09 18:31:04 +00:00
Nathan Gauër
091972c354
[SPIR-V] initial support for @llvm.structured.gep (#178668)
This commit adds initial support to lower the intrinsinc
`@llvm.structured.gep` into proper SPIR-V.
For now, the backend continues to support both GEP formats. We might
want to revisit this at some point for the logical part.
2026-02-09 15:51:07 +00:00
Mikhail Gudim
94971b7c8e
[CodeGen][NFC] Update a comment. (#180531)
Since a register can represent a negative frame index, remove
"non-negative" from the comment.
2026-02-09 07:28:56 -08:00
ShashwathiNavada
2e2167309d
[OpenMP][flang] Enabling support for Allocate clause in DO construct (#180172)
Fixes [#179425](https://github.com/llvm/llvm-project/issues/179425).

Allocate clause is allowed inside DO and parallel DO constructs as per
[13.6.2](https://www.openmp.org/wp-content/uploads/OpenMP-API-Specification-6-0.pdf)
but flang seemed to throw diagnostic against the same. This patch
enables initial support for allocate clause in DO construct.
2026-02-09 20:52:35 +05:30
Aiden Grossman
12ec215e8a
[IR] Update docstring for stripAndAccumulateConstantOffset (#180365)
Make it clear that the returned object in the case where a variable
offset is found is the first value to introduce a non-constant offset,
not necessarily the actual underlying object.

Found while investigating #180361.
2026-02-09 15:12:32 +00:00
Ruoyu Qiu
da0ad392ff
[llvm-objdump][AVR] Detect AVR architecture from ELF flags for disassembling (#180468)
Reland #174731, resolve cyclic dependency issue.

The use of LLVM_Object in LLVM_Util would cause cyclic dependency.
Fix cyclic dependency by reimplement `getFeatureSetFromEFlag()`.

Original description:

---

This PR updates llvm-objdump to detect the specific AVR architecture
from the ELF header flags when no specific CPU is provided.

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

Signed-off-by: Ruoyu Qiu <cabbaken@outlook.com>
2026-02-09 21:10:14 +08:00
Jay Foad
bf1340598e
[CodeGen] Improve documentation for SUBREG_TO_REG (#180504)
The most important change is to remove the claim that the extra bits are
necessarily set to zero.
2026-02-09 12:09:55 +00:00
Nikita Popov
4ef7be9b80
[SimplifyLibCalls] Directly convert fmin/fmax to intrinsics (#177988)
Drop the custom shrinking code, which we'll also do for intrinsics.
Having libcall-only optimizations is confusing, as these are typically
directly emitted as intrinsics by the frontend.
2026-02-09 10:10:24 +00:00
Pierre van Houtryve
b79ba02479
[AMDGPU][GFX12.5] Reimplement monitor load as an atomic operation (#177343)
Load monitor operations make more sense as atomic operations, as
non-atomic operations cannot be used for inter-thread communication w/o
additional synchronization.
The previous built-in made it work because one could just override the
CPol bits, but that bypasses the memory model and forces the user to learn
about ISA bits encoding.

Making load monitor an atomic operation has a couple of advantages.
First, the memory model foundation for it is stronger. We just lean on the
existing rules for atomic operations. Second, the CPol bits are abstracted away
from the user, which avoids leaking ISA details into the API.

This patch also adds supporting memory model and intrinsics
documentation to AMDGPUUsage.

Solves SWDEV-516398.
2026-02-09 09:57:27 +01:00
Matt Arsenault
0c583e784e
AMDGPU: Add llvm.amdgcn.s.wait.event intrinsic (#180170)
Exactly match the s_wait_event instruction. For some reason we already
had this instruction used through llvm.amdgcn.s.wait.event.export.ready,
but that hardcodes a specific value. This should really be a bitmask
that
can combine multiple wait types.

gfx11 -> gfx12 broke compatabilty in a weird way, by inverting the
interpretation of the bit but also shifting the used bit by 1. Simplify
the selection of the old intrinsic by just using the magic number 2,
which should satisfy both cases.
2026-02-09 08:45:13 +01:00
Fangrui Song
80f627e6d5
TargetRegistry: Remove deprecated create*Info that take StringRef parameter (#180448) 2026-02-08 18:22:04 -08:00
paperchalice
c53acf0443
[SelectionDAGBuilder] Remove NoNaNsFPMath uses (#169904)
Replaced by checking fast-math flags or value tracking results.
2026-02-09 09:48:07 +08:00
Fangrui Song
9892b2a7b5 [DWARFLinker] Make MCTargetOptions a class member. NFC
The local `MCTargetOptions` in `init` will become a problem once
MCAsmInfo stores a pointer to it. Move it to a class member in
DwarfStreamer, DwarfEmitterImpl, and DebugLineSectionEmitter so that it
outlives MCAsmInfo.
2026-02-08 16:49:04 -08:00
paperchalice
5c5677d7b8
[llvm] Remove "no-infs-fp-math" attribute support (#180083)
One of global options in `TargetMachine::resetTargetOptions`, now all
backends no longer support it, remove it.
2026-02-09 08:43:33 +08:00
Aiden Grossman
33291dd944
[ProfCheck] Add utility to get a MDNode for unknown branch weights
There are some cases where it is non-trivial to get access to a
branch/select instruction and the helper function that creates the
branch/select of interest takes in a MDNode for branch weights. Add a
helper to create a MDNode for unknown branch weights if the function is
profiled to handle this case.

Reviewers: mtrofin, snehasish, alanzhao1

Pull Request: https://github.com/llvm/llvm-project/pull/180389
2026-02-08 10:15:55 -08:00
Qinkun Bao
1b0f139f8e
Revert "[NFC][LiveStacks] Use vectors instead of map and unordred_map" (#180421)
Reverts llvm/llvm-project#165477

Break https://lab.llvm.org/buildbot/#/builders/52/builds/14874
2026-02-08 16:54:51 +00:00
Fangrui Song
74aa875346 MC: Remove unused overload and delete stale comment. NFC 2026-02-07 20:19:23 -08:00
Fangrui Song
62e93feba3
MC: Move generateCompactUnwindEncodings to MCObjectStreamer. NFC (#180381)
... removing the need to pass MCAsmBackend as a parameter.

This allows MCStreamer.cpp to not include MCAsmBackend.h.
2026-02-08 02:39:01 +00:00
Alex Wang
a947599991
[AMDGPU][GlobalISel] Add lowering for G_FMODF (#180152)
Add generic expansion for G_FMODF matching the SelectionDAG
implementation.

Enable G_FMODF lowering for AMDGPU with tests.

Related: #179434
2026-02-07 18:43:55 +00:00
Ralender
8bced61172
[NFC][ADT] add NumDigitsBase10 to MathExtra and update some current users (#165479) 2026-02-07 18:10:05 +01:00
Qinkun Bao
43905d6c8a
Revert "[ValueTracking] Propagate sign information out of loop" (#180354)
Reverts llvm/llvm-project#175590

Break https://lab.llvm.org/buildbot/#/builders/55/builds/23820 and clang
2026-02-07 17:02:17 +00:00
Ralender
1acc200d88
[NFC][LiveStacks] Use vectors instead of map and unordred_map (#165477) 2026-02-07 15:31:43 +00:00
Kshitij Paranjape
7054a4b8f9
[ValueTracking] Propagate sign information out of loop (#175590)
LLVM converts sqrt libcall to intrinsic call if the argument is within
the range(greater than or equal to 0.0). In this case the compiler is
not able to deduce the non-negativity on its own. Extended ValueTracking
to understand such loops.

Fixes llvm/llvm-project#174813
2026-02-07 14:36:00 +01:00
Vladimir Vereschaka
19d681177f
Revert "[MC][TableGen] Expand Opcode field of MCInstrDesc" (#180321)
Reverts llvm/llvm-project#179652

This PR causes the out-of-memory build failures on many Windows
builders.
2026-02-06 21:58:50 -08:00
Ganesh
a362593e0d
[X86] AMD Zen 6 Initial enablement (#179150)
This patch adds initial support for AMD Zen 6 architecture (znver6):

- Added znver6 CPU target recognition in Clang and LLVM
- Updated compiler-rt CPU model detection for znver6
- Added znver6 to target parser and host CPU detection
- Added znver6 to various optimizer tests

znver6 features: FP16, AVXVNNIINT8, AVXNECONVERT, AVXIFMA (without BMM).
2026-02-07 09:38:10 +05:30
Peter Collingbourne
191af6c254
Add llvm.cond.loop intrinsic.
The llvm.cond.loop intrinsic is semantically equivalent to a conditional
branch conditioned on ``pred`` to a basic block consisting only of an
unconditional branch to itself. Unlike such a branch, it is guaranteed
to use specific instructions. This allows an interrupt handler or
other introspection mechanism to straightforwardly detect whether
the program is currently spinning in the infinite loop and possibly
terminate the program if so. The intent is that this intrinsic may
be used as a more efficient alternative to a conditional branch to
a call to ``llvm.trap`` in circumstances where the loop detection
is guaranteed to be present. This construct has been experimentally
determined to be executed more efficiently (when the branch is not taken)
than a conditional branch to a trap instruction on AMD and older Intel
microarchitectures, and is also more code size efficient by avoiding the
need to emit a trap instruction and possibly a long branch instruction.

On i386 and x86_64, the infinite loop is guaranteed to consist of a short
conditional branch instruction that branches to itself. Specifically,
the first byte of the instruction will be between 0x70 and 0x7F, and
the second byte will be 0xFE.

Part of this RFC:
https://discourse.llvm.org/t/rfc-optimizing-conditional-traps/89456

Reviewers: arsenm, RKSimon, fmayer, vitalybuka

Pull Request: https://github.com/llvm/llvm-project/pull/177686
2026-02-06 17:11:15 -08:00
Dmitry Sidorov
9e355c8ec3
[SPIRV] Fix alignment overflow in memory intrinsics (#180184)
Per SPIR-V spec alignment is 32-bit integer, so it should be encoded as
i8 in the intrinsics'
def.
2026-02-06 22:58:33 +01:00
Argyrios Kyrtzidis
60ecb37896
[llvm/CAS] Add file-based APIs to OnDiskGraphDB (#179782)
These allow performing optimizations that reduce I/O and disk space
consumption. For example, when applicable, a file can be cloned directly
into the database directory, instead of needing to load it in memory and
then copy its contents into a new file.

These APIs are then used to optimize importing data from an upstream DB
by using file cloning where applicable.
2026-02-06 13:27:24 -08:00
Florian Hahn
bd40d1de9c
Reapply "[SCEVExp] Use SCEVPtrToAddr in tryToReuseLCSSAPhi if possible. (#180257)"
This reverts commit cb905605b2e95f88296afe136b21a7d2476cb058.

Recommit the patch with a small change to check the destination
type matches the address type, to avoid a crash on mismatch.

Original message:

This patch updates tryToReuseLCSSAPhi to use SCEVPtrToAddr, unless using
SCEVPtrToInt allows re-use, because the IR already contains a re-usable
phi using PtrToInt.

This is a first step towards migrating to SCEVPtrToAddr and avoids
regressions in follow-up changes.

PR: https://github.com/llvm/llvm-project/pull/178727
2026-02-06 21:14:41 +00:00
sstipano
13d8870d45
[MC][TableGen] Expand Opcode field of MCInstrDesc (#179652)
Increase width of Opcode to `int` from `short` to allow more capacity.
2026-02-06 20:21:48 +01:00
Henrik G. Olsson
eff21afae0
Revert "[llvm-objdump][AVR] Detect AVR architecture from ELF flags for disassembling" (#180252)
Reverts llvm/llvm-project#174731 due to introducing a cyclic dependency
when building LLVM with modules enabled: LLVM_Utils -> LLVM_Object ->
LLVM_Utils
2026-02-06 19:00:32 +00:00
Florian Hahn
cb905605b2
Revert "[SCEVExp] Use SCEVPtrToAddr in tryToReuseLCSSAPhi if possible." (#180257)
Reverts llvm/llvm-project#178727

triggers asserts in on some build bots
2026-02-06 18:26:37 +00:00
Florian Hahn
c32cde4182
[SCEVExp] Use SCEVPtrToAddr in tryToReuseLCSSAPhi if possible. (#178727)
This patch updates tryToReuseLCSSAPhi to use SCEVPtrToAddr, unless using
SCEVPtrToInt allows re-use, because the IR already contains a re-usable
phi using PtrToInt.

This is a first step towards migrating to SCEVPtrToAddr and avoids
regressions in follow-up changes.

PR: https://github.com/llvm/llvm-project/pull/178727
2026-02-06 17:38:24 +00:00
Rahul Joshi
918d57642b
[NFC][LLVM] Code cleanup in VNCoercion (#180159)
Use namespace qualifiers to define functions declared in the
`VNCoercion` namespace to conform to LLVM CS.
2026-02-06 09:07:31 -08:00
Manuel Carrasco
c8d8e5e210
[DebugInfo] Add macro tracking support to DebugInfoFinder (#179931)
Extend `DebugInfoFinder` to collect and expose macro debug information
(`DIMacro` and `DIMacroFile` nodes).

Also update `ModuleDebugInfoPrinter` to display macro information
including the macro type, name, value, and source location.

-----

The motivation behind this PR is that `DebugInfoFinder` is key for the
[SPIRV-LLVM-Translator](https://github.com/KhronosGroup/SPIRV-LLVM-Translator)
and also for future support of debug info in the SPIRV backend in LLVM.

This new lookup of `DIMacro` with their `DIMacroFile` when available
simplifies the logic around the translation for this debug information.
2026-02-06 15:33:04 +00:00
Mirko Brkušanin
20b5849e17
[AMDGPU] Define new target gfx1170 (#180185) 2026-02-06 14:38:50 +01:00
Ruoyu Qiu
d005cb2953
[llvm-objdump][AVR] Detect AVR architecture from ELF flags for disassembling (#174731)
This PR updates llvm-objdump to detect the specific AVR architecture
from the ELF header flags when no specific CPU is provided.

Fixes: #146451

---------

Signed-off-by: RuoyuQiu <cabbaken@outlook.com>
Signed-off-by: Ruoyu Qiu <cabbaken@outlook.com>
Co-authored-by: qiuruoyu <qiuruoyu@hygon.cn>
2026-02-06 08:58:12 +08:00
Min-Yih Hsu
6441f1c9d5
[RISCV] Introduce a new syntax for processor-specific tuning feature strings (#175063)
This patch proposes new a tuning feature string format that helps users
to build a performance model by "configuring" an existing tune CPU,
along with its scheduling model. For example, this string
```
"sifive-x280:single-element-vec-fp64"
```
takes ``sifive-x280`` as the "base" tune CPU and configured it with
``single-element-vec-fp64``. This gives us a performance model that
looks exactly like that of ``sifive-x280``, except some of the 64-bit
vector floating point instructions now produce only a single element per
cycle due to ``single-element-vec-fp64``.

This string could eventually be used in places like ``-mtune`` at the
frontend. Right now, this patch only implements the parser part, which
is put under the TargetParser library.

The grammar for this string is:
```
    tune-cpu      ::= 'tuning CPU name in lower case'
    directive     ::= "[a-zA-Z0-9_-]+"
    tune-features ::= directive ["," directive]*
```
A *directive* can and can only _enable_ or _disable_ a certain tuning
feature from the tuning CPU. A **positive directive**, like the
``single-element-vec-fp64`` we just saw, enables an additional tuning
feature in the associated tuning model.

A **negative directive**, on the other hand, removes a certain tuning
feature. For example, ``sifive-x390`` already has the
``single-element-vec-fp64`` feature, and we can use
"sifive-x390:no-single-element-vec-fp64" to create a new performance
model that looks nearly the same as ``sifive-x390`` except
``single-element-vec-fp64`` being cut out. In this case,
``no-single-element-vec-fp64`` is a negative directive.

There are additional restrictions on what we can put in the list of
directives, please refer to the documentations for more details.

Right now, this string only accepts directives that are explicitly
supported by the tune CPU. For example, "sifive-x280:prefer-w-inst" is
not a valide string as ``prefer-w-inst`` is not supported by
``sifive-x280`` at this moment. Vendors of these processors are expected
to maintain the compatibility of their supported directives across
different versions.

---------

Co-authored-by: Sam Elliott <aelliott@qti.qualcomm.com>
2026-02-05 15:22:07 -08:00
David Green
08cf3e62b4
[AArch64][GlobalISel] Add GISel handling for FCVT fixed. (#178903)
This uses the generalized code from #178603 to allow GISel to
select fixed-point fcvt in the same way as SDAG.
2026-02-05 22:25:38 +00:00