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

Side by Side Diff: test/NaCl/ARM/divrem-guards.ll

Issue 14607004: Insert denominator zero checks for NaCl (Closed) Base URL: http://git.chromium.org/native_client/pnacl-llvm.git@master
Patch Set: Add more complex control flow test. Created 7 years, 7 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 | « lib/Transforms/NaCl/InsertDivideCheck.cpp ('k') | test/NaCl/ARM/divrem-guards-complex.ll » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 ; RUN: opt < %s -insert-divide-check -S | FileCheck -check-prefix=OPT %s
2 ; RUN: llc -mtriple=armv7-unknown-nacl -sfi-branch -filetype=obj %s -o - \
3 ; RUN: | llvm-objdump -disassemble -triple armv7 -mattr=+nacl-trap - \
4 ; RUN: | FileCheck -check-prefix=ARM %s
5
6
7 ; Check for all four operators that need guards.
8 define i32 @mysdiv(i32 %x, i32 %y) #0 {
9 entry:
10 %div1 = sdiv i32 %x, %y
11 ; OPT: %0 = icmp eq i32 %y, 0
12 ; OPT-NEXT: br i1 %0, label %divrem.by.zero, label %guarded.divrem
13 ; OPT: guarded.divrem:
14 ; OPT-NEXT: sdiv
15 ; OPT-NEXT: ret
16 ; OPT: divrem.by.zero:
17 ; OPT-NEXT: call void @llvm.trap()
18 ; OPT-NEXT: unreachable
19 ; ARM: cmp r1, #0
20 ; ARM-NEXT: beq
21 ret i32 %div1
22 ; ARM: f0 de fe e7
23 }
24
25 define i32 @myudiv(i32 %x, i32 %y) #0 {
26 entry:
27 %div1 = udiv i32 %x, %y
28 ; OPT: %0 = icmp eq i32 %y, 0
29 ; OPT-NEXT: br i1 %0, label %divrem.by.zero, label %guarded.divrem
30 ; OPT: guarded.divrem:
31 ; OPT-NEXT: udiv
32 ; OPT-NEXT: ret
33 ; OPT: divrem.by.zero:
34 ; OPT-NEXT: call void @llvm.trap()
35 ; OPT-NEXT: unreachable
36 ; ARM: cmp r1, #0
37 ; ARM-NEXT: beq
38 ret i32 %div1
39 ; ARM: f0 de fe e7
40 }
41
42 define i32 @mysrem(i32 %x, i32 %y) #0 {
43 entry:
44 %rem1 = srem i32 %x, %y
45 ; OPT: %0 = icmp eq i32 %y, 0
46 ; OPT-NEXT: br i1 %0, label %divrem.by.zero, label %guarded.divrem
47 ; OPT: guarded.divrem:
48 ; OPT-NEXT: srem
49 ; OPT-NEXT: ret
50 ; OPT: divrem.by.zero:
51 ; OPT-NEXT: call void @llvm.trap()
52 ; OPT-NEXT: unreachable
53 ; ARM: cmp r1, #0
54 ; ARM-NEXT: beq
55 ret i32 %rem1
56 ; ARM: f0 de fe e7
57 }
58
59 define i32 @myurem(i32 %x, i32 %y) #0 {
60 entry:
61 %rem1 = urem i32 %x, %y
62 ; OPT: %0 = icmp eq i32 %y, 0
63 ; OPT-NEXT: br i1 %0, label %divrem.by.zero, label %guarded.divrem
64 ; OPT: guarded.divrem:
65 ; OPT-NEXT: urem
66 ; OPT-NEXT: ret
67 ; OPT: divrem.by.zero:
68 ; OPT-NEXT: call void @llvm.trap()
69 ; OPT-NEXT: unreachable
70 ; ARM: cmp r1, #0
71 ; ARM-NEXT: beq
72 ret i32 %rem1
73 ; ARM: f0 de fe e7
74 }
75
76 ; Divides by non-zero constants should not be guarded.
77 define i32 @mysdiv_const(i32 %x) #0 {
78 entry:
79 %div1 = sdiv i32 %x, 10
80 ; OPT-NOT: icmp
81 ; OPT-NOT: br
82 ; OPT-NOT: guarded.divrem:
83 ; OPT-NOT: divrem.by.zero:
84 ; OPT-NOT: call void @llvm.trap()
85 ; OPT-NOT: unreachable
86 ; ARM-NOT: cmp r1, #0
87 ; ARM-NOT: f0 de fe e7
88 ret i32 %div1
89 }
90
91 ; Divides by explicit zero should prefixed by a trap.
92 define i32 @mysdiv_zero(i32 %x) #0 {
93 entry:
94 %div1 = sdiv i32 %x, 0
95 ; OPT-NOT: guarded.divrem:
96 ; OPT-NOT: divrem.by.zero:
97 ; OPT: call void @llvm.trap()
98 ; OPT-NEXT: sdiv
99 ; ARM-NOT: cmp r1, #0
100 ; ARM: f0 de fe e7
101 ret i32 %div1
102 }
103
104 attributes #0 = { nounwind }
OLDNEW
« no previous file with comments | « lib/Transforms/NaCl/InsertDivideCheck.cpp ('k') | test/NaCl/ARM/divrem-guards-complex.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698