[llvm] [SandboxIR] Added setVolatile member function to LoadInst and StoreInst (PR #101284)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 31 18:44:45 PDT 2024
================
@@ -160,6 +160,33 @@ void CallBrInstSetIndirectDest::dump() const {
}
#endif
+SetVolatile::SetVolatile(Instruction *I, Tracker &Tracker)
+ : IRChangeBase(Tracker) {
+ if (auto *Load = dyn_cast<LoadInst>(I)) {
+ WasVolatile = Load->isVolatile();
+ StoreOrLoad = Load;
+ } else if (auto *Store = dyn_cast<StoreInst>(I)) {
+ WasVolatile = Store->isVolatile();
+ StoreOrLoad = Store;
+ } else {
+ llvm_unreachable("Expected LoadInst or StoreInst");
+ }
+}
+
+void SetVolatile::revert() {
+ if (auto *Load = StoreOrLoad.dyn_cast<LoadInst *>()) {
+ Load->setVolatile(WasVolatile);
+ } else if (auto *Store = StoreOrLoad.dyn_cast<StoreInst *>()) {
+ Store->setVolatile(WasVolatile);
+ }
----------------
vporpo wrote:
nit: just like in `SetVolatile`s constructor please add:
```
} else {
llvm_unreachable("Expected LoadInst or StoreInst");
}
```
https://github.com/llvm/llvm-project/pull/101284
More information about the llvm-commits
mailing list