mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 20:23:11 +01:00
[OpaquePtr] Return opaque pointer from opaque pointer GEP
For a GEP on an opaque pointer, also return an opaque pointer (or vector of opaque pointer) result. This requires explicitly enumerating the GEP source element type, because it is now no longer implicitly enumerated as part of either the source or result pointer types. Differential Revision: https://reviews.llvm.org/D104652
This commit is contained in:
parent
6abba09064
commit
7f56d08fc8
@ -1098,8 +1098,12 @@ public:
|
||||
/// instruction, which may be a vector of pointers.
|
||||
static Type *getGEPReturnType(Type *ElTy, Value *Ptr,
|
||||
ArrayRef<Value *> IdxList) {
|
||||
Type *PtrTy = PointerType::get(checkGEPType(getIndexedType(ElTy, IdxList)),
|
||||
Ptr->getType()->getPointerAddressSpace());
|
||||
PointerType *OrigPtrTy = cast<PointerType>(Ptr->getType()->getScalarType());
|
||||
unsigned AddrSpace = OrigPtrTy->getAddressSpace();
|
||||
Type *ResultElemTy = checkGEPType(getIndexedType(ElTy, IdxList));
|
||||
Type *PtrTy = OrigPtrTy->isOpaque()
|
||||
? PointerType::get(OrigPtrTy->getContext(), AddrSpace)
|
||||
: PointerType::get(ResultElemTy, AddrSpace);
|
||||
// Vector GEP
|
||||
if (auto *PtrVTy = dyn_cast<VectorType>(Ptr->getType())) {
|
||||
ElementCount EltCount = PtrVTy->getElementCount();
|
||||
|
@ -463,6 +463,8 @@ ValueEnumerator::ValueEnumerator(const Module &M,
|
||||
}
|
||||
if (auto *SVI = dyn_cast<ShuffleVectorInst>(&I))
|
||||
EnumerateType(SVI->getShuffleMaskForBitcode()->getType());
|
||||
if (auto *GEP = dyn_cast<GetElementPtrInst>(&I))
|
||||
EnumerateType(GEP->getSourceElementType());
|
||||
EnumerateType(I.getType());
|
||||
if (const auto *Call = dyn_cast<CallBase>(&I))
|
||||
EnumerateAttributes(Call->getAttributes());
|
||||
|
@ -41,12 +41,28 @@ define void @store(ptr %a, i32 %i) {
|
||||
ret void
|
||||
}
|
||||
|
||||
; CHECK: define void @gep(ptr %a)
|
||||
; CHECK: %b = getelementptr i8, ptr %a, i32 2
|
||||
; CHECK: ret void
|
||||
define void @gep(ptr %a) {
|
||||
%b = getelementptr i8, ptr %a, i32 2
|
||||
ret void
|
||||
; CHECK: define ptr @gep(ptr %a)
|
||||
; CHECK: %res = getelementptr i8, ptr %a, i32 2
|
||||
; CHECK: ret ptr %res
|
||||
define ptr @gep(ptr %a) {
|
||||
%res = getelementptr i8, ptr %a, i32 2
|
||||
ret ptr %res
|
||||
}
|
||||
|
||||
; CHECK: define <2 x ptr> @gep_vec1(ptr %a)
|
||||
; CHECK: %res = getelementptr i8, ptr %a, <2 x i32> <i32 1, i32 2>
|
||||
; CHECK: ret <2 x ptr> %res
|
||||
define <2 x ptr> @gep_vec1(ptr %a) {
|
||||
%res = getelementptr i8, ptr %a, <2 x i32> <i32 1, i32 2>
|
||||
ret <2 x ptr> %res
|
||||
}
|
||||
|
||||
; CHECK: define <2 x ptr> @gep_vec2(<2 x ptr> %a)
|
||||
; CHECK: %res = getelementptr i8, <2 x ptr> %a, i32 2
|
||||
; CHECK: ret <2 x ptr> %res
|
||||
define <2 x ptr> @gep_vec2(<2 x ptr> %a) {
|
||||
%res = getelementptr i8, <2 x ptr> %a, i32 2
|
||||
ret <2 x ptr> %res
|
||||
}
|
||||
|
||||
; CHECK: define void @cmpxchg(ptr %p, i32 %a, i32 %b)
|
||||
|
Loading…
Reference in New Issue
Block a user