GlobalISel: prevent heap use-after-free when looking up VReg.

Translating the constant can create more VRegs, which can invalidate the
reference into the DenseMap. So we have to look up the value again after all
that's happened.

llvm-svn: 292675
diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
index 1cfe534..ba6db37 100644
--- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
@@ -81,7 +81,9 @@
       }
     }
   }
-  return ValReg;
+
+  // Look Val up again in case the reference has been invalidated since.
+  return ValToVReg[&Val];
 }
 
 int IRTranslator::getOrCreateFrameIndex(const AllocaInst &AI) {