[RegAllocFast] Give an undef tied use the register of its tied def (#222249)
X86TargetLowering::emitSetJmpShadowStackFix zeroes a register by
building an XOR whose two uses are undef reads of its own def (per
MachineOperand.h "... reading the same dont-care value"). Def processing
frees a def whose tied use is undef before the uses are allocated, so
allocVirtRegUndef() no longer finds the virtual register and takes the
head of the allocation order instead. -verify-machineinstrs would fail:
```
renamable $rcx = XOR64rr undef renamable $rax(tied-def 0), undef renamable $rax, implicit-def dead $eflags
*** Bad machine code: Tied physical registers must match. ***
```
Take the register from the tie, and rewrite the instruction's other
reads of the value with it so that they keep agreeing on one register.
Aided by Opus 5
[lldb] Add SBCompileUnit::GetIDInModule (#222470)
Expose an ID that identifies a compile unit within its module so clients
can name a CU across API calls and look it up again with
SBModule::GetCompileUnitAtIndex. The user ID is not usable for this:
with a Darwin debug map every compile unit reports uid 0.
CompileUnit stores the index, set by SymbolFileCommon when a CU is
parsed or installed at a given slot.
[lldb-dap] Set stopped event text for signals and instrumentation (#222394)
DAP maps signals and instrumentation to reason 'exception'. Populate
'text' with the signal or runtime name to distinguish stop types. For
example, text contains the specific signal name (e.g., "SIGABRT") or
instrumentation runtime name (e.g., "AddressSanitizer").
[docs] Enable absolute self-documentation link checks
Configure the LLVM and Clang documentation URL prefixes so their Sphinx
builds reject new absolute links to documents in the same project.
Part of #214861
[docs] Check for absolute self-documentation links
Add an opt-in llvm_sphinx check that diagnoses absolute links to
documents in the current Sphinx project. Operate on the parsed doctree
so the check works for both reStructuredText and MyST without flagging
examples in literal blocks.
For example, restoring one absolute link in the LLVM documentation makes
a warnings-as-errors build report:
llvm/docs/ReleaseNotes.md:321: WARNING: absolute URL points to document
'index' in this Sphinx project; use an internal 'doc' or 'ref' role
instead: https://llvm.org/docs/ [llvm_sphinx.absolute-doc-link]
Part of #214861
[docs] Replace llvm.org/docs links with project links
Use Sphinx document and reference roles or project-relative links for
links within the LLVM documentation. This lets Sphinx validate the
targets and keeps local documentation builds and archived release
documentation self-contained.
Part of #214861
[docs] Replace clang.llvm.org/docs links with Sphinx links
Use Sphinx document and option roles or project-relative links for links
within the Clang documentation. Repair stale generated-document
fragments found while validating the replacements. This ensures that
standalone documentation builds are self-contained, although
cross-project links (Clang->LLVM) typically go via absolute llvm.org
hrefs.
Part of #214861
Assisted-by: Codex
[MemCpyOpt] Remove libcall availability checks for memory intrinsics (#198558)
Fixes #197683
- Delete the enable-memcpyopt-without-libcalls flag from MemCpyOptimizer
- Remove libcall availability checks in processStoreOfLoad() and
processStore()
- Remove the flag from CUDA/OpenMP toolchain in Clang
- Update no-libcalls.ll test to expect optimizations on all targets
cc @arsenm
Signed-off-by: addmisol <addmisol9 at gmail.com>
[SLP][modularisation][NFC] Move BaseShuffleAnalysis to SLPShuffleAnalysis.h (#222236)
Move the BoUpSLP-independent shuffle-analysis base class out of
SLPVectorizer.cpp into a new header-only
SLPVectorizer/SLPShuffleAnalysis.h. BoUpSLP::ShuffleCostEstimator and
BoUpSLP::ShuffleInstructionBuilder keep deriving from it.
createShuffle read the file-local SLPReVec cl::opt in an assert; the
option stays static in SLPVectorizer.cpp and the moved template takes
its value as an explicit bool parameter. Behavior is unchanged.
Part of the SLPVectorizer.cpp modularization effort:
https://discourse.llvm.org/t/modularizing-slpvectorizer-cpp/90922
Assisted by AI.
[lldb] Add SBCompileUnit::GetIsOptimized (#222403)
Expose Module::GetIsOptimized through the SB API so clients can tell
whether a compile unit was built with optimization. This change is
motivated by lldb-dap, where I want to extend the protocol::CompileUnit
with this information.
The new tests build the same source with and without -O1, so the test
case can no longer share a build with the others.
[SLP][modularisation][NFC] Move clusterSortPtrAccesses to SLPMemoryUtils (#222235)
Move the BoUpSLP-independent pointer-clustering sort out of
SLPVectorizer.cpp into SLPVectorizer/SLPMemoryUtils.{h,cpp}.
clusterSortPtrAccesses reads the file-local RecursionMaxDepth cl::opt
via getUnderlyingObject; the option stays static in SLPVectorizer.cpp
and the moved helper takes its value as an explicit unsigned parameter
(also captured by the local comparison lambda). Behavior is unchanged.
Part of the SLPVectorizer.cpp modularization effort:
https://discourse.llvm.org/t/modularizing-slpvectorizer-cpp/90922
Assisted by AI
[AMDGPU] Reject DPP combine when old is narrower than dst (#217894)
Old is copied from the mov dst class, but the combined dst can be wider
(e.g. V_CVT_F64_I32), making old illegal for it
[MISched] Apply debug filters before starting a block (#222270)
Apply the `misched-only-func` and `misched-only-block` filters before
calling `startBlock`. This avoids entering a target scheduling strategy
for a filtered block without a matching `finishBlock`/`leaveMBB` call.
Add a SystemZ post-RA scheduler regression that checks a filtered block
does not contribute hazard-recognizer state.
Split from #221984 in response to review.
[Flang][OpenMP] Add lowering and translation for the threadset clause (#215513)
Adds Flang lowering, and LLVM IR translation for the OpenMP 6.0 `threadset` clause (spec 14.8) on `task` and `taskloop`.
- Add a `ThreadsetPolicy` enum (`omp_pool`/`omp_team`) and clause on `omp.task` and `omp.taskloop.context`, lowered from Flang.
- Translate `threadset(omp_pool)` to the free-agent task flag (`0x80`); `omp_team` leaves it unset, matching clang.
- Add semantics, lowering, and translation tests.
Related: https://github.com/llvm/llvm-project/pull/135807,https://github.com/llvm/llvm-project/pull/144409,https://github.com/llvm/llvm-project/pull/169856
[RISCV] Fix infinite DAGCombine loop with SETCC and SIGN_EXTEND_INREG (#221593)
We generalized (X & -(1 << C1) & 0xffffffff) == C2 << C1 using `sraiw`.
The combine generates a `SIGN_EXTEND_INREG` when simplifying.
However, when C1 is 0 and the sign bit (bit 31) of X is already known to
be zero, `DAGCombiner` sees that `SIGN_EXTEND_INREG` is semantically
equivalent to `AND X, 0xFFFFFFFF` (zext). Because `DAGCombiner`
considers `AND` to be more canonical than `SIGN_EXTEND_INREG` in this
context, it immediately reverts the node back to `AND`.
This caused an infinite DAGCombine loop. This patch disables the folding
when the C1 is zero. That case is covered by a later combine that already
checks if bit 31 is known to be zero.
Fixes: https://github.com/llvm/llvm-project/issues/221521
(cherry picked from commit f9a8dec9496fea7c55f591a66a64dbcdc085fc2d)
[CodeGen] Skip pseudo instructions in AggressiveAntiDepBreaker (#222271)
`ScheduleDAGInstrs` does not create SUnits for debug or pseudo
instructions. The aggressive anti-dependency breaker only skipped debug
instructions, so encountering a pseudo such as `PSEUDO_PROBE`
dereferenced a null SUnit.
Skip both debug and pseudo instructions and add a Hexagon regression
covering the existing aggressive anti-dependency path with legacy and
new machine pass managers.
Split from #221984 in response to review.
[clang-tidy] Normalize windows line filter paths (#217038)
`git | clang-tidy-diff.py` emits line-filter paths with forward slashes,
while Windows compilation databases use a mix of forwards and backwards
slashes. These paths are then silently rejected (and no report is
emitted).
Reproduce on windows via:
```
git.exe diff -U0 main -- . | python clang-tidy-diff.py -p1 -path .\build"
```
Git will produce a path like:
```
my/source/file.cpp
```
The compilation database has files with entries like this:
```
[18 lines not shown]
[Clang] Avoid unnecessary overload resolution when building RecoveryExpr (#222296)
When overload resolution fails, we tried RecoveryCallExpr which
ended up performing duplicate overload resolutions, where the template
argument deduction can be expensive.
This patch removes those 'known' invalid overload candidates before
RecoveryCallExpr.
[CIR] Add offload container attribute (#206576)
Introduce `cir.offload.container`, a CIR dialect unit attribute that marks an
MLIR module as holding a host CIR module and its associated device CIR
modules in one IR unit while later offload merge/split pipeline passes need
visibility into both sides.
The marked module's body holds nested `builtin.module` operations. Each
nested module is tagged with `cir.offload.kind`, represented by the new
`#cir.offload_kind<host>` / `#cir.offload_kind<device>` enum attribute.
The structural contract expected by the follow-up pipeline work is
enforced in `CIRDialect::verifyOperationAttribute`, following the
`gpu.container_module` precedent:
* `cir.offload.container` is a unit attribute attached to a
`builtin.module`
* the first nested module is the host module
* all following nested modules are device modules
[10 lines not shown]
[Driver][OpenBSD] Use -no-pie instead of -nopie (#220464)
Downstream in OpenBSD there is a patch to add support for -nopie in lld
(which it has used by default since 2018). In this repo lld does not
support `-nopie`, so when building clang and lld, you cannot link an
executable with `clang -fno-pic`. Clang now uses the more widely used
spelling here so that toolchains built from this repo can cross compile
to OpenBSD successfully.
This change is an issue on OpenBSD if users passed a different linker
with `-fuse-ld` / `--ld-path` to `ld.bfd` which is still installed by
default but doesn't support the `-no-pie` spelling with their patches.
(cherry picked from commit a2171756dd5d690faf30bafe63810d1dc6cdb342)
[Driver][OpenBSD] Pass -pie for static PIE links (#216907)
OpenBSD uses `rcrt0.o` for static PIE executables. This startup object
references the linker-defined `_DYNAMIC` symbol.
OpenBSD's system linker defaults to PIE, which previously masked the
missing driver flag. An LLD cross-linker built on a non-OpenBSD host
does not share that default. Consequently,
`clang --target=...-openbsd -static` selects `rcrt0.o`, but LLD does not
create `_DYNAMIC`, causing the link to fail.
(cherry picked from commit 118efe7680bdc010ab984f8ae4505699f53bbca6)
[AMDGPU] Add missing attributes to llvm.amdgcn.init.whole.wave (#222493)
`llvm.amdgcn.init.whole.wave` only sets the EXEC mask and reports
whether the lane was active on entry. It never calls into the module,
never frees memory, and always returns, so it can carry `nocallback`,
`nofree`, and `willreturn`.
The neighboring `llvm.amdgcn.init.exec` and
`llvm.amdgcn.init.exec.from.input` already have all three; this brings
`init.whole.wave` in line and lets the attributor propagate them to
callers.
[GitHub] Bump CI Container Runner Version to 2.337.0 (#222480)
This is the latest version and keeps us ahead of the relatively short
runner support horizon.
[AMDGPU] Add missing attributes to llvm.amdgcn.init.whole.wave
`llvm.amdgcn.init.whole.wave` only sets the EXEC mask and reports whether
the lane was active on entry. It never calls into the module, never frees
memory, and always returns, so it can carry `nocallback`, `nofree`, and
`willreturn`.
The neighboring `llvm.amdgcn.init.exec` and
`llvm.amdgcn.init.exec.from.input` already have all three; this brings
`init.whole.wave` in line and lets the attributor propagate them to
callers.
[NFC][AMDGPU] Remove unused MC insts in isPackedSingleSGPR64BitInst (#222463)
There is no opsel support for these instructions, and thus we do not have
to manipulate opsel at MC layer. As a result, isPackedSingleSGPR64BitIns
is currently only used before pseudo-expansion. So we remove MC instruction
check inside.