Skip to content

Commit

Permalink
Removed all simplifications for -m 1
Browse files Browse the repository at this point in the history
  • Loading branch information
HoseongLee committed Oct 8, 2024
1 parent 1c26f76 commit a6c1254
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/ai/analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ pub fn analyze(

if conf.max_loop_head_states <= 1 {
wbrets.clear();
rcfws.clear();
}

if let Some(n) = &conf.function_times {
Expand Down
58 changes: 44 additions & 14 deletions src/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,9 @@ fn transform(
continue;
}

unsafe { N_REMOVED_CHECKS += 1; }
unsafe {
N_REMOVED_CHECKS += 1;
}

let pos = span.hi() + BytePos(1);
let span = span.with_hi(pos).with_lo(pos);
Expand Down Expand Up @@ -577,7 +579,9 @@ fn transform(
if let Some(spans) = ref_to_spans.get(&param.name) {
for span in spans {
let assign = format!("{}___v", param.name);
unsafe { N_REMOVED_POINTERS += 1; }
unsafe {
N_REMOVED_POINTERS += 1;
}
fix(*span, assign);
}
}
Expand Down Expand Up @@ -653,11 +657,21 @@ fn transform(
});
}

println!("Number of must write before return simplifications : {}", unsafe { N_MUST });
println!("Number of must not write before return simplifications : {}", unsafe { N_MAY });
println!("Number of direct return simplifications : {}", unsafe { N_DIRECT_RETURNS });
println!(
"Number of must write before return simplifications : {}",
unsafe { N_MUST }
);
println!(
"Number of must not write before return simplifications : {}",
unsafe { N_MAY }
);
println!("Number of direct return simplifications : {}", unsafe {
N_DIRECT_RETURNS
});
println!("Number of removed checks: {}", unsafe { N_REMOVED_CHECKS });
println!("Number of removed pointers: {}", unsafe { N_REMOVED_POINTERS });
println!("Number of removed pointers: {}", unsafe {
N_REMOVED_POINTERS
});

suggestions
}
Expand Down Expand Up @@ -822,7 +836,9 @@ impl Func {
let name = lit_map
.and_then(|(n, v)| {
if *n == param.name {
unsafe { N_DIRECT_RETURNS += 1; }
unsafe {
N_DIRECT_RETURNS += 1;
}
Some((*v).clone())
} else {
None
Expand All @@ -831,10 +847,14 @@ impl Func {
.unwrap_or(format!("{}___v", param.name));
let v = if let Some((may, must)) = wbret {
if must.contains(&param.name) {
unsafe { N_MUST += 1; }
unsafe {
N_MUST += 1;
}
format!("Ok({})", name)
} else if !may.contains(&param.name) {
unsafe { N_MAY += 1; }
unsafe {
N_MAY += 1;
}
format!("Err({})", orig)
} else {
format!(
Expand All @@ -857,7 +877,9 @@ impl Func {
let name = lit_map
.and_then(|(n, v)| {
if *n == param.name {
unsafe { N_DIRECT_RETURNS += 1; }
unsafe {
N_DIRECT_RETURNS += 1;
}
Some((*v).clone())
} else {
None
Expand All @@ -868,10 +890,14 @@ impl Func {
name
} else if let Some((may, must)) = wbret {
if must.contains(&param.name) {
unsafe { N_MUST += 1; }
unsafe {
N_MUST += 1;
}
format!("Some ({})", name)
} else if !may.contains(&param.name) {
unsafe { N_MAY += 1; }
unsafe {
N_MAY += 1;
}
"None".to_string()
} else {
format!(
Expand Down Expand Up @@ -1243,12 +1269,16 @@ fn generate_set_flag(
let rcfw = &rcfws.get(arg);
if let Some(rcfw) = rcfw {
if rcfw.iter().any(|sp| span.contains(*sp)) {
unsafe { N_REMOVED_CHECKS += 1; }
unsafe {
N_REMOVED_CHECKS += 1;
}
return "".to_string();
}
}
return format!("{}___s = true;", arg);
}
unsafe { N_REMOVED_CHECKS += 1; }
unsafe {
N_REMOVED_CHECKS += 1;
}
"".to_string()
}

0 comments on commit a6c1254

Please sign in to comment.