[PATCH] D47345: [InstructionCombining] Replace small heap allocations with local variables

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 25 12:47:32 PDT 2018


efriedma added inline comments.


================
Comment at: lib/Transforms/InstCombine/InstCombineInternal.h:256
 
+  MapVector<Function *, unsigned> HeapAllocEliminations;
+
----------------
This still doesn't really do what you want: opt -instcombine -instcombine will ignore the limit (and we effectively do that in a lot of places).  Maybe you could solve that by moving the transform into its own pass?  Not sure; I'll think about it over the weekend and get back to you.


================
Comment at: lib/Transforms/InstCombine/InstructionCombining.cpp:2307
+  if (PointerMayBeCaptured(Malloc, true, true))
+    return false;
+
----------------
This check isn't sufficient to ensure some other function doesn't call free() on the pointer (actually, this doesn't even handle the case where there are two calls to free() along different codepaths).


https://reviews.llvm.org/D47345





More information about the llvm-commits mailing list