dtolnay / cargo-llvm-lines

Count lines of LLVM IR per generic function
Apache License 2.0
408 stars 24 forks source link

Option to show the type parameters of every instantiation of a function #7

Open dtolnay opened 6 years ago

dtolnay commented 6 years ago

Basically this. For example the instantiations of HashMap::insert could be:

HashMap<(alloc::string::String, usize), alloc::rc::Rc<core::cell::RefCell<mir::node::MirNode>>>
HashMap<(dataflow::domain::Index, usize), (dataflow::statistics::DomainStats, std::collections::hash::map::HashMap<petgraph::graph_impl::NodeIndex<u32>, dataflow::statistics::NodeStats>)>
HashMap<(dataflow::domain::Index, usize), usize, core::hash::BuildHasherDefault<fnv::FnvHasher>>
HashMap<(petgraph::graph_impl::NodeIndex<u32>, petgraph::graph_impl::NodeIndex<u32>), petgraph::graph_impl::NodeIndex<u32>>
HashMap<alloc::string::String, ()>
HashMap<alloc::string::String, controller::sql::query_graph::QueryGraphNode>
HashMap<alloc::string::String, petgraph::graph_impl::NodeIndex<u32>>
HashMap<alloc::string::String, usize>
HashMap<alloc::vec::Vec<usize>, ()>
HashMap<core::any::TypeId, alloc::boxed::Box<hyper::header::Header>>
HashMap<core::any::TypeId, alloc::boxed::Box<hyper::header::HeaderFormat>>
HashMap<dataflow::domain::Index, ()>
HashMap<dataflow::domain::Index, i64>
HashMap<nom_sql::column::Column, ()>
HashMap<petgraph::graph_impl::NodeIndex<u32>, ()>
HashMap<petgraph::graph_impl::NodeIndex<u32>, (alloc::vec::Vec<usize>, bool)>
HashMap<petgraph::graph_impl::NodeIndex<u32>, alloc::vec::Vec<core::addressing::LocalNodeIndex>>
HashMap<petgraph::graph_impl::NodeIndex<u32>, core::addressing::IndexPair>
HashMap<petgraph::graph_impl::NodeIndex<u32>, dataflow::Sharding>
HashMap<petgraph::graph_impl::NodeIndex<u32>, dataflow::statistics::NodeStats>
HashMap<petgraph::graph_impl::NodeIndex<u32>, usize>
HashMap<u64, (controller::sql::query_graph::QueryGraph, mir::query::MirQuery)>
djc commented 3 years ago

This would be particularly useful for futures, where all await functions actually get listed as std::future::from_generator::GenFuture<T>::poll().

bluss commented 3 years ago

(might be useful to others) Rustc has a flag under -Z to print every item from monomorphization collection: -Z print-mono-items=lazy

matklad commented 3 years ago

I think RUSTC_BOOTSTRAP=1 RUSTFLAGS="-Zsymbol-mangling-version=v0" cargo llvm-lines does this, learned from the one who knows everything.

davidhewitt commented 2 years ago

Since Rust 1.59 the above is now RUSTFLAGS="-Csymbol-mangling-version=v0" cargo llvm-lines.