summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2014-03-13 22:51:43 +0000
committerOwen Anderson <resistor@mac.com>2014-03-13 22:51:43 +0000
commit9b8f9c3d95c40bbe4e575929d97ad8b3cce7244e (patch)
treede06eb3404eaa9f117a39efc06885525ff995cc2 /llvm/lib
parent8c26761018f8e19bb7789dafe7f37c8442f4cf02 (diff)
downloadbcm5719-llvm-9b8f9c3d95c40bbe4e575929d97ad8b3cce7244e.tar.gz
bcm5719-llvm-9b8f9c3d95c40bbe4e575929d97ad8b3cce7244e.zip
Fix a bug in InstCombine where we would incorrectly attempt to construct a
bitcast between pointers of two different address spaces if they happened to have the same pointer size. llvm-svn: 203862
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
index 1db55fea008..a34acdd8320 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
@@ -335,6 +335,13 @@ static Instruction *InstCombineLoadCast(InstCombiner &IC, LoadInst &LI,
NewLoad->setAlignment(LI.getAlignment());
NewLoad->setAtomic(LI.getOrdering(), LI.getSynchScope());
// Now cast the result of the load.
+ PointerType *OldTy = dyn_cast<PointerType>(NewLoad->getType());
+ PointerType *NewTy = dyn_cast<PointerType>(LI.getType());
+ if (OldTy && NewTy &&
+ OldTy->getAddressSpace() != NewTy->getAddressSpace()) {
+ return new AddrSpaceCastInst(NewLoad, LI.getType());
+ }
+
return new BitCastInst(NewLoad, LI.getType());
}
}
OpenPOWER on IntegriCloud