[llvm] 906ffc4 - [SandboxIR][NFC] Move Utils test to proper file (#110763)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 2 13:21:22 PDT 2024
Author: Sterling-Augustine
Date: 2024-10-02T13:21:19-07:00
New Revision: 906ffc4b4a4444c69a759c2c19b3cf5da1cf6e1f
URL: https://github.com/llvm/llvm-project/commit/906ffc4b4a4444c69a759c2c19b3cf5da1cf6e1f
DIFF: https://github.com/llvm/llvm-project/commit/906ffc4b4a4444c69a759c2c19b3cf5da1cf6e1f.diff
LOG: [SandboxIR][NFC] Move Utils test to proper file (#110763)
Added:
Modified:
llvm/unittests/SandboxIR/SandboxIRTest.cpp
llvm/unittests/SandboxIR/UtilsTest.cpp
Removed:
################################################################################
diff --git a/llvm/unittests/SandboxIR/SandboxIRTest.cpp b/llvm/unittests/SandboxIR/SandboxIRTest.cpp
index 0ab0eb6a434d8f..06c6e05ee6aae7 100644
--- a/llvm/unittests/SandboxIR/SandboxIRTest.cpp
+++ b/llvm/unittests/SandboxIR/SandboxIRTest.cpp
@@ -1470,48 +1470,6 @@ define i32 @foo(i32 %arg0, i32 %arg1) {
EXPECT_EQ(Glob0->getOperand(0), Glob1);
}
-TEST_F(SandboxIRTest, GetExpected) {
- parseIR(C, R"IR(
-define float @foo(float %v, ptr %ptr) {
- %add = fadd float %v, %v
- store float %v, ptr %ptr
- ret float %v
-}
-define void @bar(float %v, ptr %ptr) {
- ret void
-}
-)IR");
- llvm::Function &Foo = *M->getFunction("foo");
- sandboxir::Context Ctx(C);
-
- Ctx.createFunction(&Foo);
- auto *FooBB = cast<sandboxir::BasicBlock>(Ctx.getValue(&*Foo.begin()));
- auto FooIt = FooBB->begin();
- auto Add = cast<sandboxir::Instruction>(&*FooIt++);
- auto *S0 = cast<sandboxir::Instruction>(&*FooIt++);
- auto *RetF = cast<sandboxir::Instruction>(&*FooIt++);
- // getExpectedValue
- EXPECT_EQ(sandboxir::Utils::getExpectedValue(Add), Add);
- EXPECT_EQ(sandboxir::Utils::getExpectedValue(S0),
- cast<sandboxir::StoreInst>(S0)->getValueOperand());
- EXPECT_EQ(sandboxir::Utils::getExpectedValue(RetF),
- cast<sandboxir::ReturnInst>(RetF)->getReturnValue());
- // getExpectedType
- EXPECT_EQ(sandboxir::Utils::getExpectedType(Add), Add->getType());
- EXPECT_EQ(sandboxir::Utils::getExpectedType(S0),
- cast<sandboxir::StoreInst>(S0)->getValueOperand()->getType());
- EXPECT_EQ(sandboxir::Utils::getExpectedType(RetF),
- cast<sandboxir::ReturnInst>(RetF)->getReturnValue()->getType());
-
- // getExpectedValue for void returns
- llvm::Function &Bar = *M->getFunction("bar");
- Ctx.createFunction(&Bar);
- auto *BarBB = cast<sandboxir::BasicBlock>(Ctx.getValue(&*Bar.begin()));
- auto BarIt = BarBB->begin();
- auto *RetV = cast<sandboxir::Instruction>(&*BarIt++);
- EXPECT_EQ(sandboxir::Utils::getExpectedValue(RetV), nullptr);
-}
-
TEST_F(SandboxIRTest, RAUW_RUWIf) {
parseIR(C, R"IR(
define void @foo(ptr %ptr) {
diff --git a/llvm/unittests/SandboxIR/UtilsTest.cpp b/llvm/unittests/SandboxIR/UtilsTest.cpp
index 16eb1aead34668..41317e4ab46684 100644
--- a/llvm/unittests/SandboxIR/UtilsTest.cpp
+++ b/llvm/unittests/SandboxIR/UtilsTest.cpp
@@ -136,6 +136,48 @@ define void @foo(ptr %ptr) {
EXPECT_FALSE(sandboxir::Utils::atLowerAddress(L3, V3L3, SE, DL));
}
+TEST_F(UtilsTest, GetExpected) {
+ parseIR(C, R"IR(
+define float @foo(float %v, ptr %ptr) {
+ %add = fadd float %v, %v
+ store float %v, ptr %ptr
+ ret float %v
+}
+define void @bar(float %v, ptr %ptr) {
+ ret void
+}
+)IR");
+ llvm::Function &Foo = *M->getFunction("foo");
+ sandboxir::Context Ctx(C);
+
+ Ctx.createFunction(&Foo);
+ auto *FooBB = cast<sandboxir::BasicBlock>(Ctx.getValue(&*Foo.begin()));
+ auto FooIt = FooBB->begin();
+ auto Add = cast<sandboxir::Instruction>(&*FooIt++);
+ auto *S0 = cast<sandboxir::Instruction>(&*FooIt++);
+ auto *RetF = cast<sandboxir::Instruction>(&*FooIt++);
+ // getExpectedValue
+ EXPECT_EQ(sandboxir::Utils::getExpectedValue(Add), Add);
+ EXPECT_EQ(sandboxir::Utils::getExpectedValue(S0),
+ cast<sandboxir::StoreInst>(S0)->getValueOperand());
+ EXPECT_EQ(sandboxir::Utils::getExpectedValue(RetF),
+ cast<sandboxir::ReturnInst>(RetF)->getReturnValue());
+ // getExpectedType
+ EXPECT_EQ(sandboxir::Utils::getExpectedType(Add), Add->getType());
+ EXPECT_EQ(sandboxir::Utils::getExpectedType(S0),
+ cast<sandboxir::StoreInst>(S0)->getValueOperand()->getType());
+ EXPECT_EQ(sandboxir::Utils::getExpectedType(RetF),
+ cast<sandboxir::ReturnInst>(RetF)->getReturnValue()->getType());
+
+ // getExpectedValue for void returns
+ llvm::Function &Bar = *M->getFunction("bar");
+ Ctx.createFunction(&Bar);
+ auto *BarBB = cast<sandboxir::BasicBlock>(Ctx.getValue(&*Bar.begin()));
+ auto BarIt = BarBB->begin();
+ auto *RetV = cast<sandboxir::Instruction>(&*BarIt++);
+ EXPECT_EQ(sandboxir::Utils::getExpectedValue(RetV), nullptr);
+}
+
TEST_F(UtilsTest, GetNumBits) {
parseIR(C, R"IR(
define void @foo(float %arg0, double %arg1, i8 %arg2, i64 %arg3, ptr %arg4) {
More information about the llvm-commits
mailing list