[llvm] MCFragment: Use trailing data for fixed-size part (PR #150846)
Alexis Engelke via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 28 02:45:33 PDT 2025
================
@@ -46,23 +46,84 @@ MCAssembler *MCObjectStreamer::getAssemblerPtr() {
return nullptr;
}
+constexpr size_t FragChunkSize = 16384;
+// Ensure the new fragment can at least at least a few bytes.
+constexpr size_t NewFragHeadroom = 8;
+
+static_assert(NewFragHeadroom >= alignof(MCFragment));
+static_assert(FragChunkSize >= sizeof(MCFragment) + NewFragHeadroom);
+
+MCFragment *MCObjectStreamer::allocFragSpace(size_t Headroom) {
+ auto Size = std::max(FragChunkSize, sizeof(MCFragment) + Headroom);
----------------
aengelke wrote:
We could consider growing the size exponentially, similar to what BumpPtrAllocator does. This should reduce the number of individual heap allocations for large files.
https://github.com/llvm/llvm-project/pull/150846
More information about the llvm-commits
mailing list