[llvm-dev] How to understand "tail" call?
Peng Yu via llvm-dev
llvm-dev at lists.llvm.org
Wed Feb 6 10:04:12 PST 2019
Hi,
%1 = tail call i32 (i8*, ...) @printf(i8* getelementptr inbounds
([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 10)
%2 = tail call i32 (i8*, ...) @printf(i8* getelementptr inbounds
([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 10)
When I use -O2 to compile the following C code, I will get the above
IR code. I don't understand the explanation of tail-call-optimization
in the langref. Could anybody help me understand what tail call means?
Thanks.
https://llvm.org/docs/CodeGenerator.html#tail-call-optimization
#include <stdio.h>
int main(void) {
const int local = 10;
int *ptr = (int*) &local;
printf("Initial value of local : %d \n", local);
*ptr = 100;
printf("Modified value of local: %d \n", local);
return 0;
}
--
Regards,
Peng
More information about the llvm-dev
mailing list