diff options
author | Chris Lattner <sabre@nondot.org> | 2005-05-06 05:59:50 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-05-06 05:59:50 +0000 |
commit | 47968e4dfd849b83a7eb958611c994e6b500998c (patch) | |
tree | 085b3cc7e97cbb48d5060e53afc3d613388701e7 /examples | |
parent | ddb6db4fa11d06217d01d8431596131abdfb7ef0 (diff) |
These are legal for tail calls
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21723 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'examples')
-rw-r--r-- | examples/Fibonacci/fibonacci.cpp | 3 | ||||
-rw-r--r-- | examples/HowToUseJIT/HowToUseJIT.cpp | 3 |
2 files changed, 5 insertions, 1 deletions
diff --git a/examples/Fibonacci/fibonacci.cpp b/examples/Fibonacci/fibonacci.cpp index 2bef63bb15..7c24e9e2fc 100644 --- a/examples/Fibonacci/fibonacci.cpp +++ b/examples/Fibonacci/fibonacci.cpp @@ -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, diff --git a/examples/HowToUseJIT/HowToUseJIT.cpp b/examples/HowToUseJIT/HowToUseJIT.cpp index 31ea4f4540..192c76dcce 100644 --- a/examples/HowToUseJIT/HowToUseJIT.cpp +++ b/examples/HowToUseJIT/HowToUseJIT.cpp @@ -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); |