Skip to content

Commit 3dcd604

Browse files
authored
[AMDGPU] Initialize MachineFunctionInfo for unittest (#91820)
Initializes the MachineFunctionInfo for unittest introduced in #88257 Additionally, also rephrases the test condition considering the abort/exit does not occur within emitKernel but is generally triggered through the Ctx.hadError() call.
1 parent cb037d0 commit 3dcd604

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

llvm/unittests/MC/AMDGPU/SIProgramInfoMCExprs.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class SIProgramInfoMCExprsTest : public testing::Test {
6464
TM->getTargetFeatureString(), *TM);
6565

6666
MF = std::make_unique<MachineFunction>(*F, *TM, *ST, 1, *MMI);
67+
MF->initTargetMachineFunctionInfo(*ST);
6768
PI.reset(*MF.get());
6869
}
6970
};
@@ -76,6 +77,11 @@ TEST_F(SIProgramInfoMCExprsTest, TestDeathHSAKernelEmit) {
7677
auto &Func = MF->getFunction();
7778
Func.setCallingConv(CallingConv::AMDGPU_KERNEL);
7879
AMDGPU::HSAMD::MetadataStreamerMsgPackV4 MD;
79-
EXPECT_DEATH(MD.emitKernel(*MF, PI),
80-
"could not resolve expression when required.");
80+
81+
testing::internal::CaptureStderr();
82+
MD.emitKernel(*MF, PI);
83+
std::string err = testing::internal::GetCapturedStderr();
84+
EXPECT_EQ(
85+
err, "<unknown>:0: error: could not resolve expression when required.\n");
86+
EXPECT_TRUE(Ctx.hadError());
8187
}

0 commit comments

Comments
 (0)