Skip to content
Snippets Groups Projects

More fixes to outline

Merged rarbore2 requested to merge outline_fix_3 into main
3 files
+ 118
26
Compare changes
  • Side-by-side
  • Inline
Files
3
+ 24
22
@@ -228,27 +228,27 @@ pub fn outline(
outlined.nodes.push(Node::Parameter { index });
}
let convert_id = |old| {
if let Some(new) = old_to_new_id.get(&old) {
// Map a use inside the partition to its new ID in the
// outlined function.
*new
} else if let Some(idx) = outside_id_to_param_idx.get(&old) {
// Map a data use outside the partition to the ID of the
// corresponding parameter node.
NodeID::new(idx + 1)
} else {
// Map a control use outside the partition to the start
// node. This corresponds to the outside predecessors of the
// top node and the use of the old start by constant,
// dynamic constant, parameter, and undef nodes.
NodeID::new(0)
}
};
// Add the nodes from the partition.
let mut select_top_phi_inputs = vec![];
for id in partition.iter() {
let convert_id = |old| {
if let Some(new) = old_to_new_id.get(&old) {
// Map a use inside the partition to its new ID in the
// outlined function.
*new
} else if let Some(idx) = outside_id_to_param_idx.get(&old) {
// Map a data use outside the partition to the ID of the
// corresponding parameter node.
NodeID::new(idx + 1)
} else {
// Map a control use outside the partition to the start
// node. This corresponds to the outside predecessors of the
// top node and the use of the old start by constant,
// dynamic constant, parameter, and undef nodes.
NodeID::new(0)
}
};
let mut node = edit.get_node(*id).clone();
if let Node::Phi { control, data } = &mut node
&& *control == top_node
@@ -372,7 +372,7 @@ pub fn outline(
if dom_return_values.contains(inside_id) {
// If this outside used value dominates this return,
// then return the value itself.
*inside_id
convert_id(*inside_id)
} else {
// If not, then return an Undef. Since this value
// doesn't dominate this return, it can't be used on
@@ -408,7 +408,7 @@ pub fn outline(
// Return the return product.
outlined.nodes.push(Node::Return {
control: *exit,
control: convert_id(*exit),
data: construct_id,
});
}
@@ -558,7 +558,7 @@ pub fn outline(
}
/*
* Just outlines all of a function accept the entry and return. Minimum work
* Just outlines all of a function except the entry and return. Minimum work
* needed to cause runtime Rust code to be generated as necessary.
*/
pub fn dumb_outline(
@@ -568,7 +568,9 @@ pub fn dumb_outline(
dom: &DomTree,
to_be_function_id: FunctionID,
) -> Option<Function> {
collapse_returns(editor);
if !contains_between_control_flow(editor.func()) {
return None;
}
let partition = editor
.node_ids()
.filter(|id| {
Loading