Skip to content

Commit 426cce6

Browse files
committed
add method for checking const invoke
1 parent 252b958 commit 426cce6

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/CompilerPluginTools.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export
5151
inline_const!,
5252
permute_stmts!,
5353
const_invoke!,
54+
contains_const_invoke!,
5455
finish,
5556
IntrinsicError,
5657
# utils

src/passes.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,3 +202,17 @@ function const_invoke!(f, ir::IRCode, ref::GlobalRef)
202202
end
203203
return ir
204204
end
205+
206+
function contains_const_invoke!(ir::IRCode, ref::GlobalRef)
207+
for i in 1:length(ir.stmts)
208+
stmt = ir.stmts[i][:inst]
209+
210+
@switch stmt begin
211+
@case Expr(:invoke, _, &ref, args...)
212+
all(x->is_arg_allconst(ir, x), args) && return true
213+
@case _
214+
nothing
215+
end
216+
end
217+
return false
218+
end

0 commit comments

Comments
 (0)