[NVPTX] PTXAS - Unimplemented feature: labels as initial values

Dear NVPTX community,

PTXAS fails to compile the ptx code generated by NVPTX. Is it an issue of backend or an issue of PTXAS or a known reasonable restriction?

Thanks,

  • Dima.

cat test.ll
; ModuleID = ‘__kernelgen_main_module’
target datalayout = “e-p:64:64-i64:64:64-f64:64:64-n1:8:16:32:64”
target triple = “ptx64-unknown-unknown”

%struct.__st_parameter_dt.0.4 = type { %struct.__st_parameter_common.1.5, i64, i64*, i64*, i8*, i8*, i32, i32, i8*, i8*, i32, i32, i8*, [256 x i8], i32*, i64, i8*, i32, i32, i8*, i8*, i32, i32, i8*, i8*, i32, i32, i8*, i8*, i32, [4 x i8] }
%struct.__st_parameter_common.1.5 = type { i32, i32, i8*, i32, i32, i8*, i32* }
%“struct.kernelgen::kernel_t.2” = type opaque
%struct.kernelgen_callback_data_t.3 = type opaque

@.cst = hidden constant [11 x i8] c"reduce.f90\00", align 4096
@z = unnamed_addr global i8* getelementptr inbounds ([3 x i8]* @.cst1, i64 0, i64 0), align 4096
@.cst1 = hidden constant [3 x i8] c"zz\00", align 4096
@a = unnamed_addr global i8* getelementptr inbounds ([3 x i8]* @.cst12, i64 0, i64 0), align 4096
@.cst12 = hidden constant [3 x i8] c"aa\00", align 4096
@.cst2 = hidden constant [26 x i8] c"Usage: %s \0A\00", align 4096

llc -march=nvptx64 test.ll -o test.ptx
cat test.ptx
//
// Generated by LLVM NVPTX Back-End
//

.version 3.0
.target sm_10, texmode_independent
.address_size 64

.visible .global .align 4096 .b8 _2E_cst[11] = {114, 101, 100, 117, 99, 101, 46, 102, 57, 48, 0};
.visible .global .align 4096 .u64 z = _2E_cst1;
.visible .global .align 4096 .b8 _2E_cst1[3] = {122, 122, 0};
.visible .global .align 4096 .u64 a = _2E_cst12;
.visible .global .align 4096 .b8 _2E_cst12[3] = {97, 97, 0};
.visible .global .align 4096 .b8 _2E_cst2[26] = {85, 115, 97, 103, 101, 58, 32, 37, 115, 32, 60, 110, 120, 62, 32, 60, 110, 121, 62, 32, 60, 110, 122, 62, 10, 0};

ptxas test.ptx -o test.cubin
ptxas test.ptx, line 10; error : Unimplemented feature: labels as initial values
ptxas test.ptx, line 12; error : Unimplemented feature: labels as initial values
ptxas test.ptx, line 10; error : Label expected for forward reference of ‘_2E_cst1’
ptxas test.ptx, line 12; error : Label expected for forward reference of ‘_2E_cst12’
ptxas fatal : Ptx assembly aborted due to errors

In ptx, variables need to be defined before referenced. NVPTX emits the global variables in the order as in the LLVM IR and does not sort them. It is a bug in the NVPTX backend.

Thanks.

Yuan

Hi Justin,

With attached patch we managed to fix the issue mentioned in this
thread. Maybe it needs additional cleanups, but is it applicable in
general, how do you think?

Thanks,
- D.

nvptx.reorder.patch (3.69 KB)