Skip to content

Commit cadd631

Browse files
committed
Merge "merge main into amd-staging" into amd-staging
2 parents 25b871d + d02a618 commit cadd631

File tree

443 files changed

+24391
-6080
lines changed

Some content is hidden

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

443 files changed

+24391
-6080
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,7 @@ Bug Fixes to C++ Support
623623
- Clang now correctly ignores previous partial specializations of member templates explicitly specialized for
624624
an implicitly instantiated class template specialization. (#GH51051)
625625
- Fixed an assertion failure caused by invalid enum forward declarations. (#GH112208)
626+
- Name independent data members were not correctly initialized from default member initializers. (#GH114069)
626627

627628
Bug Fixes to AST Handling
628629
^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -920,6 +921,7 @@ OpenMP Support
920921
--------------
921922
- Added support for 'omp assume' directive.
922923
- Added support for 'omp scope' directive.
924+
- Added support for allocator-modifier in 'allocate' clause.
923925

924926
Improvements
925927
^^^^^^^^^^^^

clang/include/clang/AST/ASTContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,7 @@ class ASTContext : public RefCountedBase<ASTContext> {
10411041
void setInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst,
10421042
UsingShadowDecl *Pattern);
10431043

1044-
FieldDecl *getInstantiatedFromUnnamedFieldDecl(FieldDecl *Field);
1044+
FieldDecl *getInstantiatedFromUnnamedFieldDecl(FieldDecl *Field) const;
10451045

10461046
void setInstantiatedFromUnnamedFieldDecl(FieldDecl *Inst, FieldDecl *Tmpl);
10471047

clang/include/clang/AST/OpenMPClause.h

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,8 @@ class OMPAlignClause final
486486
/// #pragma omp parallel private(a) allocate(omp_default_mem_alloc :a)
487487
/// \endcode
488488
/// In this example directive '#pragma omp parallel' has clause 'private'
489-
/// and clause 'allocate' for the variable 'a'.
489+
/// and clause 'allocate' for the variable 'a', which specifies an explicit
490+
/// memory allocator.
490491
class OMPAllocateClause final
491492
: public OMPVarListClause<OMPAllocateClause>,
492493
private llvm::TrailingObjects<OMPAllocateClause, Expr *> {
@@ -499,6 +500,10 @@ class OMPAllocateClause final
499500
Expr *Allocator = nullptr;
500501
/// Position of the ':' delimiter in the clause;
501502
SourceLocation ColonLoc;
503+
/// Modifier of 'allocate' clause.
504+
OpenMPAllocateClauseModifier AllocatorModifier = OMPC_ALLOCATE_unknown;
505+
/// Location of allocator modifier if any.
506+
SourceLocation AllocatorModifierLoc;
502507

503508
/// Build clause with number of variables \a N.
504509
///
@@ -510,10 +515,14 @@ class OMPAllocateClause final
510515
/// \param N Number of the variables in the clause.
511516
OMPAllocateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
512517
Expr *Allocator, SourceLocation ColonLoc,
513-
SourceLocation EndLoc, unsigned N)
518+
OpenMPAllocateClauseModifier AllocatorModifier,
519+
SourceLocation AllocatorModifierLoc, SourceLocation EndLoc,
520+
unsigned N)
514521
: OMPVarListClause<OMPAllocateClause>(llvm::omp::OMPC_allocate, StartLoc,
515522
LParenLoc, EndLoc, N),
516-
Allocator(Allocator), ColonLoc(ColonLoc) {}
523+
Allocator(Allocator), ColonLoc(ColonLoc),
524+
AllocatorModifier(AllocatorModifier),
525+
AllocatorModifierLoc(AllocatorModifierLoc) {}
517526

518527
/// Build an empty clause.
519528
///
@@ -527,6 +536,9 @@ class OMPAllocateClause final
527536
void setColonLoc(SourceLocation CL) { ColonLoc = CL; }
528537

529538
void setAllocator(Expr *A) { Allocator = A; }
539+
void setAllocatorModifier(OpenMPAllocateClauseModifier AM) {
540+
AllocatorModifier = AM;
541+
}
530542

531543
public:
532544
/// Creates clause with a list of variables \a VL.
@@ -536,18 +548,31 @@ class OMPAllocateClause final
536548
/// \param LParenLoc Location of '('.
537549
/// \param Allocator Allocator expression.
538550
/// \param ColonLoc Location of ':' delimiter.
551+
/// \param AllocatorModifier Allocator modifier.
552+
/// \param SourceLocation Allocator modifier location.
539553
/// \param EndLoc Ending location of the clause.
540554
/// \param VL List of references to the variables.
541-
static OMPAllocateClause *Create(const ASTContext &C, SourceLocation StartLoc,
542-
SourceLocation LParenLoc, Expr *Allocator,
543-
SourceLocation ColonLoc,
544-
SourceLocation EndLoc, ArrayRef<Expr *> VL);
555+
static OMPAllocateClause *
556+
Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
557+
Expr *Allocator, SourceLocation ColonLoc,
558+
OpenMPAllocateClauseModifier AllocatorModifier,
559+
SourceLocation AllocatorModifierLoc, SourceLocation EndLoc,
560+
ArrayRef<Expr *> VL);
545561

546562
/// Returns the allocator expression or nullptr, if no allocator is specified.
547563
Expr *getAllocator() const { return Allocator; }
548564

565+
/// Return 'allocate' modifier.
566+
OpenMPAllocateClauseModifier getAllocatorModifier() const {
567+
return AllocatorModifier;
568+
}
569+
549570
/// Returns the location of the ':' delimiter.
550571
SourceLocation getColonLoc() const { return ColonLoc; }
572+
/// Return the location of the modifier.
573+
SourceLocation getAllocatorModifierLoc() const {
574+
return AllocatorModifierLoc;
575+
}
551576

552577
/// Creates an empty clause with the place for \a N variables.
553578
///

clang/include/clang/ASTMatchers/ASTMatchers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3226,7 +3226,7 @@ AST_MATCHER_P(CXXDependentScopeMemberExpr, memberHasSameNameAsBoundNode,
32263226

32273227
return Builder->removeBindings(
32283228
[this, MemberName](const BoundNodesMap &Nodes) {
3229-
const auto &BN = Nodes.getNode(this->BindingID);
3229+
const DynTypedNode &BN = Nodes.getNode(this->BindingID);
32303230
if (const auto *ND = BN.get<NamedDecl>()) {
32313231
if (!isa<FieldDecl, CXXMethodDecl, VarDecl>(ND))
32323232
return true;

clang/include/clang/Basic/DiagnosticCommonKinds.td

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -389,13 +389,14 @@ def remark_sloc_usage : Remark<
389389
"source manager location address space usage:">,
390390
InGroup<DiagGroup<"sloc-usage">>, DefaultRemark, ShowInSystemHeader;
391391
def note_total_sloc_usage : Note<
392-
"%0B in local locations, %1B in locations loaded from AST files, for a total "
393-
"of %2B (%3%% of available space)">;
392+
"%0B (%1B) in local locations, %2B (%3B) "
393+
"in locations loaded from AST files, for a total of %4B (%5B) "
394+
"(%6%% of available space)">;
394395
def note_file_sloc_usage : Note<
395-
"file entered %0 time%s0 using %1B of space"
396-
"%plural{0:|: plus %2B for macro expansions}2">;
396+
"file entered %0 time%s0 using %1B (%2B) of space"
397+
"%plural{0:|: plus %3B (%4B) for macro expansions}3">;
397398
def note_file_misc_sloc_usage : Note<
398-
"%0 additional files entered using a total of %1B of space">;
399+
"%0 additional files entered using a total of %1B (%2B) of space">;
399400

400401
// Modules
401402
def err_module_format_unhandled : Error<

clang/include/clang/Basic/OpenMPKinds.def

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@
8686
#ifndef OPENMP_DOACROSS_MODIFIER
8787
#define OPENMP_DOACROSS_MODIFIER(Name)
8888
#endif
89+
#ifndef OPENMP_ALLOCATE_MODIFIER
90+
#define OPENMP_ALLOCATE_MODIFIER(Name)
91+
#endif
8992

9093
// Static attributes for 'schedule' clause.
9194
OPENMP_SCHEDULE_KIND(static)
@@ -214,6 +217,9 @@ OPENMP_GRAINSIZE_MODIFIER(strict)
214217
// Modifiers for the 'num_tasks' clause.
215218
OPENMP_NUMTASKS_MODIFIER(strict)
216219

220+
// Modifiers for 'allocate' clause.
221+
OPENMP_ALLOCATE_MODIFIER(allocator)
222+
217223
// Modifiers for the 'doacross' clause.
218224
OPENMP_DOACROSS_MODIFIER(source)
219225
OPENMP_DOACROSS_MODIFIER(sink)
@@ -245,4 +251,5 @@ OPENMP_DOACROSS_MODIFIER(source_omp_cur_iteration)
245251
#undef OPENMP_DEFAULTMAP_KIND
246252
#undef OPENMP_DEFAULTMAP_MODIFIER
247253
#undef OPENMP_DOACROSS_MODIFIER
254+
#undef OPENMP_ALLOCATE_MODIFIER
248255

clang/include/clang/Basic/OpenMPKinds.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,13 @@ enum OpenMPDoacrossClauseModifier {
223223
OMPC_DOACROSS_unknown
224224
};
225225

226+
/// OpenMP modifiers for 'allocate' clause.
227+
enum OpenMPAllocateClauseModifier {
228+
#define OPENMP_ALLOCATE_MODIFIER(Name) OMPC_ALLOCATE_##Name,
229+
#include "clang/Basic/OpenMPKinds.def"
230+
OMPC_ALLOCATE_unknown
231+
};
232+
226233
/// Contains 'interop' data for 'append_args' and 'init' clauses.
227234
class Expr;
228235
struct OMPInteropInfo final {

clang/include/clang/Sema/SemaOpenMP.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,6 +1148,7 @@ class SemaOpenMP : public SemaBase {
11481148
SourceLocation OmpAllMemoryLoc;
11491149
SourceLocation
11501150
StepModifierLoc; /// 'step' modifier location for linear clause
1151+
OpenMPAllocateClauseModifier AllocClauseModifier = OMPC_ALLOCATE_unknown;
11511152
};
11521153

11531154
OMPClause *ActOnOpenMPVarListClause(OpenMPClauseKind Kind,
@@ -1165,10 +1166,10 @@ class SemaOpenMP : public SemaBase {
11651166
SourceLocation LParenLoc,
11661167
SourceLocation EndLoc);
11671168
/// Called on well-formed 'allocate' clause.
1168-
OMPClause *
1169-
ActOnOpenMPAllocateClause(Expr *Allocator, ArrayRef<Expr *> VarList,
1170-
SourceLocation StartLoc, SourceLocation ColonLoc,
1171-
SourceLocation LParenLoc, SourceLocation EndLoc);
1169+
OMPClause *ActOnOpenMPAllocateClause(
1170+
Expr *Allocator, OpenMPAllocateClauseModifier ACModifier,
1171+
ArrayRef<Expr *> VarList, SourceLocation StartLoc,
1172+
SourceLocation ColonLoc, SourceLocation LParenLoc, SourceLocation EndLoc);
11721173
/// Called on well-formed 'private' clause.
11731174
OMPClause *ActOnOpenMPPrivateClause(ArrayRef<Expr *> VarList,
11741175
SourceLocation StartLoc,

clang/lib/AST/ASTContext.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,14 +1592,17 @@ ASTContext::setInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst,
15921592
InstantiatedFromUsingShadowDecl[Inst] = Pattern;
15931593
}
15941594

1595-
FieldDecl *ASTContext::getInstantiatedFromUnnamedFieldDecl(FieldDecl *Field) {
1595+
FieldDecl *
1596+
ASTContext::getInstantiatedFromUnnamedFieldDecl(FieldDecl *Field) const {
15961597
return InstantiatedFromUnnamedFieldDecl.lookup(Field);
15971598
}
15981599

15991600
void ASTContext::setInstantiatedFromUnnamedFieldDecl(FieldDecl *Inst,
16001601
FieldDecl *Tmpl) {
1601-
assert(!Inst->getDeclName() && "Instantiated field decl is not unnamed");
1602-
assert(!Tmpl->getDeclName() && "Template field decl is not unnamed");
1602+
assert((!Inst->getDeclName() || Inst->isPlaceholderVar(getLangOpts())) &&
1603+
"Instantiated field decl is not unnamed");
1604+
assert((!Inst->getDeclName() || Inst->isPlaceholderVar(getLangOpts())) &&
1605+
"Template field decl is not unnamed");
16031606
assert(!InstantiatedFromUnnamedFieldDecl[Inst] &&
16041607
"Already noted what unnamed field was instantiated from");
16051608

clang/lib/AST/OpenMPClause.cpp

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,12 +1023,17 @@ OMPPartialClause *OMPPartialClause::CreateEmpty(const ASTContext &C) {
10231023
OMPAllocateClause *
10241024
OMPAllocateClause::Create(const ASTContext &C, SourceLocation StartLoc,
10251025
SourceLocation LParenLoc, Expr *Allocator,
1026-
SourceLocation ColonLoc, SourceLocation EndLoc,
1027-
ArrayRef<Expr *> VL) {
1026+
SourceLocation ColonLoc,
1027+
OpenMPAllocateClauseModifier AllocatorModifier,
1028+
SourceLocation AllocatorModifierLoc,
1029+
SourceLocation EndLoc, ArrayRef<Expr *> VL) {
1030+
10281031
// Allocate space for private variables and initializer expressions.
10291032
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
1030-
auto *Clause = new (Mem) OMPAllocateClause(StartLoc, LParenLoc, Allocator,
1031-
ColonLoc, EndLoc, VL.size());
1033+
auto *Clause = new (Mem) OMPAllocateClause(
1034+
StartLoc, LParenLoc, Allocator, ColonLoc, AllocatorModifier,
1035+
AllocatorModifierLoc, EndLoc, VL.size());
1036+
10321037
Clause->setVarRefs(VL);
10331038
return Clause;
10341039
}
@@ -2242,9 +2247,17 @@ void OMPClausePrinter::VisitOMPAllocateClause(OMPAllocateClause *Node) {
22422247
if (Node->varlist_empty())
22432248
return;
22442249
OS << "allocate";
2250+
OpenMPAllocateClauseModifier Modifier = Node->getAllocatorModifier();
22452251
if (Expr *Allocator = Node->getAllocator()) {
22462252
OS << "(";
2247-
Allocator->printPretty(OS, nullptr, Policy, 0);
2253+
if (Modifier == OMPC_ALLOCATE_allocator) {
2254+
OS << getOpenMPSimpleClauseTypeName(Node->getClauseKind(), Modifier);
2255+
OS << "(";
2256+
Allocator->printPretty(OS, nullptr, Policy, 0);
2257+
OS << ")";
2258+
} else {
2259+
Allocator->printPretty(OS, nullptr, Policy, 0);
2260+
}
22482261
OS << ":";
22492262
VisitOMPClauseList(Node, ' ');
22502263
} else {

clang/lib/Basic/OpenMPKinds.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,11 @@ unsigned clang::getOpenMPSimpleClauseType(OpenMPClauseKind Kind, StringRef Str,
180180
return OMPC_NUMTASKS_unknown;
181181
return Type;
182182
}
183+
case OMPC_allocate:
184+
return llvm::StringSwitch<OpenMPAllocateClauseModifier>(Str)
185+
#define OPENMP_ALLOCATE_MODIFIER(Name) .Case(#Name, OMPC_ALLOCATE_##Name)
186+
#include "clang/Basic/OpenMPKinds.def"
187+
.Default(OMPC_ALLOCATE_unknown);
183188
case OMPC_unknown:
184189
case OMPC_threadprivate:
185190
case OMPC_if:
@@ -190,7 +195,6 @@ unsigned clang::getOpenMPSimpleClauseType(OpenMPClauseKind Kind, StringRef Str,
190195
case OMPC_sizes:
191196
case OMPC_permutation:
192197
case OMPC_allocator:
193-
case OMPC_allocate:
194198
case OMPC_collapse:
195199
case OMPC_private:
196200
case OMPC_firstprivate:
@@ -505,6 +509,16 @@ const char *clang::getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind,
505509
#include "clang/Basic/OpenMPKinds.def"
506510
}
507511
llvm_unreachable("Invalid OpenMP 'num_tasks' clause modifier");
512+
case OMPC_allocate:
513+
switch (Type) {
514+
case OMPC_ALLOCATE_unknown:
515+
return "unknown";
516+
#define OPENMP_ALLOCATE_MODIFIER(Name) \
517+
case OMPC_ALLOCATE_##Name: \
518+
return #Name;
519+
#include "clang/Basic/OpenMPKinds.def"
520+
}
521+
llvm_unreachable("Invalid OpenMP 'allocate' clause modifier");
508522
case OMPC_unknown:
509523
case OMPC_threadprivate:
510524
case OMPC_if:
@@ -515,7 +529,6 @@ const char *clang::getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind,
515529
case OMPC_sizes:
516530
case OMPC_permutation:
517531
case OMPC_allocator:
518-
case OMPC_allocate:
519532
case OMPC_collapse:
520533
case OMPC_private:
521534
case OMPC_firstprivate:

clang/lib/Basic/SourceManager.cpp

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "llvm/Support/Endian.h"
3030
#include "llvm/Support/ErrorHandling.h"
3131
#include "llvm/Support/FileSystem.h"
32+
#include "llvm/Support/FormatVariadic.h"
3233
#include "llvm/Support/MathExtras.h"
3334
#include "llvm/Support/MemoryBuffer.h"
3435
#include "llvm/Support/Path.h"
@@ -2227,6 +2228,28 @@ LLVM_DUMP_METHOD void SourceManager::dump() const {
22272228
}
22282229
}
22292230

2231+
// 123 -> "123".
2232+
// 1234 -> "1.23k".
2233+
// 123456 -> "123.46k".
2234+
// 1234567 -> "1.23M".
2235+
// 1234567890 -> "1.23G".
2236+
// 1234567890123 -> "1.23T".
2237+
static std::string humanizeNumber(uint64_t Number) {
2238+
static constexpr std::array<std::pair<uint64_t, char>, 4> Units = {
2239+
{{1'000'000'000'000UL, 'T'},
2240+
{1'000'000'000UL, 'G'},
2241+
{1'000'000UL, 'M'},
2242+
{1'000UL, 'k'}}};
2243+
2244+
for (const auto &[UnitSize, UnitSign] : Units) {
2245+
if (Number >= UnitSize) {
2246+
return llvm::formatv("{0:F}{1}", Number / static_cast<double>(UnitSize),
2247+
UnitSign);
2248+
}
2249+
}
2250+
return std::to_string(Number);
2251+
}
2252+
22302253
void SourceManager::noteSLocAddressSpaceUsage(
22312254
DiagnosticsEngine &Diag, std::optional<unsigned> MaxNotes) const {
22322255
struct Info {
@@ -2296,22 +2319,27 @@ void SourceManager::noteSLocAddressSpaceUsage(
22962319
int UsagePercent = static_cast<int>(100.0 * double(LocalUsage + LoadedUsage) /
22972320
MaxLoadedOffset);
22982321
Diag.Report(SourceLocation(), diag::note_total_sloc_usage)
2299-
<< LocalUsage << LoadedUsage << (LocalUsage + LoadedUsage) << UsagePercent;
2322+
<< LocalUsage << humanizeNumber(LocalUsage) << LoadedUsage
2323+
<< humanizeNumber(LoadedUsage) << (LocalUsage + LoadedUsage)
2324+
<< humanizeNumber(LocalUsage + LoadedUsage) << UsagePercent;
23002325

23012326
// Produce notes on sloc address space usage for each file with a high usage.
23022327
uint64_t ReportedSize = 0;
23032328
for (auto &[Entry, FileInfo] :
23042329
llvm::make_range(SortedUsage.begin(), SortedEnd)) {
23052330
Diag.Report(FileInfo.Loc, diag::note_file_sloc_usage)
23062331
<< FileInfo.Inclusions << FileInfo.DirectSize
2307-
<< (FileInfo.TotalSize - FileInfo.DirectSize);
2332+
<< humanizeNumber(FileInfo.DirectSize)
2333+
<< (FileInfo.TotalSize - FileInfo.DirectSize)
2334+
<< humanizeNumber(FileInfo.TotalSize - FileInfo.DirectSize);
23082335
ReportedSize += FileInfo.TotalSize;
23092336
}
23102337

23112338
// Describe any remaining usage not reported in the per-file usage.
23122339
if (ReportedSize != CountedSize) {
23132340
Diag.Report(SourceLocation(), diag::note_file_misc_sloc_usage)
2314-
<< (SortedUsage.end() - SortedEnd) << CountedSize - ReportedSize;
2341+
<< (SortedUsage.end() - SortedEnd) << CountedSize - ReportedSize
2342+
<< humanizeNumber(CountedSize - ReportedSize);
23152343
}
23162344
}
23172345

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,6 +1427,7 @@ void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args,
14271427
}
14281428
CmdArgs.push_back("-lFortranRuntime");
14291429
CmdArgs.push_back("-lFortranDecimal");
1430+
addArchSpecificRPath(TC, Args, CmdArgs);
14301431
}
14311432

14321433
// libomp needs libatomic for atomic operations if using libgcc

0 commit comments

Comments
 (0)