[clang-sycl-linker] Improve --spirv-dump-device-code and harden CLI handling (#200096)
Several small fixes and improvements to `clang-sycl-linker`'s
command-line
handling, plus completing the `--spirv-dump-device-code` option:
- **`--version`**: now exits with `EXIT_SUCCESS` after printing, instead
of
falling through into the rest of `main`.
- **Empty input**: report a clear "No input files provided" error from
`getInput` rather than triggering an assertion deep inside
`linkDeviceCode`.
- **`--spirv-dump-device-code`**: previously parsed but ignored — now
actually
copies each generated `.spv` file into the requested directory. The
directory is created up-front (`mkdir -p` semantics) so a missing path
produces a friendly diagnostic instead of a low-level copy errno.
Co-Authored-By: Claude Sonnet 4.6 <noreply at anthropic.com>
[ExpandIRInsts] Avoid redundant dyn_cast after #175864 (#200475)
CreateCondBr always returns an Instruction, so no need to dyn_cast back
to an instruction after downcasting to a Value.
[SPIR-V] Insert service function when module has only declarations (#199964)
A declarations-only module produces no `MachineFunction` at all,
`SPIRVModuleAnalysis` is freed before `AsmPrinter::doFinalization` and
`outputModuleSections` asserts in `getAnalysis<SPIRVModuleAnalysis>()`
which causes a failure
[ThinLTO][AIX] Teach ModuleSummaryAnalysis to include globals
referenced via !implicit.ref metadata as explicit reference edges in the ThinLTO
module summary via a new helper findImplicitRefEdges. Add imported
implicit ref strings (available_externally GVs) to llvm.compiler.used during thinLTO interaction with pragma comment copyright.
[libclc][test] Update math/cos.cl check lines after #199981 revert (#200353)
The libclc lit test 'math/cos.cl' (introduced by #197151 with
auto-generated FileCheck assertions) started failing on the staging
buildbot after the revert in #199981 of the AMDGPU ABI coercion change
(#185083). The revert restores the older codegen path, which produces a
slightly different IR shape for the select instruction inside the cos()
implementation:
- the select's 'contract' fast-math flag is no longer present, and
- the result is named %.v.i.i instead of a numbered SSA temporary.
Regenerate the AMDGCN CHECK lines with
libclc/test/update_libclc_tests.py to reflect the post-revert IR. After
this change, all 10 libclc tests in check-libclc-amdgcn-amd-amdhsa-llvm
pass.
Note: running update_libclc_tests.py also produces a purely cosmetic
diff in math/rsqrt.cl (it renames a few FileCheck capture names like
[4 lines not shown]
[PowerPC] Add patterns for atomic load with immediates
Adds pattern to use the immediate form of and, or, and xor for
atomic loads. The matching is limited to 16-bit immediates, which
seems to be the most used ones.
[NVPTX][FIX] Ensure memmove are kept if not lowered to loops
Memmove lowering can fail, so we cannot unconditionally remove the
intrinsic.
Issue found by Robert Imschweiler <robert.imschweiler at amd.com>
[lit] Remove redundant f.close() in TestingConfig (#200459)
[This
commit](https://github.com/llvm/llvm-project/commit/5536348d060066e875c9bf9e056447ece59c783d)
moved the config file `open()` into a `with` context manager but left
the trailing `f.close()` call behind. Since the context manager already
closes the file, the call is redundant. It is also outside the `with`
block, so `f` is unbound on the `except OSError` path. This removes it.
No change in behavior.
Signed-off-by: Prasoon Kumar <prasoonkumar054 at gmail.com>
[offload] use argument pointer array in olLaunchKernel (#194333)
This PR changes olLaunchKernel to accept an array of pointers to
arguments:
```
void *ArgPtrs[] = {&A, &B, &C};
size_t ArgSizes[] = {sizeof(A), sizeof(B), sizeof(C)};
olLaunchKernel(Queue, Device, Kernel, &LaunchArgs, std::size(ArgPtrs), ArgPtrs, ArgSizes);
```
The newly proposed interface is implementable by existing and
anticipated
backends, is familiar to CUDA programmers, eliminates the extraneous
construction of a contiguous arguments buffer, replacing it with
constructing
an array of pointers, sidesteps the alignment requirements, does not
require reading program image metadata where it's impractical, and
enables
[34 lines not shown]
fts: Improve the description of FTS_NOSTAT
Note that we still need to stat directories and the roots.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D57325
fts: Check link count before using it
* Check the range of the link count before trying to use it.
* Rewrite the comment explaining what the link count is used for.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D57324
fts: Add some depth to the options test
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D57323
[CIR] Implement __sync_synchronize builtin (#200423)
This showed up on a spec test, but is a very simple system-sequentially
consistent fence instruction.
LangRef: Clarify that unnamed_addr constants can be duplicated.
It has always been the intent that it was possible to duplicate
unnamed_addr constants, and LTO takes advantage of it. The current LangRef
wording allows it, but it was not explicitly spelled out, which led Clang
developers to add an optimization that assumed that it wasn't possible.
We are considering changing the semantics of unnamed_addr, but for now,
just make the current state explicit.
Reviewers:
teresajohnson, zygoloid, rjmccall, ChuanqiXu9, efriedma-quic, ojhunt
Pull Request: https://github.com/llvm/llvm-project/pull/199251
[Clang][test] Fix space in ld path (#200012)
The driver resolves the path to the linker ("ld") to the absolute path.
Microsoft Visual Studio comes with its own instance of `ld.lld` which it
installs under
"c:\\program files\\microsoft visual studio\\2022\\community\\vc\\tools\\llvm\\x64\\bin\\ld.lld.exe"
In the developer command prompt, this path is added to PATH where the
Clang driver finds it. However, this path does not match regular
expression `"{{[^" ]*}}ld{{[^" ]*}}"` used by the MIPS test because the
path contains spaces.
Fix the test failure by matching only the the trailing component after
`ld`. Matching the prefix of the path is unique to the MIPS test, this
is not done with tests for other platforms.
llvm-objdump: Support --disassemble= option.
This is compatible with GNU, as well as being shorter and allowing users
to specify symbol names with commas in them.
Note that this is distinct from the existing --disassemble which has
existed for a long time and disassembles all symbols. This change adds
a near-alias for the existing LLVM-specific --disassemble-symbols=.
Reviewers: jh7370, MaskRay
Pull Request: https://github.com/llvm/llvm-project/pull/196594