Disappearing function

Why does matches disappear from the output in this godbolt?

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)?

If I stick a #[inline(never)] onto matches it will reappear (and is indeed identical to ifchain).

LLVM does appear to have a MergeFunctions pass.

2 Likes

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.

2 Likes

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.)

4 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.