[llvm] [SandboxIR][NFC] Move Utils test to proper file (PR #110763)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 1 16:25:01 PDT 2024
https://github.com/Sterling-Augustine created https://github.com/llvm/llvm-project/pull/110763
None
>From 105be376d7435a46bac64b920be7830e720b8195 Mon Sep 17 00:00:00 2001
From: Sterling Augustine <saugustine at google.com>
Date: Tue, 1 Oct 2024 16:22:01 -0700
Subject: [PATCH] [SandboxIR][NFC] Move Utils test to proper file
---
llvm/unittests/SandboxIR/SandboxIRTest.cpp | 42 ----------------------
llvm/unittests/SandboxIR/UtilsTest.cpp | 42 ++++++++++++++++++++++
2 files changed, 42 insertions(+), 42 deletions(-)
diff --git a/llvm/unittests/SandboxIR/SandboxIRTest.cpp b/llvm/unittests/SandboxIR/SandboxIRTest.cpp
index 01940e7dccbf87..d0ed98bbd3ee2f 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 2d76a20071d2ed..a803c2a1cf977c 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