1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -basicaa -newgvn -S | FileCheck %s
3 ;; Now that we do store refinement, we have to verify that we add fake uses
4 ;; when we skip existing stores.
5 ;; We also are testing that various variations that cause stores to move classes
6 ;; have the right class movement happen
7 ;; All of these tests result in verification failures if it does not.
10 define void @spam(i32 *%a) {
13 ; CHECK-NEXT: [[FOO:%.*]] = bitcast i32* [[A:%.*]] to %struct.eggs**
14 ; CHECK-NEXT: store %struct.eggs* null, %struct.eggs** [[FOO]]
15 ; CHECK-NEXT: br label [[BB1:%.*]]
17 ; CHECK-NEXT: br i1 undef, label [[BB3:%.*]], label [[BB2:%.*]]
19 ; CHECK-NEXT: call void @baz()
20 ; CHECK-NEXT: br label [[BB1]]
22 ; CHECK-NEXT: store i32 0, i32* undef
23 ; CHECK-NEXT: store %struct.eggs* null, %struct.eggs** [[FOO]]
24 ; CHECK-NEXT: unreachable
27 %foo = bitcast i32 *%a to %struct.eggs**
28 store %struct.eggs* null, %struct.eggs** %foo
31 bb1: ; preds = %bb2, %bb
32 br i1 undef, label %bb3, label %bb2
39 store i32 0, i32* undef
40 ;; This store is defined by a memoryphi of the call and the first store
41 ;; At first, we will prove it equivalent to the first store above.
42 ;; Then the call will become reachable, and the equivalence will be removed
43 ;; Without it being a use of the first store, we will not update the store
45 store %struct.eggs* null, %struct.eggs** %foo
55 ; CHECK-NEXT: br label [[C:%.*]]
57 ; CHECK-NEXT: store i64 undef, i64* null
58 ; CHECK-NEXT: br label [[E:%.*]]
60 ; CHECK-NEXT: [[G:%.*]] = load i64*, i64** null
61 ; CHECK-NEXT: store i64* undef, i64** null
62 ; CHECK-NEXT: br i1 undef, label [[C]], label [[E]]
68 %d = phi i64* [ undef, %b ], [ null, %e ]
69 store i64 undef, i64* %d
73 ;; The memory for this load starts out equivalent to just the store in c, we later discover the store after us, and
74 ;; need to make sure the right set of values get marked as changed after memory leaders change
75 %g = load i64*, i64** null
76 %0 = bitcast i64* %g to i64*
77 store i64* undef, i64** null
78 br i1 undef, label %c, label %e
81 ; ModuleID = 'bugpoint-reduced-simplified.bc'
82 source_filename = "bugpoint-output-daef094.bc"
83 target triple = "x86_64-apple-darwin16.5.0"
85 %struct.hoge = type {}
87 define void @widget(%struct.hoge* %arg) {
88 ; CHECK-LABEL: @widget(
90 ; CHECK-NEXT: br label [[BB1:%.*]]
92 ; CHECK-NEXT: [[TMP:%.*]] = phi %struct.hoge* [ [[ARG:%.*]], [[BB:%.*]] ], [ null, [[BB1]] ]
93 ; CHECK-NEXT: store %struct.hoge* [[TMP]], %struct.hoge** undef
94 ; CHECK-NEXT: br i1 undef, label [[BB1]], label [[BB2:%.*]]
96 ; CHECK-NEXT: [[TMP3:%.*]] = phi i64 [ [[TMP8:%.*]], [[BB7:%.*]] ], [ 0, [[BB1]] ]
97 ; CHECK-NEXT: [[TMP4:%.*]] = icmp eq i64 [[TMP3]], 0
98 ; CHECK-NEXT: br i1 [[TMP4]], label [[BB7]], label [[BB5:%.*]]
100 ; CHECK-NEXT: [[TMP6:%.*]] = load i64, i64* null
101 ; CHECK-NEXT: call void @quux()
102 ; CHECK-NEXT: store i64 [[TMP6]], i64* undef
103 ; CHECK-NEXT: br label [[BB7]]
105 ; CHECK-NEXT: [[TMP8]] = add i64 [[TMP3]], 1
106 ; CHECK-NEXT: br label [[BB2]]
111 bb1: ; preds = %bb1, %bb
112 %tmp = phi %struct.hoge* [ %arg, %bb ], [ null, %bb1 ]
113 store %struct.hoge* %tmp, %struct.hoge** undef
114 br i1 undef, label %bb1, label %bb2
116 bb2: ; preds = %bb7, %bb1
117 %tmp3 = phi i64 [ %tmp8, %bb7 ], [ 0, %bb1 ]
118 %tmp4 = icmp eq i64 %tmp3, 0
119 br i1 %tmp4, label %bb7, label %bb5
122 ;; Originally thought equal to the store that comes after it until the phi edges
123 ;; are completely traversed
124 %tmp6 = load i64, i64* null
126 store i64 %tmp6, i64* undef
129 bb7: ; preds = %bb5, %bb2
130 %tmp8 = add i64 %tmp3, 1
135 ; ModuleID = 'short.ll'
136 source_filename = "short.ll"
142 ; CHECK-NEXT: [[C:%.*]] = alloca [[STRUCT_A:%.*]]
143 ; CHECK-NEXT: br label [[D:%.*]]
145 ; CHECK-NEXT: unreachable
147 ; CHECK-NEXT: [[G:%.*]] = bitcast %struct.a* [[C]] to i8*
148 ; CHECK-NEXT: [[F:%.*]] = bitcast i8* [[G]] to i32*
149 ; CHECK-NEXT: [[E:%.*]] = load i32, i32* [[F]]
150 ; CHECK-NEXT: br i1 undef, label [[I:%.*]], label [[J:%.*]]
152 ; CHECK-NEXT: br i1 undef, label [[K:%.*]], label [[M:%.*]]
154 ; CHECK-NEXT: br label [[L:%.*]]
156 ; CHECK-NEXT: unreachable
158 ; CHECK-NEXT: br label [[M]]
160 %c = alloca %struct.a
164 store i32 %e, i32* %f
168 %g = bitcast %struct.a* %c to i8*
169 %h = getelementptr i8, i8* %g
170 %f = bitcast i8* %h to i32*
171 %e = load i32, i32* %f
172 br i1 undef, label %i, label %j
175 br i1 undef, label %k, label %m
181 %n = phi i32 [ %e, %k ]
182 ;; Becomes equal and then not equal to the other store, and
183 ;; along the way, the load.
184 store i32 %n, i32* %f