Index: lib/Analysis/InlineCost.cpp =================================================================== --- lib/Analysis/InlineCost.cpp +++ lib/Analysis/InlineCost.cpp @@ -1254,6 +1254,17 @@ return Base::visitCallSite(CS); } + // Check if the callee takes a function pointer argument. If it does, then the + // caller could be passed to the callee, so we should back out. + for (Use &U : CS.getInstruction()->operands()) { + if (CastInst *CI = dyn_cast(U)) { + Type *DestTy = CI->getDestTy(); + if (DestTy->isPointerTy() && + DestTy->getPointerElementType()->isFunctionTy()) + return false; + } + } + // Otherwise we're in a very special case -- an indirect function call. See // if we can be particularly clever about this. Value *Callee = CS.getCalledValue();