Skip to content

Commit 5cdd662

Browse files
committed
make inlining tests more robusts to lowering changes
In particular, JuliaLang/julia#51970 which adds more nodes in lowered ir.
1 parent d7d8c2a commit 5cdd662

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

test/ir.jl

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,12 @@ end
4242
let
4343
ir1 = @code_ir foo(1, 2)
4444
ir2 = @code_ir bar(1, 2)
45-
ir = IRTools.inline(ir1, IRTools.var(4), ir2)
45+
inline_at = findfirst(ir1) do (_, stmt)
46+
IRTools.isexpr(stmt.expr, :call) &&
47+
stmt.expr.args[1] == GlobalRef(@__MODULE__, :bar)
48+
end
49+
@test inline_at !== nothing
50+
ir = IRTools.inline(ir1, inline_at, ir2)
4651
f = IRTools.func(ir)
4752
@test f(nothing, 2, 3) == 3
4853
@test f(nothing, 3, 2) == 3
@@ -66,7 +71,12 @@ end
6671
let
6772
ir = @code_ir foo2(1)
6873
ir2 = @code_ir foo1(1)
69-
ir3 = IRTools.inline(ir, IRTools.var(4), ir2)
74+
inline_at = findfirst(ir) do (_, stmt)
75+
IRTools.isexpr(stmt.expr, :call) &&
76+
stmt.expr.args[1] == GlobalRef(@__MODULE__, :foo1)
77+
end
78+
@test inline_at !== nothing
79+
ir3 = IRTools.inline(ir, inline_at, ir2)
7080
@test IRTools.func(ir3)(nothing, 2) == 12
7181
@test IRTools.func(ir3)(nothing, 101) == 101
7282
end
@@ -87,7 +97,12 @@ end
8797
let
8898
ir = @code_ir foo2(1)
8999
ir2 = @code_ir foo1(1)
90-
ir3 = IRTools.inline(ir, IRTools.var(3), ir2)
100+
inline_at = findfirst(ir) do (_, stmt)
101+
IRTools.isexpr(stmt.expr, :call) &&
102+
stmt.expr.args[1] == GlobalRef(@__MODULE__, :foo1)
103+
end
104+
@test inline_at !== nothing
105+
ir3 = IRTools.inline(ir, inline_at, ir2)
91106
@test IRTools.func(ir3)(nothing, 2) == foo2(2)
92107
@test IRTools.func(ir3)(nothing, -2) == foo2(-2)
93108
end

0 commit comments

Comments
 (0)