Skip to content

Commit 3466a16

Browse files
authored
ir: Don't fail if :invoke has zero arguments (#58477)
All julia functions always have at least one argument (ignoring toplevel thunks, but those have special representation). However, with ABIOverride it is possible to create zero argument CodeInstances and :invoke them. I'm not entirely sure this is useful, but things do generally seem to go through, so let's not unnecessarily error in the optimizer.
1 parent 4c00176 commit 3466a16

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Compiler/src/ssair/passes.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ end
99
function is_known_invoke_or_call(@nospecialize(x), @nospecialize(func), ir::Union{IRCode,IncrementalCompact})
1010
isinvoke = isexpr(x, :invoke)
1111
(isinvoke || isexpr(x, :call)) || return false
12-
ft = argextype(x.args[isinvoke ? 2 : 1], ir)
12+
narg = isinvoke ? 2 : 1
13+
length(x.args) < narg && return false
14+
ft = argextype(x.args[narg], ir)
1315
return singleton_type(ft) === func
1416
end
1517

0 commit comments

Comments
 (0)