Preserve tail marker
authorChris Lattner <sabre@nondot.org>
Fri, 6 May 2005 06:48:21 +0000 (06:48 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 6 May 2005 06:48:21 +0000 (06:48 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21737 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/InstructionCombining.cpp
lib/Transforms/Utils/LowerAllocations.cpp
lib/Transforms/Utils/LowerInvoke.cpp

index 51141162bfb8c7f9c76a5da268d09db0c673fba0..72b45319c0cffdf347f84d0a9a7bbde104061018 100644 (file)
@@ -4232,6 +4232,8 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
                         Args, Caller->getName(), Caller);
   } else {
     NC = new CallInst(Callee, Args, Caller->getName(), Caller);
+    if (cast<CallInst>(Caller)->isTailCall())
+      cast<CallInst>(NC)->setTailCall();
   }
 
   // Insert a cast of the return type as necessary...
index 71b45fdfeaab54483181bb1f3c5dc27d9c10bfe6..1502fab759a4fdcf4e2235ee71ea04b844a080b7 100644 (file)
@@ -150,6 +150,7 @@ bool LowerAllocations::runOnBasicBlock(BasicBlock &BB) {
 
       // Create the call to Malloc...
       CallInst *MCall = new CallInst(MallocFunc, MallocArgs, "", I);
+      MCall->setTailCall();
 
       // Create a cast instruction to convert to the right type...
       Value *MCast;
@@ -180,7 +181,7 @@ bool LowerAllocations::runOnBasicBlock(BasicBlock &BB) {
        FreeArgs.push_back(Constant::getNullValue(FreeFTy->getParamType(i)));
 
       // Insert a call to the free function...
-      new CallInst(FreeFunc, FreeArgs, "", I);
+      (new CallInst(FreeFunc, FreeArgs, "", I))->setTailCall();
 
       // Delete the old free instruction
       I = --BBIL.erase(I);
index fee18aa77cf7bf2de9d263e55c9c4251d176ee6d..b751bc0d26d41231735d5a8c85c6e0a58022770c 100644 (file)
@@ -195,7 +195,7 @@ void LowerInvoke::writeAbortMessage(Instruction *IB) {
         Args[i] = ConstantExpr::getCast(cast<Constant>(Args[i]),
                                         FT->getParamType(i));
 
-    new CallInst(WriteFn, Args, "", IB);
+    (new CallInst(WriteFn, Args, "", IB))->setTailCall();
   }
 }
 
@@ -225,7 +225,7 @@ bool LowerInvoke::insertCheapEHSupport(Function &F) {
       writeAbortMessage(UI);
 
       // Insert a call to abort()
-      new CallInst(AbortFn, std::vector<Value*>(), "", UI);
+      (new CallInst(AbortFn, std::vector<Value*>(), "", UI))->setTailCall();
 
       // Insert a return instruction.  This really should be a "barrier", as it
       // is unreachable.
@@ -375,7 +375,7 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) {
     writeAbortMessage(RI);
 
     // Insert a call to abort()
-    new CallInst(AbortFn, std::vector<Value*>(), "", RI);
+    (new CallInst(AbortFn, std::vector<Value*>(), "", RI))->setTailCall();
   }
 
   return Changed;