1 ; RUN: not llc -mtriple=amdgcn-- -mcpu=gfx900 -filetype=null %s 2>&1 | FileCheck --strict-whitespace %s
3 ; FIXME: Should be adequate to run just
4 ; -passes=amdgpu-printf-runtime-binding, but llc and opt have
5 ; different behavior on error diagnostics. opt uses the default error
6 ; handler which immediately exits, and llc does not. We want to report
7 ; errors for all functions in the module.
10 ; CHECK: error: foo.cl:1:42: in function test_inttoptr_argument void (i32): printf format string must be a trivially resolved constant string global variable
11 define amdgpu_kernel void @test_inttoptr_argument(i32 %n) {
12 %str = alloca [9 x i8], align 1, addrspace(5)
13 %call1 = call i32 (ptr addrspace(4), ...) @printf(ptr addrspace(4) inttoptr (i64 1234 to ptr addrspace(4)), ptr addrspace(5) %str, i32 %n), !dbg !4
17 ; CHECK: error: foo.cl:1:42: in function test_formatstr_argument void (ptr addrspace(4), i32): printf format string must be a trivially resolved constant string global variable
18 define amdgpu_kernel void @test_formatstr_argument(ptr addrspace(4) %format.str, i32 %n) {
19 %str = alloca [9 x i8], align 1, addrspace(5)
20 %call1 = call i32 (ptr addrspace(4), ...) @printf(ptr addrspace(4) %format.str, ptr addrspace(5) %str, i32 %n), !dbg !4
24 ; CHECK: error: foo.cl:1:42: in function test_formatstr_instruction void (ptr addrspace(4), i32): printf format string must be a trivially resolved constant string global variable
25 define amdgpu_kernel void @test_formatstr_instruction(ptr addrspace(4) %kernarg, i32 %n) {
26 %str = alloca [9 x i8], align 1, addrspace(5)
27 %format.str = load ptr addrspace(4), ptr addrspace(4) %kernarg
28 %call1 = call i32 (ptr addrspace(4), ...) @printf(ptr addrspace(4) %format.str, ptr addrspace(5) %str, i32 %n), !dbg !4
32 @no.initializer = external hidden addrspace(4) constant [6 x i8]
34 ; CHECK: error: foo.cl:1:42: in function test_no_initializer_gv void (i32): printf format string must be a trivially resolved constant string global variable
35 define amdgpu_kernel void @test_no_initializer_gv(i32 %n) {
36 %str = alloca [9 x i8], align 1, addrspace(5)
37 %call1 = call i32 (ptr addrspace(4), ...) @printf(ptr addrspace(4) @no.initializer, ptr addrspace(5) %str, i32 %n), !dbg !4
41 @interposable.initializer = weak unnamed_addr addrspace(4) constant [6 x i8] c"%s:%d\00"
43 ; CHECK: error: foo.cl:1:42: in function poison_interposable_initializer_gv void (i32): printf format string must be a trivially resolved constant string global variable
44 define amdgpu_kernel void @poison_interposable_initializer_gv(i32 %n) {
45 %str = alloca [9 x i8], align 1, addrspace(5)
46 %call1 = call i32 (ptr addrspace(4), ...) @printf(ptr addrspace(4) @interposable.initializer, ptr addrspace(5) %str, i32 %n), !dbg !4
50 @not.constant = private unnamed_addr addrspace(4) global [6 x i8] c"%s:%d\00", align 1
53 ; CHECK: error: <unknown>:0:0: in function not_constant_gv void (i32): printf format string must be a trivially resolved constant string global variable
54 define amdgpu_kernel void @not_constant_gv(i32 %n) {
56 %str = alloca [9 x i8], align 1, addrspace(5)
57 %arraydecay = getelementptr inbounds [9 x i8], [9 x i8] addrspace(5)* %str, i32 0, i32 0
58 %call1 = call i32 (i8 addrspace(4)*, ...) @printf(i8 addrspace(4)* getelementptr inbounds ([6 x i8], [6 x i8] addrspace(4)* @not.constant, i32 0, i32 0), i8 addrspace(5)* %arraydecay, i32 %n)
62 declare i32 @printf(ptr addrspace(4), ...)
65 !llvm.module.flags = !{!2, !3}
67 !0 = distinct !DICompileUnit(language: DW_LANG_OpenCL, file: !1, isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug)
68 !1 = !DIFile(filename: "foo.cl", directory: ".")
69 !2 = !{i32 2, !"Dwarf Version", i32 4}
70 !3 = !{i32 2, !"Debug Info Version", i32 3}
71 !4 = !DILocation(line: 1, column: 42, scope: !5)
72 !5 = distinct !DISubprogram(name: "arst", scope: null, file: !1, line: 1, isLocal: false, isDefinition: true, scopeLine: 2, isOptimized: false, unit: !0)