[SandboxIR] Implement isVolatile() for LoadInst (#100717)
This commit is contained in:
@@ -65,6 +65,7 @@
|
||||
#define LLVM_SANDBOXIR_SANDBOXIR_H
|
||||
|
||||
#include "llvm/IR/Function.h"
|
||||
#include "llvm/IR/Instruction.h"
|
||||
#include "llvm/IR/IRBuilder.h"
|
||||
#include "llvm/IR/User.h"
|
||||
#include "llvm/IR/Value.h"
|
||||
@@ -758,6 +759,9 @@ class LoadInst final : public Instruction {
|
||||
}
|
||||
|
||||
public:
|
||||
/// Return true if this is a load from a volatile memory location.
|
||||
bool isVolatile() const { return cast<llvm::LoadInst>(Val)->isVolatile(); }
|
||||
|
||||
unsigned getUseOperandNo(const Use &Use) const final {
|
||||
return getUseOperandNoDefault(Use);
|
||||
}
|
||||
|
||||
@@ -738,6 +738,7 @@ TEST_F(SandboxIRTest, LoadInst) {
|
||||
parseIR(C, R"IR(
|
||||
define void @foo(ptr %arg0, ptr %arg1) {
|
||||
%ld = load i8, ptr %arg0, align 64
|
||||
%vld = load volatile i8, ptr %arg0, align 64
|
||||
ret void
|
||||
}
|
||||
)IR");
|
||||
@@ -749,8 +750,13 @@ define void @foo(ptr %arg0, ptr %arg1) {
|
||||
auto *BB = &*F->begin();
|
||||
auto It = BB->begin();
|
||||
auto *Ld = cast<sandboxir::LoadInst>(&*It++);
|
||||
auto *Vld = cast<sandboxir::LoadInst>(&*It++);
|
||||
auto *Ret = cast<sandboxir::ReturnInst>(&*It++);
|
||||
|
||||
// Check isVolatile()
|
||||
EXPECT_FALSE(Ld->isVolatile());
|
||||
// Check isVolatile()
|
||||
EXPECT_TRUE(Vld->isVolatile());
|
||||
// Check getPointerOperand()
|
||||
EXPECT_EQ(Ld->getPointerOperand(), Arg0);
|
||||
// Check getAlign()
|
||||
|
||||
Reference in New Issue
Block a user