Skip to content

[memprof] Add accessors to Frame::SymbolName #94085

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion llvm/include/llvm/ProfileData/MemProf.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,17 @@ struct Frame {

bool operator!=(const Frame &Other) const { return !operator==(Other); }

bool hasSymbolName() const { return SymbolName.has_value(); }

StringRef getSymbolName() const {
assert(SymbolName.has_value());
return *SymbolName;
}

std::string getSymbolNameOr(StringRef Alt) const {
return std::string(hasSymbolName() ? getSymbolName() : Alt);
}

// Write the contents of the frame to the ostream \p OS.
void serialize(raw_ostream &OS) const {
using namespace support;
Expand Down Expand Up @@ -279,7 +290,7 @@ struct Frame {
void printYAML(raw_ostream &OS) const {
OS << " -\n"
<< " Function: " << Function << "\n"
<< " SymbolName: " << SymbolName.value_or("<None>") << "\n"
<< " SymbolName: " << getSymbolNameOr("<None>") << "\n"
<< " LineOffset: " << LineOffset << "\n"
<< " Column: " << Column << "\n"
<< " Inline: " << IsInlineFrame << "\n";
Expand Down
Loading