From 2f947fd6971e284ebc0f38219c1687afa15d73b0 Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Wed, 16 Jul 2025 14:41:31 -0400 Subject: [WARP] Construct a minimal version of the function object when user only wants the symbol We were previously constructing the function type, comments and variables to just throw away, wasting precious cpu cycles! --- plugins/warp/src/lib.rs | 46 ++++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 18 deletions(-) (limited to 'plugins/warp/src/lib.rs') diff --git a/plugins/warp/src/lib.rs b/plugins/warp/src/lib.rs index dd94ada0..bea85cdd 100644 --- a/plugins/warp/src/lib.rs +++ b/plugins/warp/src/lib.rs @@ -105,34 +105,44 @@ pub fn build_variables(func: &BNFunction) -> Vec { variables } +// TODO: Get rid of the minimal bool. pub fn build_function( func: &BNFunction, lifted_il: &LowLevelILFunction, + minimal: bool, ) -> Function { - let comments = func - .comments() - .iter() - .map(|c| bn_comment_to_comment(func, c)) - .collect(); - Function { + let mut function = Function { guid: cached_function_guid(func, lifted_il), symbol: from_bn_symbol(&func.symbol()), - // Currently we only store the type if its a user type. - // TODO: In the future we might want to make this configurable. - ty: match func.has_user_type() || func.has_explicitly_defined_type() { - true => Some(from_bn_type( - &func.view(), - &func.function_type(), - MAX_CONFIDENCE, - )), - false => None, - }, // NOTE: Adding adjacent only works if analysis is complete. // NOTE: We do not filter out adjacent functions here. constraints: cached_constraints(func, |_| true), - comments, - variables: build_variables(func), + ty: None, + comments: vec![], + variables: vec![], + }; + + if minimal { + return function; } + + // Currently we only store the type if its a user type. + // TODO: In the future we might want to make this configurable. + function.ty = match func.has_user_type() || func.has_explicitly_defined_type() { + true => Some(from_bn_type( + &func.view(), + &func.function_type(), + MAX_CONFIDENCE, + )), + false => None, + }; + function.comments = func + .comments() + .iter() + .map(|c| bn_comment_to_comment(func, c)) + .collect(); + function.variables = build_variables(func); + function } /// Basic blocks sorted from high to low. -- cgit v1.3.1