This is a first part of PR21780 fix.
This change allows to keep information about removed Load instruction by InstCombine pass in order to restore those later. Here I am using Intrinsics to keep information in the IR as it was discussed in http://lists.llvm.org/pipermail/llvm-dev/2017-July/115730.html. Before that, I used metadata for that purpose https://reviews.llvm.org/D35139.
I introduced phantom_mem intrinsic that consist of two parameters the first is pointer and the second is maximum offset for that pointer. In the Instcombine pass, while constructing such intrisics, I try to avoid case if GEP's origin is in a different basic block and GEP itself is in a loop, but it is ok if both GEP and the pointer origin are in the loop and both belong to the same basic block.
clang-format this - your indentation is broken.