diff options
author | Teresa Johnson <tejohnson@google.com> | 2024-11-15 08:24:44 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-15 08:24:44 -0800 |
commit | 9513f2fdf2ad50f55726154a6b6a4aa463bc457f (patch) | |
tree | 738757d593af34a24cc6fddb5c3881386b6f9bd0 /llvm/lib/IR/Verifier.cpp | |
parent | f6e1d64458130643377511baeec430de67ddddfb (diff) | |
download | llvm-9513f2fdf2ad50f55726154a6b6a4aa463bc457f.zip llvm-9513f2fdf2ad50f55726154a6b6a4aa463bc457f.tar.gz llvm-9513f2fdf2ad50f55726154a6b6a4aa463bc457f.tar.bz2 |
[MemProf] Print full context hash when reporting hinted bytes (#114465)
Improve the information printed when -memprof-report-hinted-sizes is
enabled. Now print the full context hash computed from the original
profile, similar to what we do when reporting matching statistics. This
will make it easier to correlate with the profile.
Note that the full context hash must be computed at profile match time
and saved in the metadata and summary, because we may trim the context
during matching when it isn't needed for distinguishing hotness.
Similarly, due to the context trimming, we may have more than one full
context id and total size pair per MIB in the metadata and summary,
which now get a list of these pairs.
Remove the old aggregate size from the metadata and summary support.
One other change from the prior support is that we no longer write the
size information into the combined index for the LTO backends, which
don't use this information, which reduces unnecessary bloat in
distributed index files.
Diffstat (limited to 'llvm/lib/IR/Verifier.cpp')
-rw-r--r-- | llvm/lib/IR/Verifier.cpp | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 6ee0a5a..5cfcd21 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -4995,14 +4995,35 @@ void Verifier::visitMemProfMetadata(Instruction &I, MDNode *MD) { MDNode *StackMD = dyn_cast<MDNode>(MIB->getOperand(0)); visitCallStackMetadata(StackMD); - // Check that remaining operands, except possibly the last, are MDString. - Check(llvm::all_of(MIB->operands().drop_front().drop_back(), - [](const MDOperand &Op) { return isa<MDString>(Op); }), - "Not all !memprof MemInfoBlock operands 1 to N-1 are MDString", MIB); - // The last operand might be the total profiled size so can be an integer. - auto &LastOperand = MIB->operands().back(); - Check(isa<MDString>(LastOperand) || mdconst::hasa<ConstantInt>(LastOperand), - "Last !memprof MemInfoBlock operand not MDString or int", MIB); + // The next set of 1 or more operands should be MDString. + unsigned I = 1; + for (; I < MIB->getNumOperands(); ++I) { + if (!isa<MDString>(MIB->getOperand(I))) { + Check(I > 1, + "!memprof MemInfoBlock second operand should be an MDString", + MIB); + break; + } + } + + // Any remaining should be MDNode that are pairs of integers + for (; I < MIB->getNumOperands(); ++I) { + MDNode *OpNode = dyn_cast<MDNode>(MIB->getOperand(I)); + Check(OpNode, "Not all !memprof MemInfoBlock operands 2 to N are MDNode", + MIB); + Check(OpNode->getNumOperands() == 2, + "Not all !memprof MemInfoBlock operands 2 to N are MDNode with 2 " + "operands", + MIB); + // Check that all of Op's operands are ConstantInt. + Check(llvm::all_of(OpNode->operands(), + [](const MDOperand &Op) { + return mdconst::hasa<ConstantInt>(Op); + }), + "Not all !memprof MemInfoBlock operands 2 to N are MDNode with " + "ConstantInt operands", + MIB); + } } } |