aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Constants.cpp
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2021-06-23 20:56:55 +0200
committerNikita Popov <nikita.ppv@gmail.com>2021-06-23 20:58:08 +0200
commitf086ef3e83fd466fef2fbd1f9184d540675db0f6 (patch)
tree94329745772dbf1e3b24493668d6d4beee4de840 /llvm/lib/IR/Constants.cpp
parent5076d27ff01913a280e8ca8b40d38fb11fe7113d (diff)
downloadllvm-f086ef3e83fd466fef2fbd1f9184d540675db0f6.zip
llvm-f086ef3e83fd466fef2fbd1f9184d540675db0f6.tar.gz
llvm-f086ef3e83fd466fef2fbd1f9184d540675db0f6.tar.bz2
[Constants] Handle addrspacecast with opaque pointer type
This is the same change as D104668, but for constant expression addrspacecasts.
Diffstat (limited to 'llvm/lib/IR/Constants.cpp')
-rw-r--r--llvm/lib/IR/Constants.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp
index 2823a1e..6dcf8b5 100644
--- a/llvm/lib/IR/Constants.cpp
+++ b/llvm/lib/IR/Constants.cpp
@@ -2238,9 +2238,9 @@ Constant *ConstantExpr::getAddrSpaceCast(Constant *C, Type *DstTy,
// bitcasting the pointer type and then converting the address space.
PointerType *SrcScalarTy = cast<PointerType>(C->getType()->getScalarType());
PointerType *DstScalarTy = cast<PointerType>(DstTy->getScalarType());
- Type *DstElemTy = DstScalarTy->getElementType();
- if (SrcScalarTy->getElementType() != DstElemTy) {
- Type *MidTy = PointerType::get(DstElemTy, SrcScalarTy->getAddressSpace());
+ if (!SrcScalarTy->hasSameElementTypeAs(DstScalarTy)) {
+ Type *MidTy = PointerType::getWithSamePointeeType(
+ DstScalarTy, SrcScalarTy->getAddressSpace());
if (VectorType *VT = dyn_cast<VectorType>(DstTy)) {
// Handle vectors of pointers.
MidTy = FixedVectorType::get(MidTy,