[llvm] [SandboxIR][Tracker] Track Instruction::moveBefore() (PR #99568)
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 18 15:09:35 PDT 2024
================
@@ -255,3 +255,116 @@ define i32 @foo(i32 %arg) {
EXPECT_EQ(&*It++, Ret);
EXPECT_EQ(It, BB->end());
}
+
+// TODO: Test multi-instruction patterns.
+TEST_F(TrackerTest, MoveInstr) {
+ parseIR(C, R"IR(
+define i32 @foo(i32 %arg) {
+ %add0 = add i32 %arg, %arg
+ %add1 = add i32 %add0, %arg
+ ret i32 %add1
+}
+)IR");
+ Function &LLVMF = *M->getFunction("foo");
+ sandboxir::Context Ctx(C);
+
+ auto *F = Ctx.createFunction(&LLVMF);
+ auto *BB = &*F->begin();
+ auto It = BB->begin();
+ sandboxir::Instruction *Add0 = &*It++;
+ sandboxir::Instruction *Add1 = &*It++;
+ sandboxir::Instruction *Ret = &*It++;
+
+ // Check moveBefore(Instruction *) with tracking enabled.
+ Ctx.save();
+ Add1->moveBefore(Add0);
+ It = BB->begin();
+ EXPECT_EQ(&*It++, Add1);
+ EXPECT_EQ(&*It++, Add0);
+ EXPECT_EQ(&*It++, Ret);
+ EXPECT_EQ(It, BB->end());
+ // Check revert().
----------------
aeubanks wrote:
nit: this comment is inconsistently applied
https://github.com/llvm/llvm-project/pull/99568
More information about the llvm-commits
mailing list