fn count_called_functions(loader: &Loader) {
    let unsafe_block_calls;
    datapond_query! {
        load loader {
            relations(unsafe_terminators, terminators_call),
        }
        output unsafe_block_calls(
            build: Build, block: BasicBlock, unsafe_scope: Scope,
            check_mode: BlockCheckMode, call: FunctionCall,
            unsafety: Unsafety, abi: Abi, return_ty: Type)
        unsafe_block_calls(
            build, block, unsafe_scope, check_mode, call, unsafety, abi, return_ty
        ) :-
            unsafe_terminators(
                .build=build, .block=block, .unsafe_scope=unsafe_scope,
                .check_mode=check_mode),
            terminators_call(
                .block=block, .call=call, .unsafety=unsafety,
                .abi=abi, .return_ty=return_ty).
    }
    let unsafe_block_calls_relation = unsafe_block_calls.elements;
    info!(
        "Number of calls in unsafe blocks: {}",
        unsafe_block_calls_relation.len()
    );

    let unsafe_block_call_counts_relation: Vec<_> = unsafe_block_calls_relation
        .iter()
        .safe_group_by(
            |&&(build, _block, unsafe_scope, check_mode, _call, _unsafety, _abi, _return_ty)| {
                (build, unsafe_scope, check_mode)
            },
        )
        .into_iter()
        .map(|((build, unsafe_scope, check_mode), group)| {
            (
                build,
                unsafe_scope,
                check_mode,
                group.count().try_into().unwrap(),
            )
        })
        .collect();
    info!(
        "Number of unsafe blocks with calls: {}",
        unsafe_block_call_counts_relation.len()
    );

    let blocks_with_calls: HashSet<_> = unsafe_block_call_counts_relation
        .iter()
        .map(|&(_build, unsafe_scope, _check_mode, _call_count)| unsafe_scope)
        .collect();

    let unsafe_block_no_calls_relation: Vec<_> = loader
        .load_unsafe_blocks()
        .iter()
        .filter(
            |(_build, _mir_body_def_path, scope, _expansion_kind, _check_mode, _span)| {
                !blocks_with_calls.contains(scope)
            },
        )
        .cloned()
        .collect();
    info!(
        "Number of unsafe blocks with non-const calls: {}",
        unsafe_block_no_calls_relation.len()
    );

    loader.store_unsafe_block_calls(unsafe_block_calls_relation);
    loader.store_unsafe_block_call_counts(unsafe_block_call_counts_relation);
    loader.store_unsafe_block_no_calls(unsafe_block_no_calls_relation);
}
/// Count how many functions are called from each unsafe block.
Count how many functions are called from each unsafe block.
Count how many functions are called from each unsafe block .
fn count_called_functions(loader: &Loader) {
    let unsafe_block_calls;
    datapond_query! {
        load loader {
            relations(unsafe_terminators, terminators_call),
        }
        output unsafe_block_calls(
            build: Build, block: BasicBlock, unsafe_scope: Scope,
            check_mode: BlockCheckMode, call: FunctionCall,
            unsafety: Unsafety, abi: Abi, return_ty: Type)
        unsafe_block_calls(
            build, block, unsafe_scope, check_mode, call, unsafety, abi, return_ty
        ) :-
            unsafe_terminators(
                .build=build, .block=block, .unsafe_scope=unsafe_scope,
                .check_mode=check_mode),
            terminators_call(
                .block=block, .call=call, .unsafety=unsafety,
                .abi=abi, .return_ty=return_ty).
    }
    let unsafe_block_calls_relation = unsafe_block_calls.elements;
    info!(
        "Number of calls in unsafe blocks: {}",
        unsafe_block_calls_relation.len()
    );
    let unsafe_block_call_counts_relation: Vec<_> = unsafe_block_calls_relation
        .iter()
        .safe_group_by(
            |&&(build, _block, unsafe_scope, check_mode, _call, _unsafety, _abi, _return_ty)| {
                (build, unsafe_scope, check_mode)
            },
        )
        .into_iter()
        .map(|((build, unsafe_scope, check_mode), group)| {
            (
                build,
                unsafe_scope,
                check_mode,
                group.count().try_into().unwrap(),
            )
        })
        .collect();
    info!(
        "Number of unsafe blocks with calls: {}",
        unsafe_block_call_counts_relation.len()
    );
    let blocks_with_calls: HashSet<_> = unsafe_block_call_counts_relation
        .iter()
        .map(|&(_build, unsafe_scope, _check_mode, _call_count)| unsafe_scope)
        .collect();
    let unsafe_block_no_calls_relation: Vec<_> = loader
        .load_unsafe_blocks()
        .iter()
        .filter(
            |(_build, _mir_body_def_path, scope, _expansion_kind, _check_mode, _span)| {
                !blocks_with_calls.contains(scope)
            },
        )
        .cloned()
        .collect();
    info!(
        "Number of unsafe blocks with non-const calls: {}",
        unsafe_block_no_calls_relation.len()
    );
    loader.store_unsafe_block_calls(unsafe_block_calls_relation);
    loader.store_unsafe_block_call_counts(unsafe_block_call_counts_relation);
    loader.store_unsafe_block_no_calls(unsafe_block_no_calls_relation);
}
fn count_called_functions ( loader : & Loader ) { let unsafe_block_calls ; datapond_query ! { load loader { relations ( unsafe_terminators terminators_call ) } output unsafe_block_calls ( build Build block BasicBlock unsafe_scope Scope check_mode BlockCheckMode call FunctionCall unsafety Unsafety abi Abi return_ty Type ) unsafe_block_calls ( build block unsafe_scope check_mode call unsafety abi return_ty ) unsafe_terminators ( build build block block unsafe_scope unsafe_scope check_mode check_mode ) terminators_call ( block block call call unsafety unsafety abi abi return_ty return_ty ) } let unsafe_block_calls_relation = unsafe_block_calls . elements ; info ! ( " " unsafe_block_calls_relation len ( ) ) ; let unsafe_block_call_counts_relation : Vec < _ > = unsafe_block_calls_relation . iter ( ) . safe_group_by ( | & & ( build , _block , unsafe_scope , check_mode , _call , _unsafety , _abi , _return_ty ) | { ( build , unsafe_scope , check_mode ) } , ) . into_iter ( ) . map ( | ( ( build , unsafe_scope , check_mode ) , group ) | { ( build , unsafe_scope , check_mode , group . count ( ) . try_into ( ) . unwrap ( ) , ) } ) . collect ( ) ; info ! ( " " unsafe_block_call_counts_relation len ( ) ) ; let blocks_with_calls : HashSet < _ > = unsafe_block_call_counts_relation . iter ( ) . map ( | & ( _build , unsafe_scope , _check_mode , _call_count ) | unsafe_scope ) . collect ( ) ; let unsafe_block_no_calls_relation : Vec < _ > = loader . load_unsafe_blocks ( ) . iter ( ) . filter ( | ( _build , _mir_body_def_path , scope , _expansion_kind , _check_mode , _span ) | { ! blocks_with_calls . contains ( scope ) } , ) . cloned ( ) . collect ( ) ; info ! ( " " unsafe_block_no_calls_relation len ( ) ) ; loader . store_unsafe_block_calls ( unsafe_block_calls_relation ) ; loader . store_unsafe_block_call_counts ( unsafe_block_call_counts_relation ) ; loader . store_unsafe_block_no_calls ( unsafe_block_no_calls_relation ) ; }
Count how many functions are called from each unsafe block.
Count how many functions are called from each unsafe block .
loader
&Loader