From ac104272d9fc42af8dc6853853b96d489685e5a7 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Sat, 13 Oct 2012 10:49:30 +0000 Subject: [PATCH] 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 --- lib/Transforms/Scalar/SROA.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/Transforms/Scalar/SROA.cpp b/lib/Transforms/Scalar/SROA.cpp index 7e206f0bcec..cb6da3b9561 100644 --- a/lib/Transforms/Scalar/SROA.cpp +++ b/lib/Transforms/Scalar/SROA.cpp @@ -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()) -- 2.34.1