Skip to content

Commit 445b88a

Browse files
committed
Merge release/21.x into cheriot
2 parents 1a145d0 + 450f52e commit 445b88a

File tree

98 files changed

+3704
-1347
lines changed

Some content is hidden

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

98 files changed

+3704
-1347
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,6 +1261,11 @@ New features
12611261
Crash and bug fixes
12621262
^^^^^^^^^^^^^^^^^^^
12631263

1264+
- Fixed a regression introduced by clang-20 in #GH115918 that lead to false
1265+
positive reports when ``[[no_unique_address]]`` or empty base class
1266+
optimization techniques were used. Most notably, some ``std::unique_ptr``
1267+
implementations. (#GH157467)
1268+
12641269
- Fixed a crash when C++20 parenthesized initializer lists are used.
12651270
This affected a crash of the well-known lambda overloaded pattern.
12661271
(#GH136041, #GH135665)

clang/include/clang/Basic/riscv_vector.td

Lines changed: 77 additions & 858 deletions
Large diffs are not rendered by default.

clang/lib/AST/ASTContext.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1742,6 +1742,9 @@ ASTContext::PointerAuthContent ASTContext::findPointerAuthContent(QualType T) {
17421742
assert(isPointerAuthenticationAvailable());
17431743

17441744
T = T.getCanonicalType();
1745+
if (T->isDependentType())
1746+
return PointerAuthContent::None;
1747+
17451748
if (T.hasAddressDiscriminatedPointerAuth())
17461749
return PointerAuthContent::AddressDiscriminatedData;
17471750
const RecordDecl *RD = T->getAsRecordDecl();

clang/lib/Basic/Targets/X86.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,7 @@ class LLVM_LIBRARY_VISIBILITY CygwinX86_32TargetInfo : public X86_32TargetInfo {
649649
: X86_32TargetInfo(Triple, Opts) {
650650
this->WCharType = TargetInfo::UnsignedShort;
651651
this->WIntType = TargetInfo::UnsignedInt;
652+
this->UseMicrosoftManglingForC = true;
652653
DoubleAlign = LongLongAlign = 64;
653654
resetDataLayout("e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-"
654655
"i128:128-f80:32-n8:16:32-a:0:32-S32",
@@ -986,6 +987,7 @@ class LLVM_LIBRARY_VISIBILITY CygwinX86_64TargetInfo : public X86_64TargetInfo {
986987
: X86_64TargetInfo(Triple, Opts) {
987988
this->WCharType = TargetInfo::UnsignedShort;
988989
this->WIntType = TargetInfo::UnsignedInt;
990+
this->UseMicrosoftManglingForC = true;
989991
}
990992

991993
void getTargetDefines(const LangOptions &Opts,

clang/lib/CodeGen/TargetBuiltins/RISCV.cpp

Lines changed: 945 additions & 4 deletions
Large diffs are not rendered by default.

clang/lib/CodeGen/Targets/Sparc.cpp

Lines changed: 57 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "ABIInfoImpl.h"
1010
#include "TargetInfo.h"
11+
#include <algorithm>
1112

1213
using namespace clang;
1314
using namespace clang::CodeGen;
@@ -109,7 +110,8 @@ class SparcV9ABIInfo : public ABIInfo {
109110
SparcV9ABIInfo(CodeGenTypes &CGT) : ABIInfo(CGT) {}
110111

111112
private:
112-
ABIArgInfo classifyType(QualType RetTy, unsigned SizeLimit) const;
113+
ABIArgInfo classifyType(QualType RetTy, unsigned SizeLimit,
114+
unsigned &RegOffset) const;
113115
void computeInfo(CGFunctionInfo &FI) const override;
114116
RValue EmitVAArg(CodeGenFunction &CGF, Address VAListAddr, QualType Ty,
115117
AggValueSlot Slot) const override;
@@ -222,127 +224,114 @@ class SparcV9ABIInfo : public ABIInfo {
222224
};
223225
} // end anonymous namespace
224226

225-
ABIArgInfo
226-
SparcV9ABIInfo::classifyType(QualType Ty, unsigned SizeLimit) const {
227+
ABIArgInfo SparcV9ABIInfo::classifyType(QualType Ty, unsigned SizeLimit,
228+
unsigned &RegOffset) const {
227229
if (Ty->isVoidType())
228230
return ABIArgInfo::getIgnore();
229231

230-
uint64_t Size = getContext().getTypeSize(Ty);
232+
auto &Context = getContext();
233+
auto &VMContext = getVMContext();
234+
235+
uint64_t Size = Context.getTypeSize(Ty);
236+
unsigned Alignment = Context.getTypeAlign(Ty);
237+
bool NeedPadding = (Alignment > 64) && (RegOffset % 2 != 0);
231238

232239
// Anything too big to fit in registers is passed with an explicit indirect
233240
// pointer / sret pointer.
234-
if (Size > SizeLimit)
241+
if (Size > SizeLimit) {
242+
RegOffset += 1;
235243
return getNaturalAlignIndirect(
236244
Ty, /*AddrSpace=*/getDataLayout().getAllocaAddrSpace(),
237245
/*ByVal=*/false);
246+
}
238247

239248
// Treat an enum type as its underlying type.
240249
if (const EnumType *EnumTy = Ty->getAs<EnumType>())
241250
Ty = EnumTy->getDecl()->getIntegerType();
242251

243252
// Integer types smaller than a register are extended.
244-
if (Size < 64 && Ty->isIntegerType())
253+
if (Size < 64 && Ty->isIntegerType()) {
254+
RegOffset += 1;
245255
return ABIArgInfo::getExtend(Ty);
256+
}
246257

247258
if (const auto *EIT = Ty->getAs<BitIntType>())
248-
if (EIT->getNumBits() < 64)
259+
if (EIT->getNumBits() < 64) {
260+
RegOffset += 1;
249261
return ABIArgInfo::getExtend(Ty);
262+
}
250263

251264
// Other non-aggregates go in registers.
252-
if (!isAggregateTypeForABI(Ty))
265+
if (!isAggregateTypeForABI(Ty)) {
266+
RegOffset += Size / 64;
253267
return ABIArgInfo::getDirect();
268+
}
254269

255270
// If a C++ object has either a non-trivial copy constructor or a non-trivial
256271
// destructor, it is passed with an explicit indirect pointer / sret pointer.
257-
if (CGCXXABI::RecordArgABI RAA = getRecordArgABI(Ty, getCXXABI()))
272+
if (CGCXXABI::RecordArgABI RAA = getRecordArgABI(Ty, getCXXABI())) {
273+
RegOffset += 1;
258274
return getNaturalAlignIndirect(Ty, getDataLayout().getAllocaAddrSpace(),
259275
RAA == CGCXXABI::RAA_DirectInMemory);
276+
}
260277

261278
// This is a small aggregate type that should be passed in registers.
262279
// Build a coercion type from the LLVM struct type.
263280
llvm::StructType *StrTy = dyn_cast<llvm::StructType>(CGT.ConvertType(Ty));
264-
if (!StrTy)
281+
if (!StrTy) {
282+
RegOffset += Size / 64;
265283
return ABIArgInfo::getDirect();
284+
}
266285

267-
CoerceBuilder CB(getVMContext(), getDataLayout());
286+
CoerceBuilder CB(VMContext, getDataLayout());
268287
CB.addStruct(0, StrTy);
269288
// All structs, even empty ones, should take up a register argument slot,
270289
// so pin the minimum struct size to one bit.
271290
CB.pad(llvm::alignTo(
272291
std::max(CB.DL.getTypeSizeInBits(StrTy).getKnownMinValue(), uint64_t(1)),
273292
64));
293+
RegOffset += CB.Size / 64;
294+
295+
// If we're dealing with overaligned structs we may need to add a padding in
296+
// the front, to preserve the correct register-memory mapping.
297+
//
298+
// See SCD 2.4.1, pages 3P-11 and 3P-12.
299+
llvm::Type *Padding =
300+
NeedPadding ? llvm::Type::getInt64Ty(VMContext) : nullptr;
301+
RegOffset += NeedPadding ? 1 : 0;
274302

275303
// Try to use the original type for coercion.
276304
llvm::Type *CoerceTy = CB.isUsableType(StrTy) ? StrTy : CB.getType();
277305

278-
if (CB.InReg)
279-
return ABIArgInfo::getDirectInReg(CoerceTy);
280-
else
281-
return ABIArgInfo::getDirect(CoerceTy);
306+
ABIArgInfo AAI = ABIArgInfo::getDirect(CoerceTy, 0, Padding);
307+
AAI.setInReg(CB.InReg);
308+
return AAI;
282309
}
283310

284311
RValue SparcV9ABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
285312
QualType Ty, AggValueSlot Slot) const {
286-
ABIArgInfo AI = classifyType(Ty, 16 * 8);
287-
llvm::Type *ArgTy = CGT.ConvertType(Ty);
288-
if (AI.canHaveCoerceToType() && !AI.getCoerceToType())
289-
AI.setCoerceToType(ArgTy);
290-
291313
CharUnits SlotSize = CharUnits::fromQuantity(8);
314+
auto TInfo = getContext().getTypeInfoInChars(Ty);
292315

293-
CGBuilderTy &Builder = CGF.Builder;
294-
Address Addr = Address(Builder.CreateLoad(VAListAddr, "ap.cur"),
295-
getVAListElementType(CGF), SlotSize);
296-
llvm::Type *ArgPtrTy = CGF.CGM.getPointerInDefaultAS(ArgTy);
297-
298-
auto TypeInfo = getContext().getTypeInfoInChars(Ty);
299-
300-
Address ArgAddr = Address::invalid();
301-
CharUnits Stride;
302-
switch (AI.getKind()) {
303-
case ABIArgInfo::Expand:
304-
case ABIArgInfo::CoerceAndExpand:
305-
case ABIArgInfo::InAlloca:
306-
llvm_unreachable("Unsupported ABI kind for va_arg");
307-
308-
case ABIArgInfo::Extend: {
309-
Stride = SlotSize;
310-
CharUnits Offset = SlotSize - TypeInfo.Width;
311-
ArgAddr = Builder.CreateConstInBoundsByteGEP(Addr, Offset, "extend");
312-
break;
313-
}
314-
315-
case ABIArgInfo::Direct: {
316-
auto AllocSize = getDataLayout().getTypeAllocSize(AI.getCoerceToType());
317-
Stride = CharUnits::fromQuantity(AllocSize).alignTo(SlotSize);
318-
ArgAddr = Addr;
319-
break;
320-
}
321-
322-
case ABIArgInfo::Indirect:
323-
case ABIArgInfo::IndirectAliased:
324-
Stride = SlotSize;
325-
ArgAddr = Addr.withElementType(ArgPtrTy);
326-
ArgAddr = Address(Builder.CreateLoad(ArgAddr, "indirect.arg"), ArgTy,
327-
TypeInfo.Align);
328-
break;
316+
// Zero-sized types have a width of one byte for parameter passing purposes.
317+
TInfo.Width = std::max(TInfo.Width, CharUnits::fromQuantity(1));
329318

330-
case ABIArgInfo::Ignore:
331-
return Slot.asRValue();
332-
}
333-
334-
// Update VAList.
335-
Address NextPtr = Builder.CreateConstInBoundsByteGEP(Addr, Stride, "ap.next");
336-
Builder.CreateStore(NextPtr.emitRawPointer(CGF), VAListAddr);
337-
338-
return CGF.EmitLoadOfAnyValue(
339-
CGF.MakeAddrLValue(ArgAddr.withElementType(ArgTy), Ty), Slot);
319+
// Arguments bigger than 2*SlotSize bytes are passed indirectly.
320+
return emitVoidPtrVAArg(CGF, VAListAddr, Ty,
321+
/*IsIndirect=*/TInfo.Width > 2 * SlotSize, TInfo,
322+
SlotSize,
323+
/*AllowHigherAlign=*/true, Slot);
340324
}
341325

342326
void SparcV9ABIInfo::computeInfo(CGFunctionInfo &FI) const {
343-
FI.getReturnInfo() = classifyType(FI.getReturnType(), 32 * 8);
327+
unsigned RetOffset = 0;
328+
ABIArgInfo RetType = classifyType(FI.getReturnType(), 32 * 8, RetOffset);
329+
FI.getReturnInfo() = RetType;
330+
331+
// Indirect returns will have its pointer passed as an argument.
332+
unsigned ArgOffset = RetType.isIndirect() ? RetOffset : 0;
344333
for (auto &I : FI.arguments())
345-
I.info = classifyType(I.type, 16 * 8);
334+
I.info = classifyType(I.type, 16 * 8, ArgOffset);
346335
}
347336

348337
namespace {

clang/lib/Format/Format.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4044,6 +4044,7 @@ LangOptions getFormattingLangOpts(const FormatStyle &Style) {
40444044
switch (Style.Language) {
40454045
case FormatStyle::LK_C:
40464046
LangOpts.C11 = 1;
4047+
LangOpts.C23 = 1;
40474048
break;
40484049
case FormatStyle::LK_Cpp:
40494050
case FormatStyle::LK_ObjC:

clang/lib/Format/TokenAnnotator.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -829,11 +829,6 @@ class AnnotatingParser {
829829
if (Parent && Parent->is(TT_PointerOrReference))
830830
Parent->overwriteFixedType(TT_BinaryOperator);
831831
}
832-
// An arrow after an ObjC method expression is not a lambda arrow.
833-
if (CurrentToken->is(TT_ObjCMethodExpr) && CurrentToken->Next &&
834-
CurrentToken->Next->is(TT_LambdaArrow)) {
835-
CurrentToken->Next->overwriteFixedType(TT_Unknown);
836-
}
837832
Left->MatchingParen = CurrentToken;
838833
CurrentToken->MatchingParen = Left;
839834
// FirstObjCSelectorName is set when a colon is found. This does

clang/lib/Format/UnwrappedLineParser.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2266,7 +2266,7 @@ bool UnwrappedLineParser::tryToParseLambda() {
22662266
if (!tryToParseLambdaIntroducer())
22672267
return false;
22682268

2269-
bool SeenArrow = false;
2269+
FormatToken *Arrow = nullptr;
22702270
bool InTemplateParameterList = false;
22712271

22722272
while (FormatTok->isNot(tok::l_brace)) {
@@ -2341,17 +2341,13 @@ bool UnwrappedLineParser::tryToParseLambda() {
23412341
case tok::ellipsis:
23422342
case tok::kw_true:
23432343
case tok::kw_false:
2344-
if (SeenArrow || InTemplateParameterList) {
2344+
if (Arrow || InTemplateParameterList) {
23452345
nextToken();
23462346
break;
23472347
}
23482348
return true;
23492349
case tok::arrow:
2350-
// This might or might not actually be a lambda arrow (this could be an
2351-
// ObjC method invocation followed by a dereferencing arrow). We might
2352-
// reset this back to TT_Unknown in TokenAnnotator.
2353-
FormatTok->setFinalizedType(TT_LambdaArrow);
2354-
SeenArrow = true;
2350+
Arrow = FormatTok;
23552351
nextToken();
23562352
break;
23572353
case tok::kw_requires: {
@@ -2373,6 +2369,9 @@ bool UnwrappedLineParser::tryToParseLambda() {
23732369
FormatTok->setFinalizedType(TT_LambdaLBrace);
23742370
LSquare.setFinalizedType(TT_LambdaLSquare);
23752371

2372+
if (Arrow)
2373+
Arrow->setFinalizedType(TT_LambdaArrow);
2374+
23762375
NestedLambdas.push_back(Line->SeenDecltypeAuto);
23772376
parseChildBlock();
23782377
assert(!NestedLambdas.empty());
@@ -2386,11 +2385,6 @@ bool UnwrappedLineParser::tryToParseLambdaIntroducer() {
23862385
const FormatToken *LeftSquare = FormatTok;
23872386
nextToken();
23882387
if (Previous) {
2389-
if (Previous->Tok.getIdentifierInfo() &&
2390-
!Previous->isOneOf(tok::kw_return, tok::kw_co_await, tok::kw_co_yield,
2391-
tok::kw_co_return)) {
2392-
return false;
2393-
}
23942388
if (Previous->closesScope()) {
23952389
// Not a potential C-style cast.
23962390
if (Previous->isNot(tok::r_paren))
@@ -2400,6 +2394,13 @@ bool UnwrappedLineParser::tryToParseLambdaIntroducer() {
24002394
// and `int (*)()`.
24012395
if (!BeforeRParen || !BeforeRParen->isOneOf(tok::greater, tok::r_paren))
24022396
return false;
2397+
} else if (Previous->is(tok::star)) {
2398+
Previous = Previous->getPreviousNonComment();
2399+
}
2400+
if (Previous && Previous->Tok.getIdentifierInfo() &&
2401+
!Previous->isOneOf(tok::kw_return, tok::kw_co_await, tok::kw_co_yield,
2402+
tok::kw_co_return)) {
2403+
return false;
24032404
}
24042405
}
24052406
if (LeftSquare->isCppStructuredBinding(IsCpp))

clang/lib/Headers/avx10_2bf16intrin.h

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -519,34 +519,34 @@ _mm_maskz_min_pbh(__mmask8 __U, __m128bh __A, __m128bh __B) {
519519
(__mmask8)__U, (__v8bf)_mm_min_pbh(__A, __B), (__v8bf)_mm_setzero_pbh());
520520
}
521521

522-
static __inline__ int __DEFAULT_FN_ATTRS128 _mm_comieq_sbh(__m128bh A,
523-
__m128bh B) {
524-
return __builtin_ia32_vcomisbf16eq((__v8bf)A, (__v8bf)B);
522+
static __inline__ int __DEFAULT_FN_ATTRS128 _mm_comieq_sbh(__m128bh __A,
523+
__m128bh __B) {
524+
return __builtin_ia32_vcomisbf16eq((__v8bf)__A, (__v8bf)__B);
525525
}
526526

527-
static __inline__ int __DEFAULT_FN_ATTRS128 _mm_comilt_sbh(__m128bh A,
528-
__m128bh B) {
529-
return __builtin_ia32_vcomisbf16lt((__v8bf)A, (__v8bf)B);
527+
static __inline__ int __DEFAULT_FN_ATTRS128 _mm_comilt_sbh(__m128bh __A,
528+
__m128bh __B) {
529+
return __builtin_ia32_vcomisbf16lt((__v8bf)__A, (__v8bf)__B);
530530
}
531531

532-
static __inline__ int __DEFAULT_FN_ATTRS128 _mm_comile_sbh(__m128bh A,
533-
__m128bh B) {
534-
return __builtin_ia32_vcomisbf16le((__v8bf)A, (__v8bf)B);
532+
static __inline__ int __DEFAULT_FN_ATTRS128 _mm_comile_sbh(__m128bh __A,
533+
__m128bh __B) {
534+
return __builtin_ia32_vcomisbf16le((__v8bf)__A, (__v8bf)__B);
535535
}
536536

537-
static __inline__ int __DEFAULT_FN_ATTRS128 _mm_comigt_sbh(__m128bh A,
538-
__m128bh B) {
539-
return __builtin_ia32_vcomisbf16gt((__v8bf)A, (__v8bf)B);
537+
static __inline__ int __DEFAULT_FN_ATTRS128 _mm_comigt_sbh(__m128bh __A,
538+
__m128bh __B) {
539+
return __builtin_ia32_vcomisbf16gt((__v8bf)__A, (__v8bf)__B);
540540
}
541541

542-
static __inline__ int __DEFAULT_FN_ATTRS128 _mm_comige_sbh(__m128bh A,
543-
__m128bh B) {
544-
return __builtin_ia32_vcomisbf16ge((__v8bf)A, (__v8bf)B);
542+
static __inline__ int __DEFAULT_FN_ATTRS128 _mm_comige_sbh(__m128bh __A,
543+
__m128bh __B) {
544+
return __builtin_ia32_vcomisbf16ge((__v8bf)__A, (__v8bf)__B);
545545
}
546546

547-
static __inline__ int __DEFAULT_FN_ATTRS128 _mm_comineq_sbh(__m128bh A,
548-
__m128bh B) {
549-
return __builtin_ia32_vcomisbf16neq((__v8bf)A, (__v8bf)B);
547+
static __inline__ int __DEFAULT_FN_ATTRS128 _mm_comineq_sbh(__m128bh __A,
548+
__m128bh __B) {
549+
return __builtin_ia32_vcomisbf16neq((__v8bf)__A, (__v8bf)__B);
550550
}
551551

552552
#define _mm256_cmp_pbh_mask(__A, __B, __P) \

0 commit comments

Comments
 (0)