[llvm] [MC] Add MCFragment allocation helpers (PR #95197)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 12 10:16:53 PDT 2024


================
@@ -90,6 +90,12 @@ class MCObjectStreamer : public MCStreamer {
 
   MCFragment *getCurrentFragment() const;
 
+  template <typename F, typename... Args> F *allocAndAdd(Args &&...args) {
+    F *Frag = new F(std::forward<Args>(args)...);
----------------
MaskRay wrote:

MCObjectStreamer.h cannot include MCContext.h, so we cannot use allocFragment.
I believe in the end we will have different allocation functions. The primary one from MCObjectStreamer.h will be made to a bump allocator., but `operator new` might remain.

https://github.com/llvm/llvm-project/pull/95197


More information about the llvm-commits mailing list