Skip to content

Commit d969842

Browse files
committed
Manually Merged main:6733a505a1afb8eb4db2f6d85426d79ff0dc5eee into amd-gfx:4be7cf4eb8ab
Local branch amd-gfx 4be7cf4 Merged main:91423d71938d7a1dba27188e6d854148a750a3dd into amd-gfx:c4a99e6e24d7 Remote branch main 6733a50 [MLIR][OpenMP] NFC: Split OpenMP dialect definitions (llvm#91741)
2 parents 4be7cf4 + 6733a50 commit d969842

File tree

177 files changed

+3856
-2174
lines changed

Some content is hidden

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

177 files changed

+3856
-2174
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,9 @@ Bug Fixes in This Version
586586
- Clang now correctly disallows VLA type compound literals, e.g. ``(int[size]){}``,
587587
as the C standard mandates. (#GH89835)
588588

589+
- ``__is_array`` and ``__is_bounded_array`` no longer return ``true`` for
590+
zero-sized arrays. Fixes (#GH54705).
591+
589592
Bug Fixes to Compiler Builtins
590593
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
591594

clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ class SymbolGraphSerializer : public APISetVisitor<SymbolGraphSerializer> {
102102

103103
const bool EmitSymbolLabelsForTesting = false;
104104

105+
const bool SkipSymbolsInCategoriesToExternalTypes = false;
106+
105107
/// The object instantiated by the last call to serializeAPIRecord.
106108
Object *CurrentSymbol = nullptr;
107109

@@ -271,10 +273,13 @@ class SymbolGraphSerializer : public APISetVisitor<SymbolGraphSerializer> {
271273

272274
SymbolGraphSerializer(const APISet &API, const APIIgnoresList &IgnoresList,
273275
bool EmitSymbolLabelsForTesting = false,
274-
bool ForceEmitToMainModule = false)
276+
bool ForceEmitToMainModule = false,
277+
bool SkipSymbolsInCategoriesToExternalTypes = false)
275278
: Base(API), ForceEmitToMainModule(ForceEmitToMainModule),
276279
IgnoresList(IgnoresList),
277-
EmitSymbolLabelsForTesting(EmitSymbolLabelsForTesting) {}
280+
EmitSymbolLabelsForTesting(EmitSymbolLabelsForTesting),
281+
SkipSymbolsInCategoriesToExternalTypes(
282+
SkipSymbolsInCategoriesToExternalTypes) {}
278283
};
279284

280285
} // namespace extractapi

clang/include/clang/Serialization/ASTWriter.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -715,9 +715,6 @@ class ASTWriter : public ASTDeserializationListener,
715715
/// Force a type to be emitted and get its ID.
716716
serialization::TypeID GetOrCreateTypeID(QualType T);
717717

718-
/// Determine the type ID of an already-emitted type.
719-
serialization::TypeID getTypeID(QualType T) const;
720-
721718
/// Find the first local declaration of a given local redeclarable
722719
/// decl.
723720
const Decl *getFirstLocalDecl(const Decl *D);

clang/lib/Basic/Targets/Mips.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,13 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public TargetInfo {
8585
return CPU == "mips32r6" || CPU == "mips64r6";
8686
}
8787

88-
bool isFP64Default() const {
89-
return CPU == "mips32r6" || ABI == "n32" || ABI == "n64" || ABI == "64";
88+
enum FPModeEnum getDefaultFPMode() const {
89+
if (CPU == "mips32r6" || ABI == "n32" || ABI == "n64" || ABI == "64")
90+
return FP64;
91+
else if (CPU == "mips1")
92+
return FP32;
93+
else
94+
return FPXX;
9095
}
9196

9297
bool isNan2008() const override { return IsNan2008; }
@@ -315,8 +320,8 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public TargetInfo {
315320
IsSingleFloat = false;
316321
FloatABI = HardFloat;
317322
DspRev = NoDSP;
318-
FPMode = isFP64Default() ? FP64 : FPXX;
319323
NoOddSpreg = false;
324+
FPMode = getDefaultFPMode();
320325
bool OddSpregGiven = false;
321326
bool StrictAlign = false;
322327

clang/lib/CodeGen/CoverageMappingGen.cpp

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "clang/Basic/FileManager.h"
1818
#include "clang/Frontend/FrontendDiagnostic.h"
1919
#include "clang/Lex/Lexer.h"
20+
#include "llvm/ADT/DenseSet.h"
2021
#include "llvm/ADT/SmallSet.h"
2122
#include "llvm/ADT/StringExtras.h"
2223
#include "llvm/ProfileData/Coverage/CoverageMapping.h"
@@ -336,16 +337,26 @@ class CoverageMappingBuilder {
336337

337338
llvm::SmallSet<FileID, 8> Visited;
338339
SmallVector<std::pair<SourceLocation, unsigned>, 8> FileLocs;
339-
for (const auto &Region : SourceRegions) {
340+
for (auto &Region : SourceRegions) {
340341
SourceLocation Loc = Region.getBeginLoc();
342+
343+
// Replace Loc with FileLoc if it is expanded with system headers.
344+
if (!SystemHeadersCoverage && SM.isInSystemMacro(Loc)) {
345+
auto BeginLoc = SM.getSpellingLoc(Loc);
346+
auto EndLoc = SM.getSpellingLoc(Region.getEndLoc());
347+
if (SM.isWrittenInSameFile(BeginLoc, EndLoc)) {
348+
Loc = SM.getFileLoc(Loc);
349+
Region.setStartLoc(Loc);
350+
Region.setEndLoc(SM.getFileLoc(Region.getEndLoc()));
351+
}
352+
}
353+
341354
FileID File = SM.getFileID(Loc);
342355
if (!Visited.insert(File).second)
343356
continue;
344357

345-
// Do not map FileID's associated with system headers unless collecting
346-
// coverage from system headers is explicitly enabled.
347-
if (!SystemHeadersCoverage && SM.isInSystemHeader(SM.getSpellingLoc(Loc)))
348-
continue;
358+
assert(SystemHeadersCoverage ||
359+
!SM.isInSystemHeader(SM.getSpellingLoc(Loc)));
349360

350361
unsigned Depth = 0;
351362
for (SourceLocation Parent = getIncludeOrExpansionLoc(Loc);
@@ -818,6 +829,10 @@ struct CounterCoverageMappingBuilder
818829
/// A stack of currently live regions.
819830
llvm::SmallVector<SourceMappingRegion> RegionStack;
820831

832+
/// Set if the Expr should be handled as a leaf even if it is kind of binary
833+
/// logical ops (&&, ||).
834+
llvm::DenseSet<const Stmt *> LeafExprSet;
835+
821836
/// An object to manage MCDC regions.
822837
MCDCCoverageBuilder MCDCBuilder;
823838

@@ -1040,7 +1055,10 @@ struct CounterCoverageMappingBuilder
10401055
// region onto RegionStack but immediately pop it (which adds it to the
10411056
// function's SourceRegions) because it doesn't apply to any other source
10421057
// code other than the Condition.
1043-
if (CodeGenFunction::isInstrumentedCondition(C)) {
1058+
// With !SystemHeadersCoverage, binary logical ops in system headers may be
1059+
// treated as instrumentable conditions.
1060+
if (CodeGenFunction::isInstrumentedCondition(C) ||
1061+
LeafExprSet.count(CodeGenFunction::stripCond(C))) {
10441062
mcdc::Parameters BranchParams;
10451063
mcdc::ConditionID ID = MCDCBuilder.getCondID(C);
10461064
if (ID >= 0)
@@ -2070,7 +2088,20 @@ struct CounterCoverageMappingBuilder
20702088
createDecisionRegion(E, DecisionParams);
20712089
}
20722090

2091+
/// Check if E belongs to system headers.
2092+
bool isExprInSystemHeader(const BinaryOperator *E) const {
2093+
return (!SystemHeadersCoverage &&
2094+
SM.isInSystemHeader(SM.getSpellingLoc(E->getOperatorLoc())) &&
2095+
SM.isInSystemHeader(SM.getSpellingLoc(E->getBeginLoc())) &&
2096+
SM.isInSystemHeader(SM.getSpellingLoc(E->getEndLoc())));
2097+
}
2098+
20732099
void VisitBinLAnd(const BinaryOperator *E) {
2100+
if (isExprInSystemHeader(E)) {
2101+
LeafExprSet.insert(E);
2102+
return;
2103+
}
2104+
20742105
bool IsRootNode = MCDCBuilder.isIdle();
20752106

20762107
// Keep track of Binary Operator and assign MCDC condition IDs.
@@ -2125,6 +2156,11 @@ struct CounterCoverageMappingBuilder
21252156
}
21262157

21272158
void VisitBinLOr(const BinaryOperator *E) {
2159+
if (isExprInSystemHeader(E)) {
2160+
LeafExprSet.insert(E);
2161+
return;
2162+
}
2163+
21282164
bool IsRootNode = MCDCBuilder.isIdle();
21292165

21302166
// Keep track of Binary Operator and assign MCDC condition IDs.

clang/lib/Driver/ToolChains/Arch/Mips.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,9 @@ void mips::getMIPSTargetFeatures(const Driver &D, const llvm::Triple &Triple,
369369
} else if (mips::isFP64ADefault(Triple, CPUName)) {
370370
Features.push_back("+fp64");
371371
Features.push_back("+nooddspreg");
372+
} else if (Arg *A = Args.getLastArg(options::OPT_mmsa)) {
373+
if (A->getOption().matches(options::OPT_mmsa))
374+
Features.push_back("+fp64");
372375
}
373376

374377
AddTargetFeature(Args, Features, options::OPT_mno_odd_spreg,
@@ -499,6 +502,13 @@ bool mips::shouldUseFPXX(const ArgList &Args, const llvm::Triple &Triple,
499502
options::OPT_mdouble_float))
500503
if (A->getOption().matches(options::OPT_msingle_float))
501504
UseFPXX = false;
505+
// FP64 should be used for MSA.
506+
if (Arg *A = Args.getLastArg(options::OPT_mmsa))
507+
if (A->getOption().matches(options::OPT_mmsa))
508+
UseFPXX = llvm::StringSwitch<bool>(CPUName)
509+
.Cases("mips32r2", "mips32r3", "mips32r5", false)
510+
.Cases("mips64r2", "mips64r3", "mips64r5", false)
511+
.Default(UseFPXX);
502512

503513
return UseFPXX;
504514
}

clang/lib/Driver/ToolChains/PS4CPU.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,12 @@ void toolchains::PS4PS5Base::addClangTargetOptions(
358358

359359
CC1Args.push_back("-fno-use-init-array");
360360

361+
// Default to `hidden` visibility for PS5.
362+
if (getTriple().isPS5() &&
363+
!DriverArgs.hasArg(options::OPT_fvisibility_EQ,
364+
options::OPT_fvisibility_ms_compat))
365+
CC1Args.push_back("-fvisibility=hidden");
366+
361367
// Default to -fvisibility-global-new-delete=source for PS5.
362368
if (getTriple().isPS5() &&
363369
!DriverArgs.hasArg(options::OPT_fvisibility_global_new_delete_EQ,
@@ -376,24 +382,32 @@ void toolchains::PS4PS5Base::addClangTargetOptions(
376382
else
377383
CC1Args.push_back("-fvisibility-dllexport=protected");
378384

385+
// For PS4 we override the visibilty of globals definitions without
386+
// dllimport or dllexport annotations.
379387
if (DriverArgs.hasArg(options::OPT_fvisibility_nodllstorageclass_EQ))
380388
DriverArgs.AddLastArg(CC1Args,
381389
options::OPT_fvisibility_nodllstorageclass_EQ);
382-
else
390+
else if (getTriple().isPS4())
383391
CC1Args.push_back("-fvisibility-nodllstorageclass=hidden");
392+
else
393+
CC1Args.push_back("-fvisibility-nodllstorageclass=keep");
384394

385395
if (DriverArgs.hasArg(options::OPT_fvisibility_externs_dllimport_EQ))
386396
DriverArgs.AddLastArg(CC1Args,
387397
options::OPT_fvisibility_externs_dllimport_EQ);
388398
else
389399
CC1Args.push_back("-fvisibility-externs-dllimport=default");
390400

401+
// For PS4 we override the visibilty of external globals without
402+
// dllimport or dllexport annotations.
391403
if (DriverArgs.hasArg(
392404
options::OPT_fvisibility_externs_nodllstorageclass_EQ))
393405
DriverArgs.AddLastArg(
394406
CC1Args, options::OPT_fvisibility_externs_nodllstorageclass_EQ);
395-
else
407+
else if (getTriple().isPS4())
396408
CC1Args.push_back("-fvisibility-externs-nodllstorageclass=default");
409+
else
410+
CC1Args.push_back("-fvisibility-externs-nodllstorageclass=keep");
397411
}
398412
}
399413

clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -925,6 +925,10 @@ bool SymbolGraphSerializer::visitObjCInterfaceRecord(
925925

926926
bool SymbolGraphSerializer::traverseObjCCategoryRecord(
927927
const ObjCCategoryRecord *Record) {
928+
if (SkipSymbolsInCategoriesToExternalTypes &&
929+
!API.findRecordForUSR(Record->Interface.USR))
930+
return true;
931+
928932
auto *CurrentModule = ModuleForCurrentSymbol;
929933
if (Record->isExtendingExternalModule())
930934
ModuleForCurrentSymbol = &ExtendedModules[Record->Interface.Source];
@@ -1040,8 +1044,11 @@ void SymbolGraphSerializer::serializeGraphToStream(
10401044
void SymbolGraphSerializer::serializeMainSymbolGraph(
10411045
raw_ostream &OS, const APISet &API, const APIIgnoresList &IgnoresList,
10421046
SymbolGraphSerializerOption Options) {
1043-
SymbolGraphSerializer Serializer(API, IgnoresList,
1044-
Options.EmitSymbolLabelsForTesting);
1047+
SymbolGraphSerializer Serializer(
1048+
API, IgnoresList, Options.EmitSymbolLabelsForTesting,
1049+
/*ForceEmitToMainModule=*/true,
1050+
/*SkipSymbolsInCategoriesToExternalTypes=*/true);
1051+
10451052
Serializer.traverseAPISet();
10461053
Serializer.serializeGraphToStream(OS, Options, API.ProductName,
10471054
std::move(Serializer.MainModule));

clang/lib/Headers/opencl-c-base.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@
4646
#define __opencl_c_ext_fp32_global_atomic_min_max 1
4747
#define __opencl_c_ext_fp32_local_atomic_min_max 1
4848
#define __opencl_c_ext_image_raw10_raw12 1
49+
#define cl_khr_kernel_clock 1
50+
#define __opencl_c_kernel_clock_scope_device 1
51+
#define __opencl_c_kernel_clock_scope_work_group 1
52+
#define __opencl_c_kernel_clock_scope_sub_group 1
4953

5054
#endif // defined(__SPIR__) || defined(__SPIRV__)
5155
#endif // (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)

clang/lib/Headers/opencl-c.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17314,6 +17314,21 @@ half __ovld __conv sub_group_clustered_rotate(half, int, uint);
1731417314
#endif // cl_khr_fp16
1731517315
#endif // cl_khr_subgroup_rotate
1731617316

17317+
#if defined(cl_khr_kernel_clock)
17318+
#if defined(__opencl_c_kernel_clock_scope_device)
17319+
ulong __ovld clock_read_device();
17320+
uint2 __ovld clock_read_hilo_device();
17321+
#endif // __opencl_c_kernel_clock_scope_device
17322+
#if defined(__opencl_c_kernel_clock_scope_work_group)
17323+
ulong __ovld clock_read_work_group();
17324+
uint2 __ovld clock_read_hilo_work_group();
17325+
#endif // __opencl_c_kernel_clock_scope_work_group
17326+
#if defined(__opencl_c_kernel_clock_scope_sub_group)
17327+
ulong __ovld clock_read_sub_group();
17328+
uint2 __ovld clock_read_hilo_sub_group();
17329+
#endif // __opencl_c_kernel_clock_scope_sub_group
17330+
#endif // cl_khr_kernel_clock
17331+
1731717332
#if defined(cl_intel_subgroups)
1731817333
// Intel-Specific Sub Group Functions
1731917334
float __ovld __conv intel_sub_group_shuffle( float , uint );

clang/lib/Sema/OpenCLBuiltins.td

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1852,6 +1852,20 @@ let Extension = FunctionExtension<"cl_khr_subgroup_rotate"> in {
18521852
def : Builtin<"sub_group_clustered_rotate", [AGenType1, AGenType1, Int, UInt], Attr.Convergent>;
18531853
}
18541854

1855+
// cl_khr_kernel_clock
1856+
let Extension = FunctionExtension<"cl_khr_kernel_clock __opencl_c_kernel_clock_scope_device"> in {
1857+
def : Builtin<"clock_read_device", [ULong]>;
1858+
def : Builtin<"clock_read_hilo_device", [VectorType<UInt, 2>]>;
1859+
}
1860+
let Extension = FunctionExtension<"cl_khr_kernel_clock __opencl_c_kernel_clock_scope_work_group"> in {
1861+
def : Builtin<"clock_read_work_group", [ULong]>;
1862+
def : Builtin<"clock_read_hilo_work_group", [VectorType<UInt, 2>]>;
1863+
}
1864+
let Extension = FunctionExtension<"cl_khr_kernel_clock __opencl_c_kernel_clock_scope_sub_group"> in {
1865+
def : Builtin<"clock_read_sub_group", [ULong]>;
1866+
def : Builtin<"clock_read_hilo_sub_group", [VectorType<UInt, 2>]>;
1867+
}
1868+
18551869
//--------------------------------------------------------------------
18561870
// Arm extensions.
18571871
let Extension = ArmIntegerDotProductInt8 in {

clang/lib/Sema/SemaExprCXX.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5217,10 +5217,18 @@ static bool EvaluateUnaryTypeTrait(Sema &Self, TypeTrait UTT,
52175217
case UTT_IsFloatingPoint:
52185218
return T->isFloatingType();
52195219
case UTT_IsArray:
5220+
// Zero-sized arrays aren't considered arrays in partial specializations,
5221+
// so __is_array shouldn't consider them arrays either.
5222+
if (const auto *CAT = C.getAsConstantArrayType(T))
5223+
return CAT->getSize() != 0;
52205224
return T->isArrayType();
52215225
case UTT_IsBoundedArray:
52225226
if (DiagnoseVLAInCXXTypeTrait(Self, TInfo, tok::kw___is_bounded_array))
52235227
return false;
5228+
// Zero-sized arrays aren't considered arrays in partial specializations,
5229+
// so __is_bounded_array shouldn't consider them arrays either.
5230+
if (const auto *CAT = C.getAsConstantArrayType(T))
5231+
return CAT->getSize() != 0;
52245232
return T->isArrayType() && !T->isIncompleteArrayType();
52255233
case UTT_IsUnboundedArray:
52265234
if (DiagnoseVLAInCXXTypeTrait(Self, TInfo, tok::kw___is_unbounded_array))

clang/lib/Serialization/ASTCommon.h

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -46,30 +46,6 @@ enum DeclUpdateKind {
4646

4747
TypeIdx TypeIdxFromBuiltin(const BuiltinType *BT);
4848

49-
template <typename IdxForTypeTy>
50-
TypeID MakeTypeID(ASTContext &Context, QualType T, IdxForTypeTy IdxForType) {
51-
if (T.isNull())
52-
return PREDEF_TYPE_NULL_ID;
53-
54-
unsigned FastQuals = T.getLocalFastQualifiers();
55-
T.removeLocalFastQualifiers();
56-
57-
if (T.hasLocalNonFastQualifiers())
58-
return IdxForType(T).asTypeID(FastQuals);
59-
60-
assert(!T.hasLocalQualifiers());
61-
62-
if (const BuiltinType *BT = dyn_cast<BuiltinType>(T.getTypePtr()))
63-
return TypeIdxFromBuiltin(BT).asTypeID(FastQuals);
64-
65-
if (T == Context.AutoDeductTy)
66-
return TypeIdx(PREDEF_TYPE_AUTO_DEDUCT).asTypeID(FastQuals);
67-
if (T == Context.AutoRRefDeductTy)
68-
return TypeIdx(PREDEF_TYPE_AUTO_RREF_DEDUCT).asTypeID(FastQuals);
69-
70-
return IdxForType(T).asTypeID(FastQuals);
71-
}
72-
7349
unsigned ComputeHash(Selector Sel);
7450

7551
/// Retrieve the "definitive" declaration that provides all of the

0 commit comments

Comments
 (0)