[CIR][AMDGPU] Add AMDGPU-specific function attributes for HIP kernels (#188007)
Upstreaming clangIR PR: https://github.com/llvm/clangir/pull/2091
This patch adds support for AMDGPU-specific function attributes for HIP
kernels
Added setTargetAttributes for AMDGPUTargetCIRGenInfo to set kernel
attributes
Added generic string attribute handler in amendFunction to translate
string-values with "cir." prefix function attributes to LLVM function
attributes
Follows OGCG AMDGPU implementation from
"clang/lib/CodeGen/Targets/AMDGPU.cpp".
[DA] Add precondition `0 <=s UB` to function `inferAffineDomain` (#187218)
This patch fixes issues where the Exact SIV/RDIV tests can return
incorrect results when the BTC is negative in a signed sense. The root
cause is that BTCs should be interpreted in an unsigned sense, but
`inferAffineDomain` uses the BTC in inequalities that are interpreted in
a signed sense. These inequalities make sense only when the BTC is
non-negative. Thus we need to check it beforehand.
[Hexagon] Fix load/store widening to preserve subreg operands (#188181)
HexagonLoadStoreWidening pass was incorrectly using DoubleRegs registers
where IntRegs was required when widening load/store pairs. When the
S2_addasl_rrri instruction used a subreg (e.g., %2.isub_lo), the
widening pass extracted only the base register without preserving the
subreg, causing machine verifier errors.
[ClangScanDeps] Avoid use-of-uninitialized-memory for end-of-directive edge case (#188590)
https://github.com/llvm/llvm-project/pull/186966 was reverted because
the test case triggered a use-of-uninitialized-memory
(https://lab.llvm.org/buildbot/#/builders/94/builds/16379), due to the
include directive omitting a trailing newline. This patch adds a minor
fix to avoid the use-of-uninitialized-memory, and deliberately re-adds
the test case sans trailing newline for regression testing.
MSan report prior to this fix:
```
@@@BUILD_STEP sanitizer logs: stage2/msan_track_origins check@@@
==clang-scan-deps==616960==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x5555599c3300 in isAnnotation /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/include/clang/Lex/Token.h:131:38
#1 0x5555599c3300 in setLength /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/include/clang/Lex/Token.h:152:13
#2 0x5555599c3300 in clang::Lexer::FormTokenWithChars(clang::Token&, char const*, clang::tok::TokenKind) /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/include/clang/Lex/Lexer.h:644:12
#3 0x5555599cf895 in clang::Lexer::LexEndOfFile(clang::Token&, char const*) /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Lex/Lexer.cpp:3166:5
#4 0x555559bb229b in clang::Preprocessor::Lex(clang::Token&) /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Lex/Preprocessor.cpp:916:11
#5 0x555559aa5365 in __invoke<void (clang::Preprocessor::*&)(clang::Token &), clang::Preprocessor *, clang::Token &> /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/libcxx_install_msan_track_origins/include/c++/v1/__type_traits/invoke.h:90:27
[5 lines not shown]
[clang][Modules] Reject export declarations in implementation partitions (#188698)
[module.interface]/1 says:
> An export-declaration shall [...] appear in the purview of
a module interface unit.
But clang currently fails to enforce this rule in implementation
partitions.
Partially addresses #107602.
[Hexagon] Fix use-before-def of AP register in prologue CSR spills (#188504)
PS_aligna initializes the AP register (eg:callee-saved R16) with an
aligned value derived from FP. It was being placed before the
CSR spills, causing the spill of R16 to save the AP value instead of the
caller's original R16, breaking the callee-saved register contract and
it must be defined before any AP-relative stack accesses. Fix by moving
PS_aligna to after all CSR spills in insertCSRSpillsInBlock().
Fixes #184531
[TargetLowering][RISCV] Prefer (S/U)MUL_LOHI over MULH(S/U) in expandMULO. (#188870)
The RISC-V P extension adds WMUL and WMULU instruction that produce
a full 64-bit product in 2 GPRs. The base ISA already had MULH and
MULHU.
[Clang] fix bad codegen from constexpr structured bindings (#186594)
Resolves: https://github.com/llvm/llvm-project/issues/164150
C++26 allows for constexpr packs in structured bindings. This is a new
feature (the code doesn't compile on lower the -std=c++26) and so was
previously unhandled in clang.
This makes clang aware of packs and handle them as one constant unit
instead of materializing them as separate mutable reference temporaries
allowing llvm to optimize them.
This turns the example code from the issue into this as you would expect
without compiling for zen 5 (the good codegen described).
```asm
movq %rdi, %rax
movups (%rsi), %xmm0
movups %xmm0, (%rdi)
[3 lines not shown]
[DebugInfo] Lower DW_OP_LLVM_implicit_pointer to DWARF (#186763)
This patch adds backend support by intercepting
`DW_OP_LLVM_implicit_pointer` during variable DIE emission in
DwarfCompileUnit. For each implicit pointer variable, an artificial
`DW_TAG_variable` DIE is created to describe the dereferenced value's
location, and the pointer variable's location is emitted as
`DW_OP_implicit_pointer` referencing that artificial DIE.
Constant integer entries are de-duplicated so that multiple pointer
variables referencing the same constant value share a single artificial
DIE.
Emits `DW_OP_implicit_pointer` for DWARF 5 and
`DW_OP_GNU_implicit_pointer` for DWARF 4.
Here is the RFC with the design
https://discourse.llvm.org/t/rfc-implementing-dw-op-implicit-pointer-support-in-llvm/90217
[2 lines not shown]
[libclang/python] Renaming `get_version` into `get_clang_version` (#188515)
Rename `get_version` to `get_clang_version` to match the `libclang.so`
name[1], and be clear we doesn't return some `cindex.py` internal
versioning but the `libclang.so` one.
[1] This match was some current API are doing for example
`conf.lib.clang_getArraySize` is mapped to `get_array_size`.
[debuginfo-tests] Update line numbers in llgdb-tests/nrvo-string.cpp (#188901)
Update the line numbers in llgdb-tests/nrvo-string.cpp for #188780 which
shifts the file by 6 lines.
[ORC] Move DylibManager ownership out of ExecutorProcessControl. (#188711)
This removes an unnecessary coupling between ExecutorProcessControl and
DylibManager, allowing clients to select DylibManager implementations
independently.
To simplify the transition, the
ExecutorProcessControl::createDefaultJITDylib method will return an
instance of whatever DylibManager the ExecutorProcessControl
implementation had been using previously.
[ClangLinkerWrapper] Fix `-v` for newer CMake passing it directly (#188883)
Summary:
Normally `-v` is version for tools, but it's also verbose for the
linker. CMake tries to identify the linker by passing `-Wl,-v` which
goes to the linker wrapper instead. Make this only print version on
`--version` and forward the other one to the linker so it appears
transparent to the host ABI. A bit of a hack, but it should work.
[AArch64] Update preserved analyses for AArch64PostCoalescer (#188875)
Preserving all analyses likely is a wrong assertion since we do not know
what other analyses might exist that we've updated.
Updated to preserve CFG, LiveIntervalsAnalysis and SlotIndexAnalysis
(which is transitively preserved from LiveIntervalsAnalysis)
[Clang][NFC] Pre-commit tests for #185408
The tests demonstrate how incorrect LLVM IR is generated without diagnostics,
when an OpenCL or HIP scope number is passed to an AMDGPU intrinsic. #185408
lays the groundwork for properly diagnosing this situation by internally
using a separate enum type to represent each set of scope numbers.