Skip to content
Snippets Groups Projects

Fix DC param ID identfication

Merged rarbore2 requested to merge paper_stuff2 into main
7 files
+ 138
34
Compare changes
  • Side-by-side
  • Inline
Files
7
+ 14
21
@@ -24,21 +24,19 @@ pub fn inline(editors: &mut [FunctionEditor], callgraph: &CallGraph) {
.map(|editor| collapse_returns(editor))
.collect();
// Step 3: verify that each possible dynamic constant parameter index has a
// single unique dynamic constant ID. If this isn't true, dynamic constant
// substitution won't work, and this should be true anyway!
let mut found_idxs = HashMap::new();
for id in editors[0].dynamic_constant_ids() {
let dc = editors[0].get_dynamic_constant(id);
if let DynamicConstant::Parameter(idx) = *dc {
assert!(!found_idxs.contains_key(&idx));
found_idxs.insert(idx, id);
}
}
let mut dc_param_idx_to_dc_id = vec![];
for idx in 0..found_idxs.len() {
dc_param_idx_to_dc_id.push(found_idxs[&idx]);
}
// Step 3: get dynamic constant IDs for parameters.
let max_num_dc_params = editors
.iter()
.map(|editor| editor.func().num_dynamic_constants)
.max()
.unwrap();
let mut dc_args = vec![];
editors[0].edit(|mut edit| {
dc_args = (0..max_num_dc_params as usize)
.map(|i| edit.add_dynamic_constant(DynamicConstant::Parameter(i)))
.collect();
Ok(edit)
});
// Step 4: run inlining on each function individually. Iterate the functions
// in topological order.
@@ -49,12 +47,7 @@ pub fn inline(editors: &mut [FunctionEditor], callgraph: &CallGraph) {
// 2. Shared references to all of the functions called by that function.
let callees = callgraph.get_callees(to_inline_id);
let editor_refs = get_mut_and_immuts(editors, to_inline_id, callees);
inline_func(
editor_refs.0,
editor_refs.1,
&single_return_nodes,
&dc_param_idx_to_dc_id,
);
inline_func(editor_refs.0, editor_refs.1, &single_return_nodes, &dc_args);
}
}
Loading