xref: /llvm-project/llvm/test/Bitcode/function-nonzero-address-spaces.ll (revision 45067d1a74c8409328332c0d60cfc71601bfc846)
1; Verify that we accept calls to variables in the program AS:
2; RUN: llvm-as -data-layout "P40" %s -o - | llvm-dis - | FileCheck %s
3; CHECK: target datalayout = "P40"
4
5; We should get a sensible error for a non-program address call:
6; RUN: not llvm-as -data-layout "P39" %s -o /dev/null 2>&1 | FileCheck %s -check-prefix ERR-AS39
7; ERR-AS39: error: '%fnptr' defined with type 'ptr addrspace(40)' but expected 'ptr addrspace(39)'
8
9; And also if we don't set a custom program address space:
10; RUN: not llvm-as %s -o /dev/null 2>&1 | FileCheck %s -check-prefix ERR-AS0
11; ERR-AS0: error: '%fnptr' defined with type 'ptr addrspace(40)' but expected 'ptr'
12
13define void @f_named(i16 %n, ptr addrspace(40) %f) addrspace(40) {
14entry:
15  %f.addr = alloca ptr addrspace(40), align 1
16  store ptr addrspace(40) %f, ptr %f.addr
17  %fnptr = load ptr addrspace(40), ptr %f.addr
18  call void %fnptr(i16 8)
19  ret void
20}
21
22define void @f_numbered(i16 %n, ptr addrspace(40) %f) addrspace(40){
23entry:
24  %f.addr = alloca ptr addrspace(40), align 1
25  store ptr addrspace(40) %f, ptr %f.addr
26  %0 = load ptr addrspace(40), ptr %f.addr
27  call void %0(i16 8)
28  ret void
29}
30