Teach instsimplify to simplify calls to undef.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143719 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/InstructionSimplify.cpp b/lib/Analysis/InstructionSimplify.cpp
index c2ddc6d..c141632 100644
--- a/lib/Analysis/InstructionSimplify.cpp
+++ b/lib/Analysis/InstructionSimplify.cpp
@@ -2474,6 +2474,14 @@
   return ::SimplifyCmpInst(Predicate, LHS, RHS, TD, DT, RecursionLimit);
 }
 
+static Value *SimplifyCallInst(CallInst *CI) {
+  // call undef -> undef
+  if (isa<UndefValue>(CI->getCalledValue()))
+    return UndefValue::get(CI->getType());
+
+  return 0;
+}
+
 /// SimplifyInstruction - See if we can compute a simplified version of this
 /// instruction.  If not, this returns null.
 Value *llvm::SimplifyInstruction(Instruction *I, const TargetData *TD,
@@ -2569,6 +2577,9 @@
   case Instruction::PHI:
     Result = SimplifyPHINode(cast<PHINode>(I), DT);
     break;
+  case Instruction::Call:
+    Result = SimplifyCallInst(cast<CallInst>(I));
+    break;
   }
 
   /// If called on unreachable code, the above logic may report that the