[pull] main from llvm:main - #1714
Merged
Merged
Conversation
…allel for_each (#213487) This PR implements a parallel version of `std::reverse()` based on the parallel `__for_each()`. The implementation walks the first half of the range in chunks, each chunk is swapped with its mirrored counterpart via `std::swap_ranges()` and `std::reverse_iterator<>`: ```c++ // Perform a chunked for_each on the first half of the range. return __cpu_traits<_Backend>::__for_each( first, first + (last - first) / 2, [first, last](ForwardIterator i, ForwardIterator j) { // Derive the last position of the mirrored range. ForwardIterator mirror_last = last - (i - first); // Swap the elements in the range of the first half with their mirrored counterparts in the second half. std::swap_ranges(i, j, std::reverse_iterator<ForwardIterator>(mirror_last)); }); ``` Included tests check that: - Semantics of the function is correct. - The function correctly SFINAE out when the first argument is not an execution policy. - The `noexcept` policy is followed. - `static_assert` verifies iterators' categories. Part of #99938.
…d on std::adjacent_find() (#213445) This PR adds implementation of a parallel `std::is_sorted_until()` based on the parallel `std::adjacent_find()` and rebases the parallel `std::is_sorted()` onto `std::is_sorted_until()`. The implementation is effectively a one-liner: ```c++ // Find the first pair of adjacent elements that are not in sorted order, // i.e. comp(rhs, lhs) is true. auto res = AdjacentFind()(policy, std::move(first), last, [&](Ref lhs, Ref rhs) { return comp(rhs, lhs); }); ``` Included tests check that: - Semantics of the iterator-only version is correct. - Semantics of the predicated version is correct. - The functions correctly SFINAE out when the first argument is not an execution policy. - The `noexcept` policy is followed. - The `nodiscard` policy is followed. - `static_assert` verifies iterators' categories. Part of #99938.
…213774) Perform some initial validation that the feature set of generic targets is consistent with the set of covered targets. For now, this only performs this validation for the subset of frontend exported features, so is limited to catching missed builtin support. In the future arbitrary features should be validated, but this is complicated by workaround features and size features which need to clamp to the common minimum. Co-authored-by: Claude (Claude-Opus-4.8)
…#213657) This removes the dependency on the host C library (hermetic tests), makes sure the tests actually do something in release builds (where assert() is a noop), and makes better and more consistent failure messages. This is just a thin wrapper over the existing framework which repackages the C++ interface into something consumable by C code. I tried to keep the interface consistent, but of course, many of the framework features are C++ only. Registering more than one test function was tricky, so the framework currently supports only one. The main trick here was getting the static library linker to extract LibcCTest.cpp.o from libLibcTest.unit.a. Since C test cases don't instantiate static CTest objects in their own translation unit like C++ tests do (they cannot do that portably), nothing in the object file referenced LibcCTest.cpp. I made this work by introducing libc_c_test_anchor() and calling it explicitly inside the generated libc_c_test_run() function.
…213682) I went through the TODOs in if_nameindex_test.cpp: - string::operator+=(string_view) was already present in string.h (added in #210895), so I removed the append_bytes helper and switched to operator+= directly. - I added value_or (const & and && overloads) to cpp::optional and added a test suite for it in optional_test.cpp. - I replaced pop_front_or with pop_front returning optional<T> and inlined the .value_or(...) calls in the fake network policy. - Updated the CMake dependencies to account for the new optional usage. Assisted by Gemini.
Previously this bitset was only used to populate the feature name string map used by clang. Eventually this will replace the current bitmask integer. AArch64 already has a similar interface. Co-authored-by: Claude (Claude-Opus-4.8)
Co-authored-by: Andrew Ng <andrew.ng@sony.com>
…212448) These GNU extensions hold the name of the program as invoked (argv[0]) and its short name (the basename after the last slash). Both variables are initialized in the startup code. As with all of our other variables, they are only available in full build mode. The trickiest part of this patch are the error reporting functions from <err.h>, which access this variable, and they are currently enabled in overlay mode. To make them work, I add an #ifdef to select the right version. I considered doing something more elaborate, like we have with `errno`, but that seemed too heavy for a single occurrence. I also drop the linux check in this function. The documentation says the functions should print the "last component of the program name", which "llvmlibc" is not. If someone wants to enable these functions on non-linux, they can figure out what they want to print here and how. Assisted by Gemini.
…es (#201821) A function whose entire name is a strippable suffix canonicalizes to an empty name, making InstrProfSymtab::create return an error The current solution with `(void)(bool)` does not really suppress the error which leads to the crash
Lets plugins loaded with --load-dialect-plugin / --load-pass-plugin resolve MLIR and LLVM symbols against fir-opt, as mlir-opt already does. --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Every function in `ObjectFileMachO` and `ObjectContainerMachOFileset` that iterates over load commands advances the file offset by `lc.cmdsize` after reading each command. A malformed command with cmdsize smaller than `sizeof(load_command)` (in particular cmdsize = 0) does not make forward progress, so the loop spins for ncmds iterations. With `ncmds` close to `INT_MAX` the function never returns in practice. Factor the read-and-validate step into a static template helper `ReadMachOCommand<T>` in each plugin's translation unit. It reads the 8-byte cmd/cmdsize header and returns false on EOF or on a cmdsize that is too small to make forward progress. All load-command loops now use this helper, replacing the previously duplicated GetU32 + cmdsize check. `T` may be `llvm::MachO::load_command` or any of its richer variants (uuid_command, dylib_command, thread_command, ident_command, encryption_info_command, ...). The helper only touches the leading cmd/cmdsize fields, leaving the rest of `T` for the caller to fill in. Affected loops in `ObjectFileMachO`: IsStripped, GetEncryptedFileRanges, CreateSections, ParseSymtab, GetUUID (static), GetAllArchSpecs (two loops), GetDependentModules, GetEntryPointAddress, GetNumThreadContexts, FindLC_NOTEByName, GetIdentifierString, GetVersion, FindMinimumVersionInfo And in ObjectContainerMachOFileset: ParseFileset Add unit tests (`ObjectFileMachOTest::ZeroCmdSize` and `ObjectContainerMachOFilesetTest::ZeroCmdSize`) that feed a 40-byte Mach-O with `ncmds = 0x7FFFFFFF` and `cmdsize = 0` into the relevant parsers. Without the fix the tests spin ~2 billion iterations; with the fix they return immediately. Found by lldb-target-fuzzer. Assisted-by: Claude
…211621) Part of #211620. This is the first of two stacked changes implementing OpenMP `allocate` clause lowering for fixed-size intrinsic scalar `private` and `firstprivate` items on host `omp.parallel`. It carries each allocate item’s private-storage mapping through the OpenMP dialect, allocates with the requested allocator (using the runtime default for an omitted or null handle), and releases the storage during region finalization. The `align` modifier is handled by the stacked follow-up. Assisted-by: Copilot
… workflow (#213871) From time to time we'll fail to fetch the test merge commit during the checkout step, e.g. see https://github.com/llvm/llvm-project/actions/runs/30626469894/job/91931527829 After a bit of research apparently the test merge commit is actually stored on the base repository, not the fork. I think this just happened to work previously because the fork repository synced objects in the background, but it's not always guaranteed to be available. So switch the checkout step to use llvm/llvm-project as the remote.
Here we have: artifact combiner creating one element unmerge and unmerge lowering of FP source using FP type for bit twiddling.
Bug in LegalizationArtifactCombiner when: DstSize < UnmergeSrcSize case can create unmerge with one element. DstSize > UnmergeSrcSize case can end up attempting to create merge with one source element and hits assert(TmpVec.size() > 1).
Bitcast to integer and use integer type for bit twiddling.
…205525) Split SME load/store intrinsic definitions so loads and stores model ArgMem, ZA, and ZT0 effects separately. Also mark ZA enable/disable as side-effecting intrinsics with no memory access.
…212198) In this PR I've added support for the vplan fold: urem(X, Y) -> and(X, Y - 1) when Y is a power of 2. This should reduce the cost of the urem and ensure the vplan is accurately costed. Such a change would normally affect over 300 test files due to this being a common pattern in the vector preheader. For now, I've limited the scope to only simplifying occurences that are not in the vector preheader. In a follow-on PR I will extend this to add support for sub(X, urem(X, Y)) -> and(X, -Y) as well permitting folds in the preheader.
InstCombine converts vXi1 logic reductions to bitcasted scalar integer ops - we should be testing that, not llvm.vector.reduce.*.vXi1 calls We were also failing to tag the i1 return values as zeroext Shows a couple of hidden issues - poor handling of comparison results from sub-128-bit vectors and handling of v32i1/v64i1 MOVMSK patterns on pre-AVX2 targets
…eadsInfo (#212706) Add `ReadFrameZeroStackMemory`, which expedites the innermost frame's stack memory so a variables view on a stop is served from lldb's memory cache. When frame 0's `$fp` looks usable, two windows are expedited: * `[$fp + 2*ptr_size, $fp + 2*ptr_size + k_expedite_stack_arg_size)` for stack-passed parameters, starting above the saved `{fp, lr}` pair the backchain already covers. * `[$fp - below, $fp)`, `below = min($fp - $sp, k_expedite_stack_window - k_expedite_stack_arg_size)`, for locals and spilled register arguments. A small frame gets all of `[$sp, $fp)`; a large one keeps the part nearest `$fp`, so the cost stays bounded. If `$fp` fails validation (frameless leaf, or `$fp` used as a scratch GPR), a single `[$sp, $sp + k_expedite_stack_window)` window is expedited instead. Each window is a separate chunk, because lldb's L1 cache only serves reads fully contained in one expedited chunk. Only the thread that stopped gets these windows, so the stop reply does not grow with thread count. `GetJSONThreadsInfo` now builds the `"memory"` array from both sources and emits it whenever either produced an entry. Add `JSONGenerator::Array::empty` for that check.
A shuffle mask that interleaves zeros between every other byte element
is equivalent to a vector shift left on a wider element type. This
avoids generating a `tbl` instruction with a constant mask loaded from
memory, replacing it with a single `shl` instruction.
Before:
```asm
adrp x8, .LCPI0_0
ldr q1, [x8, :lo12:.LCPI0_0]
tbl v0.16b, { v0.16b }, v1.16b
```
After:
```asm
shl v0.8h, v0.8h, #8
```
Both `<16 x i8>` and `<8 x i8>` vectors are handled. The canonicalized
form where zeros appear in either the first or second shuffle operand is
also handled.
Fixes #107287
…me flags" (#213342) The current user-manual is missing implemented options that are useful for machine-readable output, such as `-fdiagnostics-format=sarif` and `-fdiagnostics-absolute-paths`.
The checker `security.ArrayBound` contains general-purpose logic that will be useful to bring other bounds checking checkers out of `alpha` stage. This change refactors the implementation of `security.ArrayBound` to separate the general-purpose logic and the concrete details that are only relevant in that particular checkers. Shortly after merging this, a follow-up commit will move the general-purpose code to separate files. (This is left out of this change to ensure continuity in the git history: this commit renames and reorganizes functions, the next one will move them with minimal changes.) Note that after this commit the `ProgramState` associated with the error nodes created by `security.ArrayBound` will be slightly different in some cases (they may have different constraints) but the state of a sink node is practically unused, so this does not cause any functional changes.
Closes #211620. Stacked on #211621. This adds `align` modifier lowering to the host `omp.parallel` path introduced by the parent change. It carries and verifies per-item alignment metadata and uses aligned runtime allocation when alignment is specified, while retaining the unaligned path otherwise. Other clause-bearing constructs and unsupported data types remain out of scope. Assisted-by: Copilot
…ate (#213640) Variable templates are a bit nicer to read and improve compile times a bit.
Also adds the place holders for other OS's as well as the structure for cross platform code going forward. Prefer sys calls as we can't be sure what runtime we may end up linking with Some features can be controlled via the kernel so this makes it easier than relying on __cpuid for now. The triples are now more accurate and include the os version on darwin. All results are a string that are passed in the default map with the key are llvm subtarget features valid strings orc-rt.Executor.SubtargetFeatures Adds a new process regression test as well, with a best effort guess that the triple returned is correct.
PointerReplacer mutates PHI types when replacing an alloca with a pointer in another address space. Mutating a value type in place can invalidate existing users whose result types or operand constraints were formed from the original pointer type. For example: ``` %p = phi ptr addrspace(5) [ %a, %bb0 ], [ %b, %bb1 ] %g = getelementptr i8, ptr addrspace(5) %p, i64 1 ``` Changing `%p` to `ptr addrspace(4)` leaves the existing GEP result in `AS5` while its pointer operand is now in `AS4`. (This is what exposed the bug). This triggered: https://github.com/llvm/llvm-project/blob/0bcff14b1740cf32f9e0983726238dcf353c6ac8/llvm/lib/IR/Operator.cpp#L129-L131 Create a new PHI when the replacement changes type so existing users remain attached to the original well-typed graph while PointerReplacer builds their replacements. Preserve in-place operand updates when the PHI type is unchanged. Assisted-by: Codex --------- Signed-off-by: Keshav Vinayak Jha <keshavvinayakjha@gmail.com>
InstCombine converts the high-half addition of vector comparison masks into an OR. Recognise the resulting trunc(or(setcc, setcc)) DAG and reconstruct the canonical ADDHN pattern for the supported NEON types.
…ToStaticExpandShape) (#207241) Fixes encoding drop in `tensor.*` canonicalizers. Patterns that only refine a tensor's shape (never merge/combine data) now propagate the encoding: `ConvertToStaticExpandShape`, `PadOp::inferResultType` (and its callers `FoldSourceTensorCast`, `FoldStaticPadding`). An encoding implementing `VerifiableTensorEncoding` is re-verified against the refined shape and dropped if invalid (e.g. sparse); an opaque encoding (no interface) is propagated as-is. Patterns that merge/combine tensors (`ConcatOp::inferResultType`, `InferConcatOperandTypes`, `CollapseShapeOp::inferCollapsedType`) keep the existing drop-encoding behavior - there's no static way to verify an arbitrary encoding survives a merge or rank change when dynamic dims are involved. Documents this contract on `VerifiableTensorEncoding` in `TensorEncoding.td`. co-authored Claude Opus 4.7 Signed-off-by: Dmitrii Makarenko <dmitrii.makarenko@intel.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )