diff options
author | Kazu Hirata <kazu@google.com> | 2024-11-24 21:07:59 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-24 21:07:59 -0800 |
commit | 9e3215ac167b80dcf51d6693ecdd6275c4e89954 (patch) | |
tree | c66f245906158f526e5e8b176781adfd252e19c5 /llvm/lib/ProfileData/InstrProfWriter.cpp | |
parent | 87cc4b48c08a627f330396f941b84671c5e591d5 (diff) | |
download | llvm-9e3215ac167b80dcf51d6693ecdd6275c4e89954.zip llvm-9e3215ac167b80dcf51d6693ecdd6275c4e89954.tar.gz llvm-9e3215ac167b80dcf51d6693ecdd6275c4e89954.tar.bz2 |
[memprof] Add an assert to InstrProfWriter::addMemProfData (#117426)
This patch adds a quick validity check to
InstrProfWriter::addMemProfData. Specifically, we check to see if we
have all (or none) of the MemProf profile components (frames, call
stacks, records).
The credit goes to Teresa Johnson for suggesting this assert.
Diffstat (limited to 'llvm/lib/ProfileData/InstrProfWriter.cpp')
-rw-r--r-- | llvm/lib/ProfileData/InstrProfWriter.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/llvm/lib/ProfileData/InstrProfWriter.cpp b/llvm/lib/ProfileData/InstrProfWriter.cpp index 725ff92..4470e2c 100644 --- a/llvm/lib/ProfileData/InstrProfWriter.cpp +++ b/llvm/lib/ProfileData/InstrProfWriter.cpp @@ -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); |