Skip to content

AMDGPU: Start using LLVMContext errors in buffer fat pointer lowering #142014

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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
23 changes: 16 additions & 7 deletions llvm/lib/Target/AMDGPU/AMDGPULowerBufferFatPointers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2430,17 +2430,26 @@ bool AMDGPULowerBufferFatPointers::run(Module &M, const TargetMachine &TM) {
// its arguments or return types adjusted.
SmallVector<std::pair<Function *, bool>> NeedsRemap;

LLVMContext &Ctx = M.getContext();

BufferFatPtrToStructTypeMap StructTM(DL);
BufferFatPtrToIntTypeMap IntTM(DL);
for (const GlobalVariable &GV : M.globals()) {
if (GV.getAddressSpace() == AMDGPUAS::BUFFER_FAT_POINTER)
report_fatal_error("Global variables with a buffer fat pointer address "
"space (7) are not supported");
if (GV.getAddressSpace() == AMDGPUAS::BUFFER_FAT_POINTER) {
// FIXME: Use DiagnosticInfo unsupported but it requires a Function
Ctx.emitError("global variables with a buffer fat pointer address "
"space (7) are not supported");
continue;
}

Type *VT = GV.getValueType();
if (VT != StructTM.remapType(VT))
report_fatal_error("Global variables that contain buffer fat pointers "
"(address space 7 pointers) are unsupported. Use "
"buffer resource pointers (address space 8) instead.");
if (VT != StructTM.remapType(VT)) {
// FIXME: Use DiagnosticInfo unsupported but it requires a Function
Ctx.emitError("global variables that contain buffer fat pointers "
"(address space 7 pointers) are unsupported. Use "
"buffer resource pointers (address space 8) instead");
continue;
}
}

{
Expand Down
22 changes: 22 additions & 0 deletions llvm/test/CodeGen/AMDGPU/buffer-fat-pointer-unsupported-errors.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
; RUN: split-file %s %t
; RUN: not opt -mtriple=amdgcn-amd-amdhsa -disable-output -passes=amdgpu-lower-buffer-fat-pointers %t/contains-null-init.ll 2>&1 | FileCheck -check-prefix=ERR0 %s
; RUN: not opt -mtriple=amdgcn-amd-amdhsa -disable-output -passes=amdgpu-lower-buffer-fat-pointers %t/contains-poison-init.ll 2>&1 | FileCheck -check-prefix=ERR1 %s
; RUN: not opt -mtriple=amdgcn-amd-amdhsa -disable-output -passes=amdgpu-lower-buffer-fat-pointers %t/defined-gv-type.ll 2>&1 | FileCheck -check-prefix=ERR2 %s
; RUN: not opt -mtriple=amdgcn-amd-amdhsa -disable-output -passes=amdgpu-lower-buffer-fat-pointers %t/declared-gv-type.ll 2>&1 | FileCheck -check-prefix=ERR3 %s

;--- contains-null-init.ll
; ERR0: error: global variables that contain buffer fat pointers (address space 7 pointers) are unsupported. Use buffer resource pointers (address space 8) instead
@init_null = global ptr addrspace(7) null

;--- contains-poison-init.ll
; ERR1: error: global variables that contain buffer fat pointers (address space 7 pointers) are unsupported. Use buffer resource pointers (address space 8) instead
@init_poison = global ptr addrspace(7) poison

;--- defined-gv-type.ll
; ERR2: error: global variables with a buffer fat pointer address space (7) are not supported
@gv_is_addrspace_7 = addrspace(7) global i32 0

;--- declared-gv-type.ll
; ERR3: error: global variables with a buffer fat pointer address space (7) are not supported
@extern_gv_is_addrspace_7 = external addrspace(7) global i32

Loading