If a function is GlobalMemOnly and a memory location does not point to a global object, getModRefInfo can infer that no aliasing between the function and the location can occur.
Just because the underlying object is not a global value, doesn't mean that it can't be based on one -- e.g. imagine a global being passed to a function argument. getUnderlyingObject() will just give you the argument in that case, which may still alias with a global.
At the very least, you need to check for isIdentifiedObject() here. However, even that may be insufficient, as noalias arguments are identified objects, but I don't think you can apply this optimization to them (a noalias argument could point to a global, and a globalmemonly function could access the global through a passed-on noalias argument).
The last part is were it becomes interesting. If we say accesses to a global via an argument are globalmemonly or argmemonly. I think, given argmemonly, we could/should not say a function accessing globals only but via argument pointers can be globalmemonly. That resolves the problem here, I think. Identified objects are necessary for sure though.