rust/src/test/codegen
Björn Steinbrink 91f7c60d2d Tell LLVM when a match is exhaustive
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:
```
2015-09-25 11:09:19 +02:00
..
adjustments.rs Avoid loading the whole gdb debug scripts section. 2015-09-21 15:43:52 -05:00
coercions.rs Avoid loading the whole gdb debug scripts section. 2015-09-21 15:43:52 -05:00
extern-functions.rs Avoid loading the whole gdb debug scripts section. 2015-09-21 15:43:52 -05:00
function-arguments.rs Avoid loading the whole gdb debug scripts section. 2015-09-21 15:43:52 -05:00
gdb_debug_script_load.rs Avoid loading the whole gdb debug scripts section. 2015-09-21 15:43:52 -05:00
intrinsic-no-unnamed-attr.rs Don't add unnamed address attributes to intrinsics. 2015-09-06 19:26:41 -05:00
link_section.rs Avoid loading the whole gdb debug scripts section. 2015-09-21 15:43:52 -05:00
loads.rs Avoid loading the whole gdb debug scripts section. 2015-09-21 15:43:52 -05:00
match.rs Tell LLVM when a match is exhaustive 2015-09-25 11:09:19 +02:00
stores.rs Avoid loading the whole gdb debug scripts section. 2015-09-21 15:43:52 -05:00