diff options
author | Teresa Johnson <tejohnson@google.com> | 2024-07-10 09:41:36 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-10 09:41:36 -0700 |
commit | 8c1bd67dee964f286ad78a76a7e87f0284b47ebb (patch) | |
tree | 2bf920c2bd67719cf9f3f9e07db9cab4391967a9 /llvm/lib/IR/Verifier.cpp | |
parent | 3c8b18bc512ad87b379b4b7c06d52ca2d13860b2 (diff) | |
download | llvm-8c1bd67dee964f286ad78a76a7e87f0284b47ebb.zip llvm-8c1bd67dee964f286ad78a76a7e87f0284b47ebb.tar.gz llvm-8c1bd67dee964f286ad78a76a7e87f0284b47ebb.tar.bz2 |
[MemProf] Optionally print or record the profiled sizes of allocations (#98248)
This is the first step in being able to track the total profiled sizes
of allocations successfully marked as cold.
Under a new option -memprof-report-hinted-sizes:
- For unambiguous (non-context-sensitive) allocations, print the
profiled size and the allocation coldness, along with a hash of the
allocation's location (to allow for deduplication across modules or
inline instances).
- For context sensitive allocations, add the size as a 3rd operand on
the MIB metadata. A follow on patch will propagate this through to the
thin link where the sizes will be reported for each context after
cloning.
Diffstat (limited to 'llvm/lib/IR/Verifier.cpp')
-rw-r--r-- | llvm/lib/IR/Verifier.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 3b6d76e..75a53c1 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -4941,10 +4941,14 @@ void Verifier::visitMemProfMetadata(Instruction &I, MDNode *MD) { MDNode *StackMD = dyn_cast<MDNode>(MIB->getOperand(0)); visitCallStackMetadata(StackMD); - // Check that remaining operands are MDString. - Check(llvm::all_of(llvm::drop_begin(MIB->operands()), + // 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 are MDString", MIB); + "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); } } |