[PATCH] D130883: [MachineInstrBuilder] Introduce MIMetadata to simplify metadata propagation
Marco Elver via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 2 11:19:27 PDT 2022
melver marked an inline comment as done.
melver added inline comments.
================
Comment at: llvm/unittests/CodeGen/MachineInstrTest.cpp:462
+ MCInstrDesc MCID = {0, 0, 0, 0, 0, 0, 0, nullptr, nullptr, nullptr};
+ CheckMI([&] { return BuildMI(*MF, MIMD, MCID); });
+ CheckMI([&] { return BuildMI(*MBB, MBB->end(), MIMD, MCID); });
----------------
vitalybuka wrote:
> I don't insist, but you want to avoid such wrapping of EXPECTs into functions or lambdas.
> When test fails it will not provide location of the failed line with CheckMI
>
> If you want to reuse pair of checks,
> EXPECT_EQ(MIB->getDebugLoc(), DL);
> EXPECT_EQ(MIB->getPCSections(), PCS);
>
> you can use EXPECT_THAT with custom matches
> EXPECT_THAT(BuildMI(*MBB, MBB->end(), MIMD, MCID)(), MyMatches);
>
> another alternative:
> ```
> auto BuildDiPc = [&](...) -> pair<> {
> MachineInstrBuilder MIB = BuildMI(...)();
> return {MIB->getDebugLoc(), MIB->getPCSections()}
> };
>
> EXPECT_EQ({DL, PC}. BuildDiPc(*MBB, MBB->end(), MIMD, MCID));
> ```
Thanks, updated to use EXPECT_THAT.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D130883/new/
https://reviews.llvm.org/D130883
More information about the llvm-commits
mailing list