[PATCH] D58359: [Analysis] fold load of untouched alloca to undef

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 19 11:27:31 PST 2019


efriedma added a comment.

Yes, we fold loads from alloca to undef. (In GVN like you mention, but also in mem2reg.)  LangRef should state memory allocated with alloca is uninitialized, and that loading from uninitialized memory produces undef; if either of those is missing, patch welcome to fix it.

That said, this seems like the wrong direction, in terms of where we want to perform this sort of optimization.  Most functions have more than one basic block, and you won't catch any of those cases.  EarlyCSE/GVN/NewGVN should be able to handle this case, and similar cases where there's more than one basic block.  Also, FindAvailablePtrLoadStore is basically only used from two places: JumpThreading, and InstCombine.   InstCombine really shouldn't be doing this sort of scan, and JumpThreading obviously only triggers in functions with more than one BB.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58359/new/

https://reviews.llvm.org/D58359





More information about the llvm-commits mailing list