changeset 22:d0228214ed38

minor fix : Check a function pointer whether it's null pointer or not before check its type.
author Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
date Wed, 23 Oct 2013 10:38:31 +0900
parents fc4a6333556f
children 7694d90773c7
files lib/Transforms/Scalar/SROA.cpp lib/Transforms/Scalar/TailRecursionElimination.cpp
diffstat 2 files changed, 12 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/lib/Transforms/Scalar/SROA.cpp	Mon Oct 14 19:09:00 2013 +0900
+++ b/lib/Transforms/Scalar/SROA.cpp	Wed Oct 23 10:38:31 2013 +0900
@@ -3743,9 +3743,12 @@
     bool contains__Code = false;
     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))
-	  if (CI->getCalledFunction()->getReturnType()->is__CodeTy())
-	    contains__Code = true;
+        if (CallInst *CI = dyn_cast<CallInst>(I)){
+	  Function* CalledFunction = CI->getCalledFunction();
+	  if (CalledFunction != NULL) 
+	    if (CalledFunction->getReturnType()->is__CodeTy())
+	      contains__Code = true;
+	}
     if (!contains__Code)
       return false; // if the function doesn't contains __code , we have not to touch it. 
   }
--- a/lib/Transforms/Scalar/TailRecursionElimination.cpp	Mon Oct 14 19:09:00 2013 +0900
+++ b/lib/Transforms/Scalar/TailRecursionElimination.cpp	Wed Oct 23 10:38:31 2013 +0900
@@ -201,10 +201,12 @@
     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)) {
-	  if (CI->getCalledFunction()->getReturnType()->is__CodeTy()) {
-	    CI->setTailCall();
-	    MadeChange = true;
-	  }
+	  Function* CalledFunction = CI->getCalledFunction();
+	  if (CalledFunction != NULL) 
+	    if (CalledFunction->getReturnType()->is__CodeTy()){
+	      CI->setTailCall();
+	      MadeChange = true;
+	    }
         }
 #endif