rust/src/librustc_codegen_llvm
Rich Kadel a6f8b8a211 Generating the coverage map
rustc now generates the coverage map and can support (limited)
coverage report generation, at the function level.

Example:

$ BUILD=$HOME/rust/build/x86_64-unknown-linux-gnu
$ $BUILD/stage1/bin/rustc -Zinstrument-coverage \
$HOME/rust/src/test/run-make-fulldeps/instrument-coverage/main.rs
$ LLVM_PROFILE_FILE="main.profraw" ./main
called
$ $BUILD/llvm/bin/llvm-profdata merge -sparse main.profraw -o main.profdata
$ $BUILD/llvm/bin/llvm-cov show --instr-profile=main.profdata main
    1|      1|pub fn will_be_called() {
    2|      1|    println!("called");
    3|      1|}
    4|       |
    5|      0|pub fn will_not_be_called() {
    6|      0|    println!("should not have been called");
    7|      0|}
    8|       |
    9|      1|fn main() {
   10|      1|    let less = 1;
   11|      1|    let more = 100;
   12|      1|
   13|      1|    if less < more {
   14|      1|        will_be_called();
   15|      1|    } else {
   16|      1|        will_not_be_called();
   17|      1|    }
   18|      1|}
2020-07-17 11:49:35 -07:00
..
back Avoid "whitelist" 2020-07-10 07:39:28 -04:00
coverageinfo Generating the coverage map 2020-07-17 11:49:35 -07:00
debuginfo Change SymbolName::name to a &str. 2020-07-15 14:37:55 +10:00
llvm Generating the coverage map 2020-07-17 11:49:35 -07:00
abi.rs [AVR] Add AVR platform support 2020-06-09 17:34:07 +12:00
allocator.rs Add Option to Force Unwind Tables 2020-05-04 12:08:35 +01:00
asm.rs Add initial asm!() support for hexagon 2020-06-16 08:58:13 -05:00
attributes.rs Generating the coverage map 2020-07-17 11:49:35 -07:00
base.rs Generating the coverage map 2020-07-17 11:49:35 -07:00
build.rs Remove licenses 2018-12-25 21:08:33 -07:00
builder.rs Generating the coverage map 2020-07-17 11:49:35 -07:00
callee.rs Change SymbolName::name to a &str. 2020-07-15 14:37:55 +10:00
Cargo.toml Make things build again 2020-06-02 20:38:24 +03:00
common.rs Undo the const_str changes from the previous commit. 2020-07-15 14:38:00 +10:00
consts.rs Generating the coverage map 2020-07-17 11:49:35 -07:00
context.rs Undo the const_str changes from the previous commit. 2020-07-15 14:38:00 +10:00
declare.rs rustc -> rustc_middle part 3 (rustfmt) 2020-03-30 07:19:55 +02:00
intrinsic.rs Generating the coverage map 2020-07-17 11:49:35 -07:00
lib.rs Use for<'tcx> fn pointers in Providers, instead of having Providers<'tcx>. 2020-07-05 23:00:14 +03:00
llvm_util.rs Avoid "whitelist" 2020-07-10 07:39:28 -04:00
metadata.rs rustc -> rustc_middle part 2 2020-03-30 07:16:56 +02:00
mono_item.rs fix abuses of tykind::err 2020-04-07 22:47:25 -05:00
README.md Fix broken link in README 2020-03-30 10:09:51 -04:00
type_.rs nix rustc_target::abi::* reexport in ty::layout 2020-04-02 13:40:43 +02:00
type_of.rs Allow calling GeneratorSubsts::variant_name() without substs 2020-06-24 14:53:29 -07:00
va_arg.rs nix rustc_target::abi::* reexport in ty::layout 2020-04-02 13:40:43 +02: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.