15660 Commits

Author SHA1 Message Date
Sergei Barannikov
b96d5c2452
[TableGen][DecoderEmitter] Outline InstructionEncoding constructor (NFC) (#154673)
It is going to grow, so it makes sense to move its definition
out of class. Instead, inline `populateInstruction()` into it.
Also, rename a couple of methods to better convey their meaning.
2025-08-21 06:08:57 +00:00
Aiden Grossman
c811f522f6
[ProfCheck] Add list of xfail tests (#154655)
This patch contains a list of tests that are currently failing in the
LLVM_ENABLE_PROFCHECK=ON build. This enables passing them to lit through
the LIT_XFAIL env variable. This is necessary for getting a buildbot
spun up to catch regressions while work is being done to fix the
existing issues.

We need to keep this in the LLVM tree so that tests can be removed from
the list at the same time the passes causing issues are fixed.

Issue #147390
2025-08-21 01:28:05 +00:00
Sergei Barannikov
46343ca374
[TableGen][DecoderEmitter] Add DecoderMethod to InstructionEncoding (NFC) (#154477)
We used to abuse Operands list to store instruction encoding's
DecoderMethod there. Let's store it in the InstructionEncoding class
instead, where it belongs.
2025-08-20 21:59:59 +00:00
Sergei Barannikov
19ac1ff56e
[TableGen][DecoderEmitter] Factor populateFixedLenEncoding (NFC) (#154511)
Also drop the debug code under `#if 0` and a seemingly outdated comment.
2025-08-20 11:34:59 +00:00
Sergei Barannikov
9ae0bd2c9f
[TableGen][DecoderEmitter] Move Operands to InstructionEncoding (NFCI) (#154456)
This is where they belong, no need to maintain a separate map keyed by
encoding ID.
`populateInstruction()` has been made a member of `InstructionEncoding`
and is now called from the constructor.
2025-08-20 07:10:34 +03:00
Sergei Barannikov
8666ffdd15 [TableGen][DecoderEmitter] Rename some variables (NFC)
And change references to pointers, to make the future diff smaller.
2025-08-20 04:55:07 +03:00
Sergei Barannikov
6462223853 [TableGen] Make ParseOperandName method const (NFC)
Also change its name to start with a lowercase letter and update
the doxygen comment to conform to the coding standard.
2025-08-20 03:21:15 +03:00
Sergei Barannikov
803edce6f7
[TableGen][DecoderEmitter] Analyze encodings once (#154309)
Follow-up to #154288.

With HwModes involved, we used to analyze the same encoding multiple
times (unless `-suppress-per-hwmode-duplicates=O2` is specified). This
affected the build time and made the statistics inaccurate.

From the point of view of the generated code, this is an NFC.
2025-08-19 23:17:12 +00:00
Sergei Barannikov
07a6323c32
[TableGen][DecoderEmitter] Turn EncodingAndInst into a class (NFC) (#154230)
The class will get more methods in follow-up patches.
2025-08-20 01:29:26 +03:00
Arthur Eubanks
b35b6297fd [gn build] Build win asan libraries against MutliThreadedDLL
win asan only supports /MD. Without this, the asan runtime cannot intercept functions.
2025-08-19 19:48:32 +00:00
Alexandre Ganea
13391ce183
On Windows, in the release build script, fix detecting if clang-cl is in PATH (#149597)
The checks for detecting if `clang-cl` and `lld-link` are in `%PATH`
were wrong.

This fixes the comment in
https://github.com/llvm/llvm-project/pull/135446#discussion_r2215511129
2025-08-19 13:13:51 +00:00
Sergei Barannikov
56ce40bc73
[TableGen][DecoderEmitter] Stop duplicating encodings (NFC) (#154288)
When HwModes are involved, we can duplicate an instruction encoding that
does not belong to any HwMode multiple times. We can do better by
mapping HwMode to a list of encoding IDs it contains. (That is,
duplicate IDs instead of encodings.)

The encodings that were duplicated are still processed multiple times
(e.g., we call an expensive populateInstruction() on each instance).
This is going to be fixed in subsequent patches.
2025-08-19 09:02:22 +00:00
Sergei Barannikov
cded128009
[TableGen][DecoderEmitter] Extract encoding parsing into a method (NFC) (#154271)
Call it from the constructor so that we can make `run` method `const`.
Turn a couple of related functions into methods as well.
2025-08-19 06:35:59 +00:00
Sergei Barannikov
6c3a0ab51a [TableGen][DecoderEmitter] Shorten a few variable names (NFC)
These "Numbered"-prefixed names were rather confusing than helpful.
2025-08-19 08:05:02 +03:00
Sergei Barannikov
f84ce1e1d0 [TableGen][DecoderEmitter] Extract a couple of loop invariants (NFC) 2025-08-19 07:47:15 +03:00
Henrik G. Olsson
e1ff432eb6
Reland "[Utils] Add new --update-tests flag to llvm-lit" (#153821)
This reverts commit
e495231238
to reland
the --update-tests feature, originally landed in
https://github.com/llvm/llvm-project/pull/108425.
2025-08-18 20:24:27 -07:00
Sergei Barannikov
c8c2218c00
[TableGen][DecoderEmitter] Synthesize decoder table name in emitTable (#154255)
Previously, HW mode name was appended to decoder namespace name when
enumerating encodings, and then emitTable appended the bit width to it
to form the final table name. Let's do this all in one place.
A nice side effect is that this allows us to avoid having to deal with
std::string.

The changes in the tests are caused by the different order of tables.
2025-08-19 06:19:54 +03:00
Matt Arsenault
19ebfa6d0b
RuntimeLibcalls: Move exception call config to tablegen (#151948)
Also starts pruning out these calls if the exception model is
forced to none.

I worked backwards from the logic in addPassesToHandleExceptions
and the pass content. There appears to be some tolerance
for mixing and matching exception modes inside of a single module.
As far as I can tell _Unwind_CallPersonality is only relevant for
wasm, so just add it there.

As usual, the arm64ec case makes things difficult and is
missing test coverage. The set of calls in list form is necessary
to use foreach for the duplication, but in every other context a
dag is more convenient. You cannot use foreach over a dag, and I
haven't found a way to flatten a dag into a list.

This removes the last manual setLibcallImpl call in generic code.
2025-08-19 10:35:59 +09:00
Sergei Barannikov
61a859bf6f Use llvm::copy instead of append_range to work around MacOS build failure 2025-08-19 01:43:22 +03:00
Sergei Barannikov
0cd4ae9be0
Reland "[TableGen][DecoderEmitter] Store HW mode ID instead of name (NFC) (#154052)" (#154212)
This reverts commit 5612dc533a9222a0f5561b2ba7c897115f26673f.

Reland with MacOS build fixed.
2025-08-18 22:28:20 +00:00
Shubham Sandeep Rastogi
5612dc533a Revert "[TableGen][DecoderEmitter] Store HW mode ID instead of name (NFC) (#154052)"
This reverts commit b20bbd48e8b1966731a284b4208e048e060e97c2.

Reverted due to greendragon failures:

20:34:43  In file included from /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/llvm/utils/TableGen/DecoderEmitter.cpp:14:
20:34:43  In file included from /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/llvm/utils/TableGen/Common/CodeGenHwModes.h:14:
20:34:43  In file included from /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/llvm/include/llvm/ADT/DenseMap.h:20:
20:34:43  In file included from /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/llvm/include/llvm/ADT/STLExtras.h:21:
20:34:43  In file included from /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/llvm/include/llvm/ADT/Hashing.h:53:
20:34:43  In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/algorithm:1913:
20:34:43  In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/chrono:746:
20:34:43  In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/__chrono/convert_to_tm.h:19:
20:34:43  In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/__chrono/statically_widen.h:17:
20:34:43  In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/__format/concepts.h:17:
20:34:43  In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/__format/format_parse_context.h:15:
20:34:43  In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/string_view:1027:
20:34:43  In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/functional:515:
20:34:43  In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/__functional/boyer_moore_searcher.h:26:
20:34:43  /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/vector:1376:19: error: object of type 'llvm::const_set_bits_iterator_impl<llvm::SmallBitVector>' cannot be assigned because its copy assignment operator is implicitly deleted
20:34:43              __mid =  __first;
20:34:43                    ^
20:34:43  /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/llvm/utils/TableGen/DecoderEmitter.cpp:2404:13: note: in instantiation of function template specialization 'std::vector<unsigned int>::assign<llvm::const_set_bits_iterator_impl<llvm::SmallBitVector>, 0>' requested here
20:34:43    HwModeIDs.assign(BV.set_bits_begin(), BV.set_bits_end());
20:34:43              ^
20:34:43  /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/llvm/include/llvm/ADT/BitVector.h:35:21: note: copy assignment operator of 'const_set_bits_iterator_impl<llvm::SmallBitVector>' is implicitly deleted because field 'Parent' is of reference type 'const llvm::SmallBitVector &'
20:34:43    const BitVectorT &Parent;
20:34:43                      ^
20:34:43  1 warning and 1 error generated.
2025-08-18 14:36:54 -07:00
Sergei Barannikov
13dd65096b [TableGen][DecoderEmitter] Rename some variables for clarity (NFC) 2025-08-19 00:16:56 +03:00
Sergei Barannikov
b20bbd48e8
[TableGen][DecoderEmitter] Store HW mode ID instead of name (NFC) (#154052)
This simplifies code a bit.
2025-08-18 22:53:09 +03:00
LLVM GN Syncbot
d6e0922a5e [gn build] Port 3ecfc0330d93 2025-08-18 16:02:02 +00:00
LLVM GN Syncbot
f4b5c24022 [gn build] Port e6e874ce8f05 2025-08-18 14:52:19 +00:00
LLVM GN Syncbot
ad064bc5c3 [gn build] Port a0f325bd41c9 2025-08-18 14:52:18 +00:00
Sergei Barannikov
bad02e38c8
[TableGen][DecoderEmitter] Avoid using a sentinel value (#153986)
`NO_FIXED_SEGMENTS_SENTINEL` has a value that is actually a valid field
encoding and so it cannot be used as a sentinel.
Replace the sentinel with a new member variable, `VariableFC`, that
contains the value previously stored in `FilterChooserMap` with
`NO_FIXED_SEGMENTS_SENTINEL` key.
2025-08-18 08:25:17 +03:00
Sergei Barannikov
9ddc043538 [TableGen] Use structured binding in one more place (NFC) 2025-08-18 06:15:44 +03:00
Sergei Barannikov
6947fb4556 [TableGen] Use structured binding in one place (NFC) 2025-08-17 23:50:23 +03:00
Sergei Barannikov
a10773c864
[TableGen][DecoderEmitter] Remove EncodingIDAndOpcode struct (NFC) (#154028)
Most of the time we don't need instruction opcode. There is no need to
carry it around all the time, we can easily get it by other means.
Rename affected variables accordingly.

Part of an effort to simplify DecoderEmitter code.
2025-08-17 20:13:48 +00:00
Sergei Barannikov
ea4325f174
[TableGen][DecoderEmitter] Improve conflicts dump (#154001)
* Print filter stack in non-reversed order.
* Print encoding name to the right of encoding bits to deal with
alignment issues.
* Use the correct bit width when printing encoding bits.

Example of old output:
```
		01000100........
		01000...........
		0100............
		................
	tADDhirr 000000000000000001000100________
	tADDrSP 000000000000000001000100_1101___
	tADDspr 0000000000000000010001001____101
```

New output:
```
    ................
    0100............
    01000...........
    01000100........
    01000100________  tADDhirr
    01000100_1101___  tADDrSP
    010001001____101  tADDspr
```
2025-08-17 06:42:25 +00:00
Sergei Barannikov
05f1673e75 [TableGen] Make a function static (NFC)
Also, modernize the return value to std::optional.
2025-08-17 09:31:28 +03:00
Sergei Barannikov
05827e7ccb [TableGen][DecoderEmitter] Dump conflicts earlier
Dump a conflict as soon as we discover it, no need to wait until
we start building the decoder table.
This improves debugging experience.
2025-08-17 08:20:31 +03:00
Sergei Barannikov
fc6024d895
[TableGen][DecoderEmitter] Shrink lifetime of Filters vector (NFC) (#153998)
Only one element of the `Filters` vector (see `BestIndex`) is used
outside the method that fills it. Localize the vector to the method,
replacing the member variable with the only used element.

Part of an effort to simplify DecoderEmitter code.
2025-08-17 04:02:16 +00:00
Sergei Barannikov
7bb73455f7
[TableGen][DecoderEmitter] Add helpers for working with scopes (NFC) (#153979)
Part of an effort to simplify DecoderEmitter code.
2025-08-16 21:49:17 +00:00
Sergei Barannikov
3acb679bda [TableGen] Remove redundant variable (NFC) 2025-08-16 23:11:53 +03:00
Matt Arsenault
3e5d8a1439 Reapply "RuntimeLibcalls: Generate table of libcall name lengths (#153… (#153864)
This reverts commit 334e9bf2dd01fbbfe785624c0de477b725cde6f2.

Check if llvm-nm exists before building the benchmark.
2025-08-16 09:53:50 +09:00
gulfemsavrun
334e9bf2dd
Revert "RuntimeLibcalls: Generate table of libcall name lengths (#153… (#153864)
…210)"

This reverts commit 9a14b1d254a43dc0d4445c3ffa3d393bca007ba3.

Revert "RuntimeLibcalls: Return StringRef for libcall names (#153209)"

This reverts commit cb1228fbd535b8f9fe78505a15292b0ba23b17de.

Revert "TableGen: Emit statically generated hash table for runtime
libcalls (#150192)"

This reverts commit 769a9058c8d04fc920994f6a5bbb03c8a4fbcd05.

Reverted three changes because of a CMake error while building llvm-nm
as reported in the following PR:
https://github.com/llvm/llvm-project/pull/150192#issuecomment-3192223073
2025-08-15 13:32:27 -07:00
George Burgess IV
c10766cf49
[utils] add stop_at_sha to revert_checker's API (#152011)
This is useful for downstream consumers of this as a module. It's
unclear if interactive use wants this lever, but support can easily be
added if so.
2025-08-15 16:13:29 +00:00
Matt Arsenault
9a14b1d254
RuntimeLibcalls: Generate table of libcall name lengths (#153210)
Avoids strlen when constructing the returned StringRef. We were emitting
these in the libcall name lookup anyway, so split out the offsets for
general use.

Currently emitted as a separate table, not sure if it would be better
to change the string offset table to store pairs of offset and width
instead.
2025-08-15 23:29:10 +09:00
Stephen Tozer
bc216b057d
[Debugify] Improve reduction of debugify coverage build output (#150212)
In current DebugLoc coverage builds, the output for any reasonably large
build can become very large if any missing DebugLocs are present; this
happens because single errors in LLVM may result in many errors being
reported in the output report. The main cause of this is that the empty
locations attached to instructions may be propagated to other
instructions in later passes, which will each be reported as new errors.
This patch prevents this by adding an "unknown" annotation to
instructions after reporting them once, ensuring that any other
DebugLocs copied or derived from the original empty location will not be
marked as new errors.

As a separate but related change, this patch updates the report
generation script to deduplicate results using the recorded stacktrace
if they are available, instead of the pass+instruction combination. This
reduces the size of the reduction, but makes the reduction highly
reliable, as the stacktrace allows us to very precisely identify when
two bugs have originated from the same place.
2025-08-15 14:01:04 +01:00
Yanzuo Liu
3b27d50cc7
[LLVM][utils] Add script which clears release notes (#153593)
The script copies `ReleaseNotesTemplate.txt` to corresponding
`ReleaseNotes.rst`/`.md` to clear release notes.

The suffix of `ReleaseNotesTemplate.txt` must be `.txt`. If it is
`.rst`/`.md`, it will be treated as a documentation source file when
building documentation.
2025-08-15 19:00:08 +08:00
Sergei Barannikov
56681c94f3
[TableGen][DecoderEmitter] Compute bit attribute once (NFC) (#153530)
Pull the logic to compute bit attributes from `filterProcessor()` to its
caller to avoid recomputing them on the second call.
2025-08-15 13:28:38 +03:00
LLVM GN Syncbot
0226e94491 [gn build] Port 769a9058c8d0 2025-08-15 00:24:52 +00:00
Matt Arsenault
769a9058c8
TableGen: Emit statically generated hash table for runtime libcalls (#150192)
a96121089b9c94e08c6632f91f2dffc73c0ffa28 reverted a change
to use a binary search on the string name table because it
was too slow. This replaces it with a static string hash
table based on the known set of libcall names. Microbenchmarking
shows this is similarly fast to using DenseMap. It's possibly
slightly slower than using StringSet, though these aren't an
exact comparison. This also saves on the one time use construction
of the map, so it could be better in practice.

This search isn't simple set check, since it does find the
range of possible matches with the same name. There's also
an additional check for whether the current target supports
the name. The runtime constructed set doesn't require this,
since it only adds the symbols live for the target.

Followed algorithm from this post
http://0x80.pl/notesen/2023-04-30-lookup-in-strings.html

I'm also thinking the 2 special case global symbols should
just be added to RuntimeLibcalls. There are also other global
references emitted in the backend that aren't tracked; we probably
should just use this as a centralized database for all compiler
selected symbols.
2025-08-15 09:02:56 +09:00
LLVM GN Syncbot
47bc6acf86 [gn build] Port d56fa965243b 2025-08-14 22:56:30 +00:00
Shoreshen
04aebbfbe2
[AMDGPU] Delete AMDGPU Unify Metadata pass (#153548)
Fixes #153150
2025-08-14 16:16:32 +08:00
Matt Arsenault
bbcac029db
ARM: Move more aeabi libcall config into tablegen (#152109) 2025-08-14 15:43:15 +09:00
Sergei Barannikov
a73403ba8a [TableGen] Use empty() instead of size() == 0 (NFC) 2025-08-14 06:36:24 +03:00
Sergei Barannikov
6abb6264ea [TableGen] Declare loop induction variables in the loop header (NFC) 2025-08-14 05:48:16 +03:00