[PATCH] D28150: Move the section name from GlobalObject to the LLVMContext

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 29 10:56:41 PST 2016


rnk added inline comments.


================
Comment at: lib/IR/Globals.cpp:180
+  // context.
+  S = getContext().pImpl->SectionStrings.insert(S).first->first();
+  getContext().pImpl->GlobalObjectSections[this] = S;
----------------
jlebar wrote:
> mehdi_amini wrote:
> > jlebar wrote:
> > > Don't we "leak" section strings now?  (That is, if I call setSection(x) a bunch of times on the same object, all of the unique values of x will persist in the context forever.)
> > Yes: this is the common practice with the LLVMContext (Metadata, Type, Constant, ...)
> Ah, okay then!
Didn't we used to have some kind of GC-like functionality where we try to delete dead constants? dropTriviallyDeadConstantArrays looks a little specific to arrays. Constant aggregate initializers in particular accumulate pretty quickly. If such an API existed, it would be easy to GC the strings by building a new set by iterating the GlobalObjectSections map, updating the references there, and swapping that into place on the context.


https://reviews.llvm.org/D28150





More information about the llvm-commits mailing list