Hi, I have a function expression (as input), and it is greatly simplified by the time it becomes LLVM code.
How can I get the optimized simplified version back as an Expression?
Origin expression:
ex = :(
function ab(bt)
function a(x, y)
t = 5
v = y*y
return x*2
end;
function b(t)
return a(t+1, 0)
end;
b(bt)
end;
)
eval(ex)
MacroTools.prettify(ex)
:(function ab(bt)
function a(x, y)
t = 5
v = y * y
return x * 2
end
function b(t)
return a(t + 1, 0)
end
b(bt)
end)
@code_llvm ab(5)
; @ func_expr_simple.ipynb:2 within `ab`
define i64 @julia_ab_2973(i64 signext %0) #0 {
top:
; @ func_expr_simple.ipynb:14 within `ab`
; ┌ @ func_expr_simple.ipynb:11 within `b`
; │┌ @ func_expr_simple.ipynb:7 within `a`
; ││┌ @ int.jl:88 within `*`
%1 = shl i64 %0, 1
%2 = add i64 %1, 2
; └└└
ret i64 %2
}
How can I get an Expr where the unused variables (y, t, v) are gone, the functions (a, b) are inlined etc?