Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion llvm/lib/Target/AMDGPU/AMDGPULowerBufferFatPointers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2366,8 +2366,12 @@ static bool containsBufferFatPointers(const Function &F,
BufferFatPtrToStructTypeMap *TypeMap) {
bool HasFatPointers = false;
for (const BasicBlock &BB : F)
for (const Instruction &I : BB)
for (const Instruction &I : BB) {
HasFatPointers |= (I.getType() != TypeMap->remapType(I.getType()));
// Catch null pointer constants in loads, stores, etc.
for (const Value *V : I.operand_values())
HasFatPointers |= (V->getType() != TypeMap->remapType(V->getType()));
}
return HasFatPointers;
}

Expand Down
40 changes: 40 additions & 0 deletions llvm/test/CodeGen/AMDGPU/lower-buffer-fat-pointers-constants.ll
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,43 @@ define i32 @fancy_zero() {
ptr addrspace(7) addrspacecast (ptr addrspace(8) @buf to ptr addrspace(7))
to i32)
}

define i32 @load_null() {
; CHECK-LABEL: define i32 @load_null
; CHECK-SAME: () #[[ATTR0]] {
; CHECK-NEXT: [[X:%.*]] = call i32 @llvm.amdgcn.raw.ptr.buffer.load.i32(ptr addrspace(8) align 4 null, i32 0, i32 0, i32 0)
; CHECK-NEXT: ret i32 [[X]]
;
%x = load i32, ptr addrspace(7) null, align 4
ret i32 %x
}

define void @store_null() {
; CHECK-LABEL: define void @store_null
; CHECK-SAME: () #[[ATTR0]] {
; CHECK-NEXT: call void @llvm.amdgcn.raw.ptr.buffer.store.i32(i32 0, ptr addrspace(8) align 4 null, i32 0, i32 0, i32 0)
; CHECK-NEXT: ret void
;
store i32 0, ptr addrspace(7) null, align 4
ret void
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also test the poison case


define i32 @load_poison() {
; CHECK-LABEL: define i32 @load_poison
; CHECK-SAME: () #[[ATTR0]] {
; CHECK-NEXT: [[X:%.*]] = call i32 @llvm.amdgcn.raw.ptr.buffer.load.i32(ptr addrspace(8) align 4 poison, i32 poison, i32 0, i32 0)
; CHECK-NEXT: ret i32 [[X]]
;
%x = load i32, ptr addrspace(7) poison, align 4
ret i32 %x
}

define void @store_poison() {
; CHECK-LABEL: define void @store_poison
; CHECK-SAME: () #[[ATTR0]] {
; CHECK-NEXT: call void @llvm.amdgcn.raw.ptr.buffer.store.i32(i32 0, ptr addrspace(8) align 4 poison, i32 poison, i32 0, i32 0)
; CHECK-NEXT: ret void
;
store i32 0, ptr addrspace(7) poison, align 4
ret void
}