# HG changeset patch # User Kaito Tokumori # Date 1392311007 -32400 # Node ID 5c3d43beb4d95de3017516808a4af49836dd5ca7 # Parent a61c4aaeb4ed1077c8ec814c8bdd71da4c7368b4 fix tail call bug. If the codesegment is variadic function, we cannot do TCE so we don't add fastcc to that codesegment. It should be treat void function. diff -r a61c4aaeb4ed -r 5c3d43beb4d9 lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp --- a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Thu Feb 13 23:05:42 2014 +0900 +++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Fri Feb 14 02:03:27 2014 +0900 @@ -5440,11 +5440,6 @@ DAG.setRoot(DAG.getEHLabel(getCurSDLoc(), getControlRoot(), BeginLabel)); } -#ifndef noCbC - if (RetTy->is__CodeTy()) // force to set tail call flag if the called function is code segment. - isTailCall = true; -#endif - // Check if target-independent constraints permit a tail call here. // Target-dependent constraints are checked within TLI->LowerCallTo. if (isTailCall && !isInTailCallPosition(CS, *TLI)) @@ -5461,14 +5456,12 @@ #ifndef noCbC // if code segment's tail call flag was changed false , we report it on error. if (CLI.RetTy->is__CodeTy() && CS.getCaller()->getReturnType()->is__CodeTy() && !isTailCall) { - /* - if (CS.getCalledFunction()) // if this call is direct access; ex) goto codesegment(); + if (CS.getCalledFunction()) // if this codesegment call is a direct access; ex) goto codesegment(); DAG.getContext()->emitError(CS.getInstruction(), CS.getCaller()->getName() + " : Tail call elimination was failed on goto " + CS.getCalledFunction()->getName() + " !"); - else if (CS.getCalledValue()->getType()->isPointerTy()) // if the pointer access; ex) goto codesegmentPointer; + else if (CS.getCalledValue()->getType()->isPointerTy()) // if it is a pointer access; ex) goto codesegmentPointer; DAG.getContext()->emitError(CS.getInstruction(), CS.getCaller()->getName() + " : Tail call elimination was failed on codesegment which is accessed by pointer!"); // we can't get name from Type... - */ } #endif if (Result.first.getNode()) { diff -r a61c4aaeb4ed -r 5c3d43beb4d9 lib/Transforms/Scalar/TailRecursionElimination.cpp --- a/lib/Transforms/Scalar/TailRecursionElimination.cpp Thu Feb 13 23:05:42 2014 +0900 +++ b/lib/Transforms/Scalar/TailRecursionElimination.cpp Fri Feb 14 02:03:27 2014 +0900 @@ -271,8 +271,8 @@ if (isOnlyForCbC()){ Function* CalledFunction = CI->getCalledFunction(); 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()) { + FunctionType* PointerAccessedFType = dyn_cast(CI->getCalledValue()->getType()->getPointerElementType()); + if (PointerAccessedFType == NULL || !PointerAccessedFType->getReturnType()->is__CodeTy()) { // indirect call check.