[SPIRV][Matrix] Change Matrix Shader legalization to largest common divisor (#207768)
fixes #186864
New process for matrix legalization documented here:
https://github.com/llvm/wg-hlsl/pull/446
The current Matrix legalization strategy is to take a vector of and
expanded to a larger power of 2 vector and then split it into vectors of
size 4. For example a vector of size 6 is expanded to 8, and then split.
This creates uniform 4-lane chunks but requires padding. For example
`<12>`-->`<16>`, `<6>`-->`<8>`, `<9>`-->`<16>`. These forces an illegal
wide `G_BUILD_VECTOR` with undef lanes. This padding wastes lanes and
adds undef bookkeeping the backend must then clean up.
Instead This PR splits both operands into `W`-lane chunks, where `W` is
the largest divisor of the element count in `[2, MaxVectorSize]` shared
by source and destination (`<12>`-->3×`<4>`, `<6>`-->2×`<3>`,
[4 lines not shown]
[libc++] Pin down the compiler in the various benchmark scripts and jobs (#211563)
We have various scripts that build and test the library at pinpointed
commits: benchmark-historical, run-benchmarks, build-at-commit and
test-at-commit. They were handling the compiler in different ways: some
scripts would just run the libc++ build (or test suite configuration)
without specifying the compiler, which means the $CXX environment
variable was used if present. Other scripts (e.g. run-benchmarks) would
accept the compiler as an argument, but would fail to pass it down when
configuring the test suite, which led to issues.
This patch passes the compiler explicitly in all scripts: this removes
any potential confusion around how the compiler should be specified (env
var or argument). The only exception is build-at-commit, where the
compiler is still specified by passing the appropriate CMake arguments.
The reason for this exception is that passing arguments to CMake is
actually the way we want to configure aspects of the build (and the test
suite) in the long term, it's just that the test suite doesn't support
this cleanly due to the CMake/Lit split at the moment.
[3 lines not shown]
[NFC][Clang][Lex] Add assert to prevent null pointer dereference in Preprocessor::HandleModuleContextualKeyword (#211117)
Coverity static analysis scans on clang are unhappy with
[this](https://github.com/llvm/llvm-project/blob/e55d3bca36ff8a23ef598f6f452ec1e3f399dc31/clang/lib/Lex/Preprocessor.cpp#L920)
invocation of `HandleModuleContextualKeyword` due to the fact that
_technically_ nothing is stopping `CurPPLexer` reference in
`Preprocessor` from being `nullptr`, although AFAICT the current code
ensures this doesn't happen when `Preprocessor` is in file-lexing mode.
However, an assertion could be added to `HandleModuleContextualKeyword`
for future debugging's sake.
---------
Co-authored-by: Yihan Wang <yronglin777 at gmail.com>
[lldb] Create a GetStartLineEntry helper (#211264)
A WebAssembly function's entry address points at the locals-declaration
header, which carries no line information, so the first line table row
begins past the entry point.
We already handled this in GetPrologueByteSize (dd069b691dd3), but there
are other places that need the same support (GetStartLineSourceInfo,
GetFunctionStartLineEntry). Rather than duplicating the logic, create a
shared helper.
[flang][OpenMP] Switch TableGen generation to use llvm::EnumSet
Replace the remaining uses of the common::EnumSet-based OmpClauseSet to
llvm::omp::ClauseSet.
[LCSSA] Avoid rewriting lifetime markers through PHIs (#210811)
Lifetime intrinsics have been required to reference an alloca directly
since #149310. LCSSA can currently violate that invariant when a
loop-local alloca has a lifetime marker outside the loop: SSA
reconstruction rewrites the marker operand through an exit PHI, and the
verifier rejects the result.
Collect lifetime markers while scanning uses. If one crosses the loop
boundary, conservatively erase the complete marker set for that alloca
instead of rewriting any marker. Removing the markers extends the
modeled lifetime and preserves program semantics. This follows the same
strategy adopted for JumpThreading in #188147.
The regression test covers both sides of the behavior:
- a lifetime end outside the loop drops both the start and end markers;
- markers that remain inside the loop are preserved while another alloca
use receives an LCSSA PHI.
[7 lines not shown]
[NFC][analyzer] Apply any_of to detect destructors stack frame (#211582)
Since #210938 is merged I have also applied the same parent-chain helper
to detect if a destructor's stack frame is on the current stack.
RuntimeLibcalls: Add generic FCMP3_F* three-way compare for single-symbol ABIs
MSP430's __mspabi_cmpd/__mspabi_cmpf are one three-way compare symbol serving
every predicate, previously modeled as six suffixed impls each. Replace them
with a single generic operator FCMP3_*, and give softenSetCCOperands a 3rd
lowering option. After the boolean O*_F* and the per-predicate FCMP3_<pred>_F*
helpers, use the generic FCMP3_F* helper tested with the predicate's condition
code.
Also opt __nedf2 out of the MSP430 default set: it was the only libgcc F64
compare not already opted out, so it would otherwise provide FCMP3_UNE_F64 and
win over __mspabi_cmpd for not-equal.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
[libc] Implement pthread_setschedparam and getschedparam (#205770)
Implemented the pthread_setschedparam and pthread_getschedparam
functions.
Added Linux syscall wrappers:
* sched_setscheduler
* sched_getscheduler
* sched_getparam
Updated the Thread class to support getting and setting scheduling
parameters.
Added integration tests to verify the implementation.
Assisted-by: Automated tooling, human reviewed.
[WebKit Checkers] Share the safety model of WebKit smart pointers (#210195)
This PR introduces PtrRefSafetyModel to abstract away type checks for
various smart pointer types in WebKit to share more code between
different checkers.
clang/AMDGPU: Stop passing redundant -target-cpu to cc1
Now that the exact target is encoded in the triple's subarch field,
-target-cpu is redundant. This avoids polluting the resultant IR with
unwanted "target-cpu" attributes. The net result is the desired codegen
when compiling libraries for a major subarch and linking it into a
program compiled for a specific arch. e.g., compiling for "gfx9-generic"
would pollute the IR with "target-cpu"="gfx9-generic", so codegen
would ultimately be performed for the generic target even after
linking into the concrete gfx9 cpu. The specialization will now be
achieved by merging the triples without the linker or optimization
passes needing to fixup function attributes.
clang: Start using new amdgpu subarch triples
Fixup invocations using --target=amdgcn + -mcpu to introduce
the subarch in the triple.
For offload toolchains, a single toolchain is constructed for the
top level amdgpu architecture, and the effective triple is used for
target specific tool invocations.
The specifics of the resource directory layout are tbd. This does
try to find resources in the subarch named directory. The paths
are searched at toolchain creation time, so that does not work
when there are multiple subarches.
Fixes #154925
RuntimeLibcalls: Split soft-float three-way compares into distinct libcall kinds
Soft-float compares come in two flavors. ARM AEABI (__aeabi_dcmpeq) and VFP
(__eqdf2vfp) return a simple 0/1 boolean and use the existing O*_F* / UO_F*
libcalls. The libgcc/compiler-rt helpers (__eqdf2, __ltdf2, ...) return a
three-way -1/0/1, which the legalizer needs to insert the appropriate compare
against.
The three-way helpers previously masqueraded as O*_F* implementations, with the
condition code recovered from a hardcoded switch. Model them instead as distinct
operations. The legalizer then reasons about how to make use of the call result
based on which flavor of operation is available, rather than special casing what
the specific implementation is.
This leaves the mspabi cases for a later cleanup, because it's 3-way usage is
slightly different from the ARM case.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
Specialize IterateOverMembers instead of ClauseSetToString
There was still a use of common::EnumSet::IterateOverMembers left
over after the prior changes. Get rid of it via the specialization,
and revert the specialization of ClauseSetToString, which was
originally implemented using IterateOverMembers.
[flang] Provide "clause set" type as parameter to DirectiveStructureChecker
This will remove the hardcoded dependence of DirectiveStructureChecker on
the common::EnumSet class. Both consumers of it will be able to use their
own type for the clause set.
The only complication was the ClauseSetToString member function, whose
implementation depended on the specifics of common::EnumSet, namely the
IterateOverMembers member function. It was moved out of the class, and
turned into a function template to make it possible to provide different
specializations for common::EnumSet and llvm::EnumSet.
[flang][OpenMP] Use llvm::omp::DirectiveSet instead of common::EnumSet
Replace uses of OmpDirectiveSet (defined in terms of common::EnumSet)
with the common llvm::omp::DirectiveSet (defined via llvm::EnumSet).
The llvm::omp::DirectiveSet class will also be used in openmp-parsers,
where OmpDirectiveSet was an instance of llvm::Bitset.
[flang][OpenMP] Use llvm::omp::ClauseSet instead of common::EnumSet
Replace uses of OmpClauseSet (defined in terms of common::EnumSet)
with the common llvm::omp::ClauseSet (defined via llvm::EnumSet).
[OpenMP] Implement EnumSet container
This is close to flang's common::EnumSet with the difference being that
it provides forward iterators.
The reason for having an implementation that is separate from
common::EnumSet is that this is intended to be shared for all consumers
of llvm/lib/Frontend/OpenMP. This class is also planned to be one of the
core containers for representing auto-generated OpenMP data in the future.