This bases the CleanupConstantGlobalUsers() implementation around the ConstantFoldLoadFromConst() API. The general approach is that we discover all users while looking through casts, and then constant fold loads and drop stores and memintrinsics.
This avoids special cases and limitations in the previous implementation, which is also incompatible with opaque pointers. The result is a bit more powerful than before, because we now use more general load folding logic which can for example look through pointer bitcasts between different sizes. This is where the test changes come from, as we now fold more loads and can thus remove more globals.
is this true for non-inbounds GEPs?