@@ -145,6 +145,47 @@ define void @foo(ptr %ptr, i8 %v0, i8 %v1) {
145
145
testing::ElementsAre (SN0, SN1));
146
146
}
147
147
148
+ // Check that when we erase a DAG node its SchedBundle gets updated.
149
+ TEST_F (SchedulerTest, SchedBundleEraseDGNode) {
150
+ parseIR (C, R"IR(
151
+ define void @foo(ptr %ptr, i8 %v0, i8 %v1, i8 %v2, i8 %v3) {
152
+ store i8 %v0, ptr %ptr
153
+ store i8 %v1, ptr %ptr
154
+ store i8 %v2, ptr %ptr
155
+ store i8 %v3, ptr %ptr
156
+ ret void
157
+ }
158
+ )IR" );
159
+ llvm::Function *LLVMF = &*M->getFunction (" foo" );
160
+ sandboxir::Context Ctx (C);
161
+ auto *F = Ctx.createFunction (LLVMF);
162
+ auto *BB = &*F->begin ();
163
+ auto It = BB->begin ();
164
+ auto *S0 = cast<sandboxir::StoreInst>(&*It++);
165
+ auto *S1 = cast<sandboxir::StoreInst>(&*It++);
166
+ auto *S2 = cast<sandboxir::StoreInst>(&*It++);
167
+ auto *S3 = cast<sandboxir::StoreInst>(&*It++);
168
+
169
+ sandboxir::DependencyGraph DAG (getAA (*LLVMF), Ctx);
170
+ DAG.extend ({&*BB->begin (), BB->getTerminator ()});
171
+ auto *SN0 = DAG.getNode (S0);
172
+ auto *SN1 = DAG.getNode (S1);
173
+ auto *SN2 = DAG.getNode (S2);
174
+ auto *SN3 = DAG.getNode (S3);
175
+ {
176
+ // Check the common case, when the bundle contains unique nodes.
177
+ sandboxir::SchedBundle Bndl ({SN0, SN1});
178
+ S0->eraseFromParent ();
179
+ EXPECT_THAT (Bndl, testing::ElementsAre (SN1));
180
+ }
181
+ {
182
+ // Check corner case when the node appears more than once.
183
+ sandboxir::SchedBundle Bndl ({SN2, SN3, SN2});
184
+ S2->eraseFromParent ();
185
+ EXPECT_THAT (Bndl, testing::ElementsAre (SN3));
186
+ }
187
+ }
188
+
148
189
TEST_F (SchedulerTest, Basic) {
149
190
parseIR (C, R"IR(
150
191
define void @foo(ptr %ptr, i8 %v0, i8 %v1) {
0 commit comments