[PATCH] D31058: Store Arguments in a flat array instead of an iplist

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 16 16:51:55 PDT 2017


rnk added inline comments.


================
Comment at: lib/IR/Function.cpp:230-231
+  if (NumArgs > 0) {
+    Arguments =
+        reinterpret_cast<Argument *>(malloc(sizeof(Argument) * NumArgs));
+    for (unsigned i = 0, e = NumArgs; i != e; ++i) {
----------------
rnk wrote:
> chandlerc wrote:
> > Why malloc?
> Is there a way to use 'new' to allocate uninitialized memory suitable for this kind of placement new construction? I can do `new char[sizeof(Argument)*NumArgs]`, but it didn't seem prettier. Regular array new wants a default ctor, which Argument doesn't have, and adding one would be wasteful. I just want to allocate some memory and initialize some complex, non-value type objects into it. How hard can that be? ¯\_(ツ)_/¯
Maybe you're suggesting `::operator new(...)`? That'd work.


https://reviews.llvm.org/D31058





More information about the llvm-commits mailing list