(static_constraint: &mut APIConstraints, deopt: &Deopt)
| 97 | } |
| 98 | |
| 99 | pub fn infer(static_constraint: &mut APIConstraints, deopt: &Deopt) -> Result<()> { |
| 100 | log::info!("Dynamically infer the constraints imposed on integral."); |
| 101 | |
| 102 | let mut dyn_constraints: APIConstraints = APIConstraints::new(); |
| 103 | for (func, args) in find_exploitable_func(static_constraint)? { |
| 104 | log::info!("infer constraint for: {func} and args: {args:?}"); |
| 105 | let mut func_constraints = Vec::new(); |
| 106 | let test_programs = find_testbed_program(&func, deopt); |
| 107 | for program in test_programs { |
| 108 | log::info!("infer constraint on program: {program:?}"); |
| 109 | for arg in &args { |
| 110 | let has_constraint = infer_constraint_for_func(&func, *arg, program, deopt)?; |
| 111 | if let Some(constraint) = has_constraint { |
| 112 | log::debug!("Infered! {func}, {constraint:?}"); |
| 113 | func_constraints.push(constraint); |
| 114 | } |
| 115 | } |
| 116 | } |
| 117 | func_constraints = dedup_constraint(func_constraints); |
| 118 | dyn_constraints.insert(func, func_constraints); |
| 119 | } |
| 120 | for (func, cs) in dyn_constraints { |
| 121 | if cs.is_empty() { |
| 122 | continue; |
| 123 | } |
| 124 | if let Some(static_cs) = static_constraint.get_mut(&func) { |
| 125 | static_cs.extend(cs); |
| 126 | } else { |
| 127 | static_constraint.insert(func, cs); |
| 128 | } |
| 129 | } |
| 130 | Ok(()) |
| 131 | } |
| 132 | |
| 133 | pub fn infer_constraint_for_func( |
| 134 | func: &str, |
no test coverage detected