[llvm] 094e6b8 - [IR] Make UnaryInstruction::classof recognize FreezeInst. (#107944)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 9 21:01:48 PDT 2024
Author: Jorge Gorbe Moya
Date: 2024-09-09T21:01:44-07:00
New Revision: 094e6b82766a4a3fbe75bd116fd01174518528c3
URL: https://github.com/llvm/llvm-project/commit/094e6b82766a4a3fbe75bd116fd01174518528c3
DIFF: https://github.com/llvm/llvm-project/commit/094e6b82766a4a3fbe75bd116fd01174518528c3.diff
LOG: [IR] Make UnaryInstruction::classof recognize FreezeInst. (#107944)
Added:
Modified:
llvm/include/llvm/IR/InstrTypes.h
llvm/unittests/IR/InstructionsTest.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/InstrTypes.h b/llvm/include/llvm/IR/InstrTypes.h
index 6fddedd86e97b8..5ed3ec46dce57d 100644
--- a/llvm/include/llvm/IR/InstrTypes.h
+++ b/llvm/include/llvm/IR/InstrTypes.h
@@ -80,11 +80,11 @@ class UnaryInstruction : public Instruction {
// Methods for support type inquiry through isa, cast, and dyn_cast:
static bool classof(const Instruction *I) {
- return I->isUnaryOp() ||
- I->getOpcode() == Instruction::Alloca ||
+ return I->isUnaryOp() || I->getOpcode() == Instruction::Alloca ||
I->getOpcode() == Instruction::Load ||
I->getOpcode() == Instruction::VAArg ||
I->getOpcode() == Instruction::ExtractValue ||
+ I->getOpcode() == Instruction::Freeze ||
(I->getOpcode() >= CastOpsBegin && I->getOpcode() < CastOpsEnd);
}
static bool classof(const Value *V) {
diff --git a/llvm/unittests/IR/InstructionsTest.cpp b/llvm/unittests/IR/InstructionsTest.cpp
index 529edc88ebc331..97a5c0a39800b8 100644
--- a/llvm/unittests/IR/InstructionsTest.cpp
+++ b/llvm/unittests/IR/InstructionsTest.cpp
@@ -1733,6 +1733,20 @@ TEST(InstructionsTest, BranchWeightOverflow) {
ASSERT_EQ(ProfWeight, UINT32_MAX);
}
+TEST(InstructionsTest, FreezeInst) {
+ LLVMContext C;
+ std::unique_ptr<Module> M = parseIR(C,
+ R"(
+ define void @foo(i8 %arg) {
+ freeze i8 %arg
+ ret void
+ }
+ )");
+ ASSERT_TRUE(M);
+ Value *FI = &M->getFunction("foo")->getEntryBlock().front();
+ EXPECT_TRUE(isa<UnaryInstruction>(FI));
+}
+
TEST(InstructionsTest, AllocaInst) {
LLVMContext Ctx;
std::unique_ptr<Module> M = parseIR(Ctx, R"(
More information about the llvm-commits
mailing list