changeset 24:9b9640b7b299

bug fix : include error was removed. (It's due to access to a null pointer)
author Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
date Wed, 06 Nov 2013 22:30:04 +0900
parents 7694d90773c7
children 8198410b6780
files lib/Transforms/Scalar/TailRecursionElimination.cpp
diffstat 1 files changed, 6 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/lib/Transforms/Scalar/TailRecursionElimination.cpp	Mon Nov 04 23:30:18 2013 +0900
+++ b/lib/Transforms/Scalar/TailRecursionElimination.cpp	Wed Nov 06 22:30:04 2013 +0900
@@ -196,20 +196,6 @@
   // doesn't).
   bool CannotTCETailMarkedCall = false;
 
-#ifndef noCbC
-  if (!FunctionContainsEscapingAllocas && !F.callsFunctionThatReturnsTwice())
-    for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB)
-      for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I)
-        if (CallInst *CI = dyn_cast<CallInst>(I)) {
-	  Function* CalledFunction = CI->getCalledFunction();
-	  if (CalledFunction != NULL) 
-	    if (CalledFunction->getReturnType()->is__CodeTy()){
-	      CI->setTailCall();
-	      MadeChange = true;
-	    }
-        }
-#endif
-
   // Loop over the function, looking for any returning blocks, and keeping track
   // of whether this function has any non-trivially used allocas.
   for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) {
@@ -265,12 +251,14 @@
       for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I)
         if (CallInst *CI = dyn_cast<CallInst>(I)) {
 #ifndef noCbC
-	  if (CI->getCalledFunction()->getReturnType()->is__CodeTy() || !isOnlyForCbC()) {
+	  Function* CalledFunction = CI->getCalledFunction();
+	  if (CalledFunction != NULL) 
+	    if (CI->getCalledFunction()->getReturnType()->is__CodeTy() || !isOnlyForCbC()) {
 #endif
-	    CI->setTailCall();
-	    MadeChange = true;
+	      CI->setTailCall();
+	      MadeChange = true;
 #ifndef noCbC
-	  }
+	    }
 #endif
 	}
   return MadeChange;