LLVM/project f5fd158clang-tools-extra CMakeLists.txt, clang-tools-extra/clangd CMakeLists.txt

[clang-tools-extra] Add separate CLANG_TOOLS_EXTRA_INCLUDE_TESTS option (#215761)

clang-tools-extra tests depend on the llvm-bcanalyzer CMake target,
which exists in LLVM's CMake project but is not visible when Clang is
built separately from LLVM. This causes CMake errors when
CLANG_INCLUDE_TESTS is ON but the LLVM tools are not available.

This patch introduces CLANG_TOOLS_EXTRA_INCLUDE_TESTS as a separate
CMake option to control clang-tools-extra tests independently, allowing
users to build Clang with tests enabled (CLANG_INCLUDE_TESTS=ON) while
disabling clang-tools-extra tests (CLANG_TOOLS_EXTRA_INCLUDE_TESTS=OFF)
when building Clang separately from LLVM.

For backwards compatibility, CLANG_INCLUDE_TESTS=OFF continues
to turn off clang-tools-extra tests as well.
DeltaFile
+4-2clang-tools-extra/CMakeLists.txt
+1-1clang-tools-extra/include-cleaner/CMakeLists.txt
+1-1clang-tools-extra/clangd/CMakeLists.txt
+6-43 files

LLVM/project 850cc26libc/src/__support/math CMakeLists.txt, libc/test/src/math/smoke fdimf128_test.cpp CMakeLists.txt

nits
DeltaFile
+1-1libc/test/src/math/smoke/fdimf128_test.cpp
+1-1libc/test/src/math/smoke/CMakeLists.txt
+1-1libc/src/__support/math/CMakeLists.txt
+3-33 files

LLVM/project 51efbe1libc/src/__support/math CMakeLists.txt, libc/test/src/math/smoke fminimum_mag_numf128_test.cpp fmaximum_mag_numf128_test.cpp

nits
DeltaFile
+2-2libc/test/src/math/smoke/CMakeLists.txt
+2-2libc/src/__support/math/CMakeLists.txt
+1-1libc/test/src/math/smoke/fminimum_mag_numf128_test.cpp
+1-1libc/test/src/math/smoke/fmaximum_mag_numf128_test.cpp
+6-64 files

LLVM/project af30981libc/test/src/math/smoke fminimum_magf128_test.cpp fmaximum_magf128_test.cpp

nits
DeltaFile
+2-2libc/test/src/math/smoke/CMakeLists.txt
+1-1libc/test/src/math/smoke/fminimum_magf128_test.cpp
+1-1libc/test/src/math/smoke/fmaximum_magf128_test.cpp
+4-43 files

LLVM/project c5af4f1clang/include/clang/StaticAnalyzer/Checkers BoundsChecking.h, clang/lib/StaticAnalyzer/Checkers ArrayBoundChecker.cpp BoundsChecking.cpp

[analyzer] Fix handling of zero-sized elements in ArrayBound (#218712)

Previously the `security.ArrayBound` checker mishandled the following C
code under non-windows platforms where `sizeof(struct Empty) == 0`:
```c
struct Empty {};
struct Empty Array[10];
struct Empty foo(void) { return Array[5]; }
```
Here the checker produced a false positive with explanation "Access of
'Array' at byte offset 0, while it holds only 0 byte" -- that is, the
checker said that this accesses the past-the-end pointer, which is
usually invalid.

This commit suppresses this false positive by saying that accessing a
zero-sized object starting at the past-the-end pointer is valid.

This is implemented by adding an `AlsoAcceptEquality` flag for
`checkBounds`. This flag will also be useful for implementing checkers

    [4 lines not shown]
DeltaFile
+38-4clang/test/Analysis/ArrayBound/verbose-tests.c
+22-8clang/include/clang/StaticAnalyzer/Checkers/BoundsChecking.h
+11-16clang/lib/StaticAnalyzer/Checkers/BoundsChecking.cpp
+13-13clang/lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp
+84-414 files

LLVM/project ef7d4belibc/src/__support/math CMakeLists.txt

nit
DeltaFile
+2-2libc/src/__support/math/CMakeLists.txt
+2-21 files

LLVM/project 2552529clang/lib/Headers riscv_packed_simd.h, clang/test/CodeGen/RISCV rvp-intrinsics.c

[Clang][RISCV] Add packed widening add/sub intrinsics (#219348)

Add packed widening add/sub header wrappers for the RISC-V P extension
using generic vector IR.
DeltaFile
+208-0clang/test/CodeGen/RISCV/rvp-intrinsics.c
+151-5llvm/test/CodeGen/RISCV/rvp-simd-32.ll
+74-0cross-project-tests/intrinsic-header-tests/riscv_packed_simd.c
+67-0llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+36-0llvm/lib/Target/RISCV/RISCVInstrInfoP.td
+17-0clang/lib/Headers/riscv_packed_simd.h
+553-56 files

LLVM/project 316b0edlld/test/wasm relocatable-strings-conflict.s, lld/wasm Writer.cpp

[lld][WebAssembly] Do not coalesce segments with differing flags in -r (#219606)

In PR #210747 (commit 162d9f09299d), `addInputSegment` was changed to
union segment linking flags (`linkingFlags |= inSeg->flags`) so that
flags like `RETAIN` and `STRINGS` are preserved in `--relocatable`
output.

However, coalescing segments with differing linking flags by name alone
forces one chunk's semantics onto another:
- Clang emits ordinary string literals (`STRINGS`) and string literals
  containing embedded null characters (non-`STRINGS`) into sections
  named `.rodata..L.str`. When coalesced, non-mergeable segments
  received the `STRINGS` flag, causing downstream links to split and
  corrupt them.
- Similarly, coalescing a chunk with `RETAIN` and a chunk without
  `RETAIN` forces the un-retained chunk to inherit `RETAIN`, preventing
  `--gc-sections` from discarding it if it is unused.

Fix this by distinguishing segments by their linking flags in

    [3 lines not shown]
DeltaFile
+46-0lld/test/wasm/relocatable-strings-conflict.s
+19-7lld/wasm/Writer.cpp
+65-72 files

LLVM/project e1a4ef5clang/docs ReleaseNotes.md, clang/lib/Parse ParseDecl.cpp

[clang][Parse] Stop parsing declarator chunks after a parenthesized structured binding (#219270)

Fixes #218144
Fixes #193687

`ParseDirectDeclarator` stops right after a structured binding like `[a,
b]`, since nothing can follow it — but that check only covers the
unparenthesized form. For `([a, b])`, the binding gets parsed inside
`ParseParenDeclarator`, and the outer `ParseDirectDeclarator` doesn't
notice — it carries on into its suffix loop and parses a trailing `()`
as a function declarator. `([a, b])() {}` then looks like a function
definition, so `ActOnStartOfFunctionDef` gets handed a
`DecompositionDecl` where it expects a `FunctionDecl`:
`cast<FunctionDecl>` asserts, or segfaults later without assertions —
that's #193687. (The `b;` in the report is noise; `([a])() {}` alone
crashes.)

This patch makes `ParseDirectDeclarator` stop as well when the
parenthesized declarator turns out to be a structured binding, so

    [8 lines not shown]
DeltaFile
+30-0clang/test/Parser/GH218144.cpp
+5-0clang/lib/Parse/ParseDecl.cpp
+4-0clang/docs/ReleaseNotes.md
+39-03 files

LLVM/project 63b4d98llvm/lib/Transforms/Vectorize SLPVectorizer.cpp, llvm/test/Transforms/SLPVectorizer/X86 perfect-match-gather-undef.ll

[SLP]Fix undef/poison matching in TreeEntry::isSame

Undef no longer matches poison mask elements (poison is stronger than
undef and its lane is unrecoverable); poison matches any lane.

Fixes #219631

Reviewers: 

Pull Request: https://github.com/llvm/llvm-project/pull/219704
DeltaFile
+110-0llvm/test/Transforms/SLPVectorizer/X86/perfect-match-gather-undef.ll
+9-5llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+119-52 files

LLVM/project 902bfaellvm/include/llvm/IR Instructions.h, llvm/lib/Analysis MemoryBuiltins.cpp

[IR] Add helpers to AllocaInst to avoid getAllocatedType(). (#219594)

Add AllocaInst::getAllocationBaseSize() and AllocaInst::isScalable(),
which represent common patterns for uses which only need the size of an
alloca, but can't use getAllocationSize().

This only replaces uses which are equivalent. (There are a couple of
places in DebugInfo which getTypeSizeInBits(), which is not equivalent,
so this patch doesn't touch them for now.)
DeltaFile
+3-8llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+4-6llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
+2-5llvm/lib/Analysis/MemoryBuiltins.cpp
+7-0llvm/include/llvm/IR/Instructions.h
+5-1llvm/lib/IR/Instructions.cpp
+1-2llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+22-228 files not shown
+30-3214 files

LLVM/project 05da143libc/include/llvm-libc-macros float16-macros.h

[libc] Disable float16 on 32-bit x86 without SSE2 (#219675)

Fixes #219668

Building llvm 23.1.0 (and current main) for 32-bit x86 without SSE2
fails since APFloat.cpp started including libc's shared/math.h. All the
errors come from the float16 headers:

```
libc/src/__support/FPUtil/BasicOperations.h:63:67: error: SSE register return with SSE2 disabled
libc/src/__support/math/acosf16.h:73:14: error: invalid conversion from type '_Float16' without option '-msse2'
```

The float16 detection in float16-macros.h checks __FLT16_MANT_DIG__.
Since GCC 14 that macro is defined on ia32 even without SSE2, where
_Float16 is storage-only and any arithmetic or returning by value is an
error.
The GCC 14 release notes say to check __SSE2__ for arithmetic support
instead: https://gcc.gnu.org/gcc-14/changes.html

    [9 lines not shown]
DeltaFile
+1-1libc/include/llvm-libc-macros/float16-macros.h
+1-11 files

LLVM/project a818d43llvm/lib/Target/X86 X86ISelLowering.cpp, llvm/test/CodeGen/X86 subcarry.ll combine-adc.ll

[X86] Fold ADC(SHL(X, 1), 0, Carry) to ADC(X, X, Carry) (#219512)

During DAG optimization, expressions like `a + a` are canonicalized to
`a << 1` (`ISD::SHL X, 1`).

We need to undo that if we can use adc x, x.
DeltaFile
+3-5llvm/test/CodeGen/X86/combine-adc.ll
+8-0llvm/lib/Target/X86/X86ISelLowering.cpp
+1-2llvm/test/CodeGen/X86/subcarry.ll
+12-73 files

LLVM/project 7ec284bllvm/lib/Target/AMDGPU AMDGPUISelDAGToDAG.h AMDGPU.h, llvm/lib/Target/AMDGPU/MCTargetDesc AMDGPUInstPrinter.h

[AMDGPU] Remove dead declarations (#219649)

createSIFixControlFlowLiveIntervalsPass: The corresponding function
definition was removed on August 7, 2017 in commit
3db456820dcb89fc8bab58414de801fdfcfb0e88.

SelectADD_SUB_I64: The corresponding function definition was removed on
June 22, 2026 in commit 8062e6dc822b7832d8d988bd9cc70a04a327848a.

hasHalfRate64Ops: The corresponding function definition was removed on
January 21, 2026 in commit 2692f5ed537ff81f057340aeaba933428ba3bdd8.

printAbs, printClamp: The corresponding function definitions were
removed on June 28, 2018 in commit
c5a154db48c3cd9e16b5c74977d506415414daf7.

getVCMPXNoSDstOp: The corresponding function definition was removed on
February 11, 2021 in commit c16f776028ddd39a4d5ea39d5c3831b1bcbb8c02.
DeltaFile
+1-4llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUInstPrinter.h
+0-3llvm/lib/Target/AMDGPU/SIInstrInfo.h
+0-3llvm/lib/Target/AMDGPU/GCNSubtarget.h
+0-1llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.h
+0-1llvm/lib/Target/AMDGPU/AMDGPU.h
+1-125 files

LLVM/project 2b25240llvm/lib/Transforms/InstCombine InstCombineSelect.cpp, llvm/test/Transforms/InstCombine select-with-bitwise-ops.ll

[InstCombine] Avoid creating redundant and in foldSelectICmpAndBinOp (#219676)

when the created shl shifts out all but one bit the and with one is not needed.

proof: https://alive2.llvm.org/ce/z/MQYp6f
DeltaFile
+26-0llvm/test/Transforms/InstCombine/select-with-bitwise-ops.ll
+4-0llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+30-02 files

LLVM/project 3575a76clang/lib/CIR/Lowering/DirectToLLVM LowerToLLVMOpenCLMetadata.h LowerToLLVM.cpp, clang/test/CIR/CodeGenOpenCL version.cl

[CIR][OpenCL] Lower OpenCL language version metadata to LLVM dialect

Propagate CIR OpenCL language version module attributes as LLVM dialect named metadata before LLVM IR translation.

Assisted-by: Codex / GPT-5.6 Sol
DeltaFile
+43-0clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVMOpenCLMetadata.cpp
+16-0clang/test/CIR/CodeGenOpenCL/version.cl
+16-0clang/test/CIR/Lowering/opencl-version-metadata.cir
+2-0clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVMOpenCLMetadata.h
+2-0clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
+79-05 files

LLVM/project 8a4e938clang/lib/CIR/CodeGen CIRGenModule.h CIRGenModule.cpp, clang/test/CIR/CodeGenOpenCL version.cl

[CIR][OpenCL] Emit OpenCL language version metadata in CIR

Emit OpenCL and C++ for OpenCL language version attributes from CIRGen. Preserve the compatible OpenCL version and the C++ for OpenCL version separately so later lowering does not infer one from the other.

Assisted-by: Codex / GPT-5.6 Sol
DeltaFile
+15-0clang/test/CIR/CodeGenOpenCL/version.cl
+13-0clang/lib/CIR/CodeGen/CIRGenModule.cpp
+4-0clang/test/CodeGenCUDASPIRV/kernel-cc.cu
+1-0clang/lib/CIR/CodeGen/CIRGenModule.h
+33-04 files

LLVM/project ac9f570clang/include/clang/CIR/Dialect/IR CIRDialect.td CIROpenCLAttrs.td, clang/lib/CIR/Dialect/IR CIROpenCLAttrs.cpp CIRDialect.cpp

[CIR][OpenCL] Add OpenCL language version module attributes

Add structured CIR module attributes for OpenCL and C++ for OpenCL language versions. Verify their module-level placement and version components so lowering can consume explicit source-language version state.

Assisted-by: Codex / GPT-5.6 Sol
DeltaFile
+76-0clang/lib/CIR/Dialect/IR/CIRDialect.cpp
+73-0clang/test/CIR/IR/invalid-version.cir
+28-0clang/include/clang/CIR/Dialect/IR/CIROpenCLAttrs.td
+19-0clang/test/CIR/IR/version.cir
+15-0clang/lib/CIR/Dialect/IR/CIROpenCLAttrs.cpp
+5-0clang/include/clang/CIR/Dialect/IR/CIRDialect.td
+216-01 files not shown
+219-17 files

LLVM/project e94b49eclang/test/CIR/CodeGenOpenCL address-space-conversions.cl address-spaces.cl, clang/test/CIR/IR address-space.cir

[CIR][OpenCL][NFC] Add language address-space preservation coverage (#219678)

Expand coverage for preserving OpenCL language address spaces across CIR
textual representation and source emission before target lowering.

Assisted-by: Codex / GPT-5.6 Sol
DeltaFile
+53-13clang/test/CIR/IR/address-space.cir
+43-0clang/test/CIR/CodeGenOpenCL/address-spaces.cl
+23-0clang/test/CIR/CodeGenOpenCL/address-space-conversions.cl
+119-133 files

LLVM/project 87b1a2fmlir/lib/Dialect/Ptr/IR PtrTypes.cpp, mlir/test/Dialect/Ptr layout.mlir

[mlir][Ptr] Don't assert when the default memory space isn't a MemorySpaceAttrInterface (#217512)
DeltaFile
+19-0mlir/test/Dialect/Ptr/layout.mlir
+4-4mlir/lib/Dialect/Ptr/IR/PtrTypes.cpp
+23-42 files

LLVM/project 4717a10llvm/lib/Target/AArch64 AArch64TargetTransformInfo.cpp, llvm/test/Analysis/CostModel/AArch64 free-widening-casts.ll cast.ll

[AArch64] Refine large sext/zext costs. (#216683)

A v2i64->v2i128 sext and zext will be scalarized to a pair of extracts
and individual extends.
DeltaFile
+6-6llvm/test/Analysis/CostModel/AArch64/arith-overflow.ll
+12-0llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
+4-4llvm/test/Analysis/CostModel/AArch64/cast.ll
+1-1llvm/test/Analysis/CostModel/AArch64/free-widening-casts.ll
+23-114 files

LLVM/project ccf0113llvm/lib/CodeGen/SelectionDAG DAGCombiner.cpp, llvm/test/CodeGen/X86/apx cf.ll

[DAGCombiner] Make sure VT > SrcVT before doing ANY_EXTEND (#219674)

This happens when we have i1 (bitcast (v1i1 (scalar_to_vector i1))).

Fixes: #219637

Assisted-by: Claude Opus 4.8
DeltaFile
+12-0llvm/test/CodeGen/X86/apx/cf.ll
+2-1llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+14-12 files

LLVM/project d156987orc-rt/lib/bedrock ExecutorProcessInfo.cpp

[orc-rt] Add context to detectPageSize's sysconf error. (#219670)

It only reported the strerror text without context, so failure would
surface as a bare "Invalid argument" with nothing to say what failed.
DeltaFile
+4-1orc-rt/lib/bedrock/ExecutorProcessInfo.cpp
+4-11 files

LLVM/project 823efd8libcxx/include version, libcxx/include/__expected expected.h

[libc++] Implement P3798R1: The unexpected in `std::expected` (#219236)

Closes https://github.com/llvm/llvm-project/issues/204394
Re-application of https://github.com/llvm/llvm-project/pull/204826
(45a65bb48b5925707f43d08e30df2263a5e4e268)

Implements P3798R1 and related tests.
DeltaFile
+40-0libcxx/test/std/utilities/expected/expected.void/observers/has_error.pass.cpp
+40-0libcxx/test/std/utilities/expected/expected.expected/observers/has_error.pass.cpp
+8-0libcxx/test/libcxx/utilities/expected/nodiscard.verify.cpp
+8-0libcxx/include/__expected/expected.h
+4-1libcxx/include/version
+2-2libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp
+102-35 files not shown
+109-711 files

LLVM/project 7e1652borc-rt/include/orc-rt-internal/support/sys Errno.h, orc-rt/lib/bedrock ExecutorProcessInfo.cpp

[orc-rt] Add sys::strError, replacing strerror. (#219666)

strerror may return a pointer to a static buffer, so it isn't safe to
call from more than one thread, and the memory operations using it are
exactly those that run concurrently.
DeltaFile
+55-0orc-rt/lib/bedrock/posix/Errno.cpp
+44-0orc-rt/test/unit/support/sys/ErrnoTest.cpp
+29-0orc-rt/include/orc-rt-internal/support/sys/Errno.h
+4-4orc-rt/lib/bedrock/posix/Memory.cpp
+2-1orc-rt/lib/bedrock/ExecutorProcessInfo.cpp
+2-0orc-rt/test/unit/CMakeLists.txt
+136-51 files not shown
+137-57 files

LLVM/project f1537cfclang/lib/CIR/CodeGen CIRGenExprScalar.cpp, clang/test/CIR/CodeGen vector-strict-fp.cpp

[CIR] Support fp strict for VecCmpOp in UnaryLNot (#218244)

Support FP strict mode for VecCmpOp in UnaryLNot
DeltaFile
+28-0clang/test/CIR/CodeGen/vector-strict-fp.cpp
+1-3clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
+29-32 files

LLVM/project fdf0409llvm/lib/Target/WebAssembly WebAssemblyDebugValueManager.cpp

[WebAssembly] Avoid scanning unrelated debug values (NFCI) (#218378)

RegStackify looks for debug values when moving an instruction.

But when a debug use comes before the definition, it may collect values
for a lot of unrelated variables until the end of the block.

Stop early once all relevant values have been found instead.

(cherry picked from commit 5bff640ac99dc29ab61cb55bdfc9b992d09b5a85)
DeltaFile
+74-54llvm/lib/Target/WebAssembly/WebAssemblyDebugValueManager.cpp
+74-541 files

LLVM/project cefac32llvm/lib/DWARFLinker/Parallel DependencyTracker.h DependencyTracker.cpp, llvm/test/tools/dsymutil/X86/DWARFLinkerParallel odr-shared-subtree-demotion.s

[DWARFLinker] Walk each shared subtree's dependencies once (#218072)

cdc31cfa66f0 made every root that references an already-marked subtree
re-walk that subtree to record the completeness dependencies it
contributes, which is what makes the recorded dependency set complete
and independent of thread interleaving. That walk replaced the
isAlreadyMarked short-circuit which had kept marking linear, so a widely
shared subtree is re-parsed and re-resolved once per referencing root.

Linking a RelWithDebInfo clang went from 27s to 67s of wall time and
from 242s to 1447s of CPU, peak memory grew from 35GB to 63GB, and 7.0
billion dependencies were recorded for an unchanged dSYM.

Record only that a root carries the subtree's dependencies and walk each
distinct subtree once. All of a subtree's dependencies demote the same
root, so the expansion stops at the first one that does.

A subtree contributes two kinds of dependency. One kind is recorded
under the root referencing the subtree, varies with that root, and is

    [24 lines not shown]
DeltaFile
+298-0llvm/test/tools/dsymutil/X86/DWARFLinkerParallel/odr-shared-subtree-demotion.s
+164-55llvm/lib/DWARFLinker/Parallel/DependencyTracker.cpp
+121-14llvm/lib/DWARFLinker/Parallel/DependencyTracker.h
+583-693 files

LLVM/project 5f58ba5lldb/source/API SBEnvironment.cpp, lldb/unittests/API CMakeLists.txt SBEnvironmentTest.cpp

[lldb][API] Fix SBEnvironment crash when Set is called with a nullptr. (#218906)

Crashed because std::string is constructed with a nullptr. Wrap with
`llvm::StringRef`.

Add a unittest

(cherry picked from commit 69db8489be2f4e3cb1cf3f874403481d206b545c)
DeltaFile
+36-0lldb/unittests/API/SBEnvironmentTest.cpp
+12-3lldb/source/API/SBEnvironment.cpp
+1-0lldb/unittests/API/CMakeLists.txt
+49-33 files

LLVM/project b201342clang/lib/Format UnwrappedLineParser.cpp, clang/unittests/Format TokenAnnotatorTest.cpp

[clang-format] Harden star and amp annotation (#212856)

At this point we can't (or won't) decide wether this is a template
argument or just an expression, opt out of the specialized (and in the
test cases wrong) assignment.

Fixes #212622

(cherry picked from commit af15d15f9bbd5ac5d3f020d270b38ffe01b0a72a)

[clang-format][NFC] Apply review comments (#218142)

That were missed while merging #212856.

(cherry picked from commit 8dba93818258d95c46fa2c17e902a8256e4d91b5)
DeltaFile
+18-3clang/lib/Format/UnwrappedLineParser.cpp
+12-0clang/unittests/Format/TokenAnnotatorTest.cpp
+30-32 files