11514 Commits

Author SHA1 Message Date
Craig Topper
3c13257f32
[RISCV] Rename XTHeadVdot instructions to match their mnemonic. NFC (#146953)
We were using the extension name as a prefix rather than TH_.
2025-07-03 13:43:34 -07:00
Craig Topper
d0d84c4150
[RISCV] Add SF_ to SiFive instructions in RISCVGenInstrInfo.inc. NFC (#146939) 2025-07-03 13:38:27 -07:00
Florian Hahn
bfd457588a
Revert "[AMDGPU] SelectionDAG divergence tracking should take into account Target divergency. (#144947)"
This reverts commit 8ac7210b7f0ad49ae7809bf6a9faf2f7433384b0.

This breaks the building the AArch64 backend, e.g. see
https://github.com/llvm/llvm-project/pull/144947

Revert to unbreak the build.

Also reverts follow-up commits 1e76f012db3ccfaa05e238812e572b5b6d12c17e.
2025-07-03 19:25:01 +01:00
Krzysztof Parzyszek
795b17d0b8
[Frontend][OpenMP] Implement directive name parser (#146776)
Implement a state machine that consumes tokens (words delimited by white
space), and returns the corresponding directive id, or fails if the tokens
did not form a valid name.
2025-07-03 12:18:01 -05:00
alex-t
8ac7210b7f
[AMDGPU] SelectionDAG divergence tracking should take into account Target divergency. (#144947)
If a kernel is known to be executing only a single lane, IR
UniformityAnalysis will take note of that (via
GCNTTIImpl::hasBranchDivergence) and report that all values are uniform.
SelectionDAG's built-in divergence tracking should do the same.
2025-07-03 18:37:37 +02:00
Lang Hames
2638fa1be6
[ORC] Add cloneToContext: Clone Module to a given ThreadSafeContext (#146852)
This is a generalization of the existing cloneToNewContext operation:
rather than cloning the given module into a new ThreadSafeContext it
clones it into any given ThreadSafeContext. The given ThreadSafeContext
is locked to ensure that the cloning operation is safe.
2025-07-03 22:04:41 +10:00
UmeshKalappa
032966ff56
[RISCV] Added the MIPS prefetch extensions for MIPS RV64 P8700. (#145647)
the extension enabled with xmipscbop.

Please refer "MIPS RV64 P8700/P8700-F Multiprocessing System
Programmer’s Guide" for more info on the extension at
https://mips.com/wp-content/uploads/2025/06/P8700_Programmers_Reference_Manual_Rev1.84_5-31-2025.pdf
2025-07-03 10:59:10 +02:00
Lang Hames
0bfa0bcd79
[ORC] Replace ThreadSafeContext::getContext with withContextDo. (#146819)
This removes ThreadSafeContext::Lock, ThreadSafeContext::getLock, and
ThreadSafeContext::getContext, and replaces them with a
ThreadSafeContext::withContextDo method (and const override).

The new method can be used to access an existing
ThreadSafeContext-wrapped LLVMContext in a safe way:

ThreadSafeContext TSCtx = ... ;
TSCtx.withContextDo([](LLVMContext *Ctx) {
  // this closure has exclusive access to Ctx.
});

The new API enforces correct locking, whereas the old APIs relied on
manual locking (which almost no in-tree code preformed, relying instead
on incidental exclusive access to the ThreadSafeContext).
2025-07-03 17:03:39 +10:00
Longsheng Mou
65537539e1
[llvm][ADT] Add wrappers to std::fill (#146681)
This PR adds `llvm::fill` that accepts a range instead of begin/end
iterator.
2025-07-03 14:32:47 +08:00
Rahul Joshi
2725765432
[LLVM][ADT] Add consume_front and consume_back to ArrayRef (#146741)
Add `consume_front` that returns the first element and drops it from the
current ArrayRef, and `consume_back` that returns the last element and
drops it from the current ArrayRef.
2025-07-02 13:32:27 -07:00
Rahman Lavaee
6b623a6622
[SHT_LLVM_BB_ADDR_MAP] Remove support for versions 1 and 0 (SHT_LLVM_BB_ADDR_MAP_V0). (#146186)
Version 2 was added more than two years ago
(6015a045d7).
So it should be safe to deprecate older versions.
2025-07-02 10:31:52 -07:00
Kazu Hirata
bbf4402635
[Analysis] Remove a redundant control flow statement (NFC) (#146708) 2025-07-02 09:32:30 -07:00
S. VenkataKeerthy
119292c40b
[IR2Vec] Add out-of-place arithmetic operators to Embedding class (#145118)
This PR adds out-of-place arithmetic operators (`+`, `-`, `*`) to the `Embedding` class in IR2Vec, complementing the existing in-place operators (`+=`, `-=`, `*=`). 

Tests have been added to verify the functionality of these new operators.

(Tracking issue - #141817)
2025-07-01 12:09:54 -07:00
S. VenkataKeerthy
efe0deae3f
[NFC][IR2Vec] Increasing tolerance in approximatelyEquals() of Embedding (#145117)
Increase the default tolerance for `approximatelyEquals` in IR2Vec's Embedding class from 1e-6 to 1e-4.

(Tracking issue - #141817)
2025-07-01 12:03:37 -07:00
Simon Pilgrim
67be4fe3d5 Fix MSVC implicit double -> float truncation warning. NFC. 2025-07-01 08:48:16 +01:00
Zakk Chen
3cc200f46b
DynamicAPInt: Support APInt constructor. (#146301)
This PR introduces a constructor for `DynamicAPInt` that takes an
`APInt` object as input to simplifies the creation of a large numbers.
2025-07-01 15:44:12 +08:00
S. VenkataKeerthy
0a69c83421
[NFC][IR2Vec] Remove unreachable code and simplify invalid mode test (#146459)
The code following `llvm_unreachable`  is optimized out in Release builds. In this case, `Embedder::create` do not seem to return `nullptr` causing `CreateInvalidMode` test to break. Hence removing `llvm_unreachable`.
2025-06-30 20:31:47 -07:00
Kazu Hirata
8cf3b989a9 [Analysis] Fix a warning
This patch fixes:

  llvm/unittests/Analysis/FunctionPropertiesAnalysisTest.cpp:132:12:
  error: moving a local object in a return statement prevents copy
  elision [-Werror,-Wpessimizing-move]
2025-06-30 18:44:45 -07:00
S. VenkataKeerthy
9438048816
[IR2Vec] Simplifying creation of Embedder (#143999)
This change simplifies the API by removing the error handling complexity. 

- Changed `Embedder::create()` to return `std::unique_ptr<Embedder>` directly instead of `Expected<std::unique_ptr<Embedder>>`
- Updated documentation and tests to reflect the new API
- Added death test for invalid IR2Vec kind in debug mode
- In release mode, simply returns nullptr for invalid kinds instead of creating an error

(Tracking issue - #141817)
2025-06-30 18:24:08 -07:00
S. VenkataKeerthy
0745eb501d
[IR2Vec] Scale embeddings once in vocab analysis instead of repetitive scaling (#143986)
Changes to scale opcodes, types and args once in `IR2VecVocabAnalysis` so that we can avoid scaling each time while computing embeddings. This PR refactors the vocabulary to explicitly define 3 sections---Opcodes, Types, and Arguments---used for computing Embeddings. 

(Tracking issue - #141817 ; partly fixes - #141832)
2025-06-30 23:09:19 +02:00
S. VenkataKeerthy
dcf8ec9218
Reland "[MLGO][IR2Vec] Integrating IR2Vec with MLInliner (#143479)" (#145664)
Relanding #143479 after fixes. 

Removed `NumberOfFeatures` from the `FeatureIndex` enum as the number of features used depends on whether IR2Vec embeddings are used.
2025-06-30 22:37:39 +02:00
Krzysztof Parzyszek
4c7d3e9315
[STLForwardCompat] Implement llvm::type_identity (#146390)
A basic implementation until we get it in `std` in C++20.
2025-06-30 15:05:49 -05:00
Rahul Joshi
d1ba2692ee
[LLVM][Clang] Enable strict mode for getTrailingObjects (#144930)
Disallow calls to templated `getTrailingObjects` if there is a single
trailing type (strict mode). Add `getTrailingObjectsNonStrict` for cases
when it's not possible to know statically if there will be a single or
multiple trailing types (like in OpenMPClause.h) to bypass the struct
checks.

This will ensure that future users of TrailingObjects class do not
accidently use the templated `getTrailingObjects` when they have a
single trailing type.
2025-06-30 07:23:34 -07:00
Rahul Joshi
b0ff473340
[LLVM] Change ModulePass::skipModule to take a const reference (#146168)
Change `ModulePass::skipModule` to take const Module reference.
Additionally, make `OptPassGate::shouldRunPass` const as well as for
most implementations it's a const query. For `OptBisect`, make
`LastBisectNum` mutable so it could be updated in `shouldRunPass`.

Additional minor cleanup: Change all StringRef arguments to simple
StringRef (no const or reference), change `OptBisect::Disabled` to
constexpr.
2025-06-30 07:23:04 -07:00
zhaohui
eb1a80bfd3
[DAG] Implement SDPatternMatch m_SpecificScalarVT and m_SpecificVectorElementVT matchers (#144996)
Resolves https://github.com/llvm/llvm-project/issues/144477

---------

Co-authored-by: Simon Pilgrim <llvm-dev@redking.me.uk>
2025-06-30 13:26:00 +01:00
Orlando Cazalet-Hyams
140e1894f2
[KeyInstr] Add DISubprogram::keyInstructions bit (#144107)
Patch 1/4 adding bitcode support.

Store whether or not a function is using Key Instructions in its DISubprogram so
that we don't need to rely on the -mllvm flag -dwarf-use-key-instructions to
determine whether or not to interpret Key Instructions metadata to decide
is_stmt placement at DWARF emission time. This makes bitcode support simple and
enables well defined mixing of non-key-instructions and key-instructions
functions in an LTO context.

This patch adds the bit (using DISubprogram::SubclassData1).

PR 144104 and 144103 use it during DWARF emission.
PR 44102 adds bitcode
support.

See pull request for overview of alternative attempts.
2025-06-30 08:01:55 +01:00
Kazu Hirata
f90025ebd9
[llvm] Compare std::optional<T> to values directly (NFC) (#146222)
This patch transforms:

  X && *X == Y

to:

  X == Y

where X is of std::optional<T>, and Y is of T or similar.
2025-06-28 13:04:16 -07:00
Antonio Frighetto
69b8e59f29 [ValueTracking] Forward-declare class instead of including header (NFC)
The header inclusion was previously causing a build time regression.
2025-06-28 11:21:24 +02:00
Mészáros Gergely
98f7d756e3
[FileCheck] Improve printing variables with escapes (#145865)
Firstly fix FileCheck printing string variables
double-escaped (first regex, then C-style).
    
This is confusing because it is not clear if the printed
value is the literal value or exactly how it is escaped, without
looking at FileCheck's source code.
    
Secondly, only escape when doing so makes it easier to read the value
(when the string contains tabs, newlines or non-printable characters).
When the variable value is escaped, make a note of it in the output too,
in order to avoid confusion.
    
The common case that is motivating this change is variables that contain
windows style paths with backslashes. These were printed as
`"C:\\\\Program Files\\\\MyApp\\\\file.txt"`.
Now prefer to print them as `"C:\Program Files\MyApp\file.txt"`.
Printing the value literally also makes it easier to search for
variables in the output, since the user can just copy-paste it.
2025-06-27 22:39:07 +02:00
vporpo
1eacdddc0c
[SandboxVec][SeedCollector][NFC] Replace cl::opt flags with constructor args (#143206)
The `SeedCollector` class gets two new arguments: `CollectStores` and
`CollectLoads`. These replace the `sbvec-collect-seeds` cl::opt flag.
This is done to help with reusing the SeedCollector class in a future
pass. The cl::opt flag is moved to the seed collection pass:
Passes/SeedCollection.cpp
2025-06-27 12:27:25 -07:00
Sterling-Augustine
23f1ba3ee4
Reapply "[NFC][DebugInfo][DWARF] Create new low-level dwarf library (#… (#145959) (#146112)
Reapply "[NFC][DebugInfo][DWARF] Create new low-level dwarf library (#…
(#145959)
    
This reapplies cbf781f0bdf2f680abbe784faedeefd6f84c246e, with fixes for
the shared-library build and the unconventional sanitizer-runtime build.

Original Description:

This is the culmination of a series of changes described in [1].
    
Although somewhat large by line count, it is almost entirely mechanical,
creating a new library in DebugInfo/DWARF/LowLevel. This new library has
very minimal dependencies, allowing it to be used from more places than
the normal DebugInfo/DWARF library--in particular from MC.
    
1.
https://discourse.llvm.org/t/rfc-debuginfo-dwarf-refactor-into-to-lower-and-higher-level-libraries/86665/2
2025-06-27 11:05:49 -07:00
Antonio Frighetto
c11ea449e5 [ValueTracking] Add matchSimpleBinaryIntrinsicRecurrence helper
Similarly to what it is being done to match simple recurrence cycle
relations, attempt to match value-accumulating recurrences of kind:
```
  %umax.acc = phi i8 [ %umax, %backedge ], [ %a, %entry ]
  %umax = call i8 @llvm.umax.i8(i8 %umax.acc, i8 %b)
```
Preliminary work to let InstCombine avoid folding such recurrences,
so that simple loop-invariant computation may get hoisted. Minor
opportunity to refactor out code as well.
2025-06-27 19:04:28 +02:00
gbMattN
0158ca21a2
Prevent a crash when a global variable has debug metadata (#145918)
This patch fixes a crash I found when trying to compile some codebases
with -fsanitize=type and -g
2025-06-27 11:43:24 +01:00
Kazu Hirata
26ec66dc18
[llvm] Use a new constructor of ArrayRef (NFC) (#146008)
ArrayRef now has a new constructor that takes a parameter whose type
has data() and size().  This patch migrates:

  ArrayRef<T>(X.data(), X.size()

to:

  ArrayRef<T>(X)
2025-06-26 23:38:12 -07:00
Lang Hames
ad6b597875 [ORC] Fix EPCGenericMemoryAccessTest write-ptrs implementation after f93df5ebd99
The write-pointers operation should be writing a pointer, not a uint64_t. This
bug existed prior to f93df5ebd99, but changes in that commit seem to have
exposed the issue (see e.g.
https://lab.llvm.org/buildbot/#/builders/154/builds/17956).
2025-06-27 12:08:25 +10:00
Lang Hames
f93df5ebd9
[ORC] Add read operations to orc::MemoryAccess. (#145834)
This commit adds operations to orc::MemoryAccess for reading basic types
(uint8_t, uint16_t, uint32_t, uint64_t, pointers, buffers, and strings)
from executor memory.

The InProcessMemoryAccess and EPCGenericMemoryAccess implementations are
updated to support the new operations.
2025-06-27 09:49:17 +10:00
Sterling-Augustine
5d03e7a204
Revert "[NFC][DebugInfo][DWARF] Create new low-level dwarf library (#… (#145959)
…145081)"

This reverts commit cbf781f0bdf2f680abbe784faedeefd6f84c246e.

Breaks a couple of buildbots.
2025-06-26 13:09:20 -07:00
Sterling-Augustine
cbf781f0bd
[NFC][DebugInfo][DWARF] Create new low-level dwarf library (#145081)
This is the culmination of a series of changes described in [1].
    
Although somewhat large by line count, it is almost entirely mechanical,
creating a new library in DebugInfo/DWARF/LowLevel. This new library has
very minimal dependencies, allowing it to be used from more places than
the normal DebugInfo/DWARF library--in particular from MC.
    
I am happy to put it in another location, or to structure it differently
if that makes sense. Some have suggested in BinaryFormat, but it is not
a great fit there. But if that makes more sense to the reviewers, I can
do that.
 
Another possibility would be to use pass-through headers to allow
clients who don't care to depend only on DebugInfo/DWARF. This would be
a much less invasive change, and perhaps easier for clients. But also a
system that hides details.

Either way, I'm open.

1.
https://discourse.llvm.org/t/rfc-debuginfo-dwarf-refactor-into-to-lower-and-higher-level-libraries/86665/2
2025-06-26 11:23:46 -07:00
Abhishek Kaushik
abf8e25ac7
[DAG] Add SDPatternMatch::m_Load (#145481)
Add SDPatternMatch matcher and unit test coverage for `ISD::LOAD`
opcode.
This only matches the loaded value i.e. ResNo 0 and not the output
chain.
e.g.
```
m_Load(m_Value(), m_Value(), m_Value())
```

The first value is the input chain, the second is the base pointer, and
the last value is the offset.
2025-06-26 23:03:31 +05:30
Min-Yih Hsu
f0c1a9a85d
[DAG] Add SDPatternMatch::m_Result to match a specific SDValue result (#145775)
`m_Result<N>` matches a SDValue that is the N-th result of the defining
SDNode. This is useful for creating a more fine-grained matching on
SDNode with multiple results.

-----
Inspired by #145481
2025-06-26 22:08:22 +05:30
Paul Walker
635acfbfca
[LLVM][AArch64] Relax SVE/SME codegen predicates for crypto and bitperm instructions. (#145696)
Adds sve-sha3 to reference FEAT_SVE_SHA3 without specifically enabling
SVE2. The SVE2 requirement for AES, SHA3 and Bitperm is replaced with
SVE for non-streaming function.
2025-06-26 13:01:07 +01:00
Benjamin Kramer
e8f85cf51f [ArrayRef] Bring MutableArrayRef's constructor in line with ArrayRef
This time when the argument has a data member returning a mutable
pointer.
2025-06-26 11:12:05 +02:00
Matt Arsenault
c91cbafad2
TargetLibraryInfo: Delete default TargetLibraryInfoImpl constructor (#145826)
It should not be possible to construct one without a triple. It would
also be nice to delete TargetLibraryInfoWrapperPass, but that is more
difficult.
2025-06-26 16:12:36 +09:00
Lang Hames
0faa181434
[ORC] Extract MemoryAccess from ExecutorProcessControl, break up header. (#145671)
This moves the MemoryAccess interface out of the ExecutorProcessControl
class and splits implementation classes InProcessMemoryManager and
SelfExecutorProcessControl out of ExecutorProcessControl.h and into
their own headers.
2025-06-26 10:31:43 +10:00
Andrew Rogers
1abe1aa7b2
[llvm] annotate remaining Analysis library interfaces for DLL export (#145359) 2025-06-25 12:18:07 -07:00
Tom Tromey
3b90597c2c
Non constant size and offset in DWARF (#141106)
In Ada, a record type can have a non-constant size, and a field can
appear at a non-constant bit offset in a record.

To support this, this patch changes DIType to record the size and offset
using metadata, rather than plain integers. In addition to a constant
offset, both DIVariable and DIExpression are now supported here.

One thing of note in this patch is the choice of how exactly to
represent a non-constant bit offset, with the difficulty being that
DWARF 5 does not support this. DWARF 3 did have a way to support a
non-constant byte offset, combined with a constant bit offset within the
byte, but this was deprecated in DWARF 4 and removed from DWARF 5.

This patch takes a simple approach: a DWARF extension allowing the use
of an expression with DW_AT_data_bit_offset. There is a corresponding
DWARF issue, see https://dwarfstd.org/issues/250501.1.html. The main
reason for this approach is that it keeps API simplicity: just a single
value is needed, rather than having separate data describing the byte
offset and the bit within the byte.
2025-06-25 11:20:35 -07:00
Benjamin Kramer
0556a2aa18
[ArrayRef] Provide constructors from any type with a data() member (#145735)
The assumption here is that if data() returns a pointer and size()
exists it's something representing contiguous storage.

Modeled after the behavior of C++20 std::span and enables two-way
conversion between std::span (or really any span-like type) and
ArrayRef. Add a unit test that verifies this if std::span is around.

This also means we can get rid of specific conversions for std::vector
and SmallVector.
2025-06-25 19:33:34 +02:00
Krzysztof Parzyszek
d7b936b633
[OpenMP] Add directive spellings introduced in OpenMP 6.0 (#141772)
For background information see

https://discourse.llvm.org/t/rfc-alternative-spellings-of-openmp-directives/85507
2025-06-25 07:55:06 -05:00
Matt Arsenault
b991b21874
Triple: Add BridgeOS to isOSDarwin (#145636)
This fixes a TODO and avoids a special case. Also required
hacking up a few cases to avoid asserting in codegen; it's not
confidence inspiring that there is only one codegen test using
a bridgeos triple and its specifically for the exp10 libcall
names.

This also changes the behavior, losing an extra leading _ in the
emitted name matching the other apple outputs. I have no idea if
this is right or not. IMO it's someone from apple's problem to fix
it and add appropriate test coverage, or we can rip all references
to BridgeOS out from upstream.
2025-06-25 20:06:51 +09:00
Lang Hames
d32239b461 [ORC] Move UnsupportedExecutorProcessControl into unittests.
The UnsupportedExecutorProcessControl implementation is only used in unit
tests, so move it out of the public headers.
2025-06-25 17:44:23 +10:00