[PATCH] D17792: Initialize much of AssemblyWriter lazily.

Justin Lebar via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 31 16:22:59 PDT 2016


jlebar added inline comments.

================
Comment at: lib/IR/AsmWriter.cpp:416
@@ +415,3 @@
+
+  void EnsureTypesInitialized();
+
----------------
timshen wrote:
> Do you think it's better to create a Lazy<T> template type, which has an Optional<T>, but automatically checks & value-initializes the underlying T on operator->()/operator*() ? It seems able to reduce the users' mind burden compared to using raw Optional.
Hm.  If we go this route, I think we don't just want to value-initialize T -- that opens us up to a bug where you accidentally use one of these containers before it's been filled with data.

Now, a Lazy<T> that takes an std::function and uses *that* to initialize T...that's interesting.  I did it, but I am not sure it's clearer.

Have a look, see what you think?  I saved my state so we can go back no problem.


http://reviews.llvm.org/D17792





More information about the llvm-commits mailing list