1
1
# Code generation
2
2
3
- Code generation or "codegen" is the part of the compiler that actually generates
4
- an executable binary. rustc uses LLVM for code generation.
3
+ Code generation or "codegen" is the part of the compiler that actually
4
+ generates an executable binary. rustc uses LLVM for code generation.
5
5
6
6
## What is LLVM?
7
7
@@ -24,8 +24,9 @@ many compiler projects, including the `clang` C compiler and our beloved
24
24
25
25
LLVM's "format ` X ` " is called LLVM IR. It is basically assembly code with
26
26
additional low-level types and annotations added. These annotations are helpful
27
- for doing optimizations on the LLVM IR and outputed machine code. The end result
28
- of all this is (at long last) something executable (e.g. an ELF object or wasm).
27
+ for doing optimizations on the LLVM IR and outputed machine code. The end
28
+ result of all this is (at long last) something executable (e.g. an ELF object
29
+ or wasm).
29
30
30
31
There are a few benefits to using LLVM:
31
32
@@ -38,8 +39,8 @@ There are a few benefits to using LLVM:
38
39
clang, and a bunch of other languages were able to compile to wasm! (Well,
39
40
there was some extra stuff to be done, but we were 90% there anyway).
40
41
- We and other compiler projects benefit from each other. For example, when the
41
- [ Spectre and Meltdown security vulnerabilities] [ spectre ] were discovered, only LLVM
42
- needed to be patched.
42
+ [ Spectre and Meltdown security vulnerabilities] [ spectre ] were discovered,
43
+ only LLVM needed to be patched.
43
44
44
45
[ spectre ] : https://meltdownattack.com/
45
46
0 commit comments