May 2015
Intermediate to advanced
296 pages
5h 10m
English
In this recipe, we will see how sibling call optimization works in LLVM. Sibling call optimization can be looked at as an optimized tail call, the only constraint being that the functions should share a similar function signature, that is, matching return types and matching function arguments.
Write a test case for sibling call optimization, making sure that the caller and callee have the same calling conventions (in either C or fastcc), and that the call in the tail position is a tail call:
$ cat sibcall.ll declare i32 @bar(i32, i32) define i32 @foo(i32 %a, i32 %b, i32 %c) { entry: %0 = tail call i32 @bar(i32 %a, i32 %b) ret i32 %0 }
llc tool to generate the assembly:
$ llc sibcall.ll ...Read now
Unlock full access