Skip to content

Commit 92c9e9a

Browse files
committed
merge main into amd-staging
Change-Id: Ib82f0e403dd6cab302c718c05124a0531a16ccd6
2 parents 7030b51 + 1edd220 commit 92c9e9a

File tree

124 files changed

+3514
-3719
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+3514
-3719
lines changed

.github/workflows/release-binaries-all.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ on:
4343
- '.github/workflows/release-binaries.yml'
4444
- '.github/workflows/release-binaries-setup-stage/*'
4545
- '.github/workflows/release-binaries-save-stage/*'
46+
- 'clang/cmake/caches/Release.cmake'
4647

4748
concurrency:
4849
group: ${{ github.workflow }}-${{ github.event.pull_request.number || 'dispatch' }}

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ ABI Changes in This Version
103103
---------------------------
104104

105105
- Fixed Microsoft name mangling of placeholder, auto and decltype(auto), return types for MSVC 1920+. This change resolves incompatibilities with code compiled by MSVC 1920+ but will introduce incompatibilities with code compiled by earlier versions of Clang unless such code is built with the compiler option -fms-compatibility-version=19.14 to imitate the MSVC 1914 mangling behavior.
106+
- Fixed the Itanium mangling of the construction vtable name. This change will introduce incompatibilities with code compiled by Clang 19 and earlier versions, unless the -fclang-abi-compat=19 option is used. (#GH108015)
106107

107108
AST Dumping Potentially Breaking Changes
108109
----------------------------------------

clang/include/clang/Basic/LangOptions.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,12 @@ class LangOptionsBase {
239239
/// in the initializers of members of local classes.
240240
Ver18,
241241

242+
/// Attempt to be ABI-compatible with code generated by Clang 19.0.x.
243+
/// This causes clang to:
244+
/// - Incorrectly mangles the 'base type' substitutions of the CXX
245+
/// construction vtable because it hasn't added 'type' as a substitution.
246+
Ver19,
247+
242248
/// Conform to the underlying platform's C and C++ ABIs as closely
243249
/// as we can.
244250
Latest

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,14 @@ bool Compiler<Emitter>::VisitCastExpr(const CastExpr *CE) {
697697
const auto *TargetSemantics = &Ctx.getFloatSemantics(CE->getType());
698698
return this->emitCastFixedPointFloating(TargetSemantics, CE);
699699
}
700+
case CK_FixedPointCast: {
701+
if (!this->visit(SubExpr))
702+
return false;
703+
auto Sem = Ctx.getASTContext().getFixedPointSemantics(CE->getType());
704+
uint32_t I;
705+
std::memcpy(&I, &Sem, sizeof(Sem));
706+
return this->emitCastFixedPoint(I, CE);
707+
}
700708

701709
case CK_ToVoid:
702710
return discard(SubExpr);
@@ -1494,25 +1502,41 @@ bool Compiler<Emitter>::VisitFixedPointBinOp(const BinaryOperator *E) {
14941502
assert(LHS->getType()->isFixedPointType() ||
14951503
RHS->getType()->isFixedPointType());
14961504

1505+
auto LHSSema = Ctx.getASTContext().getFixedPointSemantics(LHS->getType());
1506+
auto RHSSema = Ctx.getASTContext().getFixedPointSemantics(RHS->getType());
1507+
14971508
if (!this->visit(LHS))
14981509
return false;
14991510
if (!LHS->getType()->isFixedPointType()) {
1500-
auto Sem = Ctx.getASTContext().getFixedPointSemantics(LHS->getType());
15011511
uint32_t I;
1502-
std::memcpy(&I, &Sem, sizeof(Sem));
1512+
std::memcpy(&I, &LHSSema, sizeof(llvm::FixedPointSemantics));
15031513
if (!this->emitCastIntegralFixedPoint(classifyPrim(LHS->getType()), I, E))
15041514
return false;
15051515
}
1516+
15061517
if (!this->visit(RHS))
15071518
return false;
15081519
if (!RHS->getType()->isFixedPointType()) {
1509-
auto Sem = Ctx.getASTContext().getFixedPointSemantics(RHS->getType());
15101520
uint32_t I;
1511-
std::memcpy(&I, &Sem, sizeof(Sem));
1521+
std::memcpy(&I, &RHSSema, sizeof(llvm::FixedPointSemantics));
15121522
if (!this->emitCastIntegralFixedPoint(classifyPrim(RHS->getType()), I, E))
15131523
return false;
15141524
}
15151525

1526+
// Convert the result to the target semantics.
1527+
auto ConvertResult = [&](bool R) -> bool {
1528+
if (!R)
1529+
return false;
1530+
auto ResultSema = Ctx.getASTContext().getFixedPointSemantics(E->getType());
1531+
auto CommonSema = LHSSema.getCommonSemantics(RHSSema);
1532+
if (ResultSema != CommonSema) {
1533+
uint32_t I;
1534+
std::memcpy(&I, &ResultSema, sizeof(ResultSema));
1535+
return this->emitCastFixedPoint(I, E);
1536+
}
1537+
return true;
1538+
};
1539+
15161540
switch (E->getOpcode()) {
15171541
case BO_EQ:
15181542
return this->emitEQFixedPoint(E);
@@ -1528,6 +1552,9 @@ bool Compiler<Emitter>::VisitFixedPointBinOp(const BinaryOperator *E) {
15281552
case BO_GE:
15291553
return this->emitGEFixedPoint(E);
15301554
#endif
1555+
case BO_Add:
1556+
return ConvertResult(this->emitAddFixedPoint(E));
1557+
15311558
default:
15321559
return this->emitInvalid(E);
15331560
}

clang/lib/AST/ByteCode/FixedPoint.h

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,33 @@ class FixedPoint final {
4747
void print(llvm::raw_ostream &OS) const { OS << V; }
4848

4949
APValue toAPValue(const ASTContext &) const { return APValue(V); }
50-
APSInt toAPSInt(unsigned BitWidth) const { return V.getValue(); }
50+
APSInt toAPSInt(unsigned BitWidth = 0) const { return V.getValue(); }
5151

5252
unsigned bitWidth() const { return V.getWidth(); }
5353
bool isSigned() const { return V.isSigned(); }
54+
bool isZero() const { return V.getValue().isZero(); }
55+
bool isNegative() const { return V.getValue().isNegative(); }
56+
bool isPositive() const { return V.getValue().isNonNegative(); }
57+
bool isMin() const {
58+
return V.getValue() == APSInt::getMinValue(V.getSemantics().getWidth(),
59+
!V.getSemantics().isSigned());
60+
}
61+
62+
FixedPoint truncate(unsigned BitWidth) const { return *this; }
63+
64+
FixedPoint toSemantics(const llvm::FixedPointSemantics &Sem,
65+
bool *Overflow) const {
66+
return FixedPoint(V.convert(Sem, Overflow));
67+
}
5468

5569
llvm::APFloat toFloat(const llvm::fltSemantics *Sem) const {
5670
return V.convertToFloat(*Sem);
5771
}
5872

73+
std::string toDiagnosticString(const ASTContext &Ctx) const {
74+
return V.toString();
75+
}
76+
5977
ComparisonCategoryResult compare(const FixedPoint &Other) const {
6078
if (Other.V == V)
6179
return ComparisonCategoryResult::Equal;
@@ -67,6 +85,27 @@ class FixedPoint final {
6785
*R = FixedPoint(A.V.negate(&Overflow));
6886
return Overflow;
6987
}
88+
89+
static bool add(const FixedPoint A, const FixedPoint B, unsigned Bits,
90+
FixedPoint *R) {
91+
bool Overflow = false;
92+
*R = FixedPoint(A.V.add(B.V, &Overflow));
93+
return Overflow;
94+
}
95+
static bool sub(const FixedPoint A, const FixedPoint B, unsigned Bits,
96+
FixedPoint *R) {
97+
return true;
98+
}
99+
static bool mul(const FixedPoint A, const FixedPoint B, unsigned Bits,
100+
FixedPoint *R) {
101+
return true;
102+
}
103+
static bool div(const FixedPoint A, const FixedPoint B, unsigned Bits,
104+
FixedPoint *R) {
105+
return true;
106+
}
107+
static bool increment(const FixedPoint &A, FixedPoint *R) { return true; }
108+
static bool decrement(const FixedPoint &A, FixedPoint *R) { return true; }
70109
};
71110

72111
inline FixedPoint getSwappedBytes(FixedPoint F) { return F; }

clang/lib/AST/ByteCode/Interp.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2161,6 +2161,32 @@ inline bool CastFP(InterpState &S, CodePtr OpPC, const llvm::fltSemantics *Sem,
21612161
return true;
21622162
}
21632163

2164+
inline bool CastFixedPoint(InterpState &S, CodePtr OpPC, uint32_t FPS) {
2165+
FixedPointSemantics TargetSemantics(0, 0, false, false, false);
2166+
std::memcpy(&TargetSemantics, &FPS, sizeof(TargetSemantics));
2167+
2168+
const auto &Source = S.Stk.pop<FixedPoint>();
2169+
2170+
bool Overflow;
2171+
FixedPoint Result = Source.toSemantics(TargetSemantics, &Overflow);
2172+
2173+
if (Overflow) {
2174+
const Expr *E = S.Current->getExpr(OpPC);
2175+
if (S.checkingForUndefinedBehavior()) {
2176+
S.getASTContext().getDiagnostics().Report(
2177+
E->getExprLoc(), diag::warn_fixedpoint_constant_overflow)
2178+
<< Result.toDiagnosticString(S.getASTContext()) << E->getType();
2179+
}
2180+
S.CCEDiag(E, diag::note_constexpr_overflow)
2181+
<< Result.toDiagnosticString(S.getASTContext()) << E->getType();
2182+
if (!S.noteUndefinedBehavior())
2183+
return false;
2184+
}
2185+
2186+
S.Stk.push<FixedPoint>(Result);
2187+
return true;
2188+
}
2189+
21642190
/// Like Cast(), but we cast to an arbitrary-bitwidth integral, so we need
21652191
/// to know what bitwidth the result should be.
21662192
template <PrimType Name, class T = typename PrimConv<Name>::T>

clang/lib/AST/ByteCode/Opcodes.td

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def FloatTypeClass : TypeClass {
9898
}
9999

100100
def AluTypeClass : TypeClass {
101-
let Types = !listconcat(IntegerTypeClass.Types, [Bool]);
101+
let Types = !listconcat(IntegerTypeClass.Types, [Bool], [FixedPoint]);
102102
}
103103

104104
def PtrTypeClass : TypeClass {
@@ -110,7 +110,7 @@ def NonPtrTypeClass : TypeClass {
110110
}
111111

112112
def AllTypeClass : TypeClass {
113-
let Types = !listconcat(AluTypeClass.Types, PtrTypeClass.Types, FloatTypeClass.Types, [FixedPoint]);
113+
let Types = !listconcat(AluTypeClass.Types, PtrTypeClass.Types, FloatTypeClass.Types);
114114
}
115115

116116
def ComparableTypeClass : TypeClass {
@@ -626,6 +626,10 @@ def CastFP : Opcode {
626626
let Args = [ArgFltSemantics, ArgRoundingMode];
627627
}
628628

629+
def CastFixedPoint : Opcode {
630+
let Args = [ArgUint32];
631+
}
632+
629633
def FixedSizeIntegralTypes : TypeClass {
630634
let Types = [Uint8, Sint8, Uint16, Sint16, Uint32, Sint32, Uint64, Sint64, Bool];
631635
}

clang/lib/AST/ItaniumMangle.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ class CXXNameMangler {
464464
void mangleSeqID(unsigned SeqID);
465465
void mangleName(GlobalDecl GD);
466466
void mangleType(QualType T);
467-
void mangleNameOrStandardSubstitution(const NamedDecl *ND);
467+
void mangleCXXRecordDecl(const CXXRecordDecl *Record);
468468
void mangleLambdaSig(const CXXRecordDecl *Lambda);
469469
void mangleModuleNamePrefix(StringRef Name, bool IsPartition = false);
470470
void mangleVendorQualifier(StringRef Name);
@@ -3029,9 +3029,13 @@ void CXXNameMangler::mangleType(QualType T) {
30293029
addSubstitution(T);
30303030
}
30313031

3032-
void CXXNameMangler::mangleNameOrStandardSubstitution(const NamedDecl *ND) {
3033-
if (!mangleStandardSubstitution(ND))
3034-
mangleName(ND);
3032+
void CXXNameMangler::mangleCXXRecordDecl(const CXXRecordDecl *Record) {
3033+
if (mangleSubstitution(Record))
3034+
return;
3035+
mangleName(Record);
3036+
if (isCompatibleWith(LangOptions::ClangABI::Ver19))
3037+
return;
3038+
addSubstitution(Record);
30353039
}
30363040

30373041
void CXXNameMangler::mangleType(const BuiltinType *T) {
@@ -7309,15 +7313,15 @@ void ItaniumMangleContextImpl::mangleCXXVTable(const CXXRecordDecl *RD,
73097313
// <special-name> ::= TV <type> # virtual table
73107314
CXXNameMangler Mangler(*this, Out);
73117315
Mangler.getStream() << "_ZTV";
7312-
Mangler.mangleNameOrStandardSubstitution(RD);
7316+
Mangler.mangleCXXRecordDecl(RD);
73137317
}
73147318

73157319
void ItaniumMangleContextImpl::mangleCXXVTT(const CXXRecordDecl *RD,
73167320
raw_ostream &Out) {
73177321
// <special-name> ::= TT <type> # VTT structure
73187322
CXXNameMangler Mangler(*this, Out);
73197323
Mangler.getStream() << "_ZTT";
7320-
Mangler.mangleNameOrStandardSubstitution(RD);
7324+
Mangler.mangleCXXRecordDecl(RD);
73217325
}
73227326

73237327
void ItaniumMangleContextImpl::mangleCXXCtorVTable(const CXXRecordDecl *RD,
@@ -7327,10 +7331,10 @@ void ItaniumMangleContextImpl::mangleCXXCtorVTable(const CXXRecordDecl *RD,
73277331
// <special-name> ::= TC <type> <offset number> _ <base type>
73287332
CXXNameMangler Mangler(*this, Out);
73297333
Mangler.getStream() << "_ZTC";
7330-
Mangler.mangleNameOrStandardSubstitution(RD);
7334+
Mangler.mangleCXXRecordDecl(RD);
73317335
Mangler.getStream() << Offset;
73327336
Mangler.getStream() << '_';
7333-
Mangler.mangleNameOrStandardSubstitution(Type);
7337+
Mangler.mangleCXXRecordDecl(Type);
73347338
}
73357339

73367340
void ItaniumMangleContextImpl::mangleCXXRTTI(QualType Ty, raw_ostream &Out) {

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5633,8 +5633,9 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D,
56335633
emitter->finalize(GV);
56345634

56355635
// If it is safe to mark the global 'constant', do so now.
5636-
GV->setConstant(!NeedsGlobalCtor && !NeedsGlobalDtor &&
5637-
D->getType().isConstantStorage(getContext(), true, true));
5636+
GV->setConstant((D->hasAttr<CUDAConstantAttr>() && LangOpts.CUDAIsDevice) ||
5637+
(!NeedsGlobalCtor && !NeedsGlobalDtor &&
5638+
D->getType().isConstantStorage(getContext(), true, true)));
56385639

56395640
// If it is in a read-only section, mark it 'constant'.
56405641
if (const SectionAttr *SA = D->getAttr<SectionAttr>()) {

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3891,6 +3891,9 @@ void CompilerInvocationBase::GenerateLangArgs(const LangOptions &Opts,
38913891
case LangOptions::ClangABI::Ver18:
38923892
GenerateArg(Consumer, OPT_fclang_abi_compat_EQ, "18.0");
38933893
break;
3894+
case LangOptions::ClangABI::Ver19:
3895+
GenerateArg(Consumer, OPT_fclang_abi_compat_EQ, "19.0");
3896+
break;
38943897
case LangOptions::ClangABI::Latest:
38953898
break;
38963899
}
@@ -4482,6 +4485,8 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
44824485
Opts.setClangABICompat(LangOptions::ClangABI::Ver17);
44834486
else if (Major <= 18)
44844487
Opts.setClangABICompat(LangOptions::ClangABI::Ver18);
4488+
else if (Major <= 19)
4489+
Opts.setClangABICompat(LangOptions::ClangABI::Ver19);
44854490
} else if (Ver != "latest") {
44864491
Diags.Report(diag::err_drv_invalid_value)
44874492
<< A->getAsString(Args) << A->getValue();

0 commit comments

Comments
 (0)