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

via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 2 15:18:28 PDT 2024


================
@@ -708,3 +708,35 @@ define void @foo(i8 %arg0, i8 %arg1, i8 %arg2) {
   EXPECT_EQ(PHI->getIncomingBlock(1), BB1);
   EXPECT_EQ(PHI->getIncomingValue(1), Arg1);
 }
+
+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);
+  auto *BB = &*F->begin();
+  auto It = BB->begin();
+  auto *Load = cast<sandboxir::LoadInst>(&*It++);
+  auto *Store = cast<sandboxir::StoreInst>(&*It++);
+
+  EXPECT_FALSE(Load->isVolatile());
+  EXPECT_FALSE(Store->isVolatile());
----------------
vporpo wrote:

nit: I would move this line just before the Store checks at line 737.

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


More information about the llvm-commits mailing list