Skip to content

[memprof] Add an assert to InstrProfWriter::addMemProfData #117426

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
11 changes: 8 additions & 3 deletions llvm/lib/ProfileData/InstrProfWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,14 @@ bool InstrProfWriter::addMemProfCallStack(

bool InstrProfWriter::addMemProfData(memprof::IndexedMemProfData Incoming,
function_ref<void(Error)> Warn) {
// TODO: Once we remove support for MemProf format Version V1, assert that
// the three components (frames, call stacks, and records) are either all
// empty or populated.
// Return immediately if everything is empty.
if (Incoming.Frames.empty() && Incoming.CallStacks.empty() &&
Incoming.Records.empty())
return true;

// Otherwise, every component must be non-empty.
assert(!Incoming.Frames.empty() && !Incoming.CallStacks.empty() &&
!Incoming.Records.empty());

if (MemProfData.Frames.empty())
MemProfData.Frames = std::move(Incoming.Frames);
Expand Down
Loading