[llvm] [SandboxIR] Added setVolatile member function to LoadInst and StoreInst (PR #101284)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 31 08:50:39 PDT 2024
================
@@ -160,6 +160,34 @@ void CallBrInstSetIndirectDest::dump() const {
}
#endif
+SetVolatile::SetVolatile(Instruction *I, bool WasBool, Tracker &Tracker)
+ : IRChangeBase(Tracker), Inst(I) {
+ if (auto *Load = cast<llvm::LoadInst>(Inst)) {
+ WasVolatile = Load->isVolatile();
+ InstUnion = Load;
+ }
+ if (auto *Store = cast<llvm::StoreInst>(Inst)) {
+ WasVolatile = Store->isVolatile();
+ InstUnion = Store;
+ }
+}
+
+void SetVolatile::revert() {
+ if (llvm::LoadInst *Load = InstUnion.dyn_cast<llvm::LoadInst *>()) {
----------------
vporpo wrote:
InstUnion contains sandboxir::LoadInst or sandboxir::StoreInst, so this should be:
```
if (LoadInst *Load = InstUnion.dyn_cast<LoadInst>())
Load->setVolatile(WasVolatile);
else if (StoreInst *Store = InstUnion.dyn_cast<StoreInst>())
Store->setVolatile(SetVolatile);
else
llvm_unreachable("Expected LoadInst or StoreInst");
```
https://github.com/llvm/llvm-project/pull/101284
More information about the llvm-commits
mailing list