Skip to content

Commit 38c3855

Browse files
authored
[NFC] Remove unused argument (FuncName) for parseMIR (#106144)
While working on a MIR unittest, I noticed that parseMIR includes an unused argument that sets a function name. This is not only redundant but also irrelevant, as parseMIR is designed to parse entire module, not specific functions, even though most unittests contain a single function per module. To streamline the API, I have removed this unnecessary argument from parseMIR. However, if this argument was originally included to enhance readability or for any other purpose, please let me know.
1 parent b01c006 commit 38c3855

File tree

5 files changed

+22
-25
lines changed

5 files changed

+22
-25
lines changed

llvm/unittests/CodeGen/GlobalISel/GISelMITest.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,9 @@ std::ostream &
5353
operator<<(std::ostream &OS, const MachineFunction &MF);
5454
}
5555

56-
static std::unique_ptr<Module> parseMIR(LLVMContext &Context,
57-
std::unique_ptr<MIRParser> &MIR,
58-
const TargetMachine &TM,
59-
StringRef MIRCode, const char *FuncName,
60-
MachineModuleInfo &MMI) {
56+
static std::unique_ptr<Module>
57+
parseMIR(LLVMContext &Context, std::unique_ptr<MIRParser> &MIR,
58+
const TargetMachine &TM, StringRef MIRCode, MachineModuleInfo &MMI) {
6159
SMDiagnostic Diagnostic;
6260
std::unique_ptr<MemoryBuffer> MBuffer = MemoryBuffer::getMemBuffer(MIRCode);
6361
MIR = createMIRParser(std::move(MBuffer), Context);
@@ -80,8 +78,7 @@ createDummyModule(LLVMContext &Context, const LLVMTargetMachine &TM,
8078
StringRef MIRString, const char *FuncName) {
8179
std::unique_ptr<MIRParser> MIR;
8280
auto MMI = std::make_unique<MachineModuleInfo>(&TM);
83-
std::unique_ptr<Module> M =
84-
parseMIR(Context, MIR, TM, MIRString, FuncName, *MMI);
81+
std::unique_ptr<Module> M = parseMIR(Context, MIR, TM, MIRString, *MMI);
8582
return make_pair(std::move(M), std::move(MMI));
8683
}
8784

llvm/unittests/CodeGen/MachineDomTreeUpdaterTest.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class MachineDomTreeUpdaterTest : public testing::Test {
7373
MAM.registerPass([&] { return MachineModuleAnalysis(*MMI); });
7474
}
7575

76-
bool parseMIR(StringRef MIRCode, const char *FnName) {
76+
bool parseMIR(StringRef MIRCode) {
7777
SMDiagnostic Diagnostic;
7878
std::unique_ptr<MemoryBuffer> MBuffer = MemoryBuffer::getMemBuffer(MIRCode);
7979
MIR = createMIRParser(std::move(MBuffer), Context);
@@ -149,7 +149,7 @@ body: |
149149
...
150150
)";
151151

152-
ASSERT_TRUE(parseMIR(MIRString, "f0"));
152+
ASSERT_TRUE(parseMIR(MIRString));
153153

154154
auto &MF =
155155
FAM.getResult<MachineFunctionAnalysis>(*M->getFunction("f0")).getMF();
@@ -239,7 +239,7 @@ body: |
239239
...
240240
)";
241241

242-
ASSERT_TRUE(parseMIR(MIRString, "f0"));
242+
ASSERT_TRUE(parseMIR(MIRString));
243243

244244
auto &MF =
245245
FAM.getResult<MachineFunctionAnalysis>(*M->getFunction("f0")).getMF();

llvm/unittests/MI/LiveIntervalTest.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ std::unique_ptr<LLVMTargetMachine> createTargetMachine() {
5555
}
5656

5757
std::unique_ptr<Module> parseMIR(LLVMContext &Context,
58-
legacy::PassManagerBase &PM, std::unique_ptr<MIRParser> &MIR,
59-
const LLVMTargetMachine &TM, StringRef MIRCode, const char *FuncName) {
58+
legacy::PassManagerBase &PM,
59+
std::unique_ptr<MIRParser> &MIR,
60+
const LLVMTargetMachine &TM,
61+
StringRef MIRCode) {
6062
SMDiagnostic Diagnostic;
6163
std::unique_ptr<MemoryBuffer> MBuffer = MemoryBuffer::getMemBuffer(MIRCode);
6264
MIR = createMIRParser(std::move(MBuffer), Context);
@@ -209,7 +211,7 @@ static void doTest(StringRef MIRFunc,
209211

210212
legacy::PassManager PM;
211213
std::unique_ptr<MIRParser> MIR;
212-
std::unique_ptr<Module> M = parseMIR(Context, PM, MIR, *TM, MIRFunc, "func");
214+
std::unique_ptr<Module> M = parseMIR(Context, PM, MIR, *TM, MIRFunc);
213215
ASSERT_TRUE(M);
214216

215217
PM.add(new TestPassT<AnalysisType>(T, ShouldPass));

llvm/unittests/MIR/MachineMetadata.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class MachineMetadataTest : public testing::Test {
7979
}
8080

8181
std::unique_ptr<Module> parseMIR(const TargetMachine &TM, StringRef MIRCode,
82-
const char *FnName, MachineModuleInfo &MMI) {
82+
MachineModuleInfo &MMI) {
8383
SMDiagnostic Diagnostic;
8484
std::unique_ptr<MemoryBuffer> MBuffer = MemoryBuffer::getMemBuffer(MIRCode);
8585
MIR = createMIRParser(std::move(MBuffer), Context);
@@ -227,7 +227,7 @@ body: |
227227
)MIR";
228228

229229
MachineModuleInfo MMI(TM.get());
230-
M = parseMIR(*TM, MIRString, "test0", MMI);
230+
M = parseMIR(*TM, MIRString, MMI);
231231
ASSERT_TRUE(M);
232232

233233
auto *MF = MMI.getMachineFunction(*M->getFunction("test0"));
@@ -338,7 +338,7 @@ body: |
338338
)MIR";
339339

340340
MachineModuleInfo MMI(TM.get());
341-
M = parseMIR(*TM, MIRString, "test0", MMI);
341+
M = parseMIR(*TM, MIRString, MMI);
342342
ASSERT_TRUE(M);
343343

344344
auto *MF = MMI.getMachineFunction(*M->getFunction("test0"));
@@ -376,7 +376,7 @@ body: |
376376
)MIR";
377377

378378
MachineModuleInfo MMI(TM.get());
379-
M = parseMIR(*TM, MIRString, "test0", MMI);
379+
M = parseMIR(*TM, MIRString, MMI);
380380
ASSERT_TRUE(M);
381381

382382
auto *MF = MMI.getMachineFunction(*M->getFunction("test0"));
@@ -474,7 +474,7 @@ body: |
474474
)MIR";
475475

476476
MachineModuleInfo MMI(TM.get());
477-
M = parseMIR(*TM, MIRString, "test0", MMI);
477+
M = parseMIR(*TM, MIRString, MMI);
478478
ASSERT_TRUE(M);
479479

480480
auto *MF = MMI.getMachineFunction(*M->getFunction("test0"));
@@ -563,7 +563,7 @@ body: |
563563
...
564564
)MIR";
565565
MachineModuleInfo MMI(TM.get());
566-
M = parseMIR(*TM, MIRString, "foo", MMI);
566+
M = parseMIR(*TM, MIRString, MMI);
567567
ASSERT_TRUE(M);
568568
auto *MF = MMI.getMachineFunction(*M->getFunction("foo"));
569569
MachineFunctionProperties &Properties = MF->getProperties();
@@ -594,7 +594,7 @@ body: |
594594
...
595595
)MIR";
596596
MachineModuleInfo MMI(TM.get());
597-
M = parseMIR(*TM, MIRString, "foo", MMI);
597+
M = parseMIR(*TM, MIRString, MMI);
598598
ASSERT_TRUE(M);
599599
auto *MF = MMI.getMachineFunction(*M->getFunction("foo"));
600600
MachineFunctionProperties &Properties = MF->getProperties();

llvm/unittests/Target/WebAssembly/WebAssemblyExceptionInfoTest.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ std::unique_ptr<LLVMTargetMachine> createTargetMachine() {
4343
std::unique_ptr<Module> parseMIR(LLVMContext &Context,
4444
std::unique_ptr<MIRParser> &MIR,
4545
const TargetMachine &TM, StringRef MIRCode,
46-
const char *FuncName, MachineModuleInfo &MMI) {
46+
MachineModuleInfo &MMI) {
4747
SMDiagnostic Diagnostic;
4848
std::unique_ptr<MemoryBuffer> MBuffer = MemoryBuffer::getMemBuffer(MIRCode);
4949
MIR = createMIRParser(std::move(MBuffer), Context);
@@ -157,8 +157,7 @@ body: |
157157
LLVMContext Context;
158158
std::unique_ptr<MIRParser> MIR;
159159
MachineModuleInfo MMI(TM.get());
160-
std::unique_ptr<Module> M =
161-
parseMIR(Context, MIR, *TM, MIRString, "test0", MMI);
160+
std::unique_ptr<Module> M = parseMIR(Context, MIR, *TM, MIRString, MMI);
162161
ASSERT_TRUE(M);
163162

164163
Function *F = M->getFunction("test0");
@@ -332,8 +331,7 @@ body: |
332331
LLVMContext Context;
333332
std::unique_ptr<MIRParser> MIR;
334333
MachineModuleInfo MMI(TM.get());
335-
std::unique_ptr<Module> M =
336-
parseMIR(Context, MIR, *TM, MIRString, "test1", MMI);
334+
std::unique_ptr<Module> M = parseMIR(Context, MIR, *TM, MIRString, MMI);
337335
ASSERT_TRUE(M);
338336

339337
Function *F = M->getFunction("test1");

0 commit comments

Comments
 (0)