File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change 6565#define LLVM_SANDBOXIR_SANDBOXIR_H
6666
6767#include " llvm/IR/Function.h"
68+ #include " llvm/IR/Instruction.h"
6869#include " llvm/IR/IRBuilder.h"
6970#include " llvm/IR/User.h"
7071#include " llvm/IR/Value.h"
@@ -758,6 +759,9 @@ class LoadInst final : public Instruction {
758759 }
759760
760761public:
762+ // / Return true if this is a load from a volatile memory location.
763+ bool isVolatile () const { return cast<llvm::LoadInst>(Val)->isVolatile (); }
764+
761765 unsigned getUseOperandNo (const Use &Use) const final {
762766 return getUseOperandNoDefault (Use);
763767 }
Original file line number Diff line number Diff line change @@ -738,6 +738,7 @@ TEST_F(SandboxIRTest, LoadInst) {
738738 parseIR (C, R"IR(
739739define void @foo(ptr %arg0, ptr %arg1) {
740740 %ld = load i8, ptr %arg0, align 64
741+ %vld = load volatile i8, ptr %arg0, align 64
741742 ret void
742743}
743744)IR" );
@@ -749,8 +750,13 @@ define void @foo(ptr %arg0, ptr %arg1) {
749750 auto *BB = &*F->begin ();
750751 auto It = BB->begin ();
751752 auto *Ld = cast<sandboxir::LoadInst>(&*It++);
753+ auto *Vld = cast<sandboxir::LoadInst>(&*It++);
752754 auto *Ret = cast<sandboxir::ReturnInst>(&*It++);
753755
756+ // Check isVolatile()
757+ EXPECT_FALSE (Ld->isVolatile ());
758+ // Check isVolatile()
759+ EXPECT_TRUE (Vld->isVolatile ());
754760 // Check getPointerOperand()
755761 EXPECT_EQ (Ld->getPointerOperand (), Arg0);
756762 // Check getAlign()
You can’t perform that action at this time.
0 commit comments