# HG changeset patch # User Kaito Tokumori # Date 1392300342 -32400 # Node ID a61c4aaeb4ed1077c8ec814c8bdd71da4c7368b4 # Parent a37375f10d666f8aec88f9707be847ea0e1ace87 fix tail call bug. enable to set tail call flag to indirect call in TCEoptPass but some codesegments are called by call instruction yet. diff -r a37375f10d66 -r a61c4aaeb4ed lib/Transforms/Scalar/TailRecursionElimination.cpp --- a/lib/Transforms/Scalar/TailRecursionElimination.cpp Wed Feb 12 01:06:33 2014 +0900 +++ b/lib/Transforms/Scalar/TailRecursionElimination.cpp Thu Feb 13 23:05:42 2014 +0900 @@ -270,8 +270,12 @@ #ifndef noCbC if (isOnlyForCbC()){ Function* CalledFunction = CI->getCalledFunction(); - if (CalledFunction == NULL || !CalledFunction->getReturnType()->is__CodeTy()) - continue; + if (CalledFunction == NULL || !CalledFunction->getReturnType()->is__CodeTy()) { // direct call check. + FunctionType* PointerAccessedFType = dyn_cast(CI->getCalledValue()->getType()->getPointerElementType()); // indirect call check. + if (PointerAccessedFType == NULL || !PointerAccessedFType->getReturnType()->is__CodeTy()) { + continue; + } + } } #endif CI->setTailCall();