OLD | NEW |
1 ; RUN: not pnacl-abicheck < %s | FileCheck %s | 1 ; RUN: not pnacl-abicheck < %s | FileCheck %s |
2 | 2 |
3 ; This test checks that the PNaCl ABI verifier enforces the normal | 3 ; This test checks that the PNaCl ABI verifier enforces the normal |
4 ; form introduced by the ReplacePtrsWithInts pass. | 4 ; form introduced by the ReplacePtrsWithInts pass. |
5 | 5 |
6 | 6 |
7 @var = global [4 x i8] c"xxxx" | 7 @var = global [4 x i8] c"xxxx" |
8 @ptr = global i32 ptrtoint ([4 x i8]* @var to i32) | 8 @ptr = global i32 ptrtoint ([4 x i8]* @var to i32) |
9 | 9 |
10 declare i8* @llvm.nacl.read.tp() | 10 declare i8* @llvm.nacl.read.tp() |
(...skipping 18 matching lines...) Expand all Loading... |
29 } | 29 } |
30 | 30 |
31 | 31 |
32 define internal void @allowed_cases(i32 %arg) { | 32 define internal void @allowed_cases(i32 %arg) { |
33 inttoptr i32 123 to i8* | 33 inttoptr i32 123 to i8* |
34 | 34 |
35 ptrtoint [4 x i8]* @var to i32 | 35 ptrtoint [4 x i8]* @var to i32 |
36 | 36 |
37 %alloc = alloca i8 | 37 %alloc = alloca i8 |
38 ptrtoint i8* %alloc to i32 | 38 ptrtoint i8* %alloc to i32 |
39 load i8* %alloc, align 1 | 39 load i8, i8* %alloc, align 1 |
40 | 40 |
41 ; These instructions may use a NormalizedPtr, which may be a global. | 41 ; These instructions may use a NormalizedPtr, which may be a global. |
42 load i32* @ptr, align 1 | 42 load i32, i32* @ptr, align 1 |
43 store i32 123, i32* @ptr, align 1 | 43 store i32 123, i32* @ptr, align 1 |
44 | 44 |
45 ; A NormalizedPtr may be a bitcast. | 45 ; A NormalizedPtr may be a bitcast. |
46 %ptr_bitcast = bitcast [4 x i8]* @var to i32* | 46 %ptr_bitcast = bitcast [4 x i8]* @var to i32* |
47 load i32* %ptr_bitcast, align 1 | 47 load i32, i32* %ptr_bitcast, align 1 |
48 | 48 |
49 ; A NormalizedPtr may be an inttoptr. | 49 ; A NormalizedPtr may be an inttoptr. |
50 %ptr_from_int = inttoptr i32 123 to i32* | 50 %ptr_from_int = inttoptr i32 123 to i32* |
51 load i32* %ptr_from_int, align 1 | 51 load i32, i32* %ptr_from_int, align 1 |
52 | 52 |
53 ; Check direct and indirect function calls. | 53 ; Check direct and indirect function calls. |
54 %func_as_int = ptrtoint void ()* @func to i32 | 54 %func_as_int = ptrtoint void ()* @func to i32 |
55 %func_ptr = inttoptr i32 %func_as_int to void ()* | 55 %func_ptr = inttoptr i32 %func_as_int to void ()* |
56 call void %func_ptr() | 56 call void %func_ptr() |
57 call void @func() | 57 call void @func() |
58 call void @func_with_arg(i32 123) | 58 call void @func_with_arg(i32 123) |
59 | 59 |
60 ; Intrinsic calls may return pointers. | 60 ; Intrinsic calls may return pointers. |
61 %thread_ptr = call i8* @llvm.nacl.read.tp() | 61 %thread_ptr = call i8* @llvm.nacl.read.tp() |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 ret void | 129 ret void |
130 } | 130 } |
131 | 131 |
132 ; CHECK-NOT: disallowed | 132 ; CHECK-NOT: disallowed |
133 | 133 |
134 | 134 |
135 ; This stops the verifier from complaining about the lack of an entry point. | 135 ; This stops the verifier from complaining about the lack of an entry point. |
136 define void @_start(i32 %arg) { | 136 define void @_start(i32 %arg) { |
137 ret void | 137 ret void |
138 } | 138 } |
OLD | NEW |