Skip to content

Commit 91ba0fc

Browse files
committed
Addressed feedback in #76903
Created using spr 1.3.4
2 parents a60631d + b0f68c6 commit 91ba0fc

File tree

40 files changed

+1481
-915
lines changed

40 files changed

+1481
-915
lines changed

bolt/include/bolt/Profile/BoltAddressTranslation.h

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,21 +79,10 @@ class BoltAddressTranslation {
7979

8080
BoltAddressTranslation() {}
8181

82-
/// Write the serialized address translation table for a function.
83-
template <bool Cold>
84-
void writeMaps(std::map<uint64_t, MapTy> &Maps, uint64_t &PrevAddress,
85-
raw_ostream &OS);
86-
8782
/// Write the serialized address translation tables for each reordered
8883
/// function
8984
void write(const BinaryContext &BC, raw_ostream &OS);
9085

91-
/// Read the serialized address translation table for a function.
92-
/// Return a parse error if failed.
93-
template <bool Cold>
94-
void parseMaps(std::vector<uint64_t> &HotFuncs, uint64_t &PrevAddress,
95-
DataExtractor &DE, uint64_t &Offset, Error &Err);
96-
9786
/// Read the serialized address translation tables and load them internally
9887
/// in memory. Return a parse error if failed.
9988
std::error_code parse(StringRef Buf);
@@ -130,6 +119,17 @@ class BoltAddressTranslation {
130119
void writeEntriesForBB(MapTy &Map, const BinaryBasicBlock &BB,
131120
uint64_t FuncAddress);
132121

122+
/// Write the serialized address translation table for a function.
123+
template <bool Cold>
124+
void writeMaps(std::map<uint64_t, MapTy> &Maps, uint64_t &PrevAddress,
125+
raw_ostream &OS);
126+
127+
/// Read the serialized address translation table for a function.
128+
/// Return a parse error if failed.
129+
template <bool Cold>
130+
void parseMaps(std::vector<uint64_t> &HotFuncs, uint64_t &PrevAddress,
131+
DataExtractor &DE, uint64_t &Offset, Error &Err);
132+
133133
/// Returns the bitmask with set bits corresponding to indices of BRANCHENTRY
134134
/// entries in function address translation map.
135135
APInt calculateBranchEntriesBitMask(MapTy &Map, size_t EqualElems);
@@ -139,7 +139,6 @@ class BoltAddressTranslation {
139139
size_t getNumEqualOffsets(const MapTy &Map) const;
140140

141141
std::map<uint64_t, MapTy> Maps;
142-
std::map<uint64_t, MapTy> ColdMaps;
143142

144143
/// Links outlined cold bocks to their original function
145144
std::map<uint64_t, uint64_t> ColdPartSource;

bolt/lib/Profile/BoltAddressTranslation.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,18 +98,17 @@ void BoltAddressTranslation::write(const BinaryContext &BC, raw_ostream &OS) {
9898
for (const BinaryBasicBlock *const BB : FF)
9999
writeEntriesForBB(Map, *BB, FF.getAddress());
100100

101-
ColdMaps.emplace(FF.getAddress(), std::move(Map));
101+
Maps.emplace(FF.getAddress(), std::move(Map));
102102
ColdPartSource.emplace(FF.getAddress(), Function.getOutputAddress());
103103
}
104104
}
105105

106106
// Output addresses are delta-encoded
107107
uint64_t PrevAddress = 0;
108108
writeMaps</*Cold=*/false>(Maps, PrevAddress, OS);
109-
writeMaps</*Cold=*/true>(ColdMaps, PrevAddress, OS);
109+
writeMaps</*Cold=*/true>(Maps, PrevAddress, OS);
110110

111-
outs() << "BOLT-INFO: Wrote " << Maps.size() + ColdMaps.size()
112-
<< " BAT maps\n";
111+
outs() << "BOLT-INFO: Wrote " << Maps.size() << " BAT maps\n";
113112
}
114113

115114
APInt BoltAddressTranslation::calculateBranchEntriesBitMask(MapTy &Map,
@@ -143,13 +142,19 @@ size_t BoltAddressTranslation::getNumEqualOffsets(const MapTy &Map) const {
143142
template <bool Cold>
144143
void BoltAddressTranslation::writeMaps(std::map<uint64_t, MapTy> &Maps,
145144
uint64_t &PrevAddress, raw_ostream &OS) {
146-
const uint32_t NumFuncs = Maps.size();
145+
const uint32_t NumFuncs =
146+
llvm::count_if(llvm::make_first_range(Maps), [&](const uint64_t Address) {
147+
return Cold == ColdPartSource.count(Address);
148+
});
147149
encodeULEB128(NumFuncs, OS);
148150
LLVM_DEBUG(dbgs() << "Writing " << NumFuncs << (Cold ? " cold" : "")
149151
<< " functions for BAT.\n");
150152
size_t PrevIndex = 0;
151153
for (auto &MapEntry : Maps) {
152154
const uint64_t Address = MapEntry.first;
155+
// Only process cold fragments in cold mode, and vice versa.
156+
if (Cold != ColdPartSource.count(Address))
157+
continue;
153158
MapTy &Map = MapEntry.second;
154159
const uint32_t NumEntries = Map.size();
155160
LLVM_DEBUG(dbgs() << "Writing " << NumEntries << " entries for 0x"

clang/cmake/caches/Fuchsia.cmake

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,25 @@ set(_FUCHSIA_BOOTSTRAP_PASSTHROUGH
3838
CURL_ROOT
3939
OpenSSL_ROOT
4040
httplib_ROOT
41+
42+
# Deprecated
4143
CursesAndPanel_ROOT
44+
45+
CURSES_INCLUDE_DIRS
46+
CURSES_LIBRARIES
47+
PANEL_LIBRARIES
48+
49+
# Deprecated
4250
Terminfo_ROOT
51+
52+
Terminfo_LIBRARIES
53+
54+
# Deprecated
4355
LibEdit_ROOT
56+
57+
LibEdit_INCLUDE_DIRS
58+
LibEdit_LIBRARIES
59+
4460
FUCHSIA_ENABLE_LLDB
4561
LLDB_ENABLE_CURSES
4662
LLDB_ENABLE_LIBEDIT

flang/include/flang/Common/Fortran.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ ENUM_CLASS(CUDASubprogramAttrs, Host, Device, HostDevice, Global, Grid_Global)
8787
// CUDA data attributes; mutually exclusive
8888
ENUM_CLASS(CUDADataAttr, Constant, Device, Managed, Pinned, Shared, Texture)
8989

90+
// OpenACC device types
91+
ENUM_CLASS(
92+
OpenACCDeviceType, Star, Default, Nvidia, Radeon, Host, Multicore, None)
93+
9094
// OpenMP atomic_default_mem_order clause allowed values
9195
ENUM_CLASS(OmpAtomicDefaultMemOrderType, SeqCst, AcqRel, Relaxed)
9296

flang/include/flang/Parser/dump-parse-tree.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class ParseTreeDumper {
4848
NODE(std, uint64_t)
4949
NODE_ENUM(common, CUDADataAttr)
5050
NODE_ENUM(common, CUDASubprogramAttrs)
51+
NODE_ENUM(common, OpenACCDeviceType)
5152
NODE(format, ControlEditDesc)
5253
NODE(format::ControlEditDesc, Kind)
5354
NODE(format, DerivedTypeDataEditDesc)
@@ -101,7 +102,7 @@ class ParseTreeDumper {
101102
NODE(parser, AccSelfClause)
102103
NODE(parser, AccStandaloneDirective)
103104
NODE(parser, AccDeviceTypeExpr)
104-
NODE_ENUM(parser::AccDeviceTypeExpr, Device)
105+
105106
NODE(parser, AccDeviceTypeExprList)
106107
NODE(parser, AccTileExpr)
107108
NODE(parser, AccTileExprList)

flang/include/flang/Parser/parse-tree.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4072,8 +4072,8 @@ struct AccWaitArgument {
40724072
};
40734073

40744074
struct AccDeviceTypeExpr {
4075-
ENUM_CLASS(Device, Star, Default, Nvidia, Radeon, Host, Multicore)
4076-
WRAPPER_CLASS_BOILERPLATE(AccDeviceTypeExpr, Device);
4075+
WRAPPER_CLASS_BOILERPLATE(
4076+
AccDeviceTypeExpr, Fortran::common::OpenACCDeviceType);
40774077
CharBlock source;
40784078
};
40794079

flang/include/flang/Semantics/symbol.h

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ class WithBindName {
112112
bool isExplicitBindName_{false};
113113
};
114114

115-
class OpenACCRoutineInfo {
115+
// Device type specific OpenACC routine information
116+
class OpenACCRoutineDeviceTypeInfo {
116117
public:
117118
bool isSeq() const { return isSeq_; }
118119
void set_isSeq(bool value = true) { isSeq_ = value; }
@@ -124,21 +125,43 @@ class OpenACCRoutineInfo {
124125
void set_isGang(bool value = true) { isGang_ = value; }
125126
unsigned gangDim() const { return gangDim_; }
126127
void set_gangDim(unsigned value) { gangDim_ = value; }
127-
bool isNohost() const { return isNohost_; }
128-
void set_isNohost(bool value = true) { isNohost_ = value; }
129128
const std::string *bindName() const {
130129
return bindName_ ? &*bindName_ : nullptr;
131130
}
132131
void set_bindName(std::string &&name) { bindName_ = std::move(name); }
132+
void set_dType(Fortran::common::OpenACCDeviceType dType) {
133+
deviceType_ = dType;
134+
}
135+
Fortran::common::OpenACCDeviceType dType() const { return deviceType_; }
133136

134137
private:
135138
bool isSeq_{false};
136139
bool isVector_{false};
137140
bool isWorker_{false};
138141
bool isGang_{false};
139142
unsigned gangDim_{0};
140-
bool isNohost_{false};
141143
std::optional<std::string> bindName_;
144+
Fortran::common::OpenACCDeviceType deviceType_{
145+
Fortran::common::OpenACCDeviceType::None};
146+
};
147+
148+
// OpenACC routine information. Device independent info are stored on the
149+
// OpenACCRoutineInfo instance while device dependent info are stored
150+
// in as objects in the OpenACCRoutineDeviceTypeInfo list.
151+
class OpenACCRoutineInfo : public OpenACCRoutineDeviceTypeInfo {
152+
public:
153+
bool isNohost() const { return isNohost_; }
154+
void set_isNohost(bool value = true) { isNohost_ = value; }
155+
std::list<OpenACCRoutineDeviceTypeInfo> &deviceTypeInfos() {
156+
return deviceTypeInfos_;
157+
}
158+
void add_deviceTypeInfo(OpenACCRoutineDeviceTypeInfo &info) {
159+
deviceTypeInfos_.push_back(info);
160+
}
161+
162+
private:
163+
std::list<OpenACCRoutineDeviceTypeInfo> deviceTypeInfos_;
164+
bool isNohost_{false};
142165
};
143166

144167
// A subroutine or function definition, or a subprogram interface defined

flang/lib/Lower/OpenACC.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,20 +1483,22 @@ genAsyncClause(Fortran::lower::AbstractConverter &converter,
14831483
}
14841484

14851485
static mlir::acc::DeviceType
1486-
getDeviceType(Fortran::parser::AccDeviceTypeExpr::Device device) {
1486+
getDeviceType(Fortran::common::OpenACCDeviceType device) {
14871487
switch (device) {
1488-
case Fortran::parser::AccDeviceTypeExpr::Device::Star:
1488+
case Fortran::common::OpenACCDeviceType::Star:
14891489
return mlir::acc::DeviceType::Star;
1490-
case Fortran::parser::AccDeviceTypeExpr::Device::Default:
1490+
case Fortran::common::OpenACCDeviceType::Default:
14911491
return mlir::acc::DeviceType::Default;
1492-
case Fortran::parser::AccDeviceTypeExpr::Device::Nvidia:
1492+
case Fortran::common::OpenACCDeviceType::Nvidia:
14931493
return mlir::acc::DeviceType::Nvidia;
1494-
case Fortran::parser::AccDeviceTypeExpr::Device::Radeon:
1494+
case Fortran::common::OpenACCDeviceType::Radeon:
14951495
return mlir::acc::DeviceType::Radeon;
1496-
case Fortran::parser::AccDeviceTypeExpr::Device::Host:
1496+
case Fortran::common::OpenACCDeviceType::Host:
14971497
return mlir::acc::DeviceType::Host;
1498-
case Fortran::parser::AccDeviceTypeExpr::Device::Multicore:
1498+
case Fortran::common::OpenACCDeviceType::Multicore:
14991499
return mlir::acc::DeviceType::Multicore;
1500+
case Fortran::common::OpenACCDeviceType::None:
1501+
return mlir::acc::DeviceType::None;
15001502
}
15011503
return mlir::acc::DeviceType::None;
15021504
}

flang/lib/Parser/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ add_flang_library(FortranParser
3030
LINK_COMPONENTS
3131
Support
3232
FrontendOpenACC
33-
FrontendOpenMP
3433

3534
DEPENDS
3635
omp_gen

flang/lib/Parser/openacc-parsers.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ TYPE_PARSER(construct<AccSizeExpr>(scalarIntExpr) ||
5454
TYPE_PARSER(construct<AccSizeExprList>(nonemptyList(Parser<AccSizeExpr>{})))
5555

5656
TYPE_PARSER(sourced(construct<AccDeviceTypeExpr>(
57-
first("*" >> pure(AccDeviceTypeExpr::Device::Star),
58-
"DEFAULT" >> pure(AccDeviceTypeExpr::Device::Default),
59-
"NVIDIA" >> pure(AccDeviceTypeExpr::Device::Nvidia),
60-
"ACC_DEVICE_NVIDIA" >> pure(AccDeviceTypeExpr::Device::Nvidia),
61-
"RADEON" >> pure(AccDeviceTypeExpr::Device::Radeon),
62-
"HOST" >> pure(AccDeviceTypeExpr::Device::Host),
63-
"MULTICORE" >> pure(AccDeviceTypeExpr::Device::Multicore)))))
57+
first("*" >> pure(Fortran::common::OpenACCDeviceType::Star),
58+
"DEFAULT" >> pure(Fortran::common::OpenACCDeviceType::Default),
59+
"NVIDIA" >> pure(Fortran::common::OpenACCDeviceType::Nvidia),
60+
"ACC_DEVICE_NVIDIA" >> pure(Fortran::common::OpenACCDeviceType::Nvidia),
61+
"RADEON" >> pure(Fortran::common::OpenACCDeviceType::Radeon),
62+
"HOST" >> pure(Fortran::common::OpenACCDeviceType::Host),
63+
"MULTICORE" >> pure(Fortran::common::OpenACCDeviceType::Multicore)))))
6464

6565
TYPE_PARSER(
6666
construct<AccDeviceTypeExprList>(nonemptyList(Parser<AccDeviceTypeExpr>{})))

flang/lib/Semantics/check-acc-structure.cpp

Lines changed: 61 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,12 @@ static constexpr inline AccClauseSet updateOnlyAllowedAfterDeviceTypeClauses{
6969

7070
static constexpr inline AccClauseSet routineOnlyAllowedAfterDeviceTypeClauses{
7171
llvm::acc::Clause::ACCC_bind, llvm::acc::Clause::ACCC_gang,
72-
llvm::acc::Clause::ACCC_vector, llvm::acc::Clause::ACCC_worker};
72+
llvm::acc::Clause::ACCC_vector, llvm::acc::Clause::ACCC_worker,
73+
llvm::acc::Clause::ACCC_seq};
74+
75+
static constexpr inline AccClauseSet routineMutuallyExclusiveClauses{
76+
llvm::acc::Clause::ACCC_gang, llvm::acc::Clause::ACCC_worker,
77+
llvm::acc::Clause::ACCC_vector, llvm::acc::Clause::ACCC_seq};
7378

7479
bool AccStructureChecker::CheckAllowedModifier(llvm::acc::Clause clause) {
7580
if (GetContext().directive == llvm::acc::ACCD_enter_data ||
@@ -388,7 +393,6 @@ CHECK_SIMPLE_CLAUSE(NoCreate, ACCC_no_create)
388393
CHECK_SIMPLE_CLAUSE(Nohost, ACCC_nohost)
389394
CHECK_SIMPLE_CLAUSE(Private, ACCC_private)
390395
CHECK_SIMPLE_CLAUSE(Read, ACCC_read)
391-
CHECK_SIMPLE_CLAUSE(Seq, ACCC_seq)
392396
CHECK_SIMPLE_CLAUSE(UseDevice, ACCC_use_device)
393397
CHECK_SIMPLE_CLAUSE(Wait, ACCC_wait)
394398
CHECK_SIMPLE_CLAUSE(Write, ACCC_write)
@@ -532,18 +536,40 @@ void AccStructureChecker::Enter(const parser::AccClause::DeviceType &d) {
532536
.str()),
533537
ContextDirectiveAsFortran());
534538
}
539+
ResetCrtGroup();
540+
}
541+
542+
void AccStructureChecker::Enter(const parser::AccClause::Seq &g) {
543+
llvm::acc::Clause crtClause = llvm::acc::Clause::ACCC_seq;
544+
if (GetContext().directive == llvm::acc::Directive::ACCD_routine) {
545+
CheckMutuallyExclusivePerGroup(crtClause,
546+
llvm::acc::Clause::ACCC_device_type, routineMutuallyExclusiveClauses);
547+
}
548+
CheckAllowed(crtClause);
535549
}
536550

537551
void AccStructureChecker::Enter(const parser::AccClause::Vector &g) {
538-
CheckAllowed(llvm::acc::Clause::ACCC_vector);
539-
CheckAllowedOncePerGroup(
540-
llvm::acc::Clause::ACCC_vector, llvm::acc::Clause::ACCC_device_type);
552+
llvm::acc::Clause crtClause = llvm::acc::Clause::ACCC_vector;
553+
if (GetContext().directive == llvm::acc::Directive::ACCD_routine) {
554+
CheckMutuallyExclusivePerGroup(crtClause,
555+
llvm::acc::Clause::ACCC_device_type, routineMutuallyExclusiveClauses);
556+
}
557+
CheckAllowed(crtClause);
558+
if (GetContext().directive != llvm::acc::Directive::ACCD_routine) {
559+
CheckAllowedOncePerGroup(crtClause, llvm::acc::Clause::ACCC_device_type);
560+
}
541561
}
542562

543563
void AccStructureChecker::Enter(const parser::AccClause::Worker &g) {
544-
CheckAllowed(llvm::acc::Clause::ACCC_worker);
545-
CheckAllowedOncePerGroup(
546-
llvm::acc::Clause::ACCC_worker, llvm::acc::Clause::ACCC_device_type);
564+
llvm::acc::Clause crtClause = llvm::acc::Clause::ACCC_worker;
565+
if (GetContext().directive == llvm::acc::Directive::ACCD_routine) {
566+
CheckMutuallyExclusivePerGroup(crtClause,
567+
llvm::acc::Clause::ACCC_device_type, routineMutuallyExclusiveClauses);
568+
}
569+
CheckAllowed(crtClause);
570+
if (GetContext().directive != llvm::acc::Directive::ACCD_routine) {
571+
CheckAllowedOncePerGroup(crtClause, llvm::acc::Clause::ACCC_device_type);
572+
}
547573
}
548574

549575
void AccStructureChecker::Enter(const parser::AccClause::Tile &g) {
@@ -553,24 +579,45 @@ void AccStructureChecker::Enter(const parser::AccClause::Tile &g) {
553579
}
554580

555581
void AccStructureChecker::Enter(const parser::AccClause::Gang &g) {
556-
CheckAllowed(llvm::acc::Clause::ACCC_gang);
557-
CheckAllowedOncePerGroup(
558-
llvm::acc::Clause::ACCC_gang, llvm::acc::Clause::ACCC_device_type);
582+
llvm::acc::Clause crtClause = llvm::acc::Clause::ACCC_gang;
583+
if (GetContext().directive == llvm::acc::Directive::ACCD_routine) {
584+
CheckMutuallyExclusivePerGroup(crtClause,
585+
llvm::acc::Clause::ACCC_device_type, routineMutuallyExclusiveClauses);
586+
}
587+
CheckAllowed(crtClause);
588+
if (GetContext().directive != llvm::acc::Directive::ACCD_routine) {
589+
CheckAllowedOncePerGroup(crtClause, llvm::acc::Clause::ACCC_device_type);
590+
}
559591

560592
if (g.v) {
561593
bool hasNum = false;
562594
bool hasDim = false;
595+
bool hasStatic = false;
563596
const Fortran::parser::AccGangArgList &x = *g.v;
564597
for (const Fortran::parser::AccGangArg &gangArg : x.v) {
565-
if (std::get_if<Fortran::parser::AccGangArg::Num>(&gangArg.u))
598+
if (std::get_if<Fortran::parser::AccGangArg::Num>(&gangArg.u)) {
566599
hasNum = true;
567-
else if (std::get_if<Fortran::parser::AccGangArg::Dim>(&gangArg.u))
600+
} else if (std::get_if<Fortran::parser::AccGangArg::Dim>(&gangArg.u)) {
568601
hasDim = true;
602+
} else if (std::get_if<Fortran::parser::AccGangArg::Static>(&gangArg.u)) {
603+
hasStatic = true;
604+
}
569605
}
570606

571-
if (hasDim && hasNum)
607+
if (GetContext().directive == llvm::acc::Directive::ACCD_routine &&
608+
(hasStatic || hasNum)) {
609+
context_.Say(GetContext().clauseSource,
610+
"Only the dim argument is allowed on the %s clause on the %s directive"_err_en_US,
611+
parser::ToUpperCaseLetters(
612+
llvm::acc::getOpenACCClauseName(llvm::acc::Clause::ACCC_gang)
613+
.str()),
614+
ContextDirectiveAsFortran());
615+
}
616+
617+
if (hasDim && hasNum) {
572618
context_.Say(GetContext().clauseSource,
573619
"The num argument is not allowed when dim is specified"_err_en_US);
620+
}
574621
}
575622
}
576623

0 commit comments

Comments
 (0)