rust-lang/rust — pull request #16100 by brson (2014-07-30 06:30:04+00:00)
Title: More defailbloating

With this, all the failure calls are optimized to take either one or two pointers, at least one of which is a constant, with the exception that the bounds check lang item also takes `index` and `len`. Code gen for all that is gorgeous.

Divide-by-zero before:

```
leaq "str\"str\"(1762)"(%rip), %rax
movq %rax, 16(%rsp)
movq $27, 24(%rsp)
leaq "str\"str\"(1542)"(%rip), %rax
movq %rax, (%rsp)
movq $19, 8(%rsp)
leaq 16(%rsp), %rdi
leaq (%rsp), %rsi
movl $32, %edx
callq _ZN7failure5fail_20hc04408f955ce60aaqWjE@PLT
```

After:

```
leaq .Lconst(%rip), %rdi
callq _ZN7failure5fail_20haf918a97c8f7f2bfqWjE@PLT
```

Bounds check before:

```
leaq "str\"str\"(1542)"(%rip), %rax
movq %rax, 8(%rsp)
movq $19, 16(%rsp)
leaq 8(%rsp), %rdi
movl $38, %esi
movl $1, %edx
movl $1, %ecx
callq _ZN7failure17fail_bounds_check20hf4bc3c69e96caf41RXjE@PLT
```

Bounds check after:

```
leaq .Lconst2(%rip), %rdi
movl $1, %esi
movl $1, %edx
callq _ZN7failure17fail_bounds_check20h5267276a537a7de22XjE@PLT
```

Size before:

21277995 librustc-4e7c5e5c.s

```
text data
12554881 6089335
```

Size after:

21247617 librustc-4e7c5e5c.so

```
text data
12518497 6095748
```

The next two steps might be to change the amount of information we generate based on a compiler flag, and maybe debug levels; and to investigate improving codegen for `fmt::Arguments`, which appears in many `fail!` invocations.

r? @pcwalton