[PATCH] D46145: Use a buffer when allocating relocations
Rafael Avila de Espindola via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 27 07:44:40 PDT 2018
espindola added a comment.
================
Comment at: ELF/Writer.cpp:875
+ };
+
// Scan all relocations. Each relocation goes through a series
----------------
grimar wrote:
> It can be a bit simpler I think:
> (RAM profiling shows that the version below consume the same amount of memory).
>
> ```
> std::vector<Relocation> Buffer;
>
> // <new comment>
> auto WithBuffer = [&](InputSectionBase &Sec) {
> Fn(Sec);
> Buffer = std::move(Sec.Relocations);
> Sec.Relocations = Buffer;
> };
> ```
That would reduce peak allocation, but each call to Fn is still allocating a new buffer, no?
But does suggest a way to simplify it a bit.
https://reviews.llvm.org/D46145
More information about the llvm-commits
mailing list