cargo-llvm-lines

Build Status Latest Version

Count the number of lines of LLVM IR across all instantiations of a generic function. Based on a suggestion from @eddyb on how to count monomorphized functions in order to debug compiler memory usage, executable size and compile time.

\ unoptimized LLVM IR
\ first used grep '^define' to get only the lines defining function bodies
\ then regex replace in my editor to remove everything before @ and everything after (
\ then sort | uniq -c

Installation

Install with cargo install cargo-llvm-lines.

Output

One line per function with three columns of output:

  1. Total number of lines of LLVM IR generated across all instantiations of the function.
  2. Number of instantiations of the function. For a generic function, roughly the number of distinct combinations of generic type parameters it is called with.
  3. Name of the function.

``` $ cargo llvm-lines | head -20

2447 130 core::ptr::dropinplace 1720 19 >::map 862 2 core::str::pattern::TwoWaySearcher::next 726 4 >::double 698 4 >::reserve 677 6 >::map 602 1 cargollvmlines::readllvmir 598 5 >::extenddesugared 477 1 cargollvmlines::countlines 476 9 >::deallocbuffer 464 10 alloc::heap::boxfree 452 5 as alloc::vec::SpecExtend>::specextend 448 1 alloc::slice::mergesort 436 1 ::pipeto 419 4 as core::iter::iterator::Iterator>::next 400 1 ::drounds 378 9 >::currentlayout 362 3 >::allocatein 354 4 >::push 341 4 <[T] as core::slice::SliceExt>::iter ```


License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.