changeset 69:a61c4aaeb4ed

fix tail call bug. enable to set tail call flag to indirect call in TCEoptPass but some codesegments are called by call instruction yet.
author Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
date Thu, 13 Feb 2014 23:05:42 +0900
parents a37375f10d66
children 5c3d43beb4d9
files lib/Transforms/Scalar/TailRecursionElimination.cpp
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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<FunctionType>(CI->getCalledValue()->getType()->getPointerElementType()); // indirect call check.
+		if (PointerAccessedFType == NULL || !PointerAccessedFType->getReturnType()->is__CodeTy()) {
+		  continue;
+		}
+	      }
 	    }
 #endif
             CI->setTailCall();