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(Ctx.getValue(&*Foo.begin())); - auto FooIt = FooBB->begin(); - auto Add = cast(&*FooIt++); - auto *S0 = cast(&*FooIt++); - auto *RetF = cast(&*FooIt++); - // getExpectedValue - EXPECT_EQ(sandboxir::Utils::getExpectedValue(Add), Add); - EXPECT_EQ(sandboxir::Utils::getExpectedValue(S0), - cast(S0)->getValueOperand()); - EXPECT_EQ(sandboxir::Utils::getExpectedValue(RetF), - cast(RetF)->getReturnValue()); - // getExpectedType - EXPECT_EQ(sandboxir::Utils::getExpectedType(Add), Add->getType()); - EXPECT_EQ(sandboxir::Utils::getExpectedType(S0), - cast(S0)->getValueOperand()->getType()); - EXPECT_EQ(sandboxir::Utils::getExpectedType(RetF), - cast(RetF)->getReturnValue()->getType()); - - // getExpectedValue for void returns - llvm::Function &Bar = *M->getFunction("bar"); - Ctx.createFunction(&Bar); - auto *BarBB = cast(Ctx.getValue(&*Bar.begin())); - auto BarIt = BarBB->begin(); - auto *RetV = cast(&*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(Ctx.getValue(&*Foo.begin())); + auto FooIt = FooBB->begin(); + auto Add = cast(&*FooIt++); + auto *S0 = cast(&*FooIt++); + auto *RetF = cast(&*FooIt++); + // getExpectedValue + EXPECT_EQ(sandboxir::Utils::getExpectedValue(Add), Add); + EXPECT_EQ(sandboxir::Utils::getExpectedValue(S0), + cast(S0)->getValueOperand()); + EXPECT_EQ(sandboxir::Utils::getExpectedValue(RetF), + cast(RetF)->getReturnValue()); + // getExpectedType + EXPECT_EQ(sandboxir::Utils::getExpectedType(Add), Add->getType()); + EXPECT_EQ(sandboxir::Utils::getExpectedType(S0), + cast(S0)->getValueOperand()->getType()); + EXPECT_EQ(sandboxir::Utils::getExpectedType(RetF), + cast(RetF)->getReturnValue()->getType()); + + // getExpectedValue for void returns + llvm::Function &Bar = *M->getFunction("bar"); + Ctx.createFunction(&Bar); + auto *BarBB = cast(Ctx.getValue(&*Bar.begin())); + auto BarIt = BarBB->begin(); + auto *RetV = cast(&*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) {