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

Julius Alexandre via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 31 18:03:36 PDT 2024


================
@@ -160,26 +160,28 @@ void CallBrInstSetIndirectDest::dump() const {
 }
 #endif
 
-SetVolatile::SetVolatile(Instruction *I, bool WasBool, Tracker &Tracker)
-    : IRChangeBase(Tracker), Inst(I) {
-  if (auto *Load = cast<llvm::LoadInst>(Inst)) {
+SetVolatile::SetVolatile(Instruction *I, Tracker &Tracker)
+    : IRChangeBase(Tracker) {
+  if (auto *Load = cast<llvm::LoadInst>(I)) {
     WasVolatile = Load->isVolatile();
     InstUnion = Load;
-  }
-  if (auto *Store = cast<llvm::StoreInst>(Inst)) {
+    assert(Load && "This isn't a LoadInst");
+  } else if (auto *Store = cast<llvm::StoreInst>(I)) {
     WasVolatile = Store->isVolatile();
     InstUnion = Store;
+    assert(StoreInst && "This isn't a StoreInst");
+  } else {
+    llvm_unreachable("Expected LoadInst or StoreInst");
   }
 }
 
 void SetVolatile::revert() {
-  if (llvm::LoadInst *Load = InstUnion.dyn_cast<llvm::LoadInst *>()) {
-    // It's a LoadInst
+  if (llvm::LoadInst *Load = InstUnion.dyn_cast<llvm::LoadInst *>())
     Load->setVolatile(WasVolatile);
-  } else if (llvm::StoreInst *Store = InstUnion.dyn_cast<llvm::StoreInst *>()) {
-    // It's a StoreInst
+  else if (llvm::StoreInst *Store = InstUnion.dyn_cast<llvm::StoreInst *>())
----------------
medievalghoul wrote:

Fixed.

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


More information about the llvm-commits mailing list