From 71d7b18e3d7e81f707caab1e35d5e211c96a941c Mon Sep 17 00:00:00 2001 From: Ahmed Bougacha Date: Wed, 14 Jan 2015 00:55:05 +0000 Subject: [SimplifyLibCalls] Don't try to simplify indirect calls. It turns out, all callsites of the simplifier are guarded by a check for CallInst::getCalledFunction (i.e., to make sure the callee is direct). This check wasn't done when trying to further optimize a simplified fortified libcall, introduced by a refactoring in r225640. Fix that, add a testcase, and document the requirement. llvm-svn: 225895 --- llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'llvm/lib/Transforms/Utils') diff --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp index fac8bb21e7f..5b4647ddcb5 100644 --- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp @@ -1966,7 +1966,8 @@ Value *LibCallSimplifier::optimizeCall(CallInst *CI) { // Also try to simplify calls to fortified library functions. if (Value *SimplifiedFortifiedCI = FortifiedSimplifier.optimizeCall(CI)) { // Try to further simplify the result. - if (CallInst *SimplifiedCI = dyn_cast(SimplifiedFortifiedCI)) + CallInst *SimplifiedCI = dyn_cast(SimplifiedFortifiedCI); + if (SimplifiedCI && SimplifiedCI->getCalledFunction()) if (Value *V = optimizeStringMemoryLibCall(SimplifiedCI, Builder)) return V; return SimplifiedFortifiedCI; -- cgit v1.2.3