diff options
author | Nikita Popov <npopov@redhat.com> | 2022-01-27 11:50:27 +0100 |
---|---|---|
committer | Nikita Popov <npopov@redhat.com> | 2022-01-27 11:52:52 +0100 |
commit | 0f0e699776d731f3aae358428e56f4ae3968abe8 (patch) | |
tree | 4014016a0ec6643af2eb3711a62abb4161f8f004 /llvm/lib/IR/ConstantFold.cpp | |
parent | dbd1bbced9896d5caece9ee60a7953d2c80d939c (diff) | |
download | llvm-0f0e699776d731f3aae358428e56f4ae3968abe8.zip llvm-0f0e699776d731f3aae358428e56f4ae3968abe8.tar.gz llvm-0f0e699776d731f3aae358428e56f4ae3968abe8.tar.bz2 |
[ConstantFold] Disable gep of array bitcast fold with opaque pointers
Once again, this fold is meaningless with opaque pointers, as there
is no pointer element type to canonicalize. At some point, we may
want to do GEP type canonicalizations.
Diffstat (limited to 'llvm/lib/IR/ConstantFold.cpp')
-rw-r--r-- | llvm/lib/IR/ConstantFold.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp index 1cd95cd..622a984 100644 --- a/llvm/lib/IR/ConstantFold.cpp +++ b/llvm/lib/IR/ConstantFold.cpp @@ -2096,11 +2096,12 @@ Constant *llvm::ConstantFoldGetElementPtr(Type *PointeeTy, Constant *C, PointerType *SrcPtrTy = dyn_cast<PointerType>(CE->getOperand(0)->getType()); PointerType *DstPtrTy = dyn_cast<PointerType>(CE->getType()); - if (SrcPtrTy && DstPtrTy) { + if (SrcPtrTy && DstPtrTy && !SrcPtrTy->isOpaque() && + !DstPtrTy->isOpaque()) { ArrayType *SrcArrayTy = - dyn_cast<ArrayType>(SrcPtrTy->getPointerElementType()); + dyn_cast<ArrayType>(SrcPtrTy->getNonOpaquePointerElementType()); ArrayType *DstArrayTy = - dyn_cast<ArrayType>(DstPtrTy->getPointerElementType()); + dyn_cast<ArrayType>(DstPtrTy->getNonOpaquePointerElementType()); if (SrcArrayTy && DstArrayTy && SrcArrayTy->getElementType() == DstArrayTy->getElementType() && SrcPtrTy->getAddressSpace() == DstPtrTy->getAddressSpace()) |