Speculatively harden the conversion logic. I have no idea if this will
help the dragonegg builders, and no test case at this point, but this
was one dimly plausible case I spotted by inspection. Hopefully will get
a testcase from those bots soon-ish, and will tidy this up with proper
testing.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165869 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Transforms/Scalar/SROA.cpp b/lib/Transforms/Scalar/SROA.cpp
index 7e206f0..cb6da3b 100644
--- a/lib/Transforms/Scalar/SROA.cpp
+++ b/lib/Transforms/Scalar/SROA.cpp
@@ -2358,11 +2358,22 @@
       return false;
     if (!NewTy->isSingleValueType() || !OldTy->isSingleValueType())
       return false;
+
+    if (NewTy->isPointerTy() || OldTy->isPointerTy()) {
+      if (NewTy->isPointerTy() && OldTy->isPointerTy())
+        return true;
+      if (NewTy->isIntegerTy() || OldTy->isIntegerTy())
+        return true;
+      return false;
+    }
+
     return true;
   }
 
   Value *convertValue(IRBuilder<> &IRB, Value *V, Type *Ty) {
     assert(canConvertValue(V->getType(), Ty) && "Value not convertable to type");
+    if (V->getType() == Ty)
+      return V;
     if (V->getType()->isIntegerTy() && Ty->isPointerTy())
       return IRB.CreateIntToPtr(V, Ty);
     if (V->getType()->isPointerTy() && Ty->isIntegerTy())