91f7c60d2d
By putting an "unreachable" instruction into the default arm of a switch instruction we can let LLVM know that the match is exhaustive, allowing for better optimizations. For example, this match: ```rust pub enum Enum { One, Two, Three, } impl Enum { pub fn get_disc(self) -> u8 { match self { Enum::One => 0, Enum::Two => 1, Enum::Three => 2, } } } ``` Currently compiles to this on x86_64: ```asm .cfi_startproc movzbl %dil, %ecx cmpl $1, %ecx setne %al testb %cl, %cl je .LBB0_2 incb %al movb %al, %dil .LBB0_2: movb %dil, %al retq .Lfunc_end0: ``` But with this change we get: ```asm .cfi_startproc movb %dil, %al retq .Lfunc_end0: ``` |
||
---|---|---|
.. | ||
adjustments.rs | ||
coercions.rs | ||
extern-functions.rs | ||
function-arguments.rs | ||
gdb_debug_script_load.rs | ||
intrinsic-no-unnamed-attr.rs | ||
link_section.rs | ||
loads.rs | ||
match.rs | ||
stores.rs |