aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMon P Wang <wangmp@apple.com>2009-02-07 22:19:29 +0000
committerMon P Wang <wangmp@apple.com>2009-02-07 22:19:29 +0000
commitbd05ed8f30204072872fc02a416a67d5f9941451 (patch)
tree535f6b5cd5b1cf8961f5897ba1eeb141ed15c9ff /lib
parent2dbdb0ea777a13c6fa8e9fe708e728a84752c20a (diff)
downloadexternal_llvm-bd05ed8f30204072872fc02a416a67d5f9941451.zip
external_llvm-bd05ed8f30204072872fc02a416a67d5f9941451.tar.gz
external_llvm-bd05ed8f30204072872fc02a416a67d5f9941451.tar.bz2
Instrcombine should not change load(cast p) to cast(load p) if the cast
changes the address space of the pointer. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64035 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index 97af83f..b426274 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -11007,8 +11007,14 @@ static Instruction *InstCombineLoadCast(InstCombiner &IC, LoadInst &LI,
}
}
- const Type *DestPTy = cast<PointerType>(CI->getType())->getElementType();
+ const PointerType *DestTy = cast<PointerType>(CI->getType());
+ const Type *DestPTy = DestTy->getElementType();
if (const PointerType *SrcTy = dyn_cast<PointerType>(CastOp->getType())) {
+
+ // If the address spaces don't match, don't eliminate the cast.
+ if (DestTy->getAddressSpace() != SrcTy->getAddressSpace())
+ return 0;
+
const Type *SrcPTy = SrcTy->getElementType();
if (DestPTy->isInteger() || isa<PointerType>(DestPTy) ||