• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -simplifycfg -S | FileCheck %s
2; PR2967
3
4target datalayout =
5"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32"
6target triple = "i386-pc-linux-gnu"
7
8define void @test1(i32 %x) nounwind {
9entry:
10        %0 = icmp eq i32 %x, 0          ; <i1> [#uses=1]
11        br i1 %0, label %bb, label %return
12
13bb:             ; preds = %entry
14        %1 = load volatile i32, i32* null
15        unreachable
16
17        br label %return
18return:         ; preds = %entry
19        ret void
20; CHECK-LABEL: @test1(
21; CHECK: load volatile
22}
23
24define void @test1_no_null_opt(i32 %x) nounwind #0 {
25entry:
26        %0 = icmp eq i32 %x, 0          ; <i1> [#uses=1]
27        br i1 %0, label %bb, label %return
28
29bb:             ; preds = %entry
30        %1 = load volatile i32, i32* null
31        unreachable
32
33        br label %return
34return:         ; preds = %entry
35        ret void
36; CHECK-LABEL: @test1_no_null_opt(
37; CHECK: load volatile
38; CHECK: unreachable
39}
40
41; rdar://7958343
42define void @test2() nounwind {
43entry:
44        store i32 4,i32* null
45        ret void
46
47; CHECK-LABEL: @test2(
48; CHECK: call void @llvm.trap
49; CHECK: unreachable
50}
51
52define void @test2_no_null_opt() nounwind #0 {
53entry:
54        store i32 4,i32* null
55        ret void
56; CHECK-LABEL: @test2_no_null_opt(
57; CHECK: store i32 4, i32* null
58; CHECK-NOT: call void @llvm.trap
59; CHECK: ret
60}
61
62; PR7369
63define void @test3() nounwind {
64entry:
65        store volatile i32 4, i32* null
66        ret void
67
68; CHECK-LABEL: @test3(
69; CHECK: store volatile i32 4, i32* null
70; CHECK: ret
71}
72
73define void @test3_no_null_opt() nounwind #0 {
74entry:
75        store volatile i32 4, i32* null
76        ret void
77
78; CHECK-LABEL: @test3_no_null_opt(
79; CHECK: store volatile i32 4, i32* null
80; CHECK: ret
81}
82
83; Check store before unreachable.
84define void @test4(i1 %C, i32* %P) {
85; CHECK-LABEL: @test4(
86; CHECK: entry:
87; CHECK-NEXT: br i1 %C
88entry:
89  br i1 %C, label %T, label %F
90T:
91  store volatile i32 0, i32* %P
92  unreachable
93F:
94  ret void
95}
96
97; Check cmpxchg before unreachable.
98define void @test5(i1 %C, i32* %P) {
99; CHECK-LABEL: @test5(
100; CHECK: entry:
101; CHECK-NEXT: br i1 %C
102entry:
103  br i1 %C, label %T, label %F
104T:
105  cmpxchg volatile i32* %P, i32 0, i32 1 seq_cst seq_cst
106  unreachable
107F:
108  ret void
109}
110
111; Check atomicrmw before unreachable.
112define void @test6(i1 %C, i32* %P) {
113; CHECK-LABEL: @test6(
114; CHECK: entry:
115; CHECK-NEXT: br i1 %C
116entry:
117  br i1 %C, label %T, label %F
118T:
119  atomicrmw volatile xchg i32* %P, i32 0 seq_cst
120  unreachable
121F:
122  ret void
123}
124
125attributes #0 = { "null-pointer-is-valid"="true" }
126