aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/ConstantFold.cpp
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2021-06-22 12:14:31 +0200
committerNikita Popov <nikita.ppv@gmail.com>2021-06-22 15:50:55 +0200
commit87bdde4962ea926e81a3534119ac8f02901b75b9 (patch)
tree6e68ec5b5e70a63780b1189f9472c74a6852fa90 /llvm/lib/IR/ConstantFold.cpp
parent5dd4d0d46fb892975bbb3a086da5a3a9996ced4d (diff)
downloadllvm-87bdde4962ea926e81a3534119ac8f02901b75b9.zip
llvm-87bdde4962ea926e81a3534119ac8f02901b75b9.tar.gz
llvm-87bdde4962ea926e81a3534119ac8f02901b75b9.tar.bz2
[ConstantFold] Skip bitcast -> GEP transform for opaque pointers
Same as with the InstCombine transform, this is not possible for bitcasts involving opaque pointers, as GEP preserves opaqueness.
Diffstat (limited to 'llvm/lib/IR/ConstantFold.cpp')
-rw-r--r--llvm/lib/IR/ConstantFold.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp
index ecd05be..652ccd3 100644
--- a/llvm/lib/IR/ConstantFold.cpp
+++ b/llvm/lib/IR/ConstantFold.cpp
@@ -117,8 +117,9 @@ static Constant *FoldBitCast(Constant *V, Type *DestTy) {
// the first element. If so, return the appropriate GEP instruction.
if (PointerType *PTy = dyn_cast<PointerType>(V->getType()))
if (PointerType *DPTy = dyn_cast<PointerType>(DestTy))
- if (PTy->getAddressSpace() == DPTy->getAddressSpace()
- && PTy->getElementType()->isSized()) {
+ if (PTy->getAddressSpace() == DPTy->getAddressSpace() &&
+ !PTy->isOpaque() && !DPTy->isOpaque() &&
+ PTy->getElementType()->isSized()) {
SmallVector<Value*, 8> IdxList;
Value *Zero =
Constant::getNullValue(Type::getInt32Ty(DPTy->getContext()));