blob: 111ef0ccefe985a64fcbae8db158c187f4722efb [file] [log] [blame]
Alexander Richardsonb0b98842018-02-27 11:15:11 +00001; RUN: not llvm-as %s -o /dev/null 2>&1 | FileCheck %s
Alexander Richardson47ff67b2018-08-23 09:25:17 +00002; RUN: llvm-as %s -data-layout=P42 -o - | llvm-dis - -o - | FileCheck %s -check-prefix PROGAS42
Alexander Richardsonb0b98842018-02-27 11:15:11 +00003
Alexander Richardson47ff67b2018-08-23 09:25:17 +00004; Check that variables in a nonzero program address space 42 can be used in a call instruction
Alexander Richardsonb0b98842018-02-27 11:15:11 +00005
Alexander Richardson47ff67b2018-08-23 09:25:17 +00006define i8 @test(i8(i32)* %fnptr0, i8(i32) addrspace(42)* %fnptr42) {
7 %explicit_as_0 = call addrspace(0) i8 %fnptr0(i32 0)
8 %explicit_as_42 = call addrspace(42) i8 %fnptr42(i32 0)
9 ; Calling %fnptr42 without an explicit addrspace() in the call instruction is only okay if the program AS is 42
10 %call_no_as = call i8 %fnptr42(i32 0)
11 ; CHECK: call-nonzero-program-addrspace.ll:[[@LINE-1]]:25: error: '%fnptr42' defined with type 'i8 (i32) addrspace(42)*' but expected 'i8 (i32)*'
Alexander Richardsonb0b98842018-02-27 11:15:11 +000012 ret i8 0
13}
14
Alexander Richardson47ff67b2018-08-23 09:25:17 +000015; PROGAS42: target datalayout = "P42"
16; PROGAS42: define i8 @test(i8 (i32)* %fnptr0, i8 (i32) addrspace(42)* %fnptr42) addrspace(42) {
17; Print addrspace(0) since the program address space is non-zero:
18; PROGAS42-NEXT: %explicit_as_0 = call addrspace(0) i8 %fnptr0(i32 0)
19; Also print addrspace(42) since we always print non-zero addrspace:
20; PROGAS42-NEXT: %explicit_as_42 = call addrspace(42) i8 %fnptr42(i32 0)
21; PROGAS42-NEXT: %call_no_as = call addrspace(42) i8 %fnptr42(i32 0)
22; PROGAS42-NEXT: ret i8 0
23; PROGAS42-NEXT: }