Alexander Richardson | 47ff67b | 2018-08-23 09:25:17 +0000 | [diff] [blame] | 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 'void (i16) addrspace(40)*' but expected 'void (i16) 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 'void (i16) addrspace(40)*' but expected 'void (i16)*' |
| 12 | |
| 13 | define void @f_named(i16 %n, void (i16) addrspace(40)* %f) addrspace(40) { |
| 14 | entry: |
| 15 | %f.addr = alloca void (i16) addrspace(40)*, align 1 |
| 16 | store void (i16) addrspace(40)* %f, void (i16) addrspace(40)** %f.addr |
| 17 | %fnptr = load void (i16) addrspace(40)*, void (i16) addrspace(40)** %f.addr |
| 18 | call void %fnptr(i16 8) |
| 19 | ret void |
| 20 | } |
| 21 | |
| 22 | define void @f_numbered(i16 %n, void (i16) addrspace(40)* %f) addrspace(40){ |
| 23 | entry: |
| 24 | %f.addr = alloca void (i16) addrspace(40)*, align 1 |
| 25 | store void (i16) addrspace(40)* %f, void (i16) addrspace(40)** %f.addr |
| 26 | %0 = load void (i16) addrspace(40)*, void (i16) addrspace(40)** %f.addr |
| 27 | call void %0(i16 8) |
| 28 | ret void |
| 29 | } |