[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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225895 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Ahmed Bougacha
2015-01-14 00:55:05 +00:00
parent 7e73dc4ef9
commit 61d6dc41fa
3 changed files with 17 additions and 1 deletions
+2 -1
View File
@@ -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<CallInst>(SimplifiedFortifiedCI))
CallInst *SimplifiedCI = dyn_cast<CallInst>(SimplifiedFortifiedCI);
if (SimplifiedCI && SimplifiedCI->getCalledFunction())
if (Value *V = optimizeStringMemoryLibCall(SimplifiedCI, Builder))
return V;
return SimplifiedFortifiedCI;