Skip to content

Commit

Permalink
[NFC][ModuleUtils] Rename test function (llvm#101750)
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalybuka authored and banach-space committed Aug 7, 2024
1 parent d05b05c commit d96920c
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions llvm/unittests/Transforms/Utils/ModuleUtilsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ static std::unique_ptr<Module> parseIR(LLVMContext &C, const char *IR) {
return Mod;
}

static int getUsedListSize(Module &M, StringRef Name) {
auto *UsedList = M.getGlobalVariable(Name);
if (!UsedList)
static int getListSize(Module &M, StringRef Name) {
auto *List = M.getGlobalVariable(Name);
if (!List)
return 0;
auto *UsedListBaseArrayType = cast<ArrayType>(UsedList->getValueType());
return UsedListBaseArrayType->getNumElements();
auto *T = cast<ArrayType>(List->getValueType());
return T->getNumElements();
}

TEST(ModuleUtils, AppendToUsedList1) {
Expand All @@ -41,13 +41,13 @@ TEST(ModuleUtils, AppendToUsedList1) {
for (auto &G : M->globals()) {
Globals.push_back(&G);
}
EXPECT_EQ(0, getUsedListSize(*M, "llvm.compiler.used"));
EXPECT_EQ(0, getListSize(*M, "llvm.compiler.used"));
appendToCompilerUsed(*M, Globals);
EXPECT_EQ(1, getUsedListSize(*M, "llvm.compiler.used"));
EXPECT_EQ(1, getListSize(*M, "llvm.compiler.used"));

EXPECT_EQ(0, getUsedListSize(*M, "llvm.used"));
EXPECT_EQ(0, getListSize(*M, "llvm.used"));
appendToUsed(*M, Globals);
EXPECT_EQ(1, getUsedListSize(*M, "llvm.used"));
EXPECT_EQ(1, getListSize(*M, "llvm.used"));
}

TEST(ModuleUtils, AppendToUsedList2) {
Expand All @@ -59,11 +59,11 @@ TEST(ModuleUtils, AppendToUsedList2) {
for (auto &G : M->globals()) {
Globals.push_back(&G);
}
EXPECT_EQ(0, getUsedListSize(*M, "llvm.compiler.used"));
EXPECT_EQ(0, getListSize(*M, "llvm.compiler.used"));
appendToCompilerUsed(*M, Globals);
EXPECT_EQ(1, getUsedListSize(*M, "llvm.compiler.used"));
EXPECT_EQ(1, getListSize(*M, "llvm.compiler.used"));

EXPECT_EQ(0, getUsedListSize(*M, "llvm.used"));
EXPECT_EQ(0, getListSize(*M, "llvm.used"));
appendToUsed(*M, Globals);
EXPECT_EQ(1, getUsedListSize(*M, "llvm.used"));
EXPECT_EQ(1, getListSize(*M, "llvm.used"));
}

0 comments on commit d96920c

Please sign in to comment.