Currently, in InstCombineLoadStoreAlloca, we have simplification rules
for the following cases:
- load off a null
- load off a GEP with null base
- store to a null
This patch adds support for the fourth case which is store into a GEP with null
base. Since this is UB as well (and directly analogous to the load off a
GEP with null base), we can substitute the stored val with
undef in instcombine, so that SimplifyCFG can optimize this code into
unreachable code.
Note: Right now, simplifyCFG hasn't been taught about optimizing this to
unreachable and adding an llvm.trap (this is already done for the above 3 cases).
I would like to confirm whether this is just a missed optimization, or
there is something fundamental that prevents this transformation.