Skip to content

Commit 906ffc4

Browse files
[SandboxIR][NFC] Move Utils test to proper file (llvm#110763)
1 parent 0f512d1 commit 906ffc4

File tree

2 files changed

+42
-42
lines changed

2 files changed

+42
-42
lines changed

llvm/unittests/SandboxIR/SandboxIRTest.cpp

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,48 +1470,6 @@ define i32 @foo(i32 %arg0, i32 %arg1) {
14701470
EXPECT_EQ(Glob0->getOperand(0), Glob1);
14711471
}
14721472

1473-
TEST_F(SandboxIRTest, GetExpected) {
1474-
parseIR(C, R"IR(
1475-
define float @foo(float %v, ptr %ptr) {
1476-
%add = fadd float %v, %v
1477-
store float %v, ptr %ptr
1478-
ret float %v
1479-
}
1480-
define void @bar(float %v, ptr %ptr) {
1481-
ret void
1482-
}
1483-
)IR");
1484-
llvm::Function &Foo = *M->getFunction("foo");
1485-
sandboxir::Context Ctx(C);
1486-
1487-
Ctx.createFunction(&Foo);
1488-
auto *FooBB = cast<sandboxir::BasicBlock>(Ctx.getValue(&*Foo.begin()));
1489-
auto FooIt = FooBB->begin();
1490-
auto Add = cast<sandboxir::Instruction>(&*FooIt++);
1491-
auto *S0 = cast<sandboxir::Instruction>(&*FooIt++);
1492-
auto *RetF = cast<sandboxir::Instruction>(&*FooIt++);
1493-
// getExpectedValue
1494-
EXPECT_EQ(sandboxir::Utils::getExpectedValue(Add), Add);
1495-
EXPECT_EQ(sandboxir::Utils::getExpectedValue(S0),
1496-
cast<sandboxir::StoreInst>(S0)->getValueOperand());
1497-
EXPECT_EQ(sandboxir::Utils::getExpectedValue(RetF),
1498-
cast<sandboxir::ReturnInst>(RetF)->getReturnValue());
1499-
// getExpectedType
1500-
EXPECT_EQ(sandboxir::Utils::getExpectedType(Add), Add->getType());
1501-
EXPECT_EQ(sandboxir::Utils::getExpectedType(S0),
1502-
cast<sandboxir::StoreInst>(S0)->getValueOperand()->getType());
1503-
EXPECT_EQ(sandboxir::Utils::getExpectedType(RetF),
1504-
cast<sandboxir::ReturnInst>(RetF)->getReturnValue()->getType());
1505-
1506-
// getExpectedValue for void returns
1507-
llvm::Function &Bar = *M->getFunction("bar");
1508-
Ctx.createFunction(&Bar);
1509-
auto *BarBB = cast<sandboxir::BasicBlock>(Ctx.getValue(&*Bar.begin()));
1510-
auto BarIt = BarBB->begin();
1511-
auto *RetV = cast<sandboxir::Instruction>(&*BarIt++);
1512-
EXPECT_EQ(sandboxir::Utils::getExpectedValue(RetV), nullptr);
1513-
}
1514-
15151473
TEST_F(SandboxIRTest, RAUW_RUWIf) {
15161474
parseIR(C, R"IR(
15171475
define void @foo(ptr %ptr) {

llvm/unittests/SandboxIR/UtilsTest.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,48 @@ define void @foo(ptr %ptr) {
136136
EXPECT_FALSE(sandboxir::Utils::atLowerAddress(L3, V3L3, SE, DL));
137137
}
138138

139+
TEST_F(UtilsTest, GetExpected) {
140+
parseIR(C, R"IR(
141+
define float @foo(float %v, ptr %ptr) {
142+
%add = fadd float %v, %v
143+
store float %v, ptr %ptr
144+
ret float %v
145+
}
146+
define void @bar(float %v, ptr %ptr) {
147+
ret void
148+
}
149+
)IR");
150+
llvm::Function &Foo = *M->getFunction("foo");
151+
sandboxir::Context Ctx(C);
152+
153+
Ctx.createFunction(&Foo);
154+
auto *FooBB = cast<sandboxir::BasicBlock>(Ctx.getValue(&*Foo.begin()));
155+
auto FooIt = FooBB->begin();
156+
auto Add = cast<sandboxir::Instruction>(&*FooIt++);
157+
auto *S0 = cast<sandboxir::Instruction>(&*FooIt++);
158+
auto *RetF = cast<sandboxir::Instruction>(&*FooIt++);
159+
// getExpectedValue
160+
EXPECT_EQ(sandboxir::Utils::getExpectedValue(Add), Add);
161+
EXPECT_EQ(sandboxir::Utils::getExpectedValue(S0),
162+
cast<sandboxir::StoreInst>(S0)->getValueOperand());
163+
EXPECT_EQ(sandboxir::Utils::getExpectedValue(RetF),
164+
cast<sandboxir::ReturnInst>(RetF)->getReturnValue());
165+
// getExpectedType
166+
EXPECT_EQ(sandboxir::Utils::getExpectedType(Add), Add->getType());
167+
EXPECT_EQ(sandboxir::Utils::getExpectedType(S0),
168+
cast<sandboxir::StoreInst>(S0)->getValueOperand()->getType());
169+
EXPECT_EQ(sandboxir::Utils::getExpectedType(RetF),
170+
cast<sandboxir::ReturnInst>(RetF)->getReturnValue()->getType());
171+
172+
// getExpectedValue for void returns
173+
llvm::Function &Bar = *M->getFunction("bar");
174+
Ctx.createFunction(&Bar);
175+
auto *BarBB = cast<sandboxir::BasicBlock>(Ctx.getValue(&*Bar.begin()));
176+
auto BarIt = BarBB->begin();
177+
auto *RetV = cast<sandboxir::Instruction>(&*BarIt++);
178+
EXPECT_EQ(sandboxir::Utils::getExpectedValue(RetV), nullptr);
179+
}
180+
139181
TEST_F(UtilsTest, GetNumBits) {
140182
parseIR(C, R"IR(
141183
define void @foo(float %arg0, double %arg1, i8 %arg2, i64 %arg3, ptr %arg4) {

0 commit comments

Comments
 (0)