[CodeGen] Source-qualify hashes of module-local globals for GFM and outliner (#219938)
Global function merging and outliner compare hashes across modules. Some
globals are hashed by name, so two modules that each define a same-named
global with local linkage produce identical operand hashes although they
denote different storage. The hash collision caused both GFM and GFO to
make quite a few non-beneficial optimization decisions.
Add a `SourceQualifyLocalGlobals` option to IR `StructuralHash` and MIR
`stableHashValue`. When set, the name-based hash of a global with local
linkage is combined with the source file name of its module. The module
identifier itself is not suitable: the linker may name the module after
an unstable temporary LTO object file, which would make the supposedly
stable hash vary from run to run and between the generate and use
rounds. Content-based hashes are unchanged, so equivalent literals still
merge across modules.
The option defaults to off, so other users of `stableHashValue` and
`StructuralHash` keep their hashes.