Commit ac0161a
authored
optimizer: don't insert
As an application of JuliaLang#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 = φ (mmtk#2 => x, #1 => #undef)::Int64
│ %4 = φ (mmtk#2 => true, #1 => false)::Bool
└── goto mmtk#5 if not %4
-4 ─ $(Expr(:throw_undef_if_not, :val, :(%4)))::Any
-└── return %3
+4 ─ return %3
5 ─ return 0
) => Int64
```:throw_undef_if_not for defined slots (JuliaLang#55600)1 parent 950a87f commit ac0161a
2 files changed
+12
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
91 | 94 | | |
92 | 95 | | |
93 | 96 | | |
| |||
153 | 156 | | |
154 | 157 | | |
155 | 158 | | |
156 | | - | |
| 159 | + | |
157 | 160 | | |
158 | 161 | | |
159 | 162 | | |
160 | 163 | | |
161 | | - | |
| 164 | + | |
162 | 165 | | |
163 | 166 | | |
164 | 167 | | |
| |||
656 | 659 | | |
657 | 660 | | |
658 | 661 | | |
659 | | - | |
| 662 | + | |
660 | 663 | | |
661 | 664 | | |
662 | 665 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6051 | 6051 | | |
6052 | 6052 | | |
6053 | 6053 | | |
6054 | | - | |
| 6054 | + | |
6055 | 6055 | | |
6056 | 6056 | | |
6057 | 6057 | | |
| |||
6060 | 6060 | | |
6061 | 6061 | | |
6062 | 6062 | | |
6063 | | - | |
| 6063 | + | |
| 6064 | + | |
| 6065 | + | |
| 6066 | + | |
| 6067 | + | |
6064 | 6068 | | |
6065 | 6069 | | |
6066 | 6070 | | |
| |||
0 commit comments