[llvm] r216846 - Consider addrspaces in canLosslesslyBitCastTo()
Matt Arsenault
Matthew.Arsenault at amd.com
Sun Aug 31 12:19:57 PDT 2014
Author: arsenm
Date: Sun Aug 31 14:19:57 2014
New Revision: 216846
URL: http://llvm.org/viewvc/llvm-project?rev=216846&view=rev
Log:
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.
Modified:
llvm/trunk/lib/IR/Type.cpp
Modified: llvm/trunk/lib/IR/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Type.cpp?rev=216846&r1=216845&r2=216846&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Type.cpp (original)
+++ llvm/trunk/lib/IR/Type.cpp Sun Aug 31 14:19:57 2014
@@ -89,9 +89,13 @@ bool Type::canLosslesslyBitCastTo(Type *
// 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
}
More information about the llvm-commits
mailing list