about summary refs log tree commit diff
path: root/src/libstd/sys/unix/stack_overflow.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-09-27 05:29:39 +0000
committerbors <bors@rust-lang.org>2015-09-27 05:29:39 +0000
commitdde7283b807792dab4b2a10bace9b015a28aea02 (patch)
tree9de741bf6919fff0f378c615b35c12e122d80bb9 /src/libstd/sys/unix/stack_overflow.rs
parent90c04d0362699637a399a33a321ece7c644e449b (diff)
parent91f7c60d2d77423ed8f163beb6f76b92de03a09f (diff)
downloadrust-dde7283b807792dab4b2a10bace9b015a28aea02.tar.gz
rust-dde7283b807792dab4b2a10bace9b015a28aea02.zip
Auto merge of #28651 - dotdash:exhaustive_match, r=eddyb
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:
```
Diffstat (limited to 'src/libstd/sys/unix/stack_overflow.rs')
0 files changed, 0 insertions, 0 deletions