Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
1c33b82
[Clang] VectorExprEvaluator::VisitCallExpr / InterpretBuiltin - allow…
monthdev Oct 23, 2025
fedbe38
[OpenACC][CIR] Implement atomic-write lowering (#164627)
erichkeane Oct 23, 2025
5d7da0a
[lldb] Added a warning in case of instruction decode failure (#164413)
tgs-sc Oct 23, 2025
45f97f7
[libc++][docs] Add missing column headers for GitHub issues (#164745)
frederick-vs-ja Oct 23, 2025
9a5ae34
[mlir][tosa] Add support for matmul_t_block_scaled (#163433)
lhutton1 Oct 23, 2025
917d1f2
Silence "not all control paths return a value" warning; NFC
AaronBallman Oct 23, 2025
faf7af8
[lldb] update lldb-server platform help parsing (#162730)
cs01 Oct 23, 2025
536bd72
[NFC] Rename 'Expr' to 'RefExpr' to fix the build warnings (#164828)
erichkeane Oct 23, 2025
0ac4a71
[bazel][lldb] Port #162730: tablegen for lldb-server platform ops (#1…
rupprecht Oct 23, 2025
d130f40
[ARM][KCFI] Add backend support for Kernel Control-Flow Integrity (#1…
kees Oct 23, 2025
c6073d7
[LoopCacheAnalysis] Drop incorrect nowrap flags from addrec (#164796)
kasuga-fj Oct 23, 2025
1501454
[MLIR][GPU] Generalize gpu.printf op lowering to LLVM call pattern. (…
silee2 Oct 23, 2025
cf20a26
[DTLTO][Clang][LLD] Fix DTLTO for multi-call LLVM driver toolchain (#…
nga888 Oct 23, 2025
6058c0c
[NFC][clang][OpenMP] Cleanup leftover unused CodeGen functions (#164767)
ro-i Oct 23, 2025
c13ac9c
[Compiler-rt] Fix wrong assignment in compiler_rt (#164713)
mikolaj-pirog Oct 23, 2025
7ca1472
[Clang] Implement constexpr evaluation for __builtin_infer_alloc_toke…
melver Oct 23, 2025
213b8a9
[NFC][LLVM] Namespace cleanup in MergeICmps (#163761)
jurahul Oct 23, 2025
71b21b5
[CIR] Move alloca from cir.try to the surrounding cir.scope (#164488)
AmrDeveloper Oct 23, 2025
7731156
[clang] OpenMP: fix variant template mismatch crash (#164511)
mizvekov Oct 23, 2025
d8d80b6
Adding Matching and Inference Functionality to Propeller-PR2 (#162963)
wdx727 Oct 23, 2025
0149864
[clang][test] Add test for comma operator rejection in preprocessor c…
swote-git Oct 23, 2025
930b36c
[lldb] fix lldb-server test failures on windows (#164843)
cs01 Oct 23, 2025
1031f1b
[Flang][Driver] Emit module summary for Full LTO (#164302)
anchuraj Oct 23, 2025
ede9dd3
[CIR] Handle dynamic cast to null (#164732)
andykaylor Oct 23, 2025
1ab6c0d
[clang] Make explicitly-built modules independent of the CWD (#164840)
jansvoboda11 Oct 23, 2025
38473c5
[clang][headers] Need a way for math.h to share the definitions of IN…
ian-twilightcoder Oct 23, 2025
1c53bfc
[compiler-rt][ASan] Define SANITIZER_INTERCEPT_WCSNLEN (#164845)
zacklj89 Oct 23, 2025
2b42c6c
[DirectX] Use a well-formed cbuffer in the unused cbuffer test (#164844)
bogner Oct 23, 2025
2b6686f
[X86] Manage atomic load of fp -> int promotion in DAG (#148895)
jofrn Oct 23, 2025
10bec2c
[llvm-ir2vec][MIR2Vec] Supporting MIR mode in triplet and entity gene…
svkeerthy Oct 23, 2025
83f751a
[FlowSensitive] [StatusOr] [6/N] support pointer comparison (#164856)
fmayer Oct 23, 2025
ad2718d
merge main into amd-staging
ronlieb Oct 23, 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
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ namespace find_all_symbols {

const HeaderMapCollector::RegexHeaderMap *getSTLPostfixHeaderMap() {
static const HeaderMapCollector::RegexHeaderMap STLPostfixHeaderMap = {
{"include/__float_float.h$", "<cfloat>"},
{"include/__float_header_macro.h$", "<cfloat>"},
{"include/__float_infinity_nan.h$", "<cfloat>"},
{"include/__stdarg___gnuc_va_list.h$", "<cstdarg>"},
{"include/__stdarg___va_copy.h$", "<cstdarg>"},
{"include/__stdarg_header_macro.h$", "<cstdarg>"},
Expand Down
3 changes: 3 additions & 0 deletions clang-tools-extra/clangd/index/CanonicalIncludes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ namespace clang {
namespace clangd {
namespace {
const std::pair<llvm::StringRef, llvm::StringRef> IncludeMappings[] = {
{"include/__float_float.h", "<cfloat>"},
{"include/__float_header_macro.h", "<cfloat>"},
{"include/__float_infinity_nan.h", "<cfloat>"},
{"include/__stdarg___gnuc_va_list.h", "<cstdarg>"},
{"include/__stdarg___va_copy.h", "<cstdarg>"},
{"include/__stdarg_header_macro.h", "<cstdarg>"},
Expand Down
3 changes: 3 additions & 0 deletions clang/include/clang/AST/StmtOpenACC.h
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,9 @@ class OpenACCAtomicConstruct final
struct StmtInfo {
const Expr *V;
const Expr *X;
// Listed as 'expr' in the standard, this is typically a generic expression
// as a component.
const Expr *RefExpr;
// TODO: OpenACC: We should expand this as we're implementing the other
// atomic construct kinds.
};
Expand Down
29 changes: 18 additions & 11 deletions clang/include/clang/Basic/BuiltinsX86.td
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,13 @@ let Attributes = [Const, NoThrow, RequiredVectorWidth<128>] in {
}
}

let Features = "ssse3" in {
def psignb128 : X86Builtin<"_Vector<16, char>(_Vector<16, char>, _Vector<16, char>)">;
def psignw128 : X86Builtin<"_Vector<8, short>(_Vector<8, short>, _Vector<8, short>)">;
def psignd128 : X86Builtin<"_Vector<4, int>(_Vector<4, int>, _Vector<4, int>)">;
}

let Features = "ssse3", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<128>] in {
def psignb128
: X86Builtin<"_Vector<16, char>(_Vector<16, char>, _Vector<16, char>)">;
def psignw128
: X86Builtin<"_Vector<8, short>(_Vector<8, short>, _Vector<8, short>)">;
def psignd128
: X86Builtin<"_Vector<4, int>(_Vector<4, int>, _Vector<4, int>)">;
def pmulhrsw128 : X86Builtin<"_Vector<8, short>(_Vector<8, short>, _Vector<8, short>)">;
def pmaddubsw128 : X86Builtin<"_Vector<8, short>(_Vector<16, char>, _Vector<16, char>)">;
def pshufb128 : X86Builtin<"_Vector<16, char>(_Vector<16, char>, _Vector<16, char>)">;
Expand Down Expand Up @@ -603,10 +603,9 @@ let Features = "avx2", Attributes = [NoThrow, Const, RequiredVectorWidth<256>] i
def mpsadbw256 : X86Builtin<"_Vector<32, char>(_Vector<32, char>, _Vector<32, char>, _Constant char)">;
def palignr256 : X86Builtin<"_Vector<32, char>(_Vector<32, char>, "
"_Vector<32, char>, _Constant int)">;
def psadbw256 : X86Builtin<"_Vector<4, long long int>(_Vector<32, char>, _Vector<32, char>)">;
def psignb256 : X86Builtin<"_Vector<32, char>(_Vector<32, char>, _Vector<32, char>)">;
def psignw256 : X86Builtin<"_Vector<16, short>(_Vector<16, short>, _Vector<16, short>)">;
def psignd256 : X86Builtin<"_Vector<8, int>(_Vector<8, int>, _Vector<8, int>)">;
def psadbw256
: X86Builtin<
"_Vector<4, long long int>(_Vector<32, char>, _Vector<32, char>)">;
def psllw256 : X86Builtin<"_Vector<16, short>(_Vector<16, short>, _Vector<8, short>)">;
def pslldqi256_byteshift : X86Builtin<"_Vector<32, char>(_Vector<32, char>, _Constant int)">;
def pslld256 : X86Builtin<"_Vector<8, int>(_Vector<8, int>, _Vector<4, int>)">;
Expand Down Expand Up @@ -677,7 +676,15 @@ let Features = "avx2", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWi
def phsubw256 : X86Builtin<"_Vector<16, short>(_Vector<16, short>, _Vector<16, short>)">;
def phsubd256 : X86Builtin<"_Vector<8, int>(_Vector<8, int>, _Vector<8, int>)">;
def phsubsw256 : X86Builtin<"_Vector<16, short>(_Vector<16, short>, _Vector<16, short>)">;


def psignb256
: X86Builtin<"_Vector<32, char>(_Vector<32, char>, _Vector<32, char>)">;
def psignw256
: X86Builtin<
"_Vector<16, short>(_Vector<16, short>, _Vector<16, short>)">;
def psignd256
: X86Builtin<"_Vector<8, int>(_Vector<8, int>, _Vector<8, int>)">;

def pshuflw256 : X86Builtin<"_Vector<16, short>(_Vector<16, short>, _Constant int)">;
def pshufhw256 : X86Builtin<"_Vector<16, short>(_Vector<16, short>, _Constant int)">;
def pshufd256 : X86Builtin<"_Vector<8, int>(_Vector<8, int>, _Constant int)">;
Expand Down
6 changes: 6 additions & 0 deletions clang/include/clang/Basic/DiagnosticASTKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,12 @@ def note_constexpr_assumption_failed : Note<
def note_constexpr_countzeroes_zero : Note<
"evaluation of %select{__builtin_elementwise_clzg|__builtin_elementwise_ctzg}0 "
"with a zero value is undefined">;
def note_constexpr_infer_alloc_token_type_inference_failed : Note<
"could not infer allocation type for __builtin_infer_alloc_token">;
def note_constexpr_infer_alloc_token_no_metadata : Note<
"could not get token metadata for inferred type">;
def note_constexpr_infer_alloc_token_stateful_mode : Note<
"stateful alloc token mode not supported in constexpr">;
def err_experimental_clang_interp_failed : Error<
"the experimental clang interpreter failed to evaluate an expression">;

Expand Down
3 changes: 3 additions & 0 deletions clang/include/clang/Driver/CommonArgs.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ void SplitDebugInfo(const ToolChain &TC, Compilation &C, const Tool &T,
const JobAction &JA, const llvm::opt::ArgList &Args,
const InputInfo &Output, const char *OutFile);

void addDTLTOOptions(const ToolChain &ToolChain, const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs);

void addLTOOptions(const ToolChain &ToolChain, const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs, const InputInfo &Output,
const InputInfoList &Inputs, bool IsThinLTO);
Expand Down
59 changes: 59 additions & 0 deletions clang/lib/AST/ByteCode/InterpBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
#include "InterpHelpers.h"
#include "PrimType.h"
#include "Program.h"
#include "clang/AST/InferAlloc.h"
#include "clang/AST/OSLog.h"
#include "clang/AST/RecordLayout.h"
#include "clang/Basic/Builtins.h"
#include "clang/Basic/TargetBuiltins.h"
#include "clang/Basic/TargetInfo.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/AllocToken.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/SipHash.h"

Expand Down Expand Up @@ -1307,6 +1309,45 @@ interp__builtin_ptrauth_string_discriminator(InterpState &S, CodePtr OpPC,
return true;
}

static bool interp__builtin_infer_alloc_token(InterpState &S, CodePtr OpPC,
const InterpFrame *Frame,
const CallExpr *Call) {
const ASTContext &ASTCtx = S.getASTContext();
uint64_t BitWidth = ASTCtx.getTypeSize(ASTCtx.getSizeType());
auto Mode =
ASTCtx.getLangOpts().AllocTokenMode.value_or(llvm::DefaultAllocTokenMode);
uint64_t MaxTokens =
ASTCtx.getLangOpts().AllocTokenMax.value_or(~0ULL >> (64 - BitWidth));

// We do not read any of the arguments; discard them.
for (int I = Call->getNumArgs() - 1; I >= 0; --I)
discard(S.Stk, *S.getContext().classify(Call->getArg(I)));

// Note: Type inference from a surrounding cast is not supported in
// constexpr evaluation.
QualType AllocType = infer_alloc::inferPossibleType(Call, ASTCtx, nullptr);
if (AllocType.isNull()) {
S.CCEDiag(Call,
diag::note_constexpr_infer_alloc_token_type_inference_failed);
return false;
}

auto ATMD = infer_alloc::getAllocTokenMetadata(AllocType, ASTCtx);
if (!ATMD) {
S.CCEDiag(Call, diag::note_constexpr_infer_alloc_token_no_metadata);
return false;
}

auto MaybeToken = llvm::getAllocToken(Mode, *ATMD, MaxTokens);
if (!MaybeToken) {
S.CCEDiag(Call, diag::note_constexpr_infer_alloc_token_stateful_mode);
return false;
}

pushInteger(S, llvm::APInt(BitWidth, *MaybeToken), ASTCtx.getSizeType());
return true;
}

static bool interp__builtin_operator_new(InterpState &S, CodePtr OpPC,
const InterpFrame *Frame,
const CallExpr *Call) {
Expand Down Expand Up @@ -3694,6 +3735,9 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
case Builtin::BI__builtin_ptrauth_string_discriminator:
return interp__builtin_ptrauth_string_discriminator(S, OpPC, Frame, Call);

case Builtin::BI__builtin_infer_alloc_token:
return interp__builtin_infer_alloc_token(S, OpPC, Frame, Call);

case Builtin::BI__noop:
pushInteger(S, 0, Call->getType());
return true;
Expand Down Expand Up @@ -3809,6 +3853,21 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
return interp__builtin_ia32_movmsk_op(S, OpPC, Call);
}

case X86::BI__builtin_ia32_psignb128:
case X86::BI__builtin_ia32_psignb256:
case X86::BI__builtin_ia32_psignw128:
case X86::BI__builtin_ia32_psignw256:
case X86::BI__builtin_ia32_psignd128:
case X86::BI__builtin_ia32_psignd256:
return interp__builtin_elementwise_int_binop(
S, OpPC, Call, [](const APInt &AElem, const APInt &BElem) {
if (BElem.isZero())
return APInt::getZero(AElem.getBitWidth());
if (BElem.isNegative())
return -AElem;
return AElem;
});

case clang::X86::BI__builtin_ia32_pavgb128:
case clang::X86::BI__builtin_ia32_pavgw128:
case clang::X86::BI__builtin_ia32_pavgb256:
Expand Down
36 changes: 36 additions & 0 deletions clang/lib/AST/ExprConstant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "clang/AST/CharUnits.h"
#include "clang/AST/CurrentSourceLocExprScope.h"
#include "clang/AST/Expr.h"
#include "clang/AST/InferAlloc.h"
#include "clang/AST/OSLog.h"
#include "clang/AST/OptionalDiagnostic.h"
#include "clang/AST/RecordLayout.h"
Expand Down Expand Up @@ -12312,6 +12313,20 @@ bool VectorExprEvaluator::VisitCallExpr(const CallExpr *E) {
return Success(APValue(ResultElements.data(), ResultElements.size()), E);
}

case X86::BI__builtin_ia32_psignb128:
case X86::BI__builtin_ia32_psignb256:
case X86::BI__builtin_ia32_psignw128:
case X86::BI__builtin_ia32_psignw256:
case X86::BI__builtin_ia32_psignd128:
case X86::BI__builtin_ia32_psignd256:
return EvaluateBinOpExpr([](const APInt &AElem, const APInt &BElem) {
if (BElem.isZero())
return APInt::getZero(AElem.getBitWidth());
if (BElem.isNegative())
return -AElem;
return AElem;
});

case X86::BI__builtin_ia32_blendvpd:
case X86::BI__builtin_ia32_blendvpd256:
case X86::BI__builtin_ia32_blendvps:
Expand Down Expand Up @@ -14649,6 +14664,27 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
return Success(Result, E);
}

case Builtin::BI__builtin_infer_alloc_token: {
// If we fail to infer a type, this fails to be a constant expression; this
// can be checked with __builtin_constant_p(...).
QualType AllocType = infer_alloc::inferPossibleType(E, Info.Ctx, nullptr);
if (AllocType.isNull())
return Error(
E, diag::note_constexpr_infer_alloc_token_type_inference_failed);
auto ATMD = infer_alloc::getAllocTokenMetadata(AllocType, Info.Ctx);
if (!ATMD)
return Error(E, diag::note_constexpr_infer_alloc_token_no_metadata);
auto Mode =
Info.getLangOpts().AllocTokenMode.value_or(llvm::DefaultAllocTokenMode);
uint64_t BitWidth = Info.Ctx.getTypeSize(Info.Ctx.getSizeType());
uint64_t MaxTokens =
Info.getLangOpts().AllocTokenMax.value_or(~0ULL >> (64 - BitWidth));
auto MaybeToken = llvm::getAllocToken(Mode, *ATMD, MaxTokens);
if (!MaybeToken)
return Error(E, diag::note_constexpr_infer_alloc_token_stateful_mode);
return Success(llvm::APInt(BitWidth, *MaybeToken), E);
}

case Builtin::BI__builtin_ffs:
case Builtin::BI__builtin_ffsl:
case Builtin::BI__builtin_ffsll: {
Expand Down
44 changes: 32 additions & 12 deletions clang/lib/AST/StmtOpenACC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,18 @@ OpenACCAtomicConstruct *OpenACCAtomicConstruct::Create(
return Inst;
}

static std::pair<const Expr *, const Expr *> getBinaryOpArgs(const Expr *Op) {
if (const auto *BO = dyn_cast<BinaryOperator>(Op)) {
assert(BO->getOpcode() == BO_Assign);
return {BO->getLHS(), BO->getRHS()};
}

const auto *OO = cast<CXXOperatorCallExpr>(Op);
assert(OO->getOperator() == OO_Equal);

return {OO->getArg(0), OO->getArg(1)};
}

const OpenACCAtomicConstruct::StmtInfo
OpenACCAtomicConstruct::getAssociatedStmtInfo() const {
// This ends up being a vastly simplified version of SemaOpenACCAtomic, since
Expand All @@ -333,27 +345,35 @@ OpenACCAtomicConstruct::getAssociatedStmtInfo() const {

switch (AtomicKind) {
case OpenACCAtomicKind::None:
case OpenACCAtomicKind::Write:
case OpenACCAtomicKind::Update:
case OpenACCAtomicKind::Capture:
assert(false && "Only 'read' has been implemented here");
assert(false && "Only 'read'/'write' have been implemented here");
return {};
case OpenACCAtomicKind::Read: {
// Read only supports the format 'v = x'; where both sides are a scalar
// expression. This can come in 2 forms; BinaryOperator or
// CXXOperatorCallExpr (rarely).
const Expr *AssignExpr = cast<const Expr>(getAssociatedStmt());
if (const auto *BO = dyn_cast<BinaryOperator>(AssignExpr)) {
assert(BO->getOpcode() == BO_Assign);
return {BO->getLHS()->IgnoreImpCasts(), BO->getRHS()->IgnoreImpCasts()};
}

const auto *OO = cast<CXXOperatorCallExpr>(AssignExpr);
assert(OO->getOperator() == OO_Equal);

return {OO->getArg(0)->IgnoreImpCasts(), OO->getArg(1)->IgnoreImpCasts()};
std::pair<const Expr *, const Expr *> BinaryArgs =
getBinaryOpArgs(cast<const Expr>(getAssociatedStmt()));
// We want the L-value for each side, so we ignore implicit casts.
return {BinaryArgs.first->IgnoreImpCasts(),
BinaryArgs.second->IgnoreImpCasts(), /*expr=*/nullptr};
}
case OpenACCAtomicKind::Write: {
// Write supports only the format 'x = expr', where the expression is scalar
// type, and 'x' is a scalar l value. As above, this can come in 2 forms;
// Binary Operator or CXXOperatorCallExpr.
std::pair<const Expr *, const Expr *> BinaryArgs =
getBinaryOpArgs(cast<const Expr>(getAssociatedStmt()));
// We want the L-value for ONLY the X side, so we ignore implicit casts. For
// the right side (the expr), we emit it as an r-value so we need to
// maintain implicit casts.
return {/*v=*/nullptr, BinaryArgs.first->IgnoreImpCasts(),
BinaryArgs.second};
}
}

llvm_unreachable("unknown OpenACC atomic kind");
}

OpenACCCacheConstruct *OpenACCCacheConstruct::CreateEmpty(const ASTContext &C,
Expand Down
Loading