Skip to content

Commit

Permalink
Use SpecificBumpPtrAllocator to allocate mem and make sure to call de…
Browse files Browse the repository at this point in the history
…structors
  • Loading branch information
haopliu committed May 16, 2024
1 parent 8e64fa9 commit 9ae0fca
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
7 changes: 3 additions & 4 deletions llvm/lib/IR/Attributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,9 @@ Attribute Attribute::get(LLVMContext &Context, Attribute::AttrKind Kind,
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);
PA = new (pImpl->ConstantRangeListAttributeAlloc.Allocate(
ConstantRangeListAttributeImpl::totalSizeToAlloc(Val)))
ConstantRangeListAttributeImpl(Kind, Val);
pImpl->AttrsSet.InsertNode(PA, InsertPoint);
}

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/IR/ConstantRangeList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void ConstantRangeList::insert(const ConstantRange &NewRange) {
// Slow insert.
SmallVector<ConstantRange, 2> ExistingTail(LowerBound, Ranges.end());
Ranges.erase(LowerBound, Ranges.end());
// "sle" instead of "slt" to merge consecutive ranges.
// Merge consecutive ranges.
if (!Ranges.empty() && NewRange.getLower().sle(Ranges.back().getUpper())) {
APInt NewLower = Ranges.back().getLower();
APInt NewUpper =
Expand Down
3 changes: 3 additions & 0 deletions llvm/lib/IR/LLVMContextImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class AttributeListImpl;
class AttributeSetNode;
class BasicBlock;
class ConstantRangeAttributeImpl;
class ConstantRangeListAttributeImpl;
struct DiagnosticHandler;
class DbgMarker;
class ElementCount;
Expand Down Expand Up @@ -1581,6 +1582,8 @@ class LLVMContextImpl {
UniqueStringSaver Saver{Alloc};
SpecificBumpPtrAllocator<ConstantRangeAttributeImpl>
ConstantRangeAttributeAlloc;
SpecificBumpPtrAllocator<ConstantRangeListAttributeImpl>
ConstantRangeListAttributeAlloc;

DenseMap<unsigned, IntegerType *> IntegerTypes;

Expand Down

0 comments on commit 9ae0fca

Please sign in to comment.