[mlir] Make the Python binding type casters well-formed under C++23 (#208093)
The nanobind type/attr/loc/value casters in IRCore.h return a by-value
PyType/PyAttribute/PyLocation/PyValue as their DerivedTy result.
Under pre-C++23 rules, this was a rvalue that would decay to a lvalue
when passed to the DerivedTy constructor.
Under C++23's P2266 (implicit move on return), that return operand is an
xvalue, which cannot bind the PyConcrete* constructors that take a
non-const lvalue reference.
This patch constructs the derived type explicitly (return
DerivedTy(arg);) using the lvalue constructor; this preserves the
pre-C++23 behavior on C++23 builds.
[SandboxVec][Scheduler][NFC] Cleanup: Use interval in loop and reset sched state (#205465)
Replace the for loop that iterates between TopI and LowestI with a range
loop over ResetIntvl and move the reset of the scheduling state to this
loop.
We iterate over the loop in the reverse order than before but the
functionality should not change.
[SBVec] Implement topDown/botUp vectorizers in unison
This patch introduces the `top-down-vec` pass to the Sandbox Vectorizer,
adding the ability to traverse use-def chains top-down to discover and
collect vectorization opportunities. Furthermore, this patch unifies
the two vectorizers into a single implementation to minimize code
duplication.
* vectorize in the same direction as the scheduler direction
* use AuxArg to determine vectorizer direction
* move user collection to VecUtils and add unit tests
* handle legality results
* introduce getNextBundles to loop ovop over getNextBundle calls for each user
* introduce BundleTy and GetOpIdxVec
[RISCV][MCA] Avoid deriving EMUL without SEW (#207986)
When only an LMUL instrument is active, SEW is unavailable. Avoid
deriving EMUL for vector memory instructions in that case and fall back
to the base scheduling class.
Closes #170118.
[clang-repl] Avoid use `$LD_LIBRARY_PATH` in lit tests (#208170)
Strengthen clang-repl lit tests by Avoid use `$LD_LIBRARY_PATH`. The
lit's internal shell does not expand shell variables such as
`$LD_LIBRARY_PATH`, so provide the current value as a lit substitution.
This PR can fix the following failures when user build llvm with
non-system C++ standard library.
```
# executed command: env 'LD_LIBRARY_PATH=<build dir>/tools/clang/test/Interpreter/Output/cxx20-modules.cppm.tmp:$LD_LIBRARY_PATH' <build dir>/bin/clang-repl -Xcc=-std=c++20 -Xcc=-fmodule-file=M=<build dir>/tools/clang/test/Interpreter/Output/cxx20-modules.cppm.tmp/mod.pcm -Xcc=--target=x86_64-linux-gnu
# .---command stderr------------
# | <build dir>/bin/clang-repl: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by <build dir>/bin/clang-repl)
# | <build dir>/bin/clang-repl: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by <build dir>/bin/clang-repl)
# | <build dir>/bin/clang-repl: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by <build dir>/bin/clang-repl)
# | <build dir>/bin/clang-repl: /lib64/libstdc++.so.6: version `CXXABI_1.3.13' not found (required by <build dir>/bin/clang-repl)
# `-----------------------------
```
Signed-off-by: yronglin <yronglin777 at gmail.com>
[SBVec] Implement topDown/botUp vectorizers in unison
This patch introduces the `top-down-vec` pass to the Sandbox Vectorizer,
adding the ability to traverse use-def chains top-down to discover and
collect vectorization opportunities. Furthermore, this patch unifies
the two vectorizers into a single implementation to minimize code
duplication.
* vectorize in the same direction as the scheduler direction
* use AuxArg to determine vectorizer direction
* move user collection to VecUtils and add unit tests
* handle legality results
* introduce getNextBundles to loop ovop over getNextBundle calls for each user
* introduce BundleTy and GetOpIdxVec
[SampleProfile] Introduce SampleProfileNameSet (NFC) (#208114)
This patch introduces a helper class SampleProfileNameSet to
encapsulate the construction of the name set and provide a contains
method.
I'm planning to speed up the membership queries into the name table.
With this patch, changes to the underlying data structure won't affect
use sites.
Assisted-by: Antigravity
[ProfileData] Support format version 104 for extensible binary sample profiles (#206297)
This patch adds initial support for format version 104 in extensible
binary sample profiles to support the upcoming on-disk hash table.
This patch sets up the versioning scheme in the reader and writer as a
preparation step without actually introducing the on-disk hash table.
The reader is updated to support format version 104. The writer can
now write format version 104 profiles when requested via
-sample-profile-format-version, but continues to default to version
103 as version 104 is a work in progress. We plan to promote the
default version to 104 once the on-disk hash table support is fully
integrated in a subsequent patch.
RFC:
https://discourse.llvm.org/t/rfc-faster-sample-profile-loading/90957/4
Assisted-by: Antigravity
Give each mlir::Block a stable ID within its parent region (#207617)
Assign each mlir::Block a stable ID within its parent region, mirroring
llvm::BasicBlock/llvm::Function (called ID, not number, since a block/op
number denotes position in MLIR): Block gains getBlockID() and reads -1u
while it has no parent region; Region gains nextBlockID with
getMaxBlockID() and getBlockIDEpoch(); the block ilist traits assign the
ID on add/transfer and invalidate it on removal; and
GraphTraits<mlir::Block*>/<mlir::Region*> expose
getNumber/getMaxNumber/getNumberEpoch. This makes
GraphHasNodeNumbers<mlir::Block*> true, moving MLIR's CFGLoopInfo and
dominator tree onto the number-indexed path. MLIR never renumbers
blocks,
so the epoch is a fixed 0.
Prerequisite for requiring GraphHasNodeNumbers in llvm::LoopInfoBase and
dropping its DenseMap fallback.
Aided by Claude Opus 4.8
[RISCV] Fix RISCVFoldMemOffset to report when it makes changes (#208149)
runOnMachineFunction initialized MadeChange to false and returned it,
but never set it to true even though the fold path rewrites memory
offsets, replaces registers, and erases the ADDI. As a result the pass
always reported that it made no changes, so the pass manager could keep
stale analyses valid after the function had actually been modified.
Set MadeChange to true after folding an ADDI.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply at anthropic.com>
[IRBuilder] Add FMFSource overloads for CreateCall (#208171)
CreateCall had no way to set fast-math-flags at creation time, so
callers had to build the call and copy the flags in a second step:
CallInst *C = B.CreateCall(Fn, Args);
C->copyFastMathFlags(Src);
Add FMFSource overloads (mirroring CreateIntrinsic) so the flags can be
copied from a source instruction or FastMathFlags in one call:
CallInst *C = B.CreateCall(Fn, Args, /*FMFSource=*/Src);
The FMFSource parameter has no default, so existing CreateCall callers
are unaffected and overload resolution stays unambiguous.
Assisted-by: Opus 4.8
[ObjCARC] Improve empty autorelease pool elimination in OptimizeAutoreleasePools (#200310)
Verify push/pop pairing before popping the stack, clear the pool stack
on mismatch, and erase the push before the pop for consistency.