@@ -391,13 +391,13 @@ impl AnalysisResultT for EscapedSymbols {}
391
391
392
392
pub fn compute_escaped_symbols_pass (
393
393
context : & Context ,
394
- _ : & AnalysisResults ,
394
+ _analyses : & AnalysisResults ,
395
395
function : Function ,
396
396
) -> Result < AnalysisResult , IrError > {
397
397
Ok ( Box :: new ( compute_escaped_symbols ( context, & function) ) )
398
398
}
399
399
400
- pub fn compute_escaped_symbols ( context : & Context , function : & Function ) -> EscapedSymbols {
400
+ fn compute_escaped_symbols ( context : & Context , function : & Function ) -> EscapedSymbols {
401
401
let add_from_val = |result : & mut FxHashSet < Symbol > , val : & Value , is_complete : & mut bool | {
402
402
let ( complete, syms) = get_referred_symbols ( context, * val) . consume ( ) ;
403
403
@@ -422,9 +422,14 @@ pub fn compute_escaped_symbols(context: &Context, function: &Function) -> Escape
422
422
InstOp :: BinaryOp { .. } => ( ) ,
423
423
InstOp :: BitCast ( _, _) => ( ) ,
424
424
InstOp :: Branch ( _) => ( ) ,
425
- InstOp :: Call ( _ , args) => args
425
+ InstOp :: Call ( callee , args) => args
426
426
. iter ( )
427
- . for_each ( |v| add_from_val ( & mut result, v, & mut is_complete) ) ,
427
+ . enumerate ( )
428
+ . filter ( |( arg_idx, _arg) | {
429
+ // Immutable arguments are not considered as escaping symbols.
430
+ !callee. is_arg_immutable ( context, * arg_idx)
431
+ } )
432
+ . for_each ( |( _, v) | add_from_val ( & mut result, v, & mut is_complete) ) ,
428
433
InstOp :: CastPtr ( ptr, _) => add_from_val ( & mut result, ptr, & mut is_complete) ,
429
434
InstOp :: Cmp ( _, _, _) => ( ) ,
430
435
InstOp :: ConditionalBranch { .. } => ( ) ,
0 commit comments