May 2015
Intermediate to advanced
296 pages
5h 10m
English
In this recipe, we will see how tail call optimization is done in LLVM. Tail call optimization is a technique where the callee reuses the stack of the caller instead of adding a new stack frame to the call stack, hence saving stack space and the number of returns when dealing with mutually recursive functions.
We need to make sure of the following:
llc tool must be installed in $PATHtailcallopt option must be enabled$ cat tailcall.ll declare fastcc i32 @tailcallee(i32 inreg %a1, i32 inreg %a2, i32 %a3, i32 %a4) define fastcc i32 @tailcaller(i32 %in1, i32 %in2) { %l1 = add i32 %in1, %in2 %tmp = tail ...
Read now
Unlock full access