From 5cdd66233725b6035767a9f537e5932e4946b222 Mon Sep 17 00:00:00 2001 From: Paul Berg Date: Mon, 11 Dec 2023 11:44:02 +0100 Subject: [PATCH] make inlining tests more robusts to lowering changes In particular, https://github.com/JuliaLang/julia/pull/51970/ which adds more nodes in lowered ir. --- test/ir.jl | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/test/ir.jl b/test/ir.jl index f715125..f436b13 100644 --- a/test/ir.jl +++ b/test/ir.jl @@ -42,7 +42,12 @@ end let ir1 = @code_ir foo(1, 2) ir2 = @code_ir bar(1, 2) - ir = IRTools.inline(ir1, IRTools.var(4), ir2) + inline_at = findfirst(ir1) do (_, stmt) + IRTools.isexpr(stmt.expr, :call) && + stmt.expr.args[1] == GlobalRef(@__MODULE__, :bar) + end + @test inline_at !== nothing + ir = IRTools.inline(ir1, inline_at, ir2) f = IRTools.func(ir) @test f(nothing, 2, 3) == 3 @test f(nothing, 3, 2) == 3 @@ -66,7 +71,12 @@ end let ir = @code_ir foo2(1) ir2 = @code_ir foo1(1) - ir3 = IRTools.inline(ir, IRTools.var(4), ir2) + inline_at = findfirst(ir) do (_, stmt) + IRTools.isexpr(stmt.expr, :call) && + stmt.expr.args[1] == GlobalRef(@__MODULE__, :foo1) + end + @test inline_at !== nothing + ir3 = IRTools.inline(ir, inline_at, ir2) @test IRTools.func(ir3)(nothing, 2) == 12 @test IRTools.func(ir3)(nothing, 101) == 101 end @@ -87,7 +97,12 @@ end let ir = @code_ir foo2(1) ir2 = @code_ir foo1(1) - ir3 = IRTools.inline(ir, IRTools.var(3), ir2) + inline_at = findfirst(ir) do (_, stmt) + IRTools.isexpr(stmt.expr, :call) && + stmt.expr.args[1] == GlobalRef(@__MODULE__, :foo1) + end + @test inline_at !== nothing + ir3 = IRTools.inline(ir, inline_at, ir2) @test IRTools.func(ir3)(nothing, 2) == foo2(2) @test IRTools.func(ir3)(nothing, -2) == foo2(-2) end