clang/AMDGPU: Split out target ID flags in TranslateArgs. (#203750)
Change how xnack and sramecc are processed. Introduce
-mxnack/-mno-xnack and -msramecc/-mno-sramecc flags.
When the target is first parsed in TranslateArgs, synthesize
the appropriate flag for the toolchain. This avoids
special case feature string fixups in getAMDGPUTargetFeatures,
and also avoids an extra parse of the target ID.
In the future this will also simplify tracking these ABI
modifiers in a module flag.
As a side-effect, you can use these flags to override the
no specifier case with the flags. These do not fully replace
the target ID syntax, as there's no way to represent compiling
both modes for the same subtarget.
I didn't bother trying to forward these flags on the main command
line without being specified to the offload device, but I suppose
[2 lines not shown]
[libc++] Make the body of println(FILE*) dependent on the template parameter to avoid template instantiation (#200996)
Make the function parameter of the `std::print` call inside the
`std::println` overload taking `FILE*` dependent on the template
parameter to avoid eager instantiation.
[mlir][python] Fix segfault at interpreter shutdown with entered contexts
The thread-local context stack (`PyThreadContextEntry::getStack()`)
holds `nb::object` references to Python Context, Location, and
InsertionPoint objects. When a Context is entered via `__enter__` but
never exited before the interpreter shuts down, these references
cause a segfault during process teardown.
The crash sequence:
1. User calls `ctx.__enter__()`, pushing a frame onto the
`static thread_local vector<PyThreadContextEntry>`.
2. The script ends; CPython runs `Py_FinalizeEx()` which tears down
the interpreter (clears modules, destroys remaining objects).
3. `main()` returns.
4. The C runtime destroys static/thread_local storage. On the main
thread, thread_local variables have the same destruction timing
as static storage — they are destroyed *after* main() returns.
5. The vector destructor runs, and each `PyThreadContextEntry`'s
`nb::object` members call `Py_DECREF` — but the interpreter is
[8 lines not shown]
[mlir][python] Fix segfault at interpreter shutdown with entered contexts
The thread-local context stack (`PyThreadContextEntry::getStack()`)
holds `nb::object` references to Python Context, Location, and
InsertionPoint objects. When a Context is entered via `__enter__` but
never exited before the interpreter shuts down, these references
cause a segfault during process teardown.
The crash sequence:
1. User calls `ctx.__enter__()`, pushing a frame onto the
`static thread_local vector<PyThreadContextEntry>`.
2. The script ends; CPython runs `Py_FinalizeEx()` which tears down
the interpreter (clears modules, destroys remaining objects).
3. `main()` returns.
4. The C runtime destroys static/thread_local storage. On the main
thread, thread_local variables have the same destruction timing
as static storage — they are destroyed *after* main() returns.
5. The vector destructor runs, and each `PyThreadContextEntry`'s
`nb::object` members call `Py_DECREF` — but the interpreter is
[8 lines not shown]
[clang][bytecode] Overide constant context state in CallVar (#203747)
We do this for regular calls, so do it for variable calls as well. Also
remove two comments that don't have any meaning today anymore.
[Flang] Store only options in FLANG_COMPILER_OPTIONS_STRING (#201278)
Previously, FLANG_COMPILER_OPTIONS_STRING stored every argument passed
to the flang driver, including input file names. The GNU extension
compiler_options() is documented to return only the options, not the
input files. Including the input files also caused the string to exceed
ARG_MAX on large builds, producing:
posix_spawn failed: Argument list too long
Use the driver's parsed InputArgList to filter out OPT_INPUT arguments,
preserving all options and their values (e.g. `-I /path`, `-o file`).
Fixes: https://github.com/llvm/llvm-project/issues/170651
[mlir][SPIR-V] Enforce physical storage buffer pointer decorations on GlobalVariable (#203600)
Enable the rule that was already enforced by spirv.Variable (in case of
SPV_KHR_physical_storage_buffer ext) requiring exactly one of
AliasedPointer/RestrictPointer
[LoongArch] Propagate demanded bits for CRC[C].W.{B,H}.W (#203201)
CRC byte and halfword instructions only use the low 8 or 16 bits of
their data operand. Propagate these demanded-bit requirements through
SimplifyDemandedBitsForTargetNode() so redundant masking operations can
be removed during DAG combining.
[VPlan] Move tail folding logic out of addMiddleCheck. NFC (#203475)
We simplify the TripCount == VectorTrip count condition with tail
folding, but we can just do that in foldTailByMasking and keep the
logic in one place instead.
[LoongArch] Propagate demanded bits for CRC[C].W.{B,H}.W
CRC byte and halfword instructions only use the low 8 or 16 bits of
their data operand. Propagate these demanded-bit requirements through
SimplifyDemandedBitsForTargetNode() so redundant masking operations can
be removed during DAG combining.
[mlir][CSE] Remove the opsToErase container and immediately delete dead ops. (#203702)
This PR removes the `opsToErase` container and immediately erases dead
operations. Since dead ops are deleted on the fly, the value in the
`MemEffectsCache` map now correctly tracks the previous operation of
`toOp`. This change improves the storage efficiency of CSE. Furthermore,
it is part of https://github.com/llvm/llvm-project/pull/180556 and
substantially simplifies the implementation.
[libclc] Use __CLC_SCALAR instead of nonexistant __CLC_SCALAR1 for sin (#203807)
Summary:
This seems to be a typo? Every other case is guarded by `__CLC_SCALAR`
but this case had a `1` after it. Removing this improved performance on
sin/cos/tan to match the ROCm version.
[libclc] Use FMA for the pi reconstruction in acos / atan (#203804)
Summary:
This should recombine the split constant for this case. The performance
should be negligible for such large math functions, we get an extra add,
but in exchange the results should improve 1 ULP.
This was primarily done to match what AMD's math libraries do, with this
change we are byte-for-byte identical in output.
[Passes] Invoke CGSCCOptimizerLateEP callbacks in LTO pipeline (#203262)
The CGSCCOptimizerLateEP extension point was not being invoked in the
LTO pipeline. Right now only AMDGPU registers any passes during this
callback, but it was a real source of delta between the LTO and default
pipelines when targeting AMDGPU. This doesn't seem to be an intentional
omission given that it is instantiated in thinLTO as well. Just add it.