FluxML / IRTools.jl

Mike's Little Intermediate Representation
MIT License
111 stars 35 forks source link

fix ssa conversion for catch blocks #117

Closed Pangoraw closed 8 months ago

Pangoraw commented 9 months ago

the slotused function was not enough to account for all slot used by the catch block and its successors. With this change, ssa conversion keeps a live list of all catch 'branch' instructions and fetches the reaching definitions for slots at the location of these :catch instructions.

See as an example the added test where the ir is:

function f_try_catch(x)
    y = 0.
    try
        y = sqrt(x)
    catch

    end
    y
end
# Before (catch branches have no args since slotused(block(ir,2)) is empty)
#
# 1: (%1, %2)
#   %3 = try #2
#   %4 = catch 2
#   %5 = Main.sqrt(%2)
#   %6 = catch 2
#   %7 = end try
#   br 3 (%5)
# 2: (%8)
#   %9 = end try
#   %10 = pop exception %3
#   br 3 (%8)
# 3: (%11)
#   return %11
#
# After (catch branches have args corresponding to the reaching definition of y)
#
# 1: (%1, %2)
#   %3 = try #2
#   %4 = catch 2 (0.0)
#   %5 = Main.sqrt(%2)
#   %6 = catch 2 (%5)
#   %7 = end try
#   br 3 (%5)
# 2: (%8)
#   %9 = end try
#   %10 = pop exception %3
#   br 3 (%8)
# 3: (%11)
#   return %11
codecov-commenter commented 9 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (55c315a) 73.29% compared to head (f728dc8) 73.61%.

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #117 +/- ## ========================================== + Coverage 73.29% 73.61% +0.31% ========================================== Files 16 16 Lines 1494 1512 +18 ========================================== + Hits 1095 1113 +18 Misses 399 399 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.