Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
d249e67
[libc][math] Disable `FEnvSafeTest.cpp` if AArch64 target has no FP s…
vhscampos Nov 5, 2025
fedd3b0
[clang][bytecode] Remove dummy variables once they are proper globals…
tbaederr Nov 5, 2025
e856483
[clang-tidy][doc] add more information in twine-local's document (#16…
HerrCai0907 Nov 5, 2025
c1dc064
[CIR] Add support for storing into _Atomic variables (#165872)
Lancern Nov 5, 2025
a38e094
[mlir] Dialect Conversion: Add support for post-order legalization or…
matthias-springer Nov 5, 2025
6c640b8
[mlir][LLVM] Fix unsupported FP lowering in `VectorConvertToLLVMPatte…
matthias-springer Nov 5, 2025
c782ed3
[utils][UpdateLLCTestChecks] Add MIR support to update_llc_test_check…
vpykhtin Nov 5, 2025
a410570
[llvm][LoongArch] Introduce LASX and LSX conversion intrinsics (#157818)
heiher Nov 5, 2025
04c01f0
[gn] port 0c7300923638403
nico Nov 5, 2025
0d77cba
[libc][math] Refactor exp2m1f16 implementation to header-only in src/…
bassiounix Nov 5, 2025
98ca2e8
[clang-tidy][NFC] Fix broken link in `bugprone-default-operator-new-o…
zeyi2 Nov 5, 2025
a389472
[Clang][NFC] Refactor SemaCXX/dllexport.cpp to use -verify= instead o…
philnik777 Nov 5, 2025
b675c0c
[RISCV] Add a test for multiple save locations of a callee-saved regi…
mgudim Nov 5, 2025
1de55c9
[VPlan] Avoid sinking allocas in sinkScalarOperands (#166135)
artagnon Nov 5, 2025
305cf62
[Polly] Check for ISL errors after schedule optimization (#166551)
Meinersbur Nov 5, 2025
ba1dbdd
Revert "[utils][UpdateLLCTestChecks] Add MIR support to update_llc_te…
vpykhtin Nov 5, 2025
438a18c
[X86] Add test coverage for #166534 (#166552)
RKSimon Nov 5, 2025
5fedb7c
[Clang][ARM] Fix tests using thumb instead arm arch on cc1 (#166416)
tomershafir Nov 5, 2025
dd14eb8
[RISCV] Introduce pass to promote double constants to a global array …
asb Nov 5, 2025
3426f9c
[clang][NFC] Rename stale TypeSourceInfo DI variables (#166082)
teddygood Nov 5, 2025
63d6e3e
[DebugInfo] Assign best possible debugloc to bundle (#164573)
quic-santdas Nov 5, 2025
14c7643
[clang][bytecode] Check types when loading values (#165385)
tbaederr Nov 5, 2025
ad8f6b4
DAG: Avoid some libcall string name comparisons (#166321)
arsenm Nov 5, 2025
3a84aef
[PowerPC][NFC] auto gen checks vec rounding tests (#166435)
lei137 Nov 5, 2025
9762ab0
[MLIR][NVVM] Fix the lowering of mbarrier.test.wait (#166555)
durga4github Nov 5, 2025
338fb02
[BOLT][NFC] Rename funtions with _negative suffix to _unknown when th…
ElvinaYakubova Nov 5, 2025
87fb7b0
[flang] Adding NOTIFY specifier in image selector and add notify type…
JDPailleux Nov 5, 2025
52cb6e9
[ProfCheck][NFC] Make Function argument from branch weight setter opt…
mtrofin Nov 5, 2025
4334b43
[gn] port bb4ed55acdbc
nico Nov 5, 2025
fa6cc7e
[Clang] FunctionEffects: ignore (methods of) local CXXRecordDecls. (#…
dougsonos Nov 5, 2025
d568601
[NFC][TableGen] Adopt NamespaceEmitter in DirectiveEmitter (#165600)
jurahul Nov 5, 2025
3641e26
[MsDemangle] Read entire chain of target names in special tables (#15…
Nerixyz Nov 5, 2025
ff108f7
Fix failures introduced in #166032 (#166574)
mtrofin Nov 5, 2025
a796d18
[gn build] Port 370058777be2
llvmgnsyncbot Nov 5, 2025
ef6947b
[gn build] Port 3ebed51e997b
llvmgnsyncbot Nov 5, 2025
9bb67f8
[gn build] Port 51d0f6d6e172
llvmgnsyncbot Nov 5, 2025
3bf0ce1
[gn build] Port 718a3b268fcf
llvmgnsyncbot Nov 5, 2025
ce5dac6
[gn build] Port dd14eb8242d7
llvmgnsyncbot Nov 5, 2025
19291b7
[Flang][OpenMP] Add Lowering support for taskloop reductions
Stylie777 Nov 5, 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
30 changes: 15 additions & 15 deletions bolt/test/runtime/AArch64/inline-memcpy.s
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@
# CHECK-ASM: bl{{.*}}<memcpy

# Register move should NOT be inlined (size unknown at compile time)
# CHECK-ASM-LABEL: <test_register_move_negative>:
# CHECK-ASM-LABEL: <test_register_move_unknown>:
# CHECK-ASM: bl{{.*}}<memcpy

# CHECK-ASM-LABEL: <test_x2_rewrite_negative>:
# CHECK-ASM-LABEL: <test_x2_rewrite_unknown>:
# CHECK-ASM: bl{{.*}}<memcpy

# Live-in parameter should NOT be inlined (size unknown at compile time)
# CHECK-ASM-LABEL: <test_live_in_negative>:
# CHECK-ASM-LABEL: <test_live_in_unknown>:
# CHECK-ASM: bl{{.*}}<memcpy

# _memcpy8 should be inlined with end-pointer return (dest+size)
Expand Down Expand Up @@ -262,9 +262,9 @@ test_4_byte_add_immediate:
ret
.size test_4_byte_add_immediate, .-test_4_byte_add_immediate

.globl test_register_move_negative
.type test_register_move_negative,@function
test_register_move_negative:
.globl test_register_move_unknown
.type test_register_move_unknown,@function
test_register_move_unknown:
stp x29, x30, [sp, #-32]!
mov x29, sp
add x1, sp, #16
Expand All @@ -274,20 +274,20 @@ test_register_move_negative:
bl memcpy
ldp x29, x30, [sp], #32
ret
.size test_register_move_negative, .-test_register_move_negative
.size test_register_move_unknown, .-test_register_move_unknown

.globl test_x2_rewrite_negative
.type test_x2_rewrite_negative,@function
test_x2_rewrite_negative:
.globl test_x2_rewrite_unknown
.type test_x2_rewrite_unknown,@function
test_x2_rewrite_unknown:
mov x2, #8
ldr x2, [sp, #24]
bl memcpy
ret
.size test_x2_rewrite_negative, .-test_x2_rewrite_negative
.size test_x2_rewrite_unknown, .-test_x2_rewrite_unknown

.globl test_live_in_negative
.type test_live_in_negative,@function
test_live_in_negative:
.globl test_live_in_unknown
.type test_live_in_unknown,@function
test_live_in_unknown:
# x2 comes in as parameter, no instruction sets it (should NOT inline)
stp x29, x30, [sp, #-32]!
mov x29, sp
Expand All @@ -297,7 +297,7 @@ test_live_in_negative:
bl memcpy
ldp x29, x30, [sp], #32
ret
.size test_live_in_negative, .-test_live_in_negative
.size test_live_in_unknown, .-test_live_in_unknown

.globl test_memcpy8_4_byte
.type test_memcpy8_4_byte,@function
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cert-mem57-cpp
==============

The `cert-mem57-cpp` is an aliaes, please see
`bugprone-default-operator-new-on-overaligned-type <../bugprone/default-operator-new-on-overaligned-type>`_
`bugprone-default-operator-new-on-overaligned-type <../bugprone/default-operator-new-on-overaligned-type.html>`_
for more information.

This check corresponds to the CERT C++ Coding Standard rule
Expand Down
18 changes: 18 additions & 0 deletions clang-tools-extra/docs/clang-tidy/checks/llvm/twine-local.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,21 @@ should be generally avoided.
// becomes

static std::string Moo = (Twine("bark") + "bah").str();

The ``Twine`` does not own the memory of its contents, so it is not
recommended to use ``Twine`` created from temporary strings or string literals.

.. code-block:: c++

static Twine getModuleIdentifier(StringRef moduleName) {
return moduleName + "_module";
}
void foo() {
Twine result = getModuleIdentifier(std::string{"abc"} + "def");
// temporary std::string is destroyed here, result is dangling
}

After applying this fix-it hints, the code will use ``std::string`` instead of
``Twine`` for local variables. However, ``Twine`` has lots of methods that
are incompatible with ``std::string``, so the user may need to adjust the code
manually after applying the fix-it hints.
2 changes: 2 additions & 0 deletions clang/include/clang/CIR/MissingFeatures.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ struct MissingFeatures {
static bool atomicSyncScopeID() { return false; }
static bool atomicTypes() { return false; }
static bool atomicUseLibCall() { return false; }
static bool atomicMicrosoftVolatile() { return false; }
static bool atomicOpenMP() { return false; }

// Global ctor handling
static bool globalCtorLexOrder() { return false; }
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/Sema/Sema.h
Original file line number Diff line number Diff line change
Expand Up @@ -11668,7 +11668,7 @@ class Sema final : public SemaBase {
ASTTemplateArgsPtr TemplateArgsIn, SourceLocation RAngleLoc);

DeclResult ActOnVarTemplateSpecialization(
Scope *S, Declarator &D, TypeSourceInfo *DI, LookupResult &Previous,
Scope *S, Declarator &D, TypeSourceInfo *TSI, LookupResult &Previous,
SourceLocation TemplateKWLoc, TemplateParameterList *TemplateParams,
StorageClass SC, bool IsPartialSpecialization);

Expand Down
12 changes: 6 additions & 6 deletions clang/lib/AST/ASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3108,9 +3108,9 @@ TypeSourceInfo *ASTContext::CreateTypeSourceInfo(QualType T,

TypeSourceInfo *ASTContext::getTrivialTypeSourceInfo(QualType T,
SourceLocation L) const {
TypeSourceInfo *DI = CreateTypeSourceInfo(T);
DI->getTypeLoc().initialize(const_cast<ASTContext &>(*this), L);
return DI;
TypeSourceInfo *TSI = CreateTypeSourceInfo(T);
TSI->getTypeLoc().initialize(const_cast<ASTContext &>(*this), L);
return TSI;
}

const ASTRecordLayout &
Expand Down Expand Up @@ -5891,11 +5891,11 @@ TypeSourceInfo *ASTContext::getTemplateSpecializationTypeInfo(
QualType TST = getTemplateSpecializationType(
Keyword, Name, SpecifiedArgs.arguments(), CanonicalArgs, Underlying);

TypeSourceInfo *DI = CreateTypeSourceInfo(TST);
DI->getTypeLoc().castAs<TemplateSpecializationTypeLoc>().set(
TypeSourceInfo *TSI = CreateTypeSourceInfo(TST);
TSI->getTypeLoc().castAs<TemplateSpecializationTypeLoc>().set(
ElaboratedKeywordLoc, QualifierLoc, TemplateKeywordLoc, NameLoc,
SpecifiedArgs);
return DI;
return TSI;
}

QualType ASTContext::getTemplateSpecializationType(
Expand Down
20 changes: 19 additions & 1 deletion clang/lib/AST/ByteCode/Compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,19 @@ template <class Emitter> class LocOverrideScope final {
} // namespace interp
} // namespace clang

template <class Emitter>
bool Compiler<Emitter>::isValidBitCast(const CastExpr *E) {
QualType FromTy = E->getSubExpr()->getType()->getPointeeType();
QualType ToTy = E->getType()->getPointeeType();

if (classify(FromTy) == classify(ToTy))
return true;

if (FromTy->isVoidType() || ToTy->isVoidType())
return true;
return false;
}

template <class Emitter>
bool Compiler<Emitter>::VisitCastExpr(const CastExpr *CE) {
const Expr *SubExpr = CE->getSubExpr();
Expand Down Expand Up @@ -476,8 +489,9 @@ bool Compiler<Emitter>::VisitCastExpr(const CastExpr *CE) {
return this->delegate(SubExpr);

case CK_BitCast: {
QualType CETy = CE->getType();
// Reject bitcasts to atomic types.
if (CE->getType()->isAtomicType()) {
if (CETy->isAtomicType()) {
if (!this->discard(SubExpr))
return false;
return this->emitInvalidCast(CastKind::Reinterpret, /*Fatal=*/true, CE);
Expand All @@ -492,6 +506,10 @@ bool Compiler<Emitter>::VisitCastExpr(const CastExpr *CE) {
if (!FromT || !ToT)
return false;

if (!this->isValidBitCast(CE) &&
!this->emitInvalidCast(CastKind::ReinterpretLike, /*Fatal=*/false, CE))
return false;

assert(isPtrType(*FromT));
assert(isPtrType(*ToT));
if (FromT == ToT) {
Expand Down
2 changes: 2 additions & 0 deletions clang/lib/AST/ByteCode/Compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,8 @@ class Compiler : public ConstStmtVisitor<Compiler<Emitter>, bool>,

bool refersToUnion(const Expr *E);

bool isValidBitCast(const CastExpr *E);

protected:
/// Variable to storage mapping.
llvm::DenseMap<const ValueDecl *, Scope::Local> Locals;
Expand Down
27 changes: 19 additions & 8 deletions clang/lib/AST/ByteCode/Interp.h
Original file line number Diff line number Diff line change
Expand Up @@ -1915,6 +1915,9 @@ bool Load(InterpState &S, CodePtr OpPC) {
return false;
if (!Ptr.isBlockPointer())
return false;
if (const Descriptor *D = Ptr.getFieldDesc();
!(D->isPrimitive() || D->isPrimitiveArray()) || D->getPrimType() != Name)
return false;
S.Stk.push<T>(Ptr.deref<T>());
return true;
}
Expand All @@ -1926,6 +1929,9 @@ bool LoadPop(InterpState &S, CodePtr OpPC) {
return false;
if (!Ptr.isBlockPointer())
return false;
if (const Descriptor *D = Ptr.getFieldDesc();
!(D->isPrimitive() || D->isPrimitiveArray()) || D->getPrimType() != Name)
return false;
S.Stk.push<T>(Ptr.deref<T>());
return true;
}
Expand Down Expand Up @@ -3288,12 +3294,18 @@ inline bool InvalidCast(InterpState &S, CodePtr OpPC, CastKind Kind,
bool Fatal) {
const SourceLocation &Loc = S.Current->getLocation(OpPC);

if (Kind == CastKind::Reinterpret) {
switch (Kind) {
case CastKind::Reinterpret:
S.CCEDiag(Loc, diag::note_constexpr_invalid_cast)
<< static_cast<unsigned>(Kind) << S.Current->getRange(OpPC);
<< diag::ConstexprInvalidCastKind::Reinterpret
<< S.Current->getRange(OpPC);
return !Fatal;
}
if (Kind == CastKind::Volatile) {
case CastKind::ReinterpretLike:
S.CCEDiag(Loc, diag::note_constexpr_invalid_cast)
<< diag::ConstexprInvalidCastKind::ThisConversionOrReinterpret
<< S.getLangOpts().CPlusPlus << S.Current->getRange(OpPC);
return !Fatal;
case CastKind::Volatile:
if (!S.checkingPotentialConstantExpression()) {
const auto *E = cast<CastExpr>(S.Current->getExpr(OpPC));
if (S.getLangOpts().CPlusPlus)
Expand All @@ -3304,14 +3316,13 @@ inline bool InvalidCast(InterpState &S, CodePtr OpPC, CastKind Kind,
}

return false;
}
if (Kind == CastKind::Dynamic) {
case CastKind::Dynamic:
assert(!S.getLangOpts().CPlusPlus20);
S.CCEDiag(S.Current->getSource(OpPC), diag::note_constexpr_invalid_cast)
S.CCEDiag(Loc, diag::note_constexpr_invalid_cast)
<< diag::ConstexprInvalidCastKind::Dynamic;
return true;
}

llvm_unreachable("Unhandled CastKind");
return false;
}

Expand Down
4 changes: 4 additions & 0 deletions clang/lib/AST/ByteCode/PrimType.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ inline constexpr bool isSignedType(PrimType T) {

enum class CastKind : uint8_t {
Reinterpret,
ReinterpretLike,
Volatile,
Dynamic,
};
Expand All @@ -111,6 +112,9 @@ inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
case interp::CastKind::Reinterpret:
OS << "reinterpret_cast";
break;
case interp::CastKind::ReinterpretLike:
OS << "reinterpret_like";
break;
case interp::CastKind::Volatile:
OS << "volatile";
break;
Expand Down
79 changes: 36 additions & 43 deletions clang/lib/AST/ByteCode/Program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,30 +36,19 @@ unsigned Program::createGlobalString(const StringLiteral *S, const Expr *Base) {
const size_t BitWidth = CharWidth * Ctx.getCharBit();
unsigned StringLength = S->getLength();

PrimType CharType;
switch (CharWidth) {
case 1:
CharType = PT_Sint8;
break;
case 2:
CharType = PT_Uint16;
break;
case 4:
CharType = PT_Uint32;
break;
default:
llvm_unreachable("unsupported character width");
}
OptPrimType CharType =
Ctx.classify(S->getType()->castAsArrayTypeUnsafe()->getElementType());
assert(CharType);

if (!Base)
Base = S;

// Create a descriptor for the string.
Descriptor *Desc =
allocateDescriptor(Base, CharType, Descriptor::GlobalMD, StringLength + 1,
/*isConst=*/true,
/*isTemporary=*/false,
/*isMutable=*/false);
Descriptor *Desc = allocateDescriptor(Base, *CharType, Descriptor::GlobalMD,
StringLength + 1,
/*isConst=*/true,
/*isTemporary=*/false,
/*isMutable=*/false);

// Allocate storage for the string.
// The byte length does not include the null terminator.
Expand All @@ -79,26 +68,9 @@ unsigned Program::createGlobalString(const StringLiteral *S, const Expr *Base) {
} else {
// Construct the string in storage.
for (unsigned I = 0; I <= StringLength; ++I) {
const uint32_t CodePoint = I == StringLength ? 0 : S->getCodeUnit(I);
switch (CharType) {
case PT_Sint8: {
using T = PrimConv<PT_Sint8>::T;
Ptr.elem<T>(I) = T::from(CodePoint, BitWidth);
break;
}
case PT_Uint16: {
using T = PrimConv<PT_Uint16>::T;
Ptr.elem<T>(I) = T::from(CodePoint, BitWidth);
break;
}
case PT_Uint32: {
using T = PrimConv<PT_Uint32>::T;
Ptr.elem<T>(I) = T::from(CodePoint, BitWidth);
break;
}
default:
llvm_unreachable("unsupported character type");
}
uint32_t CodePoint = I == StringLength ? 0 : S->getCodeUnit(I);
INT_TYPE_SWITCH_NO_BOOL(*CharType,
Ptr.elem<T>(I) = T::from(CodePoint, BitWidth););
}
}
Ptr.initializeAllElements();
Expand Down Expand Up @@ -218,21 +190,42 @@ UnsignedOrNone Program::createGlobal(const ValueDecl *VD, const Expr *Init) {
return std::nullopt;

Global *NewGlobal = Globals[*Idx];
// Note that this loop has one iteration where Redecl == VD.
for (const Decl *Redecl : VD->redecls()) {
unsigned &PIdx = GlobalIndices[Redecl];

// If this redecl was registered as a dummy variable, it is now a proper
// global variable and points to the block we just created.
if (auto DummyIt = DummyVariables.find(Redecl);
DummyIt != DummyVariables.end()) {
assert(!Globals[DummyIt->second]->block()->hasPointers());
Globals[DummyIt->second] = NewGlobal;
DummyVariables.erase(DummyIt);
}
// If the redeclaration hasn't been registered yet at all, we just set its
// global index to Idx. If it has been registered yet, it might have
// pointers pointing to it and we need to transfer those pointers to the new
// block.
auto [Iter, Inserted] = GlobalIndices.try_emplace(Redecl);
if (Inserted) {
GlobalIndices[Redecl] = *Idx;
continue;
}

if (Redecl != VD) {
if (Block *RedeclBlock = Globals[PIdx]->block();
if (Block *RedeclBlock = Globals[Iter->second]->block();
RedeclBlock->isExtern()) {
Globals[PIdx] = NewGlobal;

// All pointers pointing to the previous extern decl now point to the
// new decl.
// A previous iteration might've already fixed up the pointers for this
// global.
if (RedeclBlock != NewGlobal->block())
RedeclBlock->movePointersTo(NewGlobal->block());

Globals[Iter->second] = NewGlobal;
}
}
PIdx = *Idx;
Iter->second = *Idx;
}

return *Idx;
Expand Down
1 change: 0 additions & 1 deletion clang/lib/AST/ByteCode/Program.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ class Program final {
const Block *block() const { return &B; }

private:
/// Required metadata - does not actually track pointers.
Block B;
};

Expand Down
Loading
Loading