[llvm] Add the 'initializes' attribute langref and support (PR #84803)
Haopeng Liu via llvm-commits
llvm-commits at lists.llvm.org
Thu May 16 16:59:20 PDT 2024
================
@@ -191,6 +192,36 @@ Attribute Attribute::get(LLVMContext &Context, Attribute::AttrKind Kind,
return Attribute(PA);
}
+Attribute Attribute::get(LLVMContext &Context, Attribute::AttrKind Kind,
+ ArrayRef<ConstantRange> Val) {
+ assert(Attribute::isConstantRangeListAttrKind(Kind) &&
+ "Not a ConstantRangeList attribute");
+ LLVMContextImpl *pImpl = Context.pImpl;
+ FoldingSetNodeID ID;
+ ID.AddInteger(Kind);
+ ID.AddInteger(Val.size());
+ for (auto &CR : Val) {
+ CR.getLower().Profile(ID);
+ CR.getUpper().Profile(ID);
+ }
+
+ void *InsertPoint;
+ AttributeImpl *PA = pImpl->AttrsSet.FindNodeOrInsertPos(ID, InsertPoint);
+
+ if (!PA) {
+ // If we didn't find any existing attributes of the same shape then create a
+ // new one and insert it.
+ void *Mem = pImpl->Alloc.Allocate(
+ ConstantRangeListAttributeImpl::totalSizeToAlloc(Val),
+ alignof(ConstantRangeListAttributeImpl));
+ PA = new (Mem) ConstantRangeListAttributeImpl(Kind, Val);
+ pImpl->AttrsSet.InsertNode(PA, InsertPoint);
----------------
haopliu wrote:
oh thanks for this info! Changed to `SpecificBumpPtrAllocator`. Please take another look :-)
https://github.com/llvm/llvm-project/pull/84803
More information about the llvm-commits
mailing list