[opaque pointer type] Explicitly store the pointee type of the result of a GEP
[oota-llvm.git] / lib / Transforms / Utils / ValueMapper.cpp
index 5c1518d72aca011cf5dfeceb5bf41bf5bda8cbcd..8c72641da9e7a7fbb3ce15ce7fe466009868e00a 100644 (file)
@@ -400,5 +400,11 @@ void llvm::RemapInstruction(Instruction *I, ValueToValueMapTy &VMap,
   }
   if (auto *AI = dyn_cast<AllocaInst>(I))
     AI->setAllocatedType(TypeMapper->remapType(AI->getAllocatedType()));
+  if (auto *GEP = dyn_cast<GetElementPtrInst>(I)) {
+    GEP->setSourceElementType(
+        TypeMapper->remapType(GEP->getSourceElementType()));
+    GEP->setResultElementType(
+        TypeMapper->remapType(GEP->getResultElementType()));
+  }
   I->mutateType(TypeMapper->remapType(I->getType()));
 }