diff options
author | Nate Begeman <natebegeman@mac.com> | 2008-03-31 00:22:16 +0000 |
---|---|---|
committer | Nate Begeman <natebegeman@mac.com> | 2008-03-31 00:22:16 +0000 |
commit | 83ad90a779f8ce46d6923bc6f63aa15b83968efb (patch) | |
tree | f4a3fa7b8c2fc4d0a222c6c9278f930dc0eedd1d /lib/Transforms | |
parent | 4f678c36922d2537c1a81bd1946691f3acabd515 (diff) |
Don't eliminate bitcast instructions that change the type of a pointer
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48971 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 35715fb8ca..9e069fd05b 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -7575,6 +7575,11 @@ Instruction *InstCombiner::visitBitCast(BitCastInst &CI) { const Type *DstElTy = DstPTy->getElementType(); const Type *SrcElTy = SrcPTy->getElementType(); + // If the address spaces don't match, don't eliminate the bitcast, which is + // required for changing types. + if (SrcPTy->getAddressSpace() != DstPTy->getAddressSpace()) + return 0; + // If we are casting a malloc or alloca to a pointer to a type of the same // size, rewrite the allocation instruction to allocate the "right" type. if (AllocationInst *AI = dyn_cast<AllocationInst>(Src)) |