@@ -517,72 +517,6 @@ function compute_trycatch(code::Vector{Any}, bbs::Union{Vector{BasicBlock},Nothi
517517    return  handler_info
518518end 
519519
520- function  is_throw_call (e:: Expr , code:: Vector{Any} )
521-     if  e. head ===  :call 
522-         f =  e. args[1 ]
523-         if  isa (f, SSAValue)
524-             f =  code[f. id]
525-         end 
526-         if  isa (f, GlobalRef)
527-             ff =  abstract_eval_globalref_type (f)
528-             if  isa (ff, Const) &&  ff. val ===  Core. throw
529-                 return  true 
530-             end 
531-         end 
532-     end 
533-     return  false 
534- end 
535- 
536- function  mark_throw_blocks! (src:: CodeInfo , handler_info:: Union{Nothing,HandlerInfo} )
537-     for  stmt in  find_throw_blocks (src. code, handler_info)
538-         src. ssaflags[stmt] |=  IR_FLAG_THROW_BLOCK
539-     end 
540-     return  nothing 
541- end 
542- 
543- #  this utility function is incomplete and won't catch every block that always throws, since:
544- #  - it only recognizes direct calls to `throw` within the target code, so it can't mark
545- #    blocks that deterministically call `throw` internally, like those containing `error`.
546- #  - it just does a reverse linear traverse of statements, there's a chance it might miss
547- #    blocks, particularly when there are reverse control edges.
548- function  find_throw_blocks (code:: Vector{Any} , handler_info:: Union{Nothing,HandlerInfo} )
549-     stmts =  BitSet ()
550-     n =  length (code)
551-     for  i in  n: - 1 : 1 
552-         s =  code[i]
553-         if  isa (s, Expr)
554-             if  s. head ===  :gotoifnot 
555-                 if  i+ 1  in  stmts &&  s. args[2 ]:: Int  in  stmts
556-                     push! (stmts, i)
557-                 end 
558-             elseif  s. head ===  :return 
559-                 #  see `ReturnNode` handling
560-             elseif  is_throw_call (s, code)
561-                 if  handler_info ===  nothing  ||  handler_info. handler_at[i][1 ] ==  0 
562-                     push! (stmts, i)
563-                 end 
564-             elseif  i+ 1  in  stmts
565-                 push! (stmts, i)
566-             end 
567-         elseif  isa (s, ReturnNode)
568-             #  NOTE: it potentially makes sense to treat unreachable nodes
569-             #  (where !isdefined(s, :val)) as `throw` points, but that can cause
570-             #  worse codegen around the call site (issue #37558)
571-         elseif  isa (s, GotoNode)
572-             if  s. label in  stmts
573-                 push! (stmts, i)
574-             end 
575-         elseif  isa (s, GotoIfNot)
576-             if  i+ 1  in  stmts &&  s. dest in  stmts
577-                 push! (stmts, i)
578-             end 
579-         elseif  i+ 1  in  stmts
580-             push! (stmts, i)
581-         end 
582-     end 
583-     return  stmts
584- end 
585- 
586520#  check if coverage mode is enabled
587521function  should_insert_coverage (mod:: Module , debuginfo:: DebugInfo )
588522    coverage_enabled (mod) &&  return  true 
0 commit comments