Unverified Commit 2e11e843 by Enkelmann Committed by GitHub

always enforce expression complexity limit (#428)

parent f82ebc5d
...@@ -233,10 +233,20 @@ pub fn propagate_input_expressions( ...@@ -233,10 +233,20 @@ pub fn propagate_input_expressions(
var, var,
value: expression, value: expression,
} => { } => {
// insert known input expressions // Extend the considered expression with already known expressions.
for (input_var, input_expr) in insertable_expressions.iter() { let mut extended_expression = expression.clone();
expression.substitute_input_var(input_var, input_expr); for input_var in expression.input_vars().into_iter() {
if let Some(expr) = insertable_expressions.get(input_var) {
// We limit the complexity of expressions to insert.
// This prevents extremely large expressions that can lead to extremely high RAM usage.
// FIXME: Right now this limit is quite arbitrary. Maybe there is a better way to achieve the same result?
if expr.recursion_depth() < 10 {
extended_expression.substitute_input_var(input_var, expr)
}
}
} }
extended_expression.substitute_trivial_operations();
*expression = extended_expression;
// expressions dependent on the assigned variable are no longer insertable // expressions dependent on the assigned variable are no longer insertable
insertable_expressions.retain(|input_var, input_expr| { insertable_expressions.retain(|input_var, input_expr| {
input_var != var && !input_expr.input_vars().into_iter().any(|x| x == var) input_var != var && !input_expr.input_vars().into_iter().any(|x| x == var)
......
...@@ -142,11 +142,7 @@ fn inter_block_propagation() { ...@@ -142,11 +142,7 @@ fn inter_block_propagation() {
variable!("X:8"), variable!("X:8"),
expr!("-(42:4)").un_op(UnOpType::BoolNegate), expr!("-(42:4)").un_op(UnOpType::BoolNegate),
), ),
Def::assign( Def::assign("entry_jmp_def_2", variable!("Z:8"), expr!("42:4"),)
"entry_jmp_def_2",
variable!("Z:8"),
expr!("-(42:4)").un_op(UnOpType::IntNegate),
)
] ]
) )
} }
...@@ -290,11 +286,7 @@ fn expressions_inserted() { ...@@ -290,11 +286,7 @@ fn expressions_inserted() {
variable!("X:8"), variable!("X:8"),
expr!("-(42:4)").un_op(UnOpType::BoolNegate), expr!("-(42:4)").un_op(UnOpType::BoolNegate),
), ),
Def::assign( Def::assign("entry_jmp_def_2", variable!("Z:8"), expr!("42:4"))
"entry_jmp_def_2",
variable!("Z:8"),
expr!("-(42:4)").un_op(UnOpType::IntNegate)
)
] ]
); );
assert_eq!( assert_eq!(
......
...@@ -165,7 +165,7 @@ public class ParseCspecContent { ...@@ -165,7 +165,7 @@ public class ParseCspecContent {
String languageId = program.getLanguageID().toString(); String languageId = program.getLanguageID().toString();
if (processorDef.startsWith("AARCH64") && languageId.endsWith("AppleSilicon")) { if (processorDef.startsWith("AARCH64") && languageId.endsWith("AppleSilicon")) {
processorDef = "AppleSilicon.ldef"; processorDef = "AppleSilicon.ldefs";
} }
if(processorDef.startsWith("MIPS") || processorDef.startsWith("AVR")) { if(processorDef.startsWith("MIPS") || processorDef.startsWith("AVR")) {
processorDef = processorDef.toLowerCase(); processorDef = processorDef.toLowerCase();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment