Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
db2d8fc
[BOLT][NFC] Add MCPlusBuilder unittests for PAuth helpers (#162251)
bgergely0 Oct 16, 2025
65363e6
[WebAssembly] Partial SMLA with relaxed dot (#163529)
sparker-arm Oct 16, 2025
4c4c028
[clang-tidy][bazel][NFC] enable custom checks in bazel build (#160548)
HerrCai0907 Oct 16, 2025
0ede563
[clang][DebugInfo] Emit DW_AT_language_{name, version} for DWARFv6 (#…
Michael137 Oct 16, 2025
06cc20c
[clang][bytecode] Diagnose out-of-bounds enum values in .... (#163530)
tbaederr Oct 16, 2025
8570ba2
[clang][analyzer] Add checker 'core.NullPointerArithm' (#157129)
balazske Oct 16, 2025
d50423e
Revert "[libc] Enable intermediate computation in float for baremetal…
petrhosek Oct 16, 2025
10be254
[clang] Fix catching pointers by reference on mingw targets (#162546)
mstorsjo Oct 16, 2025
ef4fbb5
[flang][OpenACC] add pass to bufferize fir.box recipes (#163543)
jeanPerier Oct 16, 2025
bef39e6
[libc++][C++03] Don't run cstdalign.compile.pass.cpp (#163357)
philnik777 Oct 16, 2025
be5941e
[libc++][C++03] Fix alg.copy/copy.pass.cpp (#163365)
philnik777 Oct 16, 2025
35d8360
[libc++][C++03] Make __libcpp_verbose_abort noexcept and fix the test…
philnik777 Oct 16, 2025
1f9a70f
[libc++][C++03] Fix support.dynamic/libcpp_deallocate.sh.cpp (#163378)
philnik777 Oct 16, 2025
bc3bc74
[libc++] Remove a redundant check from __hash_table::__emplace_unique…
philnik777 Oct 16, 2025
cf55dfb
[clang][bytecode] Fix null Descriptor dereference in ArrayElemPtrPop …
term-est Oct 16, 2025
9c456e5
[ORC] Add SimpleRemoteMemoryMapper (new MemoryMapper implementation).…
lhames Oct 16, 2025
a42546e
[gn build] Port 9c456e5eb7ed
llvmgnsyncbot Oct 16, 2025
71b001e
[MachinePipeliner] Add test missed in #154940 (NFC) (#163350)
kasuga-fj Oct 16, 2025
a4a6d2e
[mlir][linalg][nfc] Clean up vectorization tests (#163379)
banach-space Oct 16, 2025
910c868
[Clang] Handle ppc_fp128 in N3364 test (NFC)
nikic Oct 16, 2025
95eb2db
[libc++] std::cmp_less and other integer comparison functions could b…
kisuhorikka Oct 16, 2025
c48aa54
[LV][NFC] Remove undef from function return values (#163578)
david-arm Oct 16, 2025
62e786a
[mlir][tosa] Add specification versioning to target environment (#156…
lhutton1 Oct 16, 2025
c46fec8
[Polly] Remove PolyhedralInfo (#124437)
Meinersbur Oct 16, 2025
c336625
[InstCombine] Call InstSimplify for cast instructions (#162849)
nikic Oct 16, 2025
8160025
[lldb][util] Use Python3 print function in example code
DavidSpickett Oct 16, 2025
f7e9968
[Offload] XFAIL pgo tests until resolved (#163722)
jplehr Oct 16, 2025
7ab271c
[lldb][examples] Use Python3 versions of types module in performance.py
DavidSpickett Oct 16, 2025
65c24e5
[lldb][examples] Use "chr" in CFString.py
DavidSpickett Oct 16, 2025
d2a8486
[Clang] VectorExprEvaluator::VisitCallExpr / InterpretBuiltin - Allow…
chaitanyav Oct 16, 2025
57b797f
[LLVM][CodeGen][SVE] Add lowering for ISD::VECREDUCE_MUL/FMUL. (#161842)
paulwalker-arm Oct 16, 2025
4773751
[AMDGPU] Add product names to processor table (#163717)
jplehr Oct 16, 2025
e3f9b4c
[X86] Relax vector element width constraint on SSE pmul/madd asm comm…
RKSimon Oct 16, 2025
33503d0
[AMDGPU] Preserve literal operands on disassembling. (#163376)
kosarev Oct 16, 2025
0f35df3
[MLIR][LLVM] Add inline_hint as a first class function attribute (#16…
mmha Oct 16, 2025
d342fa1
[llvm][utils] Run 2to3 on clang-parse-diagnostics-file
DavidSpickett Oct 16, 2025
9393f23
[SimpleLoopUnswitch] Regenerate UTC test. NFC
lukel97 Oct 16, 2025
e764b6d
[lldb][test] Skip `array` test due to ASTImport lambda issue (#163735)
frederick-vs-ja Oct 16, 2025
6ea5456
[llvm][utils] Run 2to3 on zkill script
DavidSpickett Oct 16, 2025
44c9692
[lld][utils] Remove Python2 compatible imports in benchmark.py
DavidSpickett Oct 16, 2025
88b7707
fix clang_cmake_builddir (#161220)
rjodinchr Oct 16, 2025
41b1ff8
[X86] rem-seteq-illegal-types.ll - remove unnecessary X64 RUN (#163742)
RKSimon Oct 16, 2025
4ae1233
[X86] var-permute-128.ll - fix AVX512F/AVX512BW check prefix clashes …
RKSimon Oct 16, 2025
c2eed93
[llvm][utils] Remove Python2 comaptaible import in unicode-case-fold.py
DavidSpickett Oct 16, 2025
bd79667
[flang][OpenMP] Set REQUIRES flags on program unit symbol (#163448)
kparzysz Oct 16, 2025
8f04f07
[VPlan] Clarify legality check in licm (NFC) (#162486)
artagnon Oct 16, 2025
c8b8fa2
[flang][OpenMP] Format check-omp-structure.cpp, NFC (#163750)
kparzysz Oct 16, 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
76 changes: 76 additions & 0 deletions bolt/unittests/Core/MCPlusBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,82 @@ TEST_P(MCPlusBuilderTester, testAccessedRegsMultipleDefs) {
{AArch64::W5, AArch64::X5, AArch64::W5_HI});
}

TEST_P(MCPlusBuilderTester, AArch64_Psign_Pauth_variants) {
if (GetParam() != Triple::aarch64)
GTEST_SKIP();

MCInst Paciasp = MCInstBuilder(AArch64::PACIASP);
MCInst Pacibsp = MCInstBuilder(AArch64::PACIBSP);
ASSERT_TRUE(BC->MIB->isPSignOnLR(Paciasp));
ASSERT_TRUE(BC->MIB->isPSignOnLR(Pacibsp));

MCInst PaciaSPLR =
MCInstBuilder(AArch64::PACIA).addReg(AArch64::LR).addReg(AArch64::SP);
MCInst PacibSPLR =
MCInstBuilder(AArch64::PACIB).addReg(AArch64::LR).addReg(AArch64::SP);
ASSERT_TRUE(BC->MIB->isPSignOnLR(PaciaSPLR));
ASSERT_TRUE(BC->MIB->isPSignOnLR(PacibSPLR));

MCInst PacizaX5 = MCInstBuilder(AArch64::PACIZA).addReg(AArch64::X5);
MCInst PacizbX5 = MCInstBuilder(AArch64::PACIZB).addReg(AArch64::X5);
ASSERT_FALSE(BC->MIB->isPSignOnLR(PacizaX5));
ASSERT_FALSE(BC->MIB->isPSignOnLR(PacizbX5));

MCInst Paciaz = MCInstBuilder(AArch64::PACIZA).addReg(AArch64::LR);
MCInst Pacibz = MCInstBuilder(AArch64::PACIZB).addReg(AArch64::LR);
ASSERT_TRUE(BC->MIB->isPSignOnLR(Paciaz));
ASSERT_TRUE(BC->MIB->isPSignOnLR(Pacibz));

MCInst Pacia1716 = MCInstBuilder(AArch64::PACIA1716);
MCInst Pacib1716 = MCInstBuilder(AArch64::PACIB1716);
ASSERT_FALSE(BC->MIB->isPSignOnLR(Pacia1716));
ASSERT_FALSE(BC->MIB->isPSignOnLR(Pacib1716));

MCInst Pacia171615 = MCInstBuilder(AArch64::PACIA171615);
MCInst Pacib171615 = MCInstBuilder(AArch64::PACIB171615);
ASSERT_FALSE(BC->MIB->isPSignOnLR(Pacia171615));
ASSERT_FALSE(BC->MIB->isPSignOnLR(Pacib171615));

MCInst Autiasp = MCInstBuilder(AArch64::AUTIASP);
MCInst Autibsp = MCInstBuilder(AArch64::AUTIBSP);
ASSERT_TRUE(BC->MIB->isPAuthOnLR(Autiasp));
ASSERT_TRUE(BC->MIB->isPAuthOnLR(Autibsp));

MCInst AutiaSPLR =
MCInstBuilder(AArch64::AUTIA).addReg(AArch64::LR).addReg(AArch64::SP);
MCInst AutibSPLR =
MCInstBuilder(AArch64::AUTIB).addReg(AArch64::LR).addReg(AArch64::SP);
ASSERT_TRUE(BC->MIB->isPAuthOnLR(AutiaSPLR));
ASSERT_TRUE(BC->MIB->isPAuthOnLR(AutibSPLR));

MCInst AutizaX5 = MCInstBuilder(AArch64::AUTIZA).addReg(AArch64::X5);
MCInst AutizbX5 = MCInstBuilder(AArch64::AUTIZB).addReg(AArch64::X5);
ASSERT_FALSE(BC->MIB->isPAuthOnLR(AutizaX5));
ASSERT_FALSE(BC->MIB->isPAuthOnLR(AutizbX5));

MCInst Autiaz = MCInstBuilder(AArch64::AUTIZA).addReg(AArch64::LR);
MCInst Autibz = MCInstBuilder(AArch64::AUTIZB).addReg(AArch64::LR);
ASSERT_TRUE(BC->MIB->isPAuthOnLR(Autiaz));
ASSERT_TRUE(BC->MIB->isPAuthOnLR(Autibz));

MCInst Autia1716 = MCInstBuilder(AArch64::AUTIA1716);
MCInst Autib1716 = MCInstBuilder(AArch64::AUTIB1716);
ASSERT_FALSE(BC->MIB->isPAuthOnLR(Autia1716));
ASSERT_FALSE(BC->MIB->isPAuthOnLR(Autib1716));

MCInst Autia171615 = MCInstBuilder(AArch64::AUTIA171615);
MCInst Autib171615 = MCInstBuilder(AArch64::AUTIB171615);
ASSERT_FALSE(BC->MIB->isPAuthOnLR(Autia171615));
ASSERT_FALSE(BC->MIB->isPAuthOnLR(Autib171615));

MCInst Retaa = MCInstBuilder(AArch64::RETAA);
MCInst Retab = MCInstBuilder(AArch64::RETAB);
ASSERT_FALSE(BC->MIB->isPAuthOnLR(Retaa));
ASSERT_FALSE(BC->MIB->isPAuthOnLR(Retab));
ASSERT_TRUE(BC->MIB->isPAuthAndRet(Retaa));
ASSERT_TRUE(BC->MIB->isPAuthAndRet(Retab));
}

#endif // AARCH64_AVAILABLE

#ifdef X86_AVAILABLE
Expand Down
12 changes: 8 additions & 4 deletions clang/cmake/modules/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@ include(FindPrefixFromConfig)
# the usual CMake convention seems to be ${Project}Targets.cmake.
set(CLANG_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/clang" CACHE STRING
"Path for CMake subdirectory for Clang (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/clang')")
# CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below.
set(clang_cmake_builddir "${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/clang")

# Keep this in sync with llvm/cmake/CMakeLists.txt!
set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING
"Path for CMake subdirectory for LLVM (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/llvm')")
# CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below.
string(REPLACE "${CMAKE_CFG_INTDIR}" "." llvm_cmake_builddir "${LLVM_LIBRARY_DIR}")
set(llvm_cmake_builddir "${llvm_cmake_builddir}/cmake/llvm")
string(REPLACE "${CMAKE_CFG_INTDIR}" "." llvm_builddir "${LLVM_LIBRARY_DIR}")
set(llvm_cmake_builddir "${llvm_builddir}/cmake/llvm")
if(CLANG_BUILT_STANDALONE)
# CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below.
set(clang_cmake_builddir "${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/clang")
else()
set(clang_cmake_builddir "${llvm_builddir}/cmake/clang")
endif()

get_property(CLANG_EXPORTS GLOBAL PROPERTY CLANG_EXPORTS)
export(TARGETS ${CLANG_EXPORTS} FILE ${clang_cmake_builddir}/ClangTargets.cmake)
Expand Down
44 changes: 44 additions & 0 deletions clang/docs/analyzer/checkers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,50 @@ pointers with a specified address space. If the option is set to false, then
reports from the specific x86 address spaces 256, 257 and 258 are still
suppressed, but null dereferences from other address spaces are reported.

.. _core-NullPointerArithm:

core.NullPointerArithm (C, C++)
"""""""""""""""""""""""""""""""
Check for undefined arithmetic operations with null pointers.

The checker can detect the following cases:

- ``p + x`` and ``x + p`` where ``p`` is a null pointer and ``x`` is a nonzero
integer value.
- ``p - x`` where ``p`` is a null pointer and ``x`` is a nonzero integer
value.
- ``p1 - p2`` where one of ``p1`` and ``p2`` is null and the other a
non-null pointer.

Result of these operations is undefined according to the standard.
In the above listed cases, the checker will warn even if the expression
described to be "nonzero" or "non-null" has unknown value, because it is likely
that it can have non-zero value during the program execution.

.. code-block:: c

void test1(int *p, int offset) {
if (p)
return;

int *p1 = p + offset; // warn: 'p' is null, 'offset' is unknown but likely non-zero
}

void test2(int *p, int offset) {
if (p) { } // this indicates that it is possible for 'p' to be null
if (offset == 0)
return;

int *p1 = p - offset; // warn: 'p' is null, 'offset' is known to be non-zero
}

void test3(char *p1, char *p2) {
if (p1)
return;

int a = p1 - p2; // warn: 'p1' is null, 'p2' can be likely non-null
}

.. _core-StackAddressEscape:

core.StackAddressEscape (C)
Expand Down
14 changes: 4 additions & 10 deletions clang/include/clang/Basic/BuiltinsX86.td
Original file line number Diff line number Diff line change
Expand Up @@ -1359,23 +1359,17 @@ let Features = "avx512bw", Attributes = [NoThrow, Const, Constexpr, RequiredVect
def pshufb512 : X86Builtin<"_Vector<64, char>(_Vector<64, char>, _Vector<64, char>)">;
}

let Features = "avx512cd,avx512vl", Attributes = [NoThrow, Const, RequiredVectorWidth<128>] in {
let Features = "avx512cd,avx512vl", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<128>] in {
def vpconflictdi_128 : X86Builtin<"_Vector<2, long long int>(_Vector<2, long long int>)">;
}

let Features = "avx512cd,avx512vl", Attributes = [NoThrow, Const, RequiredVectorWidth<256>] in {
def vpconflictdi_256 : X86Builtin<"_Vector<4, long long int>(_Vector<4, long long int>)">;
}

let Features = "avx512cd,avx512vl", Attributes = [NoThrow, Const, RequiredVectorWidth<128>] in {
def vpconflictsi_128 : X86Builtin<"_Vector<4, int>(_Vector<4, int>)">;
}

let Features = "avx512cd,avx512vl", Attributes = [NoThrow, Const, RequiredVectorWidth<256>] in {
let Features = "avx512cd,avx512vl", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<256>] in {
def vpconflictdi_256 : X86Builtin<"_Vector<4, long long int>(_Vector<4, long long int>)">;
def vpconflictsi_256 : X86Builtin<"_Vector<8, int>(_Vector<8, int>)">;
}

let Features = "avx512cd", Attributes = [NoThrow, Const, RequiredVectorWidth<512>] in {
let Features = "avx512cd", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<512>] in {
def vpconflictdi_512 : X86Builtin<"_Vector<8, long long int>(_Vector<8, long long int>)">;
def vpconflictsi_512 : X86Builtin<"_Vector<16, int>(_Vector<16, int>)">;
}
Expand Down
5 changes: 5 additions & 0 deletions clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ def NullDereferenceChecker
HelpText<"Check for dereferences of null pointers">,
Documentation<HasDocumentation>;

def NullPointerArithmChecker
: Checker<"NullPointerArithm">,
HelpText<"Check for undefined arithmetic operations on null pointers">,
Documentation<HasDocumentation>;

def NonNullParamChecker : Checker<"NonNullParamChecker">,
HelpText<"Check for null pointers passed as arguments to a function whose "
"arguments are references or marked with the 'nonnull' attribute">,
Expand Down
3 changes: 0 additions & 3 deletions clang/lib/AST/ByteCode/Interp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1358,9 +1358,6 @@ bool Free(InterpState &S, CodePtr OpPC, bool DeleteIsArrayForm,

void diagnoseEnumValue(InterpState &S, CodePtr OpPC, const EnumDecl *ED,
const APSInt &Value) {
if (S.EvaluatingDecl && !S.EvaluatingDecl->isConstexpr())
return;

llvm::APInt Min;
llvm::APInt Max;
ED->getValueRange(Max, Min);
Expand Down
6 changes: 4 additions & 2 deletions clang/lib/AST/ByteCode/Interp.h
Original file line number Diff line number Diff line change
Expand Up @@ -3096,7 +3096,8 @@ inline bool ArrayElemPtr(InterpState &S, CodePtr OpPC) {
}

if (Offset.isZero()) {
if (Ptr.getFieldDesc()->isArray() && Ptr.getIndex() == 0) {
if (const Descriptor *Desc = Ptr.getFieldDesc();
Desc && Desc->isArray() && Ptr.getIndex() == 0) {
S.Stk.push<Pointer>(Ptr.atIndex(0).narrow());
return true;
}
Expand Down Expand Up @@ -3126,7 +3127,8 @@ inline bool ArrayElemPtrPop(InterpState &S, CodePtr OpPC) {
}

if (Offset.isZero()) {
if (Ptr.getFieldDesc()->isArray() && Ptr.getIndex() == 0) {
if (const Descriptor *Desc = Ptr.getFieldDesc();
Desc && Desc->isArray() && Ptr.getIndex() == 0) {
S.Stk.push<Pointer>(Ptr.atIndex(0).narrow());
return true;
}
Expand Down
35 changes: 34 additions & 1 deletion clang/lib/AST/ByteCode/InterpBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3101,6 +3101,33 @@ static bool interp__builtin_vec_set(InterpState &S, CodePtr OpPC,
return true;
}

static bool interp__builtin_ia32_vpconflict(InterpState &S, CodePtr OpPC,
const CallExpr *Call) {
assert(Call->getNumArgs() == 1);

QualType Arg0Type = Call->getArg(0)->getType();
const auto *VecT = Arg0Type->castAs<VectorType>();
PrimType ElemT = *S.getContext().classify(VecT->getElementType());
unsigned NumElems = VecT->getNumElements();
bool DestUnsigned = Call->getType()->isUnsignedIntegerOrEnumerationType();
const Pointer &Src = S.Stk.pop<Pointer>();
const Pointer &Dst = S.Stk.peek<Pointer>();

for (unsigned I = 0; I != NumElems; ++I) {
INT_TYPE_SWITCH_NO_BOOL(ElemT, {
APSInt ElemI = Src.elem<T>(I).toAPSInt();
APInt ConflictMask(ElemI.getBitWidth(), 0);
for (unsigned J = 0; J != I; ++J) {
APSInt ElemJ = Src.elem<T>(J).toAPSInt();
ConflictMask.setBitVal(J, ElemI == ElemJ);
}
Dst.elem<T>(I) = static_cast<T>(APSInt(ConflictMask, DestUnsigned));
});
}
Dst.initializeAllElements();
return true;
}

bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
uint32_t BuiltinID) {
if (!S.getASTContext().BuiltinInfo.isConstantEvaluated(BuiltinID))
Expand Down Expand Up @@ -3891,7 +3918,13 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
[](const APSInt &Lo, const APSInt &Hi, const APSInt &Amt) {
return llvm::APIntOps::fshr(Hi, Lo, Amt);
});

case X86::BI__builtin_ia32_vpconflictsi_128:
case X86::BI__builtin_ia32_vpconflictsi_256:
case X86::BI__builtin_ia32_vpconflictsi_512:
case X86::BI__builtin_ia32_vpconflictdi_128:
case X86::BI__builtin_ia32_vpconflictdi_256:
case X86::BI__builtin_ia32_vpconflictdi_512:
return interp__builtin_ia32_vpconflict(S, OpPC, Call);
case clang::X86::BI__builtin_ia32_blendpd:
case clang::X86::BI__builtin_ia32_blendpd256:
case clang::X86::BI__builtin_ia32_blendps:
Expand Down
31 changes: 31 additions & 0 deletions clang/lib/AST/ExprConstant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12179,6 +12179,37 @@ bool VectorExprEvaluator::VisitCallExpr(const CallExpr *E) {

return Success(APValue(ResultElements.data(), ResultElements.size()), E);
}
case X86::BI__builtin_ia32_vpconflictsi_128:
case X86::BI__builtin_ia32_vpconflictsi_256:
case X86::BI__builtin_ia32_vpconflictsi_512:
case X86::BI__builtin_ia32_vpconflictdi_128:
case X86::BI__builtin_ia32_vpconflictdi_256:
case X86::BI__builtin_ia32_vpconflictdi_512: {
APValue Source;

if (!EvaluateAsRValue(Info, E->getArg(0), Source))
return false;

unsigned SourceLen = Source.getVectorLength();
SmallVector<APValue, 32> ResultElements;
ResultElements.reserve(SourceLen);

const auto *VecT = E->getType()->castAs<VectorType>();
bool DestUnsigned =
VecT->getElementType()->isUnsignedIntegerOrEnumerationType();

for (unsigned I = 0; I != SourceLen; ++I) {
const APValue &EltI = Source.getVectorElt(I);

APInt ConflictMask(EltI.getInt().getBitWidth(), 0);
for (unsigned J = 0; J != I; ++J) {
const APValue &EltJ = Source.getVectorElt(J);
ConflictMask.setBitVal(J, EltI.getInt() == EltJ.getInt());
}
ResultElements.push_back(APValue(APSInt(ConflictMask, DestUnsigned)));
}
return Success(APValue(ResultElements.data(), ResultElements.size()), E);
}
case X86::BI__builtin_ia32_blendpd:
case X86::BI__builtin_ia32_blendpd256:
case X86::BI__builtin_ia32_blendps:
Expand Down
Loading
Loading