Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
459a64b
[lldb] Diagnose unsupported configurations when targeting the Limited…
JDevlieghere Nov 14, 2025
e8cc0d2
Revert "[SLP]Check if the copyable element is a sub instruciton with …
alexey-bataev Nov 14, 2025
4c4ffd3
[ProfCheck] Refactor Select Instrumentation to use Early Exits (#168086)
boomanaiden154 Nov 14, 2025
e02fdf0
[CIR] Upstream CIR codegen for vec_ext x86 builtins (#167942)
Thibault-Monnier Nov 14, 2025
66d5f6a
[lldb] fix parallel module loading deadlock for Linux DYLD (#166480)
zhyty Nov 14, 2025
326d4e9
[SLP]Check if the copyable element is a sub instruciton with abs in i…
alexey-bataev Nov 14, 2025
21502bd
[lldb] Drop support for the Buffer Protocol (#168144)
JDevlieghere Nov 15, 2025
55f634c
[libcxx][Github] Attempt to Fix libcxx Container Push
boomanaiden154 Nov 15, 2025
94c384c
[lldb] Enforce Py_LIMITED_API in the SWIG typemaps (#168147)
JDevlieghere Nov 15, 2025
4eea157
[GlobalISel] Return byte offsets from computeValueLLTs (NFC) (#166747)
s-barannikov Nov 15, 2025
4530047
[lldb] Add the ability to load DWARF64 .debug_str_offsets tables for …
clayborg Nov 15, 2025
5305a53
[gn] port c29b29bb6a7f (_LIBCPP_ASSERTION_SEMANTIC_DEFAULT)
nico Nov 15, 2025
9036e23
[libc++] Apply `[[nodiscard]]` to `in/out_ptr` (#167097)
H-G-Hristov Nov 15, 2025
6214dcc
[Unwind][AArch64] Match sigreturn instructions in big endian (#167139)
hstk30-hw Nov 15, 2025
5442aa1
[RDF] Rename RegisterId field in RegisterRef Reg->Id. NFC (#168154)
topperc Nov 15, 2025
1f3e2c6
[gn] Let tablegen() add root_build_dir to include search path
nico Nov 15, 2025
7016d43
[NFC][SpecialCaseList] Convert `preprocess` into `LazyInit` (#167281)
vitalybuka Nov 15, 2025
321a97e
[AMDGPU] Delete some dead code (NFC) (#167891)
s-barannikov Nov 15, 2025
afc80b7
merge main into amd-staging
z1-cciauto Nov 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/libcxx-build-containers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ jobs:

- name: Push the images
if: github.event_name == 'push'
run: docker compose push libcxx-linux-builder-base libcxx-linux-builder libcxx-android-builder
run: docker compose --file libcxx/utils/ci/docker/docker-compose.yml push libcxx-linux-builder-base libcxx-linux-builder libcxx-android-builder
env:
TAG: ${{ github.sha }}

# We create tarballs with the images and upload them as artifacts, since that's useful for testing
# the images when making changes.
Expand Down
6 changes: 4 additions & 2 deletions clang/lib/CIR/CodeGen/CIRGenBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,10 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
return getConstantInt(loc, getUInt32Ty(), c);
}
cir::ConstantOp getSInt64(uint64_t c, mlir::Location loc) {
cir::IntType sInt64Ty = getSInt64Ty();
return cir::ConstantOp::create(*this, loc, cir::IntAttr::get(sInt64Ty, c));
return getConstantInt(loc, getSInt64Ty(), c);
}
cir::ConstantOp getUInt64(uint64_t c, mlir::Location loc) {
return getConstantInt(loc, getUInt64Ty(), c);
}

mlir::Value createNeg(mlir::Value value) {
Expand Down
16 changes: 16 additions & 0 deletions clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,22 @@ CIRGenFunction::emitTargetBuiltinExpr(unsigned builtinID, const CallExpr *e,
getTarget().getTriple().getArch());
}

mlir::Value CIRGenFunction::emitScalarOrConstFoldImmArg(
const unsigned iceArguments, const unsigned idx, const Expr *argExpr) {
mlir::Value arg = {};
if ((iceArguments & (1 << idx)) == 0) {
arg = emitScalarExpr(argExpr);
} else {
// If this is required to be a constant, constant fold it so that we
// know that the generated intrinsic gets a ConstantInt.
const std::optional<llvm::APSInt> result =
argExpr->getIntegerConstantExpr(getContext());
assert(result && "Expected argument to be a constant");
arg = builder.getConstInt(getLoc(argExpr->getSourceRange()), *result);
}
return arg;
}

/// Given a builtin id for a function like "__builtin_fabsf", return a Function*
/// for "fabsf".
cir::FuncOp CIRGenModule::getBuiltinLibFunction(const FunctionDecl *fd,
Expand Down
25 changes: 21 additions & 4 deletions clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "clang/Basic/Builtins.h"
#include "clang/Basic/TargetBuiltins.h"
#include "clang/CIR/MissingFeatures.h"
#include "llvm/IR/IntrinsicsX86.h"

using namespace clang;
using namespace clang::CIRGen;
Expand Down Expand Up @@ -66,9 +65,8 @@ mlir::Value CIRGenFunction::emitX86BuiltinExpr(unsigned builtinID,
getContext().GetBuiltinType(builtinID, error, &iceArguments);
assert(error == ASTContext::GE_None && "Error while getting builtin type.");

for (auto [idx, arg] : llvm::enumerate(e->arguments())) {
for (auto [idx, arg] : llvm::enumerate(e->arguments()))
ops.push_back(emitScalarOrConstFoldImmArg(iceArguments, idx, arg));
}

CIRGenBuilderTy &builder = getBuilder();
mlir::Type voidTy = builder.getVoidTy();
Expand Down Expand Up @@ -98,6 +96,10 @@ mlir::Value CIRGenFunction::emitX86BuiltinExpr(unsigned builtinID,
case X86::BI__builtin_ia32_undef128:
case X86::BI__builtin_ia32_undef256:
case X86::BI__builtin_ia32_undef512:
cgm.errorNYI(e->getSourceRange(),
std::string("unimplemented X86 builtin call: ") +
getContext().BuiltinInfo.getName(builtinID));
return {};
case X86::BI__builtin_ia32_vec_ext_v4hi:
case X86::BI__builtin_ia32_vec_ext_v16qi:
case X86::BI__builtin_ia32_vec_ext_v8hi:
Expand All @@ -107,7 +109,22 @@ mlir::Value CIRGenFunction::emitX86BuiltinExpr(unsigned builtinID,
case X86::BI__builtin_ia32_vec_ext_v32qi:
case X86::BI__builtin_ia32_vec_ext_v16hi:
case X86::BI__builtin_ia32_vec_ext_v8si:
case X86::BI__builtin_ia32_vec_ext_v4di:
case X86::BI__builtin_ia32_vec_ext_v4di: {
unsigned numElts = cast<cir::VectorType>(ops[0].getType()).getSize();

uint64_t index =
ops[1].getDefiningOp<cir::ConstantOp>().getIntValue().getZExtValue();

index &= numElts - 1;

cir::ConstantOp indexVal =
builder.getUInt64(index, getLoc(e->getExprLoc()));

// These builtins exist so we can ensure the index is an ICE and in range.
// Otherwise we could just do this in the header file.
return cir::VecExtractOp::create(builder, getLoc(e->getExprLoc()), ops[0],
indexVal);
}
case X86::BI__builtin_ia32_vec_set_v4hi:
case X86::BI__builtin_ia32_vec_set_v16qi:
case X86::BI__builtin_ia32_vec_set_v8hi:
Expand Down
22 changes: 0 additions & 22 deletions clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1442,28 +1442,6 @@ mlir::Value CIRGenFunction::emitPromotedScalarExpr(const Expr *e,
return ScalarExprEmitter(*this, builder).Visit(const_cast<Expr *>(e));
}

mlir::Value CIRGenFunction::emitScalarOrConstFoldImmArg(unsigned iceArguments,
unsigned index,
const Expr *arg) {
mlir::Value result{};

// The bit at the specified index indicates whether the argument is required
// to be a constant integer expression.
bool isArgRequiredToBeConstant = (iceArguments & (1 << index));

if (!isArgRequiredToBeConstant) {
result = emitScalarExpr(arg);
} else {
// If this is required to be a constant, constant fold it so that we
// know that the generated intrinsic gets a ConstantInt.
std::optional<llvm::APSInt> iceOpt =
arg->getIntegerConstantExpr(getContext());
assert(iceOpt && "Expected argument to be a constant");
result = builder.getConstInt(getLoc(arg->getSourceRange()), *iceOpt);
}
return result;
}

[[maybe_unused]] static bool mustVisitNullValue(const Expr *e) {
// If a null pointer expression's type is the C++0x nullptr_t and
// the expression is not a simple literal, it must be evaluated
Expand Down
6 changes: 3 additions & 3 deletions clang/lib/CIR/CodeGen/CIRGenFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -1546,9 +1546,6 @@ class CIRGenFunction : public CIRGenTypeCache {
mlir::Value emitScalarExpr(const clang::Expr *e,
bool ignoreResultAssign = false);

mlir::Value emitScalarOrConstFoldImmArg(unsigned iceArguments, unsigned index,
const Expr *arg);

mlir::Value emitScalarPrePostIncDec(const UnaryOperator *e, LValue lv,
cir::UnaryOpKind kind, bool isPre);

Expand Down Expand Up @@ -1721,6 +1718,9 @@ class CIRGenFunction : public CIRGenTypeCache {
void emitScalarInit(const clang::Expr *init, mlir::Location loc,
LValue lvalue, bool capturedByInit = false);

mlir::Value emitScalarOrConstFoldImmArg(unsigned iceArguments, unsigned idx,
const Expr *argExpr);

void emitStaticVarDecl(const VarDecl &d, cir::GlobalLinkageKind linkage);

void emitStoreOfComplex(mlir::Location loc, mlir::Value v, LValue dest,
Expand Down
15 changes: 15 additions & 0 deletions clang/test/CIR/CodeGen/X86/sse2-builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,21 @@

#include <immintrin.h>

// Lowering to pextrw requires optimization.
int test_mm_extract_epi16(__m128i A) {
// CIR-LABEL: test_mm_extract_epi16
// CIR %{{.*}} = cir.vec.extract %{{.*}}[%{{.*}} : {{!u32i|!u64i}}] : !cir.vector<!s16i x 8>
// CIR %{{.*}} = cir.cast integral %{{.*}} : !u16i -> !s32i

// LLVM-LABEL: test_mm_extract_epi16
// LLVM: extractelement <8 x i16> %{{.*}}, {{i32|i64}} 1
// LLVM: zext i16 %{{.*}} to i32

// OGCG-LABEL: test_mm_extract_epi16
// OGCG: extractelement <8 x i16> %{{.*}}, {{i32|i64}} 1
// OGCG: zext i16 %{{.*}} to i32
return _mm_extract_epi16(A, 1);
}

void test_mm_clflush(void* A) {
// CIR-LABEL: test_mm_clflush
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__memory/inout_ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class inout_ptr_t {
};

template <class _Pointer = void, class _Smart, class... _Args>
_LIBCPP_HIDE_FROM_ABI auto inout_ptr(_Smart& __s, _Args&&... __args) {
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI auto inout_ptr(_Smart& __s, _Args&&... __args) {
using _Ptr = conditional_t<is_void_v<_Pointer>, __pointer_of_t<_Smart>, _Pointer>;
return std::inout_ptr_t<_Smart, _Ptr, _Args&&...>(__s, std::forward<_Args>(__args)...);
}
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__memory/out_ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class out_ptr_t {
};

template <class _Pointer = void, class _Smart, class... _Args>
_LIBCPP_HIDE_FROM_ABI auto out_ptr(_Smart& __s, _Args&&... __args) {
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI auto out_ptr(_Smart& __s, _Args&&... __args) {
using _Ptr = conditional_t<is_void_v<_Pointer>, __pointer_of_t<_Smart>, _Pointer>;
return std::out_ptr_t<_Smart, _Ptr, _Args&&...>(__s, std::forward<_Args>(__args)...);
}
Expand Down
29 changes: 29 additions & 0 deletions libcxx/test/libcxx/utilities/smartptr/nodiscard.verify.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

// REQUIRES: std-at-least-c++23

// <memory>

// Check that functions are marked [[nodiscard]]

#include <memory>

#include "test_macros.h"

void test() {
#if TEST_STD_VER >= 23
{
std::unique_ptr<int> uPtr;
// [inout.ptr]
std::inout_ptr(uPtr); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
// [out.ptr]
std::out_ptr(uPtr); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
}
#endif
}
17 changes: 16 additions & 1 deletion libunwind/src/UnwindCursor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2865,6 +2865,21 @@ void UnwindCursor<A, R>::setInfoBasedOnIPRegister(bool isReturnAddress) {

#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) && \
defined(_LIBUNWIND_TARGET_AARCH64)

/*
* The linux sigreturn restorer stub will always have the form:
*
* d2801168 movz x8, #0x8b
* d4000001 svc #0x0
*/
#if defined(__AARCH64EB__)
#define MOVZ_X8_8B 0x681180d2
#define SVC_0 0x010000d4
#else
#define MOVZ_X8_8B 0xd2801168
#define SVC_0 0xd4000001
#endif

template <typename A, typename R>
bool UnwindCursor<A, R>::setInfoForSigReturn(Registers_arm64 &) {
// Look for the sigreturn trampoline. The trampoline's body is two
Expand All @@ -2889,7 +2904,7 @@ bool UnwindCursor<A, R>::setInfoForSigReturn(Registers_arm64 &) {
return false;
auto *instructions = reinterpret_cast<const uint32_t *>(pc);
// Look for instructions: mov x8, #0x8b; svc #0x0
if (instructions[0] != 0xd2801168 || instructions[1] != 0xd4000001)
if (instructions[0] != MOVZ_X8_8B || instructions[1] != SVC_0)
return false;

_info = {};
Expand Down
75 changes: 24 additions & 51 deletions lldb/bindings/python/python-typemaps.swig
Original file line number Diff line number Diff line change
Expand Up @@ -628,61 +628,34 @@ template <> bool SetNumberFromPyObject<double>(double &number, PyObject *obj) {
}
}

// These two pybuffer macros are copied out of swig/Lib/python/pybuffer.i,
// and fixed so they will not crash if PyObject_GetBuffer fails.
// https://github.com/swig/swig/issues/1640
//
// I've also moved the call to PyBuffer_Release to the end of the SWIG wrapper,
// doing it right away is not legal according to the python buffer protocol.
%inline %{
struct Py_buffer_RAII {
Py_buffer buffer = {};
Py_buffer_RAII(){};
Py_buffer &operator=(const Py_buffer_RAII &) = delete;
Py_buffer_RAII(const Py_buffer_RAII &) = delete;
~Py_buffer_RAII() {
if (buffer.obj)
PyBuffer_Release(&buffer);
}
};
%}

%define %pybuffer_mutable_binary(TYPEMAP, SIZE)
%typemap(in) (TYPEMAP, SIZE) (Py_buffer_RAII view) {
int res;
Py_ssize_t size = 0;
void *buf = 0;
res = PyObject_GetBuffer($input, &view.buffer, PyBUF_WRITABLE);
if (res < 0) {
PyErr_Clear();
%argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum);
}
size = view.buffer.len;
buf = view.buffer.buf;
$1 = ($1_ltype)buf;
$2 = ($2_ltype)(size / sizeof($*1_type));
}
%enddef

%define %pybuffer_binary(TYPEMAP, SIZE)
%typemap(in) (TYPEMAP, SIZE) (Py_buffer_RAII view) {
int res;
Py_ssize_t size = 0;
const void *buf = 0;
res = PyObject_GetBuffer($input, &view.buffer, PyBUF_CONTIG_RO);
if (res < 0) {
PyErr_Clear();
%argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum);
// Typemap for SBFile::Write.
%typemap(in) (const uint8_t *buf, size_t num_bytes) {
if (PythonByteArray::Check($input)) {
PythonByteArray bytearray(PyRefType::Borrowed, $input);
$1 = (uint8_t *)bytearray.GetBytes().data();
$2 = bytearray.GetSize();
} else if (PythonBytes::Check($input)) {
PythonBytes bytes(PyRefType::Borrowed, $input);
$1 = (uint8_t *)bytes.GetBytes().data();
$2 = bytes.GetSize();
} else {
PyErr_SetString(PyExc_ValueError, "Expecting a bytes or bytearray object");
SWIG_fail;
}
size = view.buffer.len;
buf = view.buffer.buf;
$1 = ($1_ltype)buf;
$2 = ($2_ltype)(size / sizeof($*1_type));
}
%enddef

%pybuffer_binary(const uint8_t *buf, size_t num_bytes);
%pybuffer_mutable_binary(uint8_t *buf, size_t num_bytes);
// Typemap for SBFile::Read.
%typemap(in) (uint8_t *buf, size_t num_bytes) {
if (PythonByteArray::Check($input)) {
PythonByteArray bytearray(PyRefType::Borrowed, $input);
$1 = (uint8_t *)bytearray.GetBytes().data();
$2 = bytearray.GetSize();
} else {
PyErr_SetString(PyExc_ValueError, "Expecting a bytearray");
SWIG_fail;
}
}

%typemap(in) (const char **symbol_name, uint32_t num_names) {
using namespace lldb_private;
Expand Down
7 changes: 5 additions & 2 deletions lldb/bindings/python/python-wrapper.swig
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,11 @@ bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallTypeScript(

PyObject *pfunc_impl = nullptr;

if (pyfunct_wrapper && *pyfunct_wrapper &&
PyFunction_Check(*pyfunct_wrapper)) {
if (pyfunct_wrapper && *pyfunct_wrapper
#ifndef Py_LIMITED_API
&& PyFunction_Check(*pyfunct_wrapper)
#endif
) {
pfunc_impl = (PyObject *)(*pyfunct_wrapper);
if (pfunc_impl->ob_refcnt == 1) {
Py_XDECREF(pfunc_impl);
Expand Down
5 changes: 5 additions & 0 deletions lldb/bindings/python/python.swig
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ except ImportError:
// Parameter types will be used in the autodoc string.
%feature("autodoc", "1");

// Include lldb-python first as it sets Py_LIMITED_API.
%begin %{
#include "../source/Plugins/ScriptInterpreter/Python/lldb-python.h"
%}

%pythoncode%{
import uuid
import re
Expand Down
14 changes: 13 additions & 1 deletion lldb/cmake/modules/LLDBConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,25 @@ if (LLDB_ENABLE_PYTHON)
"Path to use as PYTHONHOME in lldb. If a relative path is specified, it will be resolved at runtime relative to liblldb directory.")
endif()

if (SWIG_VERSION VERSION_GREATER_EQUAL "4.2" AND NOT LLDB_EMBED_PYTHON_HOME)
# Enable targeting the Python Limited C API.
set(PYTHON_LIMITED_API_MIN_SWIG_VERSION "4.2")
if (SWIG_VERSION VERSION_GREATER_EQUAL PYTHON_LIMITED_API_MIN_SWIG_VERSION
AND NOT LLDB_EMBED_PYTHON_HOME)
set(default_enable_python_limited_api ON)
else()
set(default_enable_python_limited_api OFF)
endif()
option(LLDB_ENABLE_PYTHON_LIMITED_API "Force LLDB to only use the Python Limited API (requires SWIG 4.2 or later)"
${default_enable_python_limited_api})

# Diagnose unsupported configurations.
if (LLDB_ENABLE_PYTHON_LIMITED_API AND LLDB_EMBED_PYTHON_HOME)
message(SEND_ERROR "LLDB_ENABLE_PYTHON_LIMITED_API is not compatible with LLDB_EMBED_PYTHON_HOME")
endif()
if (LLDB_ENABLE_PYTHON_LIMITED_API AND SWIG_VERSION VERSION_LESS PYTHON_LIMITED_API_MIN_SWIG_VERSION)
message(SEND_ERROR "LLDB_ENABLE_PYTHON_LIMITED_API is not compatible with SWIG ${SWIG_VERSION} (requires SWIG ${PYTHON_LIMITED_API_MIN_SWIG_VERSION})")
endif()

else()
# Even if Python scripting is disabled, we still need a Python interpreter to
# build, for example to generate SBLanguages.h.
Expand Down
Loading