C++17 added support for polymorphic memory resources to the standard library:
https://isocpp.org/files/papers/N3916.pdf
Prior to polymorphic memory resources, the allocator was part of the compile-
time type for C++ containers. (As an example, std::vector instances with
different allocators were distinct C++ types.) With polymorphic memory
resources, the memory_resource abstract base class provides an interface that
different allocators can implement, allowing containers with different
allocators to have the same type. Runtime allocator dispatch occurs via a
virtual function call.
This diff adds a memory_resource adaptor for LLVM allocators (and in
particular, the BumpPtrAllocator). This is an opt-in modification: no existing
uses of the ubiquitous BumpPtrAllocator are affected.
With the new adaptor, LLVM code that uses the BumpPtrAllocator can make use of
the standard C++ library containers with PMR support (i.e. std::pmr::vector<>,
std::pmr::list<>, std::pmr::string, ...), with container allocations using
the LLVM BumpPtrAllocator.
Future MLIR diffs may use this feature. Those are being kept separate from this
diff to facilitate review.