rust/src/librustc_codegen_llvm
bors be055d96c4 Auto merge of #67502 - Mark-Simulacrum:opt-catch, r=Mark-Simulacrum
Optimize catch_unwind to match C++ try/catch

This refactors the implementation of catching unwinds to allow LLVM to inline the "try" closure directly into the happy path, avoiding indirection. This means that the catch_unwind implementation is (after this PR) zero-cost unless a panic is thrown.

https://rust.godbolt.org/z/cZcUSB is an example of the current codegen in a simple case. Notably, the codegen is *exactly the same* if `-Cpanic=abort` is passed, which is clearly not great.

This PR, on the other hand, generates the following assembly:

```asm
# -Cpanic=unwind:
	push   rbx
	mov    ebx,0x2a
	call   QWORD PTR [rip+0x1c53c]        # <happy>
	mov    eax,ebx
	pop    rbx
	ret
	mov    rdi,rax
	call   QWORD PTR [rip+0x1c537]        # cleanup function call
	call   QWORD PTR [rip+0x1c539]        # <unfortunate>
	mov    ebx,0xd
	mov    eax,ebx
	pop    rbx
	ret

# -Cpanic=abort:
	push   rax
	call   QWORD PTR [rip+0x20a1]        # <happy>
	mov    eax,0x2a
	pop    rcx
	ret
```

Fixes #64224, and resolves #64222.
2020-03-13 22:43:06 +00:00
..
back fix various typos 2020-03-06 15:19:31 +01:00
debuginfo Avoid unnecessary interning of enum variant part id 2020-03-09 02:05:22 +01:00
llvm remove lifetimes that can be elided (clippy::needless_lifetimes) 2020-03-12 20:03:09 +01:00
abi.rs Don't redundantly repeat field names (clippy::redundant_field_names) 2020-03-06 19:42:18 +01:00
allocator.rs librustc_codegen_llvm: Use slices instead of 0-terminated strings 2020-03-11 08:10:21 +01:00
asm.rs Rollup merge of #69893 - tmiasko:cstr, r=petrochenkov 2020-03-11 14:03:54 +01:00
attributes.rs Apply LLVM sanitize attributes to generated entry wrapper 2020-02-05 23:30:38 +01:00
base.rs Apply LLVM sanitize attributes to generated entry wrapper 2020-02-05 23:30:38 +01:00
build.rs Remove licenses 2018-12-25 21:08:33 -07:00
builder.rs librustc_codegen_llvm: Use slices instead of 0-terminated strings 2020-03-11 08:10:21 +01:00
callee.rs Add projection query for upstream drop-glue instances. 2020-01-23 16:56:59 +01:00
Cargo.toml Rename syntax to rustc_ast in source code 2020-02-29 21:59:09 +03:00
common.rs Auto merge of #69986 - JohnTitor:rollup-h0809mf, r=JohnTitor 2020-03-13 19:16:03 +00:00
consts.rs Change const eval to return ConstValue, instead of Const as the type inside it shouldn't be used. 2020-02-15 11:56:23 +13:00
context.rs Auto merge of #67502 - Mark-Simulacrum:opt-catch, r=Mark-Simulacrum 2020-03-13 22:43:06 +00:00
declare.rs librustc_codegen_llvm: Use slices instead of 0-terminated strings 2020-03-11 08:10:21 +01:00
intrinsic.rs Apply review feedback 2020-03-07 16:31:30 +00:00
lib.rs Rename syntax to rustc_ast in source code 2020-02-29 21:59:09 +03:00
llvm_util.rs use is_empty() instead of len() == x to determine if structs are empty. 2020-02-28 15:16:27 +01:00
metadata.rs Rustfmt 2020-02-07 13:59:31 +01:00
mono_item.rs Auto merge of #67886 - Centril:rustc_hir_canon_imports, r=nagisa 2020-01-06 12:55:40 +00:00
README.md rust-lang.github.io/rustc-dev-guide -> rustc-dev-guide.rust-lang.org 2020-03-10 17:08:18 -03:00
type_.rs remove lifetimes that can be elided (clippy::needless_lifetimes) 2020-03-12 20:03:09 +01:00
type_of.rs Format the world 2019-12-22 17:42:47 -05:00
va_arg.rs use conditions directly 2020-03-03 03:46:45 +01:00
value.rs Format the world 2019-12-22 17:42:47 -05:00

The codegen crate contains the code to convert from MIR into LLVM IR, and then from LLVM IR into machine code. In general it contains code that runs towards the end of the compilation process.

For more information about how codegen works, see the rustc dev guide.