Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(109)

Side by Side Diff: tests_lit/assembler/x86/sandboxing.ll

Issue 1559243002: Suzero. X8664. NaCl Sandboxing. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fixes filetype=asm; addresses comments. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/IceTypes.def ('k') | tests_lit/llvm2ice_tests/callindirect.pnacl.ll » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 ; Tests basics and corner cases of x86-32 sandboxing, using -Om1 in 1 ; Tests basics and corner cases of x86-32 sandboxing, using -Om1 in
2 ; the hope that the output will remain stable. When packing bundles, 2 ; the hope that the output will remain stable. When packing bundles,
3 ; we try to limit to a few instructions with well known sizes and 3 ; we try to limit to a few instructions with well known sizes and
4 ; minimal use of registers and stack slots in the lowering sequence. 4 ; minimal use of registers and stack slots in the lowering sequence.
5 5
6 ; XFAIL: filtype=asm
6 ; RUN: %p2i -i %s --sandbox --filetype=obj --disassemble --args -Om1 \ 7 ; RUN: %p2i -i %s --sandbox --filetype=obj --disassemble --args -Om1 \
7 ; RUN: -allow-externally-defined-symbols \ 8 ; RUN: -allow-externally-defined-symbols \
8 ; RUN: -ffunction-sections | FileCheck %s 9 ; RUN: -ffunction-sections | FileCheck %s
9 10
11 ; RUN: %p2i -i %s --sandbox --filetype=obj --disassemble --target=x8664 \
12 ; RUN: --args -Om1 -allow-externally-defined-symbols \
13 ; RUN: -ffunction-sections | FileCheck %s --check-prefix X8664
14
10 declare void @call_target() 15 declare void @call_target()
11 @global_byte = internal global [1 x i8] zeroinitializer 16 @global_byte = internal global [1 x i8] zeroinitializer
12 @global_short = internal global [2 x i8] zeroinitializer 17 @global_short = internal global [2 x i8] zeroinitializer
13 @global_int = internal global [4 x i8] zeroinitializer 18 @global_int = internal global [4 x i8] zeroinitializer
14 19
15 ; A direct call sequence uses the right mask and register-call sequence. 20 ; A direct call sequence uses the right mask and register-call sequence.
16 define internal void @test_direct_call() { 21 define internal void @test_direct_call() {
17 entry: 22 entry:
18 call void @call_target() 23 call void @call_target()
19 ret void 24 ret void
20 } 25 }
21 ; CHECK-LABEL: test_direct_call 26 ; CHECK-LABEL: test_direct_call
22 ; CHECK: nop 27 ; CHECK: nop
23 ; CHECK: 1b: {{.*}} call 1c 28 ; CHECK: 1b: {{.*}} call 1c
24 ; CHECK-NEXT: 20: 29 ; CHECK-NEXT: 20:
30 ; X8664-LABEL: test_direct_call
31 ; X8664: push {{.*}}$local$__0
32 ; X8664: jmp {{.*}} call_target
33 ; X8664: {{0+}}20 <{{.*}}$local$__0>:
25 34
26 ; An indirect call sequence uses the right mask and register-call sequence. 35 ; An indirect call sequence uses the right mask and register-call sequence.
27 define internal void @test_indirect_call(i32 %target) { 36 define internal void @test_indirect_call(i32 %target) {
28 entry: 37 entry:
29 %__1 = inttoptr i32 %target to void ()* 38 %__1 = inttoptr i32 %target to void ()*
30 call void %__1() 39 call void %__1()
31 ret void 40 ret void
32 } 41 }
33 ; CHECK-LABEL: test_indirect_call 42 ; CHECK-LABEL: test_indirect_call
34 ; CHECK: mov [[REG:.*]],DWORD PTR [esp 43 ; CHECK: mov [[REG:.*]],DWORD PTR [esp
35 ; CHECK-NEXT: nop 44 ; CHECK-NEXT: nop
36 ; CHECK: 1b: {{.*}} and [[REG]],0xffffffe0 45 ; CHECK: 1b: {{.*}} and [[REG]],0xffffffe0
37 ; CHECK-NEXT: call [[REG]] 46 ; CHECK-NEXT: call [[REG]]
38 ; CHECk-NEXT: 20: 47 ; CHECk-NEXT: 20:
48 ; X8664-LABEL: test_indirect_call
49 ; X8664: push {{.*}}$local$__0
50 ; X8664: {{.*}} and e[[REG:..]],0xffffffe0
51 ; X8664: add r[[REG]],r15
52 ; X8664: jmp r[[REG]]
53 ; X8664: {{0+}}20 <{{.*}}$local$__0>:
39 54
40 ; A return sequences uses the right pop / mask / jmp sequence. 55 ; A return sequence uses the right pop / mask / jmp sequence.
41 define internal void @test_ret() { 56 define internal void @test_ret() {
42 entry: 57 entry:
43 ret void 58 ret void
44 } 59 }
45 ; CHECK-LABEL: test_ret 60 ; CHECK-LABEL: test_ret
46 ; CHECK: pop ecx 61 ; CHECK: pop ecx
47 ; CHECK-NEXT: and ecx,0xffffffe0 62 ; CHECK-NEXT: and ecx,0xffffffe0
48 ; CHECK-NEXT: jmp ecx 63 ; CHECK-NEXT: jmp ecx
64 ; X8664-LABEL: test_ret
65 ; X8664: pop rcx
66 ; X8664: and ecx,0xffffffe0
67 ; X8664: add rcx,r15
68 ; X8664: jmp rcx
49 69
50 ; A perfectly packed bundle should not have nops at the end. 70 ; A perfectly packed bundle should not have nops at the end.
51 define internal void @packed_bundle() { 71 define internal void @packed_bundle() {
52 entry: 72 entry:
53 call void @call_target() 73 call void @call_target()
54 ; bundle boundary 74 ; bundle boundary
55 %addr_byte = bitcast [1 x i8]* @global_byte to i8* 75 %addr_byte = bitcast [1 x i8]* @global_byte to i8*
56 %addr_short = bitcast [2 x i8]* @global_short to i16* 76 %addr_short = bitcast [2 x i8]* @global_short to i16*
57 store i8 0, i8* %addr_byte, align 1 ; 7-byte instruction 77 store i8 0, i8* %addr_byte, align 1 ; 7-byte instruction
58 store i16 0, i16* %addr_short, align 1 ; 9-byte instruction 78 store i16 0, i16* %addr_short, align 1 ; 9-byte instruction
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 ; CHECK: call 252 ; CHECK: call
233 ; CHECK-NEXT: 20: {{.*}} mov BYTE PTR 253 ; CHECK-NEXT: 20: {{.*}} mov BYTE PTR
234 ; CHECK-NEXT: 27: {{.*}} mov WORD PTR 254 ; CHECK-NEXT: 27: {{.*}} mov WORD PTR
235 ; CHECK-NEXT: 30: {{.*}} mov WORD PTR 255 ; CHECK-NEXT: 30: {{.*}} mov WORD PTR
236 ; CHECK-NEXT: 39: {{.*}} mov [[REG:.*]],DWORD PTR [esp 256 ; CHECK-NEXT: 39: {{.*}} mov [[REG:.*]],DWORD PTR [esp
237 ; CHECK-NEXT: 3d: {{.*}} nop 257 ; CHECK-NEXT: 3d: {{.*}} nop
238 ; CHECK: 40: {{.*}} nop 258 ; CHECK: 40: {{.*}} nop
239 ; CHECK: 5b: {{.*}} and [[REG]],0xffffffe0 259 ; CHECK: 5b: {{.*}} and [[REG]],0xffffffe0
240 ; CHECK-NEXT: 5e: {{.*}} call [[REG]] 260 ; CHECK-NEXT: 5e: {{.*}} call [[REG]]
241 261
262 ; Tests the pad_to_end bundle alignment with no padding bytes needed.
263 define internal void @bundle_lock_pad_to_end_padding_0(i32 %arg0, i32 %arg1,
264 i32 %arg3, i32 %arg4,
265 i32 %arg5, i32 %arg6) {
266 call void @call_target()
267 ; bundle boundary
268 %x = add i32 %arg5, %arg6 ; 12 bytes
269 %y = trunc i32 %x to i16 ; 10 bytes
270 call void @call_target() ; 10 bytes
271 ; bundle boundary
272 ret void
273 }
274 ; X8664-LABEL: bundle_lock_pad_to_end_padding_0$local$__0
275 ; X8664: 56: {{.*}} push {{.*}}$local$__1
276 ; X8664: 5b: {{.*}} jmp {{.*}} call_target
277 ; X8664: 60: {{.*}} add
278
279 ; Tests the pad_to_end bundle alignment with 11 padding bytes needed, and some
280 ; instructions before the call.
281 define internal void @bundle_lock_pad_to_end_padding_11(i32 %arg0, i32 %arg1,
282 i32 %arg3, i32 %arg4,
283 i32 %arg5, i32 %arg6) {
284 call void @call_target()
285 ; bundle boundary
286 %x = add i32 %arg5, %arg6 ; 11 bytes
287 call void @call_target() ; 10 bytes
288 ; 11 bytes of nop
289 ; bundle boundary
290 ret void
291 }
292 ; X8664-LABEL: bundle_lock_pad_to_end_padding_11$local$__0
293 ; X8664: 4b: {{.*}} push {{.*}}$local$__1
294 ; X8664: 50: {{.*}} jmp {{.*}} call_target
295 ; X8664: 55: {{.*}} nop
296 ; X8664: 5d: {{.*}} nop
297 ; X8664: 60: {{.*}} add
298
299 ; Tests the pad_to_end bundle alignment with 22 padding bytes needed, and no
300 ; instructions before the call.
301 define internal void @bundle_lock_pad_to_end_padding_22(i32 %arg0, i32 %arg1,
302 i32 %arg3, i32 %arg4,
303 i32 %arg5, i32 %arg6) {
304 call void @call_target()
305 ; bundle boundary
306 call void @call_target() ; 10 bytes
307 ; 22 bytes of nop
308 ; bundle boundary
309 ret void
310 }
311 ; X8664-LABEL: bundle_lock_pad_to_end_padding_22$local$__0
312 ; X8664: 40: {{.*}} push {{.*}}$local$__1
313 ; X8664: 45: {{.*}} jmp {{.*}} call_target
314 ; X8664: 4a: {{.*}} nop
315 ; X8664: 52: {{.*}} nop
316 ; X8664: 5a: {{.*}} nop
317 ; X8664: 60: {{.*}} add
318
242 ; Stack adjustment state during an argument push sequence gets 319 ; Stack adjustment state during an argument push sequence gets
243 ; properly checkpointed and restored during the two passes, as 320 ; properly checkpointed and restored during the two passes, as
244 ; observed by the stack adjustment for accessing stack-allocated 321 ; observed by the stack adjustment for accessing stack-allocated
245 ; variables. 322 ; variables.
246 define internal void @checkpoint_restore_stack_adjustment(i32 %arg) { 323 define internal void @checkpoint_restore_stack_adjustment(i32 %arg) {
247 entry: 324 entry:
248 call void @call_target() 325 call void @call_target()
249 ; bundle boundary 326 ; bundle boundary
250 call void @checkpoint_restore_stack_adjustment(i32 %arg) 327 call void @checkpoint_restore_stack_adjustment(i32 %arg)
251 ret void 328 ret void
252 } 329 }
253 ; CHECK-LABEL: checkpoint_restore_stack_adjustment 330 ; CHECK-LABEL: checkpoint_restore_stack_adjustment
254 ; CHECK: sub esp,0x1c 331 ; CHECK: sub esp,0x1c
255 ; CHECK: call 332 ; CHECK: call
256 ; The address of %arg should be [esp+0x20], not [esp+0x30]. 333 ; The address of %arg should be [esp+0x20], not [esp+0x30].
257 ; CHECK-NEXT: mov [[REG:.*]],DWORD PTR [esp+0x20] 334 ; CHECK-NEXT: mov [[REG:.*]],DWORD PTR [esp+0x20]
258 ; CHECK-NEXT: mov DWORD PTR [esp],[[REG]] 335 ; CHECK-NEXT: mov DWORD PTR [esp],[[REG]]
259 ; CHECK: call 336 ; CHECK: call
260 ; CHECK: add esp,0x1c 337 ; CHECK: add esp,0x1c
OLDNEW
« no previous file with comments | « src/IceTypes.def ('k') | tests_lit/llvm2ice_tests/callindirect.pnacl.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698