Consider addrspaces in canLosslesslyBitCastTo()

Make this conservatively correct and report false for different
address spaces, which might require a nontrivial translation.

Based on the few uses of this, I don't think this currently
breaks anything.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216846 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Matt Arsenault 2014-08-31 19:19:57 +00:00
parent 363d0d2738
commit 30392bf191

View File

@ -89,9 +89,13 @@ bool Type::canLosslesslyBitCastTo(Type *Ty) const {
// At this point we have only various mismatches of the first class types
// remaining and ptr->ptr. Just select the lossless conversions. Everything
// else is not lossless.
if (this->isPointerTy())
return Ty->isPointerTy();
// else is not lossless. Conservatively assume we can't losslessly convert
// between pointers with different address spaces.
if (const PointerType *PTy = dyn_cast<PointerType>(this)) {
if (const PointerType *OtherPTy = dyn_cast<PointerType>(Ty))
return PTy->getAddressSpace() == OtherPTy->getAddressSpace();
return false;
}
return false; // Other types have no identity values
}