Skip to content

Commit 094e6b8

Browse files
authored
[IR] Make UnaryInstruction::classof recognize FreezeInst. (#107944)
1 parent 7034ec4 commit 094e6b8

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

llvm/include/llvm/IR/InstrTypes.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ class UnaryInstruction : public Instruction {
8080

8181
// Methods for support type inquiry through isa, cast, and dyn_cast:
8282
static bool classof(const Instruction *I) {
83-
return I->isUnaryOp() ||
84-
I->getOpcode() == Instruction::Alloca ||
83+
return I->isUnaryOp() || I->getOpcode() == Instruction::Alloca ||
8584
I->getOpcode() == Instruction::Load ||
8685
I->getOpcode() == Instruction::VAArg ||
8786
I->getOpcode() == Instruction::ExtractValue ||
87+
I->getOpcode() == Instruction::Freeze ||
8888
(I->getOpcode() >= CastOpsBegin && I->getOpcode() < CastOpsEnd);
8989
}
9090
static bool classof(const Value *V) {

llvm/unittests/IR/InstructionsTest.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1733,6 +1733,20 @@ TEST(InstructionsTest, BranchWeightOverflow) {
17331733
ASSERT_EQ(ProfWeight, UINT32_MAX);
17341734
}
17351735

1736+
TEST(InstructionsTest, FreezeInst) {
1737+
LLVMContext C;
1738+
std::unique_ptr<Module> M = parseIR(C,
1739+
R"(
1740+
define void @foo(i8 %arg) {
1741+
freeze i8 %arg
1742+
ret void
1743+
}
1744+
)");
1745+
ASSERT_TRUE(M);
1746+
Value *FI = &M->getFunction("foo")->getEntryBlock().front();
1747+
EXPECT_TRUE(isa<UnaryInstruction>(FI));
1748+
}
1749+
17361750
TEST(InstructionsTest, AllocaInst) {
17371751
LLVMContext Ctx;
17381752
std::unique_ptr<Module> M = parseIR(Ctx, R"(

0 commit comments

Comments
 (0)