1; RUN: not llc -mtriple=amdgcn-- -mcpu=gfx900 -filetype=null %s 2>&1 | FileCheck --strict-whitespace %s 2 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. 8 9 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 11define 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 14 ret void 15} 16 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 18define 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 21 ret void 22} 23 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 25define 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 29 ret void 30} 31 32@no.initializer = external hidden addrspace(4) constant [6 x i8] 33 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 35define 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 38 ret void 39} 40 41@interposable.initializer = weak unnamed_addr addrspace(4) constant [6 x i8] c"%s:%d\00" 42 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 44define 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 47 ret void 48} 49 50@not.constant = private unnamed_addr addrspace(4) global [6 x i8] c"%s:%d\00", align 1 51 52 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 54define amdgpu_kernel void @not_constant_gv(i32 %n) { 55entry: 56 %str = alloca [9 x i8], align 1, addrspace(5) 57 %arraydecay = getelementptr inbounds [9 x i8], ptr addrspace(5) %str, i32 0, i32 0 58 %call1 = call i32 (ptr addrspace(4), ...) @printf(ptr addrspace(4) @not.constant, ptr addrspace(5) %arraydecay, i32 %n) 59 ret void 60} 61 62declare i32 @printf(ptr addrspace(4), ...) 63 64!llvm.dbg.cu = !{!0} 65!llvm.module.flags = !{!2, !3} 66 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) 73