[orc-rt] Add Windows virtual memory support (#224521)
Adds Windows virtual-memory support for ORC-RT
Also adds a small Windows error helper that converts GetLastError()
results into ORC-RT Error values with the corresponding system message.
Turns back on all the memory tests for windows.
[RISC-V][MC] Update ELF streamer ArchString when emitting RISCVAttrs::ARCH
During LTO, the TargetMachine subtarget is initialized with the linker's
default CPU (e.g. `generic-rv64`, `rv64i2p1`), while
RISCVAsmPrinter::emitStartOfAsmFile() reconstructs the module's actual ISA from
the `riscv-isa` module flag and emits RISCVAttrs::ARCH via
RISCVTargetELFStreamer::emitTextAttribute(). Previously only
RISCVAsmParser::parseDirectiveAttribute() called setArchString() after
emitTextAttribute(RISCVAttrs::ARCH, ...), so direct object emission bypassed
the update and tagged `.text` with `$xrv64i2p1` instead of the module's
full architecture string.
Move the setArchString() call into RISCVTargetELFStreamer::emitTextAttribute()
when emitting RISCVAttrs::ARCH so both `.attribute arch` and
RISCVTargetStreamer::emitTargetAttributes() update the active mapping symbol
ISA.
This commit was created with the help of AI tools
[libc] Move Linux TLS routines from crt1.o into libc.a (#225418)
init_tls, cleanup_tls, and set_thread_ptr are per-thread routines used
by both Thread::run in libc.a and main-thread startup in crt1.o, but
tls.cpp was previously only merged into crt1.o. Linking libc.a without
crt1.o (such as a self-contained shared library statically linking
libc.a, or an executable built with -nostartfiles) failed with undefined
hidden symbols when thread.cpp.o was pulled in.
Move {x86_64,aarch64,riscv}/tls.cpp from libc/startup/linux/ to
libc/src/__support/threads/linux/ alongside tcb.h (matching prior
migrations of auxv and program_invocation_name from startup into src so
dependencies flow from startup -> src). Expose them via a forwarding
ALIAS target libc.src.__support.threads.linux.tls depended on by both
thread and do_start, and remove tls from merge_relocatable_object(crt1).
Mark init_tls with [[gnu::flatten]] and compile tls with
${libc_opt_high_flag}. Once tls.cpp.o is in libc.a rather than first on
the link line inside crt1.o, an earlier object compiled with
[9 lines not shown]
[libc++] Extract building libc++ into a composite action (#224670)
This allows reusing the same build script for the PR benchmark and
the historical benchmarking jobs. This also opens the door to adding
new configurations where the library isn't rebuilt (e.g. where the
artifacts are pulled from a pre-built location, or even testing against
non-libc++.
Assisted by Claude
[clang-tidy] Fix crash in readability-identifier-naming (#220221)
This PR contains the fix for the `readability-identifier-naming` crash.
The crash happens because the checker calls `hasMemberName` on a base
class without checking if that base class actually has a definition
first (like when it's just forward-declared). I added a
`RD->hasDefinition()` guard to fix it.
Fixes #213948
[lld-macho] Print Objective-C stubs in map files (#225302)
Match ld-prime by listing synthesized Objective-C message-send stubs in
Mach-O map files, including their final addresses and mode-specific sizes.
[LICM] Relax Hoistable Branch if all of the incoming node are hoistable
Like PhiNode, a branch is possibly hoistable if all of the parents are
possible to hoist. The only difference is that we cannot hoisting to
PreHeader as it might erase itself in getOrCreateHoistedBlock. This is
why we have IsReplicatedBy check in hasExactlyReplicatedControlFlow.
In phi, it is not a matter as we only change the incoming node from a
phi node without overwrite its dominator.
Also, we fix a bug while we have nested hoisted node. In that case, we
have to find the LCA of the dominators of all users.
[orc-rt] Add gmock matchers for Error and Expected<T> (#225596)
Ports llvm/Testing/Support/Error.h to orc_rt: EXPECT_THAT_ERROR and
ASSERT_THAT_ERROR, EXPECT_THAT_EXPECTED and ASSERT_THAT_EXPECTED, and
the Succeeded, Failed, Failed<InfoT>, FailedWithMessage and HasValue
matchers.
Two departures from the original. An orc_rt Error carries at most one
ErrorInfoBase -- there is no joinErrors -- so the holder keeps a single
error, FailedWithMessage takes one matcher rather than a variadic pack,
and FailedWithMessageArray is dropped. ErrorInfoBase has
dynamicRTTIName, so a type mismatch names the type that did turn up
rather than reporting only that the expected one was absent.
Header-only, under test/unit with the other test helpers rather than in
a shipped testing library. ErrorMatchersTest exercises each matcher
against a matching and a non-matching value, the latter through gtest's
failure interception.
[WebKit Checkers] Add alpha.webkit.UnborrowedLocalVarsChecker (#225274)
This is a new checker that requires a Borrow<T> when using a
pointer/reference/view that is lifetimebound to a CanBorrow type.
A CanBorrow type is a type that tracks views into its interior at
runtime, and calls crashIfBorrowed() when it invalidates such views.
Vector is the motivating example.
A design description is available at:
https://github.com/WebKit/WebKit/wiki/SaferCPP:-Borrowed-Pointer-Use-After-Destruction
I implemented UnborrowedLocalVarsChecker in terms of the existing
alpha.webkit.*LocalVarsChecker system because the requirement to hold an
overlooking smart-pointer-like-thing is pretty similar.
In some cases where the new checker is stricter than the existing
checker, this patch conditionalizes the strictness. The plan is to
upgrade existing checkers in a follow-up patch.
Assisted-by: Claude
[orc-rt] Reconcile check-rt-process-info changes. (#225592)
3648582c0a41 was supposed to make this test more generic, but
accidentally removed it instead.
Reconcile the dropped changes with 3648582c0a41, which added page-size
checking.
[RISCV] Expand scalar FP undef/poison to 0.0 with F extension. (#225567)
This ensures the undef/poison value is always nan-boxed. This is
important if the value ends up being used by a freeze. If the value
isn't properly nan-boxed, it will be treated as a nan in FP contexts
regardless of its lower bits. If the freeze is also cast to an integer,
the lack of nan-boxing will be noticed and the integer will see the real
value of the lower bits.
Fixes #225455.
[orc-rt] Add Windows page size detection (#224520)
Adds Windows page size detection for ORC-RT using GetSystemInfo.
Also updates the process-info regression coverage into a single test
[LLVM][AutoUpgrade] Support default args on overloaded intrinsics (#217859)
This patch extends intrinsic `DefaultValue` auto-upgrade to overloaded
intrinsics.
---------
Signed-off-by: DharuniRAcharya <dharunira at nvidia.com>
[AMDGPU] Port Atomic-Optimizer to use Wave Reduction Intrinsics (#211757)
Currently the atomic optimizer creates reductions via intrinsics,
and introduces new control flows.
Replace this sub-target dependent logic with the existing
wave reduction intrinsics, which get lowered in the backend.
This patch ports the uniform-value and divergent-no-return-value cases.
To port the divergent-with-return-value cases, additional scan intrinsics
will need to be added.
[lld] Add -z mark-plt support for X86_64 (#206002)
Add option [no]mark-plt to enable it. Dynamic linker can change PLT
entries with JMPABS instruction on supported targets.
Ref.:
https://maskray.me/blog/2021-09-19-all-about-procedure-linkage-table#x86-plt-rewriting
Assisted-by: Claude Sonnet 4.6
---------
Co-authored-by: Claude Opus 4.8 <noreply at anthropic.com>
[libc++] Build GoogleBenchmark directly from Lit (#224192)
Previously, we would build GoogleBenchmark against the just-built
library, not against the library being tested. When testing historical
versions of libc++ or other standard libraries, this breaks. So instead
of building Google Benchmark against the just-built library in CMake, do
it from Lit as part of the test suite's configuration.
I'm not a huge fan of using Lit as a poor man's build system and we
should make the CMake test suite self-contained, however this is a step
in the right direction and it removes a major coupling between the test
suite and the regular libc++ build.
[libc++] Pin down the OS version of macOS runners (#225536)
Otherwise, we sometimes end up using runners that don't have Xcode 26.5
on them. Pinning this allows bumping the version explicitly when we are
ready to.
[LV] Narrow truncated inductions in a VPlan transform (#220730)
VPRecipeBuilder::tryToOptimizeInductionTruncate matched a truncate of an
induction phi on the underlying IR, and it built the narrowed
VPWidenIntOrFpInductionRecipe from the recipe behind the truncate's
operand.
VPlanTransforms already answers the same question on VPValues in
getOptimizableIVOf, which returns the header IV whether the operand is
the IV
itself or an add of the IV and its step.
Add VPlanTransforms::narrowInductionTruncates and do the match there,
reusing
getOptimizableIVOf and restricting it to the phi for now. The pass runs
right
after makeCallWideningDecisions, which preserves the ordering against
makeScalarizationDecisions that the recipe builder relied on. Building
the
recipe in the transform also removes the need for the conversion loop to
[3 lines not shown]
[PGO] Add GPU wave counters
Lane counts do not show how often a GPU wave reaches an instrumentation
point. A divergent wave can execute both paths even when few lanes take
one path.
Extend the GPU profiling helper to collect a wave count alongside each
existing lane counter. The first active lane increments the wave counter
once, using the same workgroup sampling decision as the lane counters.
Collect both channels together so shared functions use a consistent
counter layout across translation units. Workgroup sampling controls
profiling overhead.
Carry wave counts through raw and indexed profiles and weighted merging
as a separate channel. Preserve ordinary lane-flow counts and leave
blocks without instrumentation unmeasured.
[libc] Implement dual freestore rotation for baremetal heap (#209811)
Implement dual FreeStore rotation in FreeListHeap under
LIBC_COPT_BAREMETAL_HEAP_ENABLE_FREESTORE_ROTATION option for baremetal
targets.
- Allocations pull from active store; free() quarantines blocks into
non-active store (1 - active).
- On allocation failure in active store, rotate() flips active index and
migrates/coalesces quarantined blocks into the new active store.
- Added 2-bit prev_free tracking in BlockRef metadata to distinguish
freestore indices.
- Added unit smoke tests and updated fuzzer for dual freestore rotation.
Assisted-by: Gemini and Claude based automation tool (human-in-the-loop)
---------
Co-authored-by: Yifan Zhu <yfzhu at google.com>
Co-authored-by: Claude Fable 5.1 <noreply at anthropic.com>
[lldb] Consistently use "null-terminated" across LLDB (NFC) (#224801)
It appears that both spellings are correct, but "null terminator" is far
more common, while "NUL terminator" is technically precise regarding the
ASCII character name. Most common in LLDB was "NULL terminated" which is
the worst of both worlds. This rallies around "null-terminated".
- Adjective -> null-terminated
- Verb -> null-terminate
- Nouns left unhyphenated but lowercased: null terminator, null
termination
[SLP]Fix crash in bool bitmask reduction match after tree vectorization
The known bits of the narrowed reduction leaves were computed after the
tree vectorization, which drops the operands of the vectorized scalars,
so the analysis dereferenced null operands. Match the bitmask form before
the vectorization and pass the result to the emission.
Fixes #225538
Reviewers:
Pull Request: https://github.com/llvm/llvm-project/pull/225568