[llvm] [IR] Make UnaryInstruction::classof recognize FreezeInst. (PR #107944)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 9 18:17:42 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-ir
Author: Jorge Gorbe Moya (slackito)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/107944.diff
2 Files Affected:
- (modified) llvm/include/llvm/IR/InstrTypes.h (+1)
- (modified) llvm/unittests/IR/InstructionsTest.cpp (+14)
``````````diff
diff --git a/llvm/include/llvm/IR/InstrTypes.h b/llvm/include/llvm/IR/InstrTypes.h
index 6fddedd86e97b8..4cbf0d2106eeb6 100644
--- a/llvm/include/llvm/IR/InstrTypes.h
+++ b/llvm/include/llvm/IR/InstrTypes.h
@@ -85,6 +85,7 @@ class UnaryInstruction : public Instruction {
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"(
``````````
</details>
https://github.com/llvm/llvm-project/pull/107944
More information about the llvm-commits
mailing list