28 "Reads and parses a basic block sections profile.",
false,
35std::pair<bool, SmallVector<BBClusterInfo>>
38 std::pair<bool, SmallVector<BBClusterInfo>> cluster_info(
false, {});
39 auto R = ProgramBBClusterInfo.
find(getAliasName(FuncName));
40 if (R != ProgramBBClusterInfo.
end()) {
41 cluster_info.second =
R->second;
42 cluster_info.first =
true;
66 auto invalidProfileError = [&](
auto Message) {
67 return make_error<StringError>(
69 Twine(LineIt.line_number()) +
": " + Message),
73 auto FI = ProgramBBClusterInfo.
end();
76 unsigned CurrentCluster = 0;
78 unsigned CurrentPosition = 0;
84 for (; !LineIt.is_at_eof(); ++LineIt) {
89 if (!S.consume_front(
"!") || S.empty())
92 if (S.consume_front(
"!")) {
93 if (FI == ProgramBBClusterInfo.
end())
94 return invalidProfileError(
95 "Cluster list does not follow a function name specifier.");
100 for (
auto BBIDStr : BBIDs) {
101 unsigned long long BBID;
103 return invalidProfileError(
Twine(
"Unsigned integer expected: '") +
105 if (!FuncBBIDs.
insert(BBID).second)
106 return invalidProfileError(
Twine(
"Duplicate basic block id found '") +
108 if (BBID == 0 && CurrentPosition)
109 return invalidProfileError(
"Entry BB (0) does not begin a cluster.");
111 FI->second.emplace_back(
120 S.split(Aliases,
'/');
121 for (
size_t i = 1; i < Aliases.
size(); ++i)
137 if (
auto Err = getBBClusterInfo(MBuf, ProgramBBClusterInfo, FuncAliasMap))
This file defines the StringMap class.
bool getBBClusterInfoForFunction(const MachineFunction &MF, BasicBlockSectionsProfileReader *BBSectionsProfileReader, DenseMap< unsigned, BBClusterInfo > &V)
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallSet class.
This file defines the SmallVector class.
std::pair< bool, SmallVector< BBClusterInfo > > getBBClusterInfoForFunction(StringRef FuncName) const
void initializePass() override
Read profiles of basic blocks if available here.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
ImmutablePass class - This class is used to provide information that does not need to be run.
This interface provides simple read-only access to a block of memory, and provides simple methods for...
virtual StringRef getBufferIdentifier() const
Return an identifier for this buffer, typically the filename it was read from.
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
std::pair< const_iterator, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
iterator find(StringRef Key)
std::pair< iterator, bool > try_emplace(StringRef Key, ArgsTy &&...Args)
Emplace a new element for the specified key into the map if the key isn't already in the map.
StringRef - Represent a constant reference to a string, i.e.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
A forward iterator which reads text lines from a buffer.
This is an optimization pass for GlobalISel generic memory operations.
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
bool getAsUnsignedInteger(StringRef Str, unsigned Radix, unsigned long long &Result)
Helper functions for StringRef::getAsInteger.
ImmutablePass * createBasicBlockSectionsProfileReaderPass(const MemoryBuffer *Buf)