debuginfo: Fixes and improvements for #12840, #12886, and #13213

This PR is a collection of debuginfo fixes and improvements:
+ Fixes #13213: This is a bug where the linker could not find a global variable inlined from another crate because it was actually optimized out from the external crate. The fix makes sure that we don't create debuginfo for globals that are defined in other crates (even if there is a local, inlined copy of the global).
+ Fixes #12840: An optimization for sharing the type metadata of generic enum discriminators between monomorphized instances.
+ Should improve the situation for #12886 by making sure that inlined code is not linked to any source locations. I don't want to close the issue automatically as it needs some manual testing.