MCPcopy Create free account
hub / github.com/Rust-GPU/rust-gpu / post_order

Method post_order

crates/rustc_codegen_spirv/src/linker/ipo.rs:63–84  ·  view source on GitHub ↗

Order functions using a post-order traversal, i.e. callees before callers. FIXME(eddyb) replace this with `rustc_data_structures::graph::iterate` (or similar).

(&self)

Source from the content-addressed store, hash-verified

61 // FIXME(eddyb) replace this with `rustc_data_structures::graph::iterate`
62 // (or similar).
63 pub fn post_order(&self) -> Vec<FuncIdx> {
64 let num_funcs = self.callees.len();
65
66 // FIXME(eddyb) use a proper bitset.
67 let mut visited = vec![false; num_funcs];
68 let mut post_order = Vec::with_capacity(num_funcs);
69
70 // Visit the call graph with entry points as roots.
71 for &entry in &self.entry_points {
72 self.post_order_step(entry, &mut visited, &mut post_order);
73 }
74
75 // Also visit any functions that were not reached from entry points
76 // (they might be dead but they should be processed nonetheless).
77 for func in 0..num_funcs {
78 if !visited[func] {
79 self.post_order_step(func, &mut visited, &mut post_order);
80 }
81 }
82
83 post_order
84 }
85
86 fn post_order_step(&self, func: FuncIdx, visited: &mut [bool], post_order: &mut Vec<FuncIdx>) {
87 if visited[func] {

Callers 4

inlineFunction · 0.80
remove_unused_paramsFunction · 0.80
specializeFunction · 0.80

Calls 1

post_order_stepMethod · 0.80

Tested by 1

specializeFunction · 0.64