[llvm] [IR] Make UnaryInstruction::classof recognize FreezeInst. (PR #107944)
Jorge Gorbe Moya via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 9 18:17:12 PDT 2024
https://github.com/slackito created https://github.com/llvm/llvm-project/pull/107944
None
>From 93dfac98c544be97b0c2101a6768fc3fb54e2c5c Mon Sep 17 00:00:00 2001
From: Jorge Gorbe Moya <jgorbe at google.com>
Date: Mon, 9 Sep 2024 17:59:08 -0700
Subject: [PATCH] [IR] Make UnaryInstruction::classof recognize FreezeInst.
---
llvm/include/llvm/IR/InstrTypes.h | 1 +
llvm/unittests/IR/InstructionsTest.cpp | 14 ++++++++++++++
2 files changed, 15 insertions(+)
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"(
More information about the llvm-commits
mailing list