Skip to content

Commit 7e0640a

Browse files
Merged main:c180e249d001 into origin/amd-gfx:2baeb40e888c
Local branch origin/amd-gfx 2baeb40 Update waterfall tests due to upstream Remote branch main c180e24 Fix crash lowering stack guard on OpenBSD/aarch64. (llvm#125416)
2 parents 2baeb40 + c180e24 commit 7e0640a

File tree

346 files changed

+9248
-3411
lines changed

Some content is hidden

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

346 files changed

+9248
-3411
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -413,10 +413,13 @@ Hexagon Support
413413
X86 Support
414414
^^^^^^^^^^^
415415

416-
- Disable ``-m[no-]avx10.1`` and switch ``-m[no-]avx10.2`` to alias of 512 bit
417-
options.
418-
- Change ``-mno-avx10.1-512`` to alias of ``-mno-avx10.1-256`` to disable both
419-
256 and 512 bit instructions.
416+
- The 256-bit maximum vector register size control was removed from
417+
`AVX10 whitepaper <https://cdrdv2.intel.com/v1/dl/getContent/784343>_`.
418+
* Re-target ``m[no-]avx10.1`` to enable AVX10.1 with 512-bit maximum vector register size.
419+
* Emit warning for ``mavx10.x-256``, noting AVX10/256 is not supported.
420+
* Emit warning for ``mavx10.x-512``, noting to use ``m[no-]avx10.x`` instead.
421+
* Emit warning for ``m[no-]evex512``, noting AVX10/256 is not supported.
422+
* The features avx10.x-256/512 keep unchanged and will be removed in the next release.
420423

421424
Arm and AArch64 Support
422425
^^^^^^^^^^^^^^^^^^^^^^^
@@ -434,6 +437,7 @@ Windows Support
434437
- Clang now can process the `i128` and `ui128` integeral suffixes when MSVC
435438
extensions are enabled. This allows for properly processing ``intsafe.h`` in
436439
the Windows SDK.
440+
- Clang now supports MSVC vector deleting destructors (GH19772).
437441

438442
LoongArch Support
439443
^^^^^^^^^^^^^^^^^

clang/include/clang/AST/VTableBuilder.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class VTableComponent {
150150

151151
bool isRTTIKind() const { return isRTTIKind(getKind()); }
152152

153-
GlobalDecl getGlobalDecl() const {
153+
GlobalDecl getGlobalDecl(bool HasVectorDeletingDtors) const {
154154
assert(isUsedFunctionPointerKind() &&
155155
"GlobalDecl can be created only from virtual function");
156156

@@ -161,7 +161,9 @@ class VTableComponent {
161161
case CK_CompleteDtorPointer:
162162
return GlobalDecl(DtorDecl, CXXDtorType::Dtor_Complete);
163163
case CK_DeletingDtorPointer:
164-
return GlobalDecl(DtorDecl, CXXDtorType::Dtor_Deleting);
164+
return GlobalDecl(DtorDecl, (HasVectorDeletingDtors)
165+
? CXXDtorType::Dtor_VectorDeleting
166+
: CXXDtorType::Dtor_Deleting);
165167
case CK_VCallOffset:
166168
case CK_VBaseOffset:
167169
case CK_OffsetToTop:

clang/include/clang/Basic/ABI.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@ enum CXXCtorType {
3131

3232
/// C++ destructor types.
3333
enum CXXDtorType {
34-
Dtor_Deleting, ///< Deleting dtor
35-
Dtor_Complete, ///< Complete object dtor
36-
Dtor_Base, ///< Base object dtor
37-
Dtor_Comdat ///< The COMDAT used for dtors
34+
Dtor_Deleting, ///< Deleting dtor
35+
Dtor_Complete, ///< Complete object dtor
36+
Dtor_Base, ///< Base object dtor
37+
Dtor_Comdat, ///< The COMDAT used for dtors
38+
Dtor_VectorDeleting ///< Vector deleting dtor
3839
};
3940

4041
} // end namespace clang

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,13 +377,12 @@ def CXX11WarnSuggestOverride : DiagGroup<"suggest-override">;
377377
def WarnUnnecessaryVirtualSpecifier : DiagGroup<"unnecessary-virtual-specifier"> {
378378
code Documentation = [{
379379
Warns when a ``final`` class contains a virtual method (including virtual
380-
destructors). Since ``final`` classes cannot be subclassed, their methods
381-
cannot be overridden, and hence the ``virtual`` specifier is useless.
380+
destructors) that does not override anything. Since ``final`` classes cannot be
381+
subclassed, their methods cannot be overridden, so there is no point to
382+
introducing new ``virtual`` methods.
382383

383384
The warning also detects virtual methods in classes whose destructor is
384385
``final``, for the same reason.
385-
386-
The warning does not fire on virtual methods which are also marked ``override``.
387386
}];
388387
}
389388

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2733,7 +2733,7 @@ def note_final_dtor_non_final_class_silence : Note<
27332733
"mark %0 as '%select{final|sealed}1' to silence this warning">;
27342734
def warn_unnecessary_virtual_specifier : Warning<
27352735
"virtual method %0 is inside a 'final' class and can never be overridden">,
2736-
InGroup<WarnUnnecessaryVirtualSpecifier>, DefaultIgnore;
2736+
InGroup<WarnUnnecessaryVirtualSpecifier>;
27372737

27382738
// C++11 attributes
27392739
def err_repeat_attribute : Error<"%0 attribute cannot be repeated">;
@@ -7031,10 +7031,10 @@ def err_offsetof_incomplete_type : Error<
70317031
def err_offsetof_record_type : Error<
70327032
"offsetof requires struct, union, or class type, %0 invalid">;
70337033
def err_offsetof_array_type : Error<"offsetof requires array type, %0 invalid">;
7034-
def ext_offsetof_non_pod_type : ExtWarn<"offset of on non-POD type %0">,
7034+
def ext_offsetof_non_pod_type : ExtWarn<"'offsetof' on non-POD type %0">,
70357035
InGroup<InvalidOffsetof>;
70367036
def ext_offsetof_non_standardlayout_type : ExtWarn<
7037-
"offset of on non-standard-layout type %0">, InGroup<InvalidOffsetof>;
7037+
"'offsetof' on non-standard-layout type %0">, InGroup<InvalidOffsetof>;
70387038
def err_offsetof_bitfield : Error<"cannot compute offset of bit-field %0">;
70397039
def err_offsetof_field_of_virtual_base : Error<
70407040
"invalid application of 'offsetof' to a field of a virtual base">;

clang/include/clang/Driver/Options.td

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6409,11 +6409,11 @@ def mavx10_1_256 : Flag<["-"], "mavx10.1-256">, Group<m_x86_AVX10_Features_Group
64096409
def mno_avx10_1_256 : Flag<["-"], "mno-avx10.1-256">, Group<m_x86_AVX10_Features_Group>;
64106410
def mavx10_1_512 : Flag<["-"], "mavx10.1-512">, Group<m_x86_AVX10_Features_Group>;
64116411
def mno_avx10_1_512 : Flag<["-"], "mno-avx10.1-512">, Alias<mno_avx10_1_256>;
6412-
def mavx10_1 : Flag<["-"], "mavx10.1">, Flags<[Unsupported]>;
6413-
def mno_avx10_1 : Flag<["-"], "mno-avx10.1">, Flags<[Unsupported]>;
6412+
def mavx10_1 : Flag<["-"], "mavx10.1">, Group<m_x86_AVX10_Features_Group>;
6413+
def mno_avx10_1 : Flag<["-"], "mno-avx10.1">, Group<m_x86_AVX10_Features_Group>;
64146414
def mavx10_2_256 : Flag<["-"], "mavx10.2-256">, Group<m_x86_AVX10_Features_Group>;
64156415
def mavx10_2_512 : Flag<["-"], "mavx10.2-512">, Group<m_x86_AVX10_Features_Group>;
6416-
def mavx10_2 : Flag<["-"], "mavx10.2">, Alias<mavx10_2_512>;
6416+
def mavx10_2 : Flag<["-"], "mavx10.2">, Group<m_x86_AVX10_Features_Group>;
64176417
def mno_avx10_2 : Flag<["-"], "mno-avx10.2">, Group<m_x86_AVX10_Features_Group>;
64186418
def mavx2 : Flag<["-"], "mavx2">, Group<m_x86_Features_Group>;
64196419
def mno_avx2 : Flag<["-"], "mno-avx2">, Group<m_x86_Features_Group>;

clang/lib/AST/ItaniumMangle.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6004,6 +6004,8 @@ void CXXNameMangler::mangleCXXDtorType(CXXDtorType T) {
60046004
case Dtor_Comdat:
60056005
Out << "D5";
60066006
break;
6007+
case Dtor_VectorDeleting:
6008+
llvm_unreachable("Itanium ABI does not use vector deleting dtors");
60076009
}
60086010
}
60096011

clang/lib/AST/MicrosoftMangle.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,8 +1484,9 @@ void MicrosoftCXXNameMangler::mangleCXXDtorType(CXXDtorType T) {
14841484
// <operator-name> ::= ?_G # scalar deleting destructor
14851485
case Dtor_Deleting: Out << "?_G"; return;
14861486
// <operator-name> ::= ?_E # vector deleting destructor
1487-
// FIXME: Add a vector deleting dtor type. It goes in the vtable, so we need
1488-
// it.
1487+
case Dtor_VectorDeleting:
1488+
Out << "?_E";
1489+
return;
14891490
case Dtor_Comdat:
14901491
llvm_unreachable("not expecting a COMDAT");
14911492
}
@@ -2886,9 +2887,12 @@ void MicrosoftCXXNameMangler::mangleFunctionType(const FunctionType *T,
28862887
// ::= @ # structors (they have no declared return type)
28872888
if (IsStructor) {
28882889
if (isa<CXXDestructorDecl>(D) && isStructorDecl(D)) {
2889-
// The scalar deleting destructor takes an extra int argument which is not
2890-
// reflected in the AST.
2891-
if (StructorType == Dtor_Deleting) {
2890+
// The deleting destructors take an extra argument of type int that
2891+
// indicates whether the storage for the object should be deleted and
2892+
// whether a single object or an array of objects is being destroyed. This
2893+
// extra argument is not reflected in the AST.
2894+
if (StructorType == Dtor_Deleting ||
2895+
StructorType == Dtor_VectorDeleting) {
28922896
Out << (PointersAre64Bit ? "PEAXI@Z" : "PAXI@Z");
28932897
return;
28942898
}
@@ -3861,10 +3865,10 @@ void MicrosoftMangleContextImpl::mangleCXXDtorThunk(const CXXDestructorDecl *DD,
38613865
const ThunkInfo &Thunk,
38623866
bool /*ElideOverrideInfo*/,
38633867
raw_ostream &Out) {
3864-
// FIXME: Actually, the dtor thunk should be emitted for vector deleting
3865-
// dtors rather than scalar deleting dtors. Just use the vector deleting dtor
3866-
// mangling manually until we support both deleting dtor types.
3867-
assert(Type == Dtor_Deleting);
3868+
// The dtor thunk should use vector deleting dtor mangling, however as an
3869+
// optimization we may end up emitting only scalar deleting dtor body, so just
3870+
// use the vector deleting dtor mangling manually.
3871+
assert(Type == Dtor_Deleting || Type == Dtor_VectorDeleting);
38683872
msvc_hashing_ostream MHO(Out);
38693873
MicrosoftCXXNameMangler Mangler(*this, MHO, DD, Type);
38703874
Mangler.getStream() << "??_E";

clang/lib/AST/VTableBuilder.cpp

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1735,8 +1735,8 @@ void ItaniumVTableBuilder::LayoutPrimaryAndSecondaryVTables(
17351735
const CXXMethodDecl *MD = I.first;
17361736
const MethodInfo &MI = I.second;
17371737
if (const CXXDestructorDecl *DD = dyn_cast<CXXDestructorDecl>(MD)) {
1738-
MethodVTableIndices[GlobalDecl(DD, Dtor_Complete)]
1739-
= MI.VTableIndex - AddressPoint;
1738+
MethodVTableIndices[GlobalDecl(DD, Dtor_Complete)] =
1739+
MI.VTableIndex - AddressPoint;
17401740
MethodVTableIndices[GlobalDecl(DD, Dtor_Deleting)]
17411741
= MI.VTableIndex + 1 - AddressPoint;
17421742
} else {
@@ -2657,7 +2657,11 @@ class VFTableBuilder {
26572657
MethodVFTableLocation Loc(MI.VBTableIndex, WhichVFPtr.getVBaseWithVPtr(),
26582658
WhichVFPtr.NonVirtualOffset, MI.VFTableIndex);
26592659
if (const CXXDestructorDecl *DD = dyn_cast<CXXDestructorDecl>(MD)) {
2660-
MethodVFTableLocations[GlobalDecl(DD, Dtor_Deleting)] = Loc;
2660+
// In Microsoft ABI vftable always references vector deleting dtor.
2661+
CXXDtorType DtorTy = Context.getTargetInfo().getCXXABI().isMicrosoft()
2662+
? Dtor_VectorDeleting
2663+
: Dtor_Deleting;
2664+
MethodVFTableLocations[GlobalDecl(DD, DtorTy)] = Loc;
26612665
} else {
26622666
MethodVFTableLocations[MD] = Loc;
26632667
}
@@ -3287,7 +3291,10 @@ void VFTableBuilder::dumpLayout(raw_ostream &Out) {
32873291
const CXXDestructorDecl *DD = Component.getDestructorDecl();
32883292

32893293
DD->printQualifiedName(Out);
3290-
Out << "() [scalar deleting]";
3294+
if (Context.getTargetInfo().getCXXABI().isMicrosoft())
3295+
Out << "() [vector deleting]";
3296+
else
3297+
Out << "() [scalar deleting]";
32913298

32923299
if (DD->isPureVirtual())
32933300
Out << " [pure]";
@@ -3736,8 +3743,7 @@ void MicrosoftVTableContext::computeVTableRelatedInformation(
37363743
}
37373744
}
37383745

3739-
MethodVFTableLocations.insert(NewMethodLocations.begin(),
3740-
NewMethodLocations.end());
3746+
MethodVFTableLocations.insert_range(NewMethodLocations);
37413747
if (Context.getLangOpts().DumpVTableLayouts)
37423748
dumpMethodLocations(RD, NewMethodLocations, llvm::outs());
37433749
}
@@ -3758,7 +3764,7 @@ void MicrosoftVTableContext::dumpMethodLocations(
37583764
PredefinedIdentKind::PrettyFunctionNoVirtual, MD);
37593765

37603766
if (isa<CXXDestructorDecl>(MD)) {
3761-
IndicesMap[I.second] = MethodName + " [scalar deleting]";
3767+
IndicesMap[I.second] = MethodName + " [vector deleting]";
37623768
} else {
37633769
IndicesMap[I.second] = MethodName;
37643770
}
@@ -3824,8 +3830,7 @@ const VirtualBaseInfo &MicrosoftVTableContext::computeVBTableRelatedInformation(
38243830
// virtual bases come first so that the layout is the same.
38253831
const VirtualBaseInfo &BaseInfo =
38263832
computeVBTableRelatedInformation(VBPtrBase);
3827-
VBI->VBTableIndices.insert(BaseInfo.VBTableIndices.begin(),
3828-
BaseInfo.VBTableIndices.end());
3833+
VBI->VBTableIndices.insert_range(BaseInfo.VBTableIndices);
38293834
}
38303835

38313836
// New vbases are added to the end of the vbtable.
@@ -3875,7 +3880,7 @@ MicrosoftVTableContext::getMethodVFTableLocation(GlobalDecl GD) {
38753880
assert(hasVtableSlot(cast<CXXMethodDecl>(GD.getDecl())) &&
38763881
"Only use this method for virtual methods or dtors");
38773882
if (isa<CXXDestructorDecl>(GD.getDecl()))
3878-
assert(GD.getDtorType() == Dtor_Deleting);
3883+
assert(GD.getDtorType() == Dtor_VectorDeleting);
38793884

38803885
GD = GD.getCanonicalDecl();
38813886

clang/lib/CodeGen/CGCXX.cpp

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ bool CodeGenModule::TryEmitBaseDestructorAsAlias(const CXXDestructorDecl *D) {
175175
// requires explicit comdat support in the IL.
176176
if (llvm::GlobalValue::isWeakForLinker(TargetLinkage))
177177
return true;
178-
179178
// Create the alias with no name.
180179
auto *Alias = llvm::GlobalAlias::create(AliasValueType, 0, Linkage, "",
181180
Aliasee, &getModule());
@@ -201,6 +200,42 @@ bool CodeGenModule::TryEmitBaseDestructorAsAlias(const CXXDestructorDecl *D) {
201200
return false;
202201
}
203202

203+
/// Emit a definition as a global alias for another definition, unconditionally.
204+
void CodeGenModule::EmitDefinitionAsAlias(GlobalDecl AliasDecl,
205+
GlobalDecl TargetDecl) {
206+
207+
llvm::Type *AliasValueType = getTypes().GetFunctionType(AliasDecl);
208+
209+
StringRef MangledName = getMangledName(AliasDecl);
210+
llvm::GlobalValue *Entry = GetGlobalValue(MangledName);
211+
if (Entry && !Entry->isDeclaration())
212+
return;
213+
auto *Aliasee = cast<llvm::GlobalValue>(GetAddrOfGlobal(TargetDecl));
214+
215+
// Determine the linkage type for the alias.
216+
llvm::GlobalValue::LinkageTypes Linkage = getFunctionLinkage(AliasDecl);
217+
218+
// Create the alias with no name.
219+
auto *Alias = llvm::GlobalAlias::create(AliasValueType, 0, Linkage, "",
220+
Aliasee, &getModule());
221+
// Destructors are always unnamed_addr.
222+
Alias->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
223+
224+
if (Entry) {
225+
assert(Entry->getValueType() == AliasValueType &&
226+
Entry->getAddressSpace() == Alias->getAddressSpace() &&
227+
"declaration exists with different type");
228+
Alias->takeName(Entry);
229+
Entry->replaceAllUsesWith(Alias);
230+
Entry->eraseFromParent();
231+
} else {
232+
Alias->setName(MangledName);
233+
}
234+
235+
// Set any additional necessary attributes for the alias.
236+
SetCommonAttributes(AliasDecl, Alias);
237+
}
238+
204239
llvm::Function *CodeGenModule::codegenCXXStructor(GlobalDecl GD) {
205240
const CGFunctionInfo &FnInfo = getTypes().arrangeCXXStructorDeclaration(GD);
206241
auto *Fn = cast<llvm::Function>(

clang/lib/CodeGen/CGCXXABI.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,20 @@ void CGCXXABI::ReadArrayCookie(CodeGenFunction &CGF, Address ptr,
272272
numElements = readArrayCookieImpl(CGF, allocAddr, cookieSize);
273273
}
274274

275+
void CGCXXABI::ReadArrayCookie(CodeGenFunction &CGF, Address ptr,
276+
QualType eltTy, llvm::Value *&numElements,
277+
llvm::Value *&allocPtr, CharUnits &cookieSize) {
278+
assert(eltTy.isDestructedType());
279+
280+
// Derive a char* in the same address space as the pointer.
281+
ptr = ptr.withElementType(CGF.Int8Ty);
282+
283+
cookieSize = getArrayCookieSizeImpl(eltTy);
284+
Address allocAddr = CGF.Builder.CreateConstInBoundsByteGEP(ptr, -cookieSize);
285+
allocPtr = allocAddr.emitRawPointer(CGF);
286+
numElements = readArrayCookieImpl(CGF, allocAddr, cookieSize);
287+
}
288+
275289
llvm::Value *CGCXXABI::readArrayCookieImpl(CodeGenFunction &CGF,
276290
Address ptr,
277291
CharUnits cookieSize) {

clang/lib/CodeGen/CGCXXABI.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ class CGCXXABI {
275275
virtual CatchTypeInfo getCatchAllTypeInfo();
276276

277277
virtual bool shouldTypeidBeNullChecked(QualType SrcRecordTy) = 0;
278+
virtual bool hasVectorDeletingDtors() = 0;
278279
virtual void EmitBadTypeidCall(CodeGenFunction &CGF) = 0;
279280
virtual llvm::Value *EmitTypeid(CodeGenFunction &CGF, QualType SrcRecordTy,
280281
Address ThisPtr,
@@ -575,6 +576,12 @@ class CGCXXABI {
575576
QualType ElementType, llvm::Value *&NumElements,
576577
llvm::Value *&AllocPtr, CharUnits &CookieSize);
577578

579+
/// Reads the array cookie associated with the given pointer,
580+
/// that should have one.
581+
void ReadArrayCookie(CodeGenFunction &CGF, Address Ptr, QualType ElementType,
582+
llvm::Value *&NumElements, llvm::Value *&AllocPtr,
583+
CharUnits &CookieSize);
584+
578585
/// Return whether the given global decl needs a VTT parameter.
579586
virtual bool NeedsVTTParameter(GlobalDecl GD);
580587

0 commit comments

Comments
 (0)