mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
These are legal for tail calls
llvm-svn: 21723
This commit is contained in:
parent
72ffd7e7d5
commit
a667732618
@ -65,10 +65,13 @@ static Function *CreateFibFunction(Module *M) {
|
||||
// create fib(x-1)
|
||||
Value *Sub = BinaryOperator::createSub(ArgX, One, "arg", RecurseBB);
|
||||
Value *CallFibX1 = new CallInst(FibF, Sub, "fibx1", RecurseBB);
|
||||
CallFibX1->setTailCall(true);
|
||||
|
||||
// create fib(x-2)
|
||||
Sub = BinaryOperator::createSub(ArgX, Two, "arg", RecurseBB);
|
||||
Value *CallFibX2 = new CallInst(FibF, Sub, "fibx2", RecurseBB);
|
||||
CallFibX2->setTailCall(true);
|
||||
|
||||
|
||||
// fib(x-1)+fib(x-2)
|
||||
Value *Sum = BinaryOperator::createAdd(CallFibX1, CallFibX2,
|
||||
|
@ -87,7 +87,8 @@ int main() {
|
||||
// Pass Ten to the call call:
|
||||
std::vector<Value*> Params;
|
||||
Params.push_back(Ten);
|
||||
CallInst * Add1CallRes = new CallInst(Add1F, Params, "add1", BB);
|
||||
CallInst *Add1CallRes = new CallInst(Add1F, Params, "add1", BB);
|
||||
Add1CallRes->setTailCall(true);
|
||||
|
||||
// Create the return instruction and add it to the basic block.
|
||||
new ReturnInst(Add1CallRes, BB);
|
||||
|
Loading…
Reference in New Issue
Block a user