[clang-tidy][NFC] Use universal utility mock in testcases [2/N] (#185797)
As of AI Usage: Gemini 3 and Codex is used for cleanup and pre-commit
reviewing.
[libunwind][PAC] Defang ptrauth's PC in valid CFI range abort
It turns out making the CFI check a release mode abort causes many,
if not the majority, of JITs to fail during unwinding as they do not
set up CFI sections for their generated code. As a result any JITs
that do nominally support unwinding (and catching) through their JIT
or assembly frames trip this abort.
rdar://170862047
[RISCV] Replace HasStdExtZbcOrZbkc with HasStdExtZbkc. NFC (#185790)
Zbc now implies Zbkc so we don't need an Or. I've moved the diagnostic
string from HasStdExtZbcOrZbkc to HasStdExtZbkc to avoid assembler
output changes.
[WebAssembly] Remove `__c_longjmp` from compiler-rt (#185798)
This is similar to #185770 where it removes an
exception-handling-related symbol from `compiler-rt` in favor of having
definitions elsewhere. The compiler-rt library is linked into all shared
objects, for example, which can result in duplicate definitions of a
symbol where this tag wants to have one unique definition. The intention
behind this commit is to defer the definition of this symbol to
downstream libraries, such as the definition of `longjmp` itself. An
example of this is WebAssembly/wasi-libc#772 where the responsibility of
defining this symbol now lies with wasi-libc.
[DA] Add tests for the Weak Zero SIV tests miss dependency (NFC) (#184998)
Add test cases where the Weak Zero SIV tests miss dependencies due to
the calculation of negative values. SCEV represents the negative value
of `x` as `-1 * x`. When `x` is the signed minimum value, this
expression effectively evaluates to `x`, which causes DA to miss the
dependency. In DA, if we cannot prove that the value is not the signed
minimum when computing the negative value, the analysis should bail out.
[Clang][NFC] Make remaining Decl.h methods accept const ASTContext
Complete the const-correctness of ASTContext parameters in Decl.h by
updating the three previously excepted methods:
- TranslationUnitDecl::Create() and constructor: Now accept const
ASTContext& and store it as a const reference. The getASTContext()
method uses const_cast to maintain API compatibility with code that
expects a non-const reference. This is safe since the ASTContext is
always created as non-const.
- DefaultedOrDeletedFunctionInfo::Create(): Now accepts const ASTContext&
since ASTContext::Allocate() is already a const method.
All Create(), CreateDeserialized(), and constructor methods in Decl.h
now consistently accept const ASTContext& references with zero exceptions.
Assisted-By: Claude Sonnet 4.5
[libunwind][PAC] Defang ptrauth's PC in valid CFI range abort
It turns out making the CFI check a release mode abort causes many,
if not the majority, of JITs to fail during unwinding as they do not
set up CFI sections for their generated code. As a result any JITs
that do nominally support unwinding (and catching) through their JIT
or assembly frames trip this abort.
rdar://170862047
[lldb/test] Add generic test variant infrastructure (#185145)
Add a generic `TestVariant` class and `_expand_test_variants` function
that can be used to create new test variant dimensions (similar to the
existing debug_info variant expansion).
Each TestVariant describes a dimension that multiplies test methods by
different configurations. The infrastructure handles method expansion,
xfail/skip decorator support, and setUp-time configuration.
This also generalizes `_xfailForDebugInfo`/`_skipForDebugInfo` into
`_xfailForVariant`/`_skipForVariant`, and changes the decorator's inner
fn() to accept **kwargs so variant values can be passed by name.
The `_test_variants` list is currently empty — downstream forks (i.e.
swift) can register their own variants without modifying the metaclass
logic.
Signed-off-by: Med Ismail Bennani <ismail at bennani.ma>
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]