GlobalISel: support 'undef' constant.

llvm-svn: 278174
diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
index ef83630..a5f62cf 100644
--- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
@@ -318,12 +318,14 @@
 }
 
 bool IRTranslator::translate(const Constant &C, unsigned Reg) {
-  if (auto CI = dyn_cast<ConstantInt>(&C)) {
+  if (auto CI = dyn_cast<ConstantInt>(&C))
     EntryBuilder.buildConstant(LLT{*CI->getType()}, Reg, CI->getZExtValue());
-    return true;
-  }
+  else if (isa<UndefValue>(C))
+    EntryBuilder.buildInstr(TargetOpcode::IMPLICIT_DEF).addDef(Reg);
+  else
+    llvm_unreachable("unhandled constant kind");
 
-  llvm_unreachable("unhandled constant kind");
+  return true;
 }