[PATCH] D47345: [InstructionCombining] Replace small allocations with local/global variable
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 25 11:55:50 PDT 2018
efriedma added inline comments.
================
Comment at: lib/Transforms/InstCombine/InstructionCombining.cpp:2299
+
+ if (LI->getLoopFor(Malloc->getParent())) {
+ // Do not optimize if malloc is in loop
----------------
xbolva00 wrote:
> efriedma wrote:
> > This isn't sufficient to guarantee malloc will be called once; getLoopFor won't find irreducible loops.
> How can we fix it and detect them?
>
> I read some comments about irreducible loops in getNearestLoop...
There's a helper containsIrreducibleCFG.
================
Comment at: lib/Transforms/InstCombine/InstructionCombining.cpp:2276
+bool InstCombiner::eliminateSmallAllocations(Value *Op, CallInst &FI) {
+ static MapVector<Function *, unsigned> Eliminations;
+ Function *F = FI.getFunction();
----------------
You can't use a static variable like this; LLVM can run on multiple threads in a program at the same time.
https://reviews.llvm.org/D47345
More information about the llvm-commits
mailing list