You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
optimizer: don't insert :throw_undef_if_not for defined slots (#55600)
As an application of #55545, this commit avoids the
insertion of `:throw_undef_if_not` nodes when the defined-ness of a slot
is guaranteed by abstract interpretation.
```julia
julia> function isdefined_nothrow(c, x)
local val
if c
val = x
end
if @isdefined val
return val
end
return zero(Int)
end;
julia> @code_typed isdefined_nothrow(true, 42)
```
```diff
diff --git a/old b/new
index c4980a5c9c..3d1d6d30f0 100644
--- a/old
+++ b/new
@@ -4,7 +4,6 @@ CodeInfo(
3 ┄ %3 = φ (#2 => x, #1 => #undef)::Int64
│ %4 = φ (#2 => true, #1 => false)::Bool
└── goto #5 if not %4
-4 ─ $(Expr(:throw_undef_if_not, :val, :(%4)))::Any
-└── return %3
+4 ─ return %3
5 ─ return 0
) => Int64
```
0 commit comments