Skip to content

Commit

Permalink
[mlir-tblgen] Stop leaking PredNodes
Browse files Browse the repository at this point in the history
Technically a leak in tblgen is harmless, but this makes asan builds of
mlir very noisy. Just use a SpecificBumpPtrAllocator that knows how to
clean up after itself.
  • Loading branch information
d0k committed Feb 6, 2020
1 parent 2694cc3 commit b68b8be
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions mlir/lib/TableGen/Predicate.cpp
Expand Up @@ -136,10 +136,11 @@ using Subst = std::pair<StringRef, StringRef>;
// have children, and perform leaf substitutions inplace. Note that after
// substitution, nodes are still pointing to the original TableGen record.
// All nodes are created within "allocator".
static PredNode *buildPredicateTree(const tblgen::Pred &root,
llvm::BumpPtrAllocator &allocator,
ArrayRef<Subst> substitutions) {
auto *rootNode = allocator.Allocate<PredNode>();
static PredNode *
buildPredicateTree(const tblgen::Pred &root,
llvm::SpecificBumpPtrAllocator<PredNode> &allocator,
ArrayRef<Subst> substitutions) {
auto *rootNode = allocator.Allocate();
new (rootNode) PredNode;
rootNode->kind = getPredCombinerKind(root);
rootNode->predicate = &root;
Expand Down Expand Up @@ -339,7 +340,7 @@ static std::string getCombinedCondition(const PredNode &root) {
}

std::string tblgen::CombinedPred::getConditionImpl() const {
llvm::BumpPtrAllocator allocator;
llvm::SpecificBumpPtrAllocator<PredNode> allocator;
auto predicateTree = buildPredicateTree(*this, allocator, {});
predicateTree = propagateGroundTruth(
predicateTree,
Expand Down

0 comments on commit b68b8be

Please sign in to comment.