[Loads] Only allow replacement with derefable constant global (#217350)
isPointerAlwaysReplaceable() currently allows replacing with Constants
that are dereferenceable for at least one byte. This patch further
restricts this carveout to cases where the Constant is based on a
constant global.
This fixes the case from #59679. In that case, the replacement is
between a noalias pointer and a dereferenceable global. After the
replacement, the noalias pointer is assumed to no longer alias with the
replaced global write, resulting in a miscompile.
The remaining carveout for constant globals is still not correct, but I
think there's less issues we can encounter in the read-only case, and we
have to support this for vtable assumptions to work.
Fixes https://github.com/llvm/llvm-project/issues/59679.