diff options
| -rw-r--r-- | lld/include/lld/Core/Simple.h | 48 |
1 files changed, 7 insertions, 41 deletions
diff --git a/lld/include/lld/Core/Simple.h b/lld/include/lld/Core/Simple.h index eaad6425b84..a6e10612c51 100644 --- a/lld/include/lld/Core/Simple.h +++ b/lld/include/lld/Core/Simple.h @@ -143,46 +143,14 @@ private: } // end namespace lld -// ilist will lazily create a sentinal (so end() can return a node past the -// end of the list). We need this trait so that the sentinal is allocated -// via the BumpPtrAllocator. +// ilist will lazily create a sentinal (so end() can return a node past the end +// of the list). This trait embeds the sentinel in the ilist to avoid the lazy +// logic. namespace llvm { -template<> -struct ilist_sentinel_traits<lld::SimpleReference> { - - ilist_sentinel_traits() : _allocator(nullptr) { } - - void setAllocator(llvm::BumpPtrAllocator *alloc) { - _allocator = alloc; - } - - lld::SimpleReference *createSentinel() const { - return new (*_allocator) lld::SimpleReference(); - } - - static void destroySentinel(lld::SimpleReference*) {} - - static lld::SimpleReference *provideInitialHead() { return nullptr; } - - lld::SimpleReference *ensureHead(lld::SimpleReference *&head) const { - if (!head) { - head = createSentinel(); - noteHead(head, head); - ilist_traits<lld::SimpleReference>::setNext(head, nullptr); - return head; - } - return ilist_traits<lld::SimpleReference>::getPrev(head); - } - - void noteHead(lld::SimpleReference *newHead, - lld::SimpleReference *sentinel) const { - ilist_traits<lld::SimpleReference>::setPrev(newHead, sentinel); - } - -private: - mutable llvm::BumpPtrAllocator *_allocator; -}; +template <> +struct ilist_sentinel_traits<lld::SimpleReference> + : public ilist_full_embedded_sentinel_traits<lld::SimpleReference> {}; } // end namespace llvm @@ -191,9 +159,7 @@ namespace lld { class SimpleDefinedAtom : public DefinedAtom { public: explicit SimpleDefinedAtom(const File &f) - : _file(f), _ordinal(f.getNextAtomOrdinalAndIncrement()) { - _references.setAllocator(&f.allocator()); - } + : _file(f), _ordinal(f.getNextAtomOrdinalAndIncrement()) {} ~SimpleDefinedAtom() override { _references.clearAndLeakNodesUnsafely(); |

