changeset 26:d84031a0fa3c

bug fix : removed the error that TCE doesn't work if the function isn't a code segment. (It's due to incorrect if statement)
author Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
date Tue, 12 Nov 2013 18:45:31 +0900
parents 8198410b6780
children ecf2394747e1
files lib/Transforms/Scalar/TailRecursionElimination.cpp
diffstat 1 files changed, 7 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/lib/Transforms/Scalar/TailRecursionElimination.cpp	Tue Nov 12 18:03:08 2013 +0900
+++ b/lib/Transforms/Scalar/TailRecursionElimination.cpp	Tue Nov 12 18:45:31 2013 +0900
@@ -251,15 +251,14 @@
       for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I)
         if (CallInst *CI = dyn_cast<CallInst>(I)) {
 #ifndef noCbC
-	  Function* CalledFunction = CI->getCalledFunction();
-	  if (CalledFunction != NULL) 
-	    if (CI->getCalledFunction()->getReturnType()->is__CodeTy() || !isOnlyForCbC()) {
+	  if (isOnlyForCbC()){
+	    Function* CalledFunction = CI->getCalledFunction();
+	    if (CalledFunction == NULL || !CalledFunction->getReturnType()->is__CodeTy())
+	      continue;
+	  }
 #endif
-	      CI->setTailCall();
-	      MadeChange = true;
-#ifndef noCbC
-	    }
-#endif
+	  CI->setTailCall();
+	  MadeChange = true;
 	}
   return MadeChange;
 }