Speculatively harden the conversion logic. I have no idea if this will
authorChandler Carruth <chandlerc@gmail.com>
Sat, 13 Oct 2012 10:49:30 +0000 (10:49 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Sat, 13 Oct 2012 10:49:30 +0000 (10:49 +0000)
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

lib/Transforms/Scalar/SROA.cpp

index 7e206f0bcec77033a619e5d55f064015f0b3c291..cb6da3b95615415a169b9c122fd99295afe76c71 100644 (file)
@@ -2358,11 +2358,22 @@ private:
       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())