cargo-llvm-lines

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:
- Total number of lines of LLVM IR generated across all instantiations of the
function.
- Number of instantiations of the function. For a generic function, roughly the
number of distinct combinations of generic type parameters it is called with.
- 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 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in cargo-llvm-lines by you, as defined in the Apache-2.0 license,
shall be dual licensed as above, without any additional terms or conditions.