attributes: introduce allockind attr for describing allocator fn behavior

I chose to encode the allockind information in a string constant because
otherwise we would get a bit of an explosion of keywords to deal with
the possible permutations of allocation function types.

I'm not sure that CodeGen.h is the correct place for this enum, but it
seemed to kind of match the UWTableKind enum so I put it in the same
place. Constructive suggestions on a better location most certainly
encouraged.

Differential Revision: https://reviews.llvm.org/D123088
This commit is contained in:
Augie Fackler
2022-03-29 11:14:07 -04:00
parent b9443cb6fa
commit 42861faa8e
16 changed files with 193 additions and 2 deletions

View File

@@ -1536,6 +1536,8 @@ static Attribute::AttrKind getAttrFromCode(uint64_t Code) {
return Attribute::DereferenceableOrNull;
case bitc::ATTR_KIND_ALLOC_ALIGN:
return Attribute::AllocAlign;
case bitc::ATTR_KIND_ALLOC_KIND:
return Attribute::AllocKind;
case bitc::ATTR_KIND_ALLOC_SIZE:
return Attribute::AllocSize;
case bitc::ATTR_KIND_ALLOCATED_POINTER:
@@ -1736,6 +1738,8 @@ Error BitcodeReader::parseAttributeGroupBlock() {
B.addVScaleRangeAttrFromRawRepr(Record[++i]);
else if (Kind == Attribute::UWTable)
B.addUWTableAttr(UWTableKind(Record[++i]));
else if (Kind == Attribute::AllocKind)
B.addAllocKindAttr(static_cast<AllocFnKind>(Record[++i]));
} else if (Record[i] == 3 || Record[i] == 4) { // String attribute
bool HasValue = (Record[i++] == 4);
SmallString<64> KindStr;