[PATCH] D17792: Initialize much of AssemblyWriter lazily.

Tim Shen via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 31 16:46:36 PDT 2016


timshen added a comment.

inline comments.


================
Comment at: lib/IR/AsmWriter.cpp:82
@@ +81,3 @@
+
+  std::function<T()> Initializer;
+  Optional<T> Obj;
----------------
Man, by last time I looked at libstdc++, it's like 48 bytes on 64-bit machines...

Even if Lazy keeps track of the raw lambda, the lambda may still capture stuff and have memory footprint.

Now I think it's a bad idea. It's as bad as that dtor doesn't have parameters so each container, which may be in a parent container, needs to keep its allocator.

Sorry, I think the Optional version is better. :(

BTW, how hard is it to make the user side lazy, rather the library side?


http://reviews.llvm.org/D17792





More information about the llvm-commits mailing list