Why does matches disappear from the output in this godbolt?
matches
Does Rust/LLVM deduplicate functions?
Or does it treat this as some sort of trivial map that will always be inlined (in the case of -O)?
-O
If I stick a #[inline(never)] onto matches it will reappear (and is indeed identical to ifchain).
#[inline(never)]
ifchain
LLVM does appear to have a MergeFunctions pass.
MergeFunctions
It depends on the target: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_target/spec/struct.TargetOptions.html#structfield.merge_functions
But yes, on x64 it does by default.
If you want to disable this behavior (e.g. on godbolt for showing generated asm), you can use -Cmerge-functions=disabled. (At this point I habitually include it when I set up a godbolt experiment.)
-Cmerge-functions=disabled