[StackSafety] Add info into function summary

Summary:
This patch adds optional field into function summary,
implements asm and bitcode serialization. YAML
serialization is omitted and can be added later if
needed.

This patch includes this information into summary only
if module contains at least one sanitize_memtag function.
In a near future MTE is the user of the analysis.
Later if needed we can provede more direct control
on when information is included into summary.

Reviewers: eugenis

Subscribers: hiraditya, steven_wu, dexonsmith, arphaman, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D80908
This commit is contained in:
Vitaly Buka
2020-05-31 23:49:57 -07:00
parent 8fd2270370
commit 4666953ce2
18 changed files with 664 additions and 25 deletions

View File

@@ -3576,6 +3576,29 @@ static void writeFunctionTypeMetadataRecords(BitstreamWriter &Stream,
FS->type_test_assume_const_vcalls());
WriteConstVCallVec(bitc::FS_TYPE_CHECKED_LOAD_CONST_VCALL,
FS->type_checked_load_const_vcalls());
auto WriteRange = [&](ConstantRange Range) {
Range = Range.sextOrTrunc(FunctionSummary::ParamAccess::RangeWidth);
assert(Range.getLower().getNumWords() == 1);
assert(Range.getUpper().getNumWords() == 1);
emitSignedInt64(Record, *Range.getLower().getRawData());
emitSignedInt64(Record, *Range.getUpper().getRawData());
};
if (!FS->paramAccesses().empty()) {
Record.clear();
for (auto &Arg : FS->paramAccesses()) {
Record.push_back(Arg.ParamNo);
WriteRange(Arg.Use);
Record.push_back(Arg.Calls.size());
for (auto &Call : Arg.Calls) {
Record.push_back(Call.ParamNo);
Record.push_back(Call.Callee);
WriteRange(Call.Offsets);
}
}
Stream.EmitRecord(bitc::FS_PARAM_ACCESS, Record);
}
}
/// Collect type IDs from type tests used by function.