Skip to content

Commit 30a7806

Browse files
committed
AMDGPU: Start using LLVMContext errors in buffer fat pointer lowering
Avoid using report_fatal_error. Many more uses that should be converted in the pass remain.
1 parent 637e92b commit 30a7806

File tree

2 files changed

+38
-7
lines changed

2 files changed

+38
-7
lines changed

llvm/lib/Target/AMDGPU/AMDGPULowerBufferFatPointers.cpp

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2430,17 +2430,26 @@ bool AMDGPULowerBufferFatPointers::run(Module &M, const TargetMachine &TM) {
24302430
// its arguments or return types adjusted.
24312431
SmallVector<std::pair<Function *, bool>> NeedsRemap;
24322432

2433+
LLVMContext &Ctx = M.getContext();
2434+
24332435
BufferFatPtrToStructTypeMap StructTM(DL);
24342436
BufferFatPtrToIntTypeMap IntTM(DL);
24352437
for (const GlobalVariable &GV : M.globals()) {
2436-
if (GV.getAddressSpace() == AMDGPUAS::BUFFER_FAT_POINTER)
2437-
report_fatal_error("Global variables with a buffer fat pointer address "
2438-
"space (7) are not supported");
2438+
if (GV.getAddressSpace() == AMDGPUAS::BUFFER_FAT_POINTER) {
2439+
// FIXME: Use DiagnosticInfo unsupported but it requires a Function
2440+
Ctx.emitError("global variables with a buffer fat pointer address "
2441+
"space (7) are not supported");
2442+
continue;
2443+
}
2444+
24392445
Type *VT = GV.getValueType();
2440-
if (VT != StructTM.remapType(VT))
2441-
report_fatal_error("Global variables that contain buffer fat pointers "
2442-
"(address space 7 pointers) are unsupported. Use "
2443-
"buffer resource pointers (address space 8) instead.");
2446+
if (VT != StructTM.remapType(VT)) {
2447+
// FIXME: Use DiagnosticInfo unsupported but it requires a Function
2448+
Ctx.emitError("global variables that contain buffer fat pointers "
2449+
"(address space 7 pointers) are unsupported. Use "
2450+
"buffer resource pointers (address space 8) instead");
2451+
continue;
2452+
}
24442453
}
24452454

24462455
{
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
; RUN: split-file %s %t
2+
; 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
3+
; 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
4+
; 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
5+
; 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
6+
7+
;--- contains-null-init.ll
8+
; ERR0: error: global variables that contain buffer fat pointers (address space 7 pointers) are unsupported. Use buffer resource pointers (address space 8) instead
9+
@init_null = global ptr addrspace(7) null
10+
11+
;--- contains-poison-init.ll
12+
; ERR1: error: global variables that contain buffer fat pointers (address space 7 pointers) are unsupported. Use buffer resource pointers (address space 8) instead
13+
@init_poison = global ptr addrspace(7) poison
14+
15+
;--- defined-gv-type.ll
16+
; ERR2: error: global variables with a buffer fat pointer address space (7) are not supported
17+
@gv_is_addrspace_7 = addrspace(7) global i32 0
18+
19+
;--- declared-gv-type.ll
20+
; ERR3: error: global variables with a buffer fat pointer address space (7) are not supported
21+
@extern_gv_is_addrspace_7 = external addrspace(7) global i32
22+

0 commit comments

Comments
 (0)