diff options
author | Matt Arsenault <Matthew.Arsenault@amd.com> | 2014-08-31 19:19:57 +0000 |
---|---|---|
committer | Matt Arsenault <Matthew.Arsenault@amd.com> | 2014-08-31 19:19:57 +0000 |
commit | a8efaf96d4eef19946b53d62ef8c68badc9cab6c (patch) | |
tree | 8d2e9ec098dde8f58164f38e4f82b55f4443cc08 | |
parent | 3fbf3b85466f9f76ced17fcbfe11c5047dd98280 (diff) | |
download | bcm5719-llvm-a8efaf96d4eef19946b53d62ef8c68badc9cab6c.tar.gz bcm5719-llvm-a8efaf96d4eef19946b53d62ef8c68badc9cab6c.zip |
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.
llvm-svn: 216846
-rw-r--r-- | llvm/lib/IR/Type.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/llvm/lib/IR/Type.cpp b/llvm/lib/IR/Type.cpp index ae7af8f1473..90fde4db192 100644 --- a/llvm/lib/IR/Type.cpp +++ b/llvm/lib/IR/Type.cpp @@ -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 } |