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 65
65
#define LLVM_SANDBOXIR_SANDBOXIR_H
66
66
67
67
#include " llvm/IR/Function.h"
68
+ #include " llvm/IR/Instruction.h"
68
69
#include " llvm/IR/IRBuilder.h"
69
70
#include " llvm/IR/User.h"
70
71
#include " llvm/IR/Value.h"
@@ -758,6 +759,9 @@ class LoadInst final : public Instruction {
758
759
}
759
760
760
761
public:
762
+ // / Return true if this is a load from a volatile memory location.
763
+ bool isVolatile () const { return cast<llvm::LoadInst>(Val)->isVolatile (); }
764
+
761
765
unsigned getUseOperandNo (const Use &Use) const final {
762
766
return getUseOperandNoDefault (Use);
763
767
}
Original file line number Diff line number Diff line change @@ -738,6 +738,7 @@ TEST_F(SandboxIRTest, LoadInst) {
738
738
parseIR (C, R"IR(
739
739
define void @foo(ptr %arg0, ptr %arg1) {
740
740
%ld = load i8, ptr %arg0, align 64
741
+ %vld = load volatile i8, ptr %arg0, align 64
741
742
ret void
742
743
}
743
744
)IR" );
@@ -749,8 +750,13 @@ define void @foo(ptr %arg0, ptr %arg1) {
749
750
auto *BB = &*F->begin ();
750
751
auto It = BB->begin ();
751
752
auto *Ld = cast<sandboxir::LoadInst>(&*It++);
753
+ auto *Vld = cast<sandboxir::LoadInst>(&*It++);
752
754
auto *Ret = cast<sandboxir::ReturnInst>(&*It++);
753
755
756
+ // Check isVolatile()
757
+ EXPECT_FALSE (Ld->isVolatile ());
758
+ // Check isVolatile()
759
+ EXPECT_TRUE (Vld->isVolatile ());
754
760
// Check getPointerOperand()
755
761
EXPECT_EQ (Ld->getPointerOperand (), Arg0);
756
762
// Check getAlign()
You can’t perform that action at this time.
0 commit comments