[llvm] [SandboxIR] Added setVolatile member function to LoadInst and StoreInst (PR #101284)

via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 31 13:46:34 PDT 2024


================
@@ -584,3 +584,38 @@ define void @foo(i8 %arg) {
   Ctx.revert();
   EXPECT_EQ(CallBr->getIndirectDest(0), OrigIndirectDest);
 }
+
+TEST_F(TrackerTest, SetVolatile) {
+  parseIR(C, R"IR(
+define void @foo(ptr %arg0, i8 %val) {
+  %ld = load i8, ptr %arg0, align 64
+  store i8 %val, ptr %arg0, align 64 
+  ret void
+}
+)IR");
+  Function &LLVMF = *M->getFunction("foo");
+  sandboxir::Context Ctx(C);
+
+  auto *F = Ctx.createFunction(&LLVMF);
+  unsigned ArgIdx = 0;
+  [[maybe_unused]] auto *Arg0 = F->getArg(ArgIdx++);
+  [[maybe_unused]] auto *Val = F->getArg(ArgIdx++);
+  auto *BB = &*F->begin();
+  auto It = BB->begin();
+  auto *Load = cast<sandboxir::LoadInst>(&*It++);
+  auto *Store = cast<sandboxir::StoreInst>(&*It++);
+  [[maybe_unused]] auto *Ret = cast<sandboxir::ReturnInst>(&*It++);
+
+  // Check setVolatile()
+  Ctx.save();
----------------
vporpo wrote:

nit: Add a check before we setVolatile to make sure Load is not volatile: `EXPECT_FALSE(Load->isVolatile())`

https://github.com/llvm/llvm-project/pull/101284


More information about the llvm-commits mailing list