Basic,Sema: introduce `__attribute__((__personality__(...)))` (#185225)
This attribute allows specifying a custom personality routine for a
function, overriding the default emitted by Clang. The motivating use
case is the Swift concurrency runtime, where C/C++ runtime functions
need to act as barriers for exception propagation — the custom
personality ensures exceptions do not propagate through these frames
unchecked. More generally, this is useful whenever a language runtime is
implemented in a host language with different EH semantics. LLVM IR
already supports arbitrary personality functions on definitions; this
attribute simply exposes that capability to the C/C++ frontend.
Co-authored-by: Erich Keane <ekeane at nvidia.com>
[WebAssembly][FastISel] Fold AND mask operations into ZExt load (#183743)
FastISel emits separate load and AND instructions for bitmasking.
(before) %1:i32 = LOAD_I32 %addr; %2:i32 = AND_I32 %1, 255
Fold AND masks into ZExt loads by verifying operands with
maskTrailingOnes. A getFoldedLoadOpcode wrapper is implemented
to manage dispatching logic for better extensibility.
(after) %1:i32 = LOAD8_U_I32 %addr
Fixed: https://github.com/llvm/llvm-project/issues/180783
[WebAssembly] Look through freeze nodes when folding vector load + ext (#185143)
When folding loads with extensions, the extension operand can be a freeze node
in addition to a load. We can look through it to do the desirability check.
Fixes #184676
[DAGCombiner] Combine (fshl A, B, S) | (fshr C, D, BW-S) --> (fshl (A|C), (B|D), S) (#180889)
This is similar to the FSHL/FSHR handling in
hoistLogicOpWithSameOpcodeHands.
Here the opcodes aren't exactly the same, but the operations are
equivalent.
Fixes regressions from #180888
[SandboxVec][DAG] Mark UnscheduledSuccs as invalid when vectorized (#185519)
When a DAG node gets scheduled, it's UnscheduledSuccs variable becomes
invalid. Up until now we had no way in the code of expressing this.
This patch converts UnscheduledSuccs to an std::optional in order to
protect its use when not valid.
[RISCV] Refactor lowerBUILD_VECTOR splat opcode selection to avoid duplication. NFC. (#185573)
Hoist the common ANY_EXTEND, DAG.getNode, and convertFromScalableVector
calls out of the duplicated if/else branches. Use a single IsScalar bool
to select between VMV_S_X_VL/VFMV_S_F_VL and VMV_V_X_VL/VFMV_V_F_VL.
[WebAssembly] Move __cpp_exception to libunwind (#185770)
The `__cpp_exception` symbol is now defined in libunwind instead of
compiler-rt. This is moved for a few reasons, but the primary reason is
that compiler-rt is linked duplicate-ly into all shared objects meaning
that it's not suitable for define-once symbols such as
`__cpp_exception`. By moving the definition to the user of the symbol,
libunwind itself, that guarantees that the symbol should be defined
exactly once and only when appropriate. A secondary reason for this
movement is that it avoids the need to compile compiler-rt twice: once
with exception and once without, and instead the same build can be used
for both exceptions-and-not.
[WebAssembly] Clang support for exception-based lookup paths (#185775)
This commit is an attempt to make progress on WebAssembly/wasi-sdk#565
where with wasi-sdk I'd like to ship a single toolchain which is capable
of building binaries both with C++ exceptions and without. This means
that there can't be a single set of precompiled libraries that are used
because one set of libraries is wrong for the other mode. The support
added here is to use `-fwasm-exceptions` to automatically select a
lookup path in the sysroot. The intention is then that wasi-sdk will
ship both a "eh" set of C++ libraries as well as a "noeh" set of C++
libraries too. Clang will automatically select the correct one based on
compilation flags which means that the final distribution will be able
to build both binaries with exceptions and without.
SelectionDAG: Use ISD::AssertNoFPClass for Load with nofpclass metadata (#184952)
1. Use ISD::AssertNoFPClass if LoadInst has !nofpclass metadata.
2. Strip ISD::AssertNoFPClass when try to combine load with bitcast
in DAGCombiner::visitBITCAST.
[Hexagon] Fix B0 macro conflict between hexagon_types.h and termios.h (#184539)
POSIX termios.h defines `#define B0 0000000` for baud rate 0. This
conflicts with the B0() member functions in hexagon_types.h vector
classes, causing compilation failures when both headers are included.
Use #pragma push_macro/pop_macro to save, undefine, and restore B0
around the class definitions so the header is safe to use alongside
termios.h without losing the macro afterward.
Fixes #183815
[libclc][CMake] Add back OUTPUT_FILENAME and PARENT_TARGET (#185633)
They were droped in e20ae16ce672.
OUTPUT_FILENAME is helpful for customizing library name. PARENT_TARGET
could be helpful for customizing dependency control.
[BPF] Fix CORE optimization bug in BPFMISimplifyPatchable (#183446)
Commit ffd57408efd4 ("[BPF] Enable relocation location for
load/store/shifts") enabled CORE relocation for load/store/shirts. In
particular, the commit did optimization to have load/store/shift insn
itself having the relocation. For the load and store, the optimization
has the following:
rX = *(rY + <relocation>) and *(rX + <relocation>) = rY
There is no value-range check for the above '<relocation>'. For example,
if the original `<relocation>` is 0x10006 due to a large struct, the
insn encoding of `<relocaiton>` will be truncated into '6' and incorrect
result will happen.
This patch fixed the issue by checking the value range of
'<relocation>'. If the `<relocation>` is more than INT16_MAX,
optimization will be skipped.
Even llvm side is fixed, libbpf side may still have issues with the
[35 lines not shown]
[lldb][test] PlatformDarwinTest.cpp: skip dSYM test on Windows
Fails on Windows with:
```
Script:
--
C:\buildbot\as-builder-10\lldb-x86-64\build\tools\lldb\unittests\Platform\.\LLDBPlatformTests.exe --gtest_filter=PlatformDarwinLocateTest.LocateExecutableScriptingResourcesFromDSYM_SpecialCharactersInModuleName_NoMatch
--
C:\buildbot\as-builder-10\lldb-x86-64\llvm-project\lldb\unittests\Platform\PlatformDarwinTest.cpp(466): error: Expected equality of these values:
ss.GetString()
Which is: "warning: the symbol file 'c:\\buildbot\\as-builder-10\\lldb-x86-64\\build\\lit-tmp-yi3ecv47\\locate-scripts-from-dsym-test-39be18\\.dSYM\\Contents\\Resources\\DWARF\\TestModule-1.1 1.o' contains a debug script. However, its name contains reserved characters and as such cannot be loaded. If you intend to have this script loaded, please rename 'c:/buildbot/as-builder-10/lldb-x86-64/build/lit-tmp-yi3ecv47/locate-scripts-from-dsym-test-39be18/.dSYM/Contents/Resources/DWARF/../Python/TestModule-1.1 1.py' to 'c:/buildbot/as-builder-10/lldb-x86-64/build/lit-tmp-yi3ecv47/locate-scripts-from-dsym-test-39be18/.dSYM/Contents/Resources/DWARF/../Python/TestModule_1_1_1.py' and retry.\n"
expected
Which is: "warning: the symbol file 'c:\\buildbot\\as-builder-10\\lldb-x86-64\\build\\lit-tmp-yi3ecv47\\locate-scripts-from-dsym-test-39be18\\.dSYM\\Contents\\Resources\\DWARF\\TestModule-1.1 1.o' contains a debug script. However, its name contains reserved characters and as such cannot be loaded. If you intend to have this script loaded, please rename 'c:\\buildbot\\as-builder-10\\lldb-x86-64\\build\\lit-tmp-yi3ecv47\\locate-scripts-from-dsym-test-39be18\\.dSYM\\Contents\\Resources\\DWARF/../Python/TestModule-1.1 1.py' to 'c:\\buildbot\\as-builder-10\\lldb-x86-64\\build\\lit-tmp-yi3ecv47\\locate-scripts-from-dsym-test-39be18\\.dSYM\\Contents\\Resources\\DWARF/../Python/TestModule_1_1_1.py' and retry.\n"
C:\buildbot\as-builder-10\lldb-x86-64\llvm-project\lldb\unittests\Platform\PlatformDarwinTest.cpp:466
Expected equality of these values:
ss.GetString()
Which is: "warning: the symbol file 'c:\\buildbot\\as-builder-10\\lldb-x86-64\\build\\lit-tmp-yi3ecv47\\locate-scripts-from-dsym-test-39be18\\.dSYM\\Contents\\Resources\\DWARF\\TestModule-1.1 1.o' contains a debug script. However, its name contains reserved characters and as such cannot be loaded. If you intend to have this script loaded, please rename 'c:/buildbot/as-builder-10/lldb-x86-64/build/lit-tmp-yi3ecv47/locate-scripts-from-dsym-test-39be18/.dSYM/Contents/Resources/DWARF/../Python/TestModule-1.1 1.py' to 'c:/buildbot/as-builder-10/lldb-x86-64/build/lit-tmp-yi3ecv47/locate-scripts-from-dsym-test-39be18/.dSYM/Contents/Resources/DWARF/../Python/TestModule_1_1_1.py' and retry.\n"
expected
Which is: "warning: the symbol file 'c:\\buildbot\\as-builder-10\\lldb-x86-64\\build\\lit-tmp-yi3ecv47\\locate-scripts-from-dsym-test-39be18\\.dSYM\\Contents\\Resources\\DWARF\\TestModule-1.1 1.o' contains a debug script. However, its name contains reserved characters and as such cannot be loaded. If you intend to have this script loaded, please rename 'c:\\buildbot\\as-builder-10\\lldb-x86-64\\build\\lit-tmp-yi3ecv47\\locate-scripts-from-dsym-test-39be18\\.dSYM\\Contents\\Resources\\DWARF/../Python/TestModule-1.1 1.py' to 'c:\\buildbot\\as-builder-10\\lldb-x86-64\\build\\lit-tmp-yi3ecv47\\locate-scripts-from-dsym-test-39be18\\.dSYM\\Contents\\Resources\\DWARF/../Python/TestModule_1_1_1.py' and retry.\n"
[3 lines not shown]
[libclc] Remove unused and incorrect pkgconf file (#185654)
Summary:
All this file does is pass `-L` to an incorrect location. These files
are installed as part of the resource directory which is always included
anyway, so I think this is vestigial and can be removed.
[InstCombine][profcheck] Set unknown branch weights when folding booleans (#185769)
In cases where two logical operations are folded into one, InstCombine
first folds one of the logical operations into an binary operation,
losing the profile information. Ordinarily, we could've used that
information to compute the branch weight information of the new
instruction, but since we don't have the original weights, we say the
new instruction has unknown branch weights.
Tracking issue: #147390
[HLSL] Ignore complex types that do not contribute to cbuffer layout (#184276)
Detect arrays of empty structs and similar constructs in constant buffers. Ignore them if they do not contribute to `cbuffer` layout
Fixes #183788
[clang][ssaf] Add ssaf-format to validate and convert summaries
This PR introduces the `ssaf-format` command-line tool, which validates
and converts translation-unit (TU) and link-unit (LU) summaries between
registered serialization formats in the SSAF framework. After the
serialization format registry and the JSON format were introduced, there
was no standalone tool to inspect, validate, or convert summary files
outside of a full compilation pipeline. `ssaf-format` fills that gap: it
serves as both a format validator (read without writing) and a format
converter (read then write to a different format or path).
[flang][openacc] Attach IndirectGlobalAccessModel to fir.use_stmt (#185767)
In some cases, `fir.use_stmt` operation can end up in offload region
like in acc routine for example. Make sure we can validate the symbols
associated with the `fir.use_stmt` operation.
[HLSL][DXIL][SPIRV] Added WaveActiveBitOr HLSL intrinsic (#165156)
Adds the WaveActiveBitOr intrinsic from issue #99167. This intrinsic
required a bit more work than the last intrinsics that I have done.
There are some peculiarities, which I verified with dxcompiler:
- WaveActiveBitOr only works on uint and uint64_t, no other types are
allowed
- There is no 16 bit version of WaveActiveBitOr
Followed the checklist:
- [x] Implement WaveActiveBitOr clang builtin,
- [x] Link WaveActiveBitOr clang builtin with hlsl_intrinsics.h
- [x] Add sema checks for WaveActiveBitOr to
CheckHLSLBuiltinFunctionCall in SemaChecking.cpp
- [x] Add codegen for WaveActiveBitOr to EmitHLSLBuiltinExpr in
CGBuiltin.cpp
- [x] Add codegen tests to
clang/test/CodeGenHLSL/builtins/WaveActiveBitOr.hlsl
[15 lines not shown]
[HLSL][Matrix] Add `half` type overloads to `mul` and exercise them (#185506)
PR #184882 was missing `half` type-specific overloads for `mul`.
This PR introduces `half` type-specific overloads for `mul` and
additional codegen tests for the half type.
Also added f16 tests for the lowering of llvm.matrix.multiply.
The offload test suite already has a `mul.fp16` test for exercising half
types at runtime, so no change is needed there.
Assisted-by: claude-opus-4.6
[HLSL] Fix intrinsics header file 16 bit attribute macro to use version 6.2 (#185757)
There have been a couple builtins declared in a header file that specify
16 bit availability for shader model 6.0.
This is incorrect, it should be 6.2.
This bug was propagated for many of the waveops, and should be
corrected.
Fixes https://github.com/llvm/llvm-project/issues/185756
[LegalizeTypes] Emit FSHL/FSHR from ExpandShiftByConstant when Legal. (#180888)
This avoids needing to combine the SHL/SHR/OR pattern later.
This improves code quality on RISC-V where our slx/srx instructions
clobber the destination register but we don't have an immediate form.
We can't recover the original direction from the SHL/SHR/OR pattern
and we can't commute it during the TwoAddressInstruction pass like X86
due to the shift amount being in a register.
[lldb] Make date test handle host-target time difference (#185759)
It seems there may be a formatter bug when there's a time zone
difference between the target machine being debugged, and the host the
debugger is running on.