Apparently the answer is yes. You have to change the definition of h to see this (because the optimizer is too good! It finds out that h is either an identifier or returns 0).
Consider
int factorial (int x, int y){ if (x==0) return y; else return factorial(x-1,y*x); }
Compiled with clang -S -emit-llvm so that optimization is not performed. It can be seen that direct calls are not specified directly, which means that the default calling convention is sufficient to support tail recursion optimization (regardless of whether it supports tail call at all - this is another story - it would be interesting to know, but I think it really another question).
The file emitted by clang -S -emit-llvm is main.s (assuming the factorial definition is in main.c). If you run
opt -O3 main.s -S -o mainOpt.s
then you can see that tail recursion is eliminated. There is an optimization called tailcallelim that can be turned on as -O3. It's hard to say because the opt --help help file only says that -O3 is similar to gcc -O3.
The fact is that we can see that the call does not need to specify an agreement. Maybe fastcc is not needed, or maybe it is the default? So, (1) partially answered; however, I still do not know (2) or (3).
source share