# HG changeset patch # User Kaito Tokumori # Date 1382492311 -32400 # Node ID d0228214ed387e6190bf0f11860a5aa469ce22b7 # Parent fc4a6333556f114e5bc0f9beaf115fb77c593230 minor fix : Check a function pointer whether it's null pointer or not before check its type. diff -r fc4a6333556f -r d0228214ed38 lib/Transforms/Scalar/SROA.cpp --- 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(I)) - if (CI->getCalledFunction()->getReturnType()->is__CodeTy()) - contains__Code = true; + if (CallInst *CI = dyn_cast(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. } diff -r fc4a6333556f -r d0228214ed38 lib/Transforms/Scalar/TailRecursionElimination.cpp --- 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(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