[llvm] 3dcd604 - [AMDGPU] Initialize MachineFunctionInfo for unittest (#91820)
via llvm-commits
llvm-commits at lists.llvm.org
Fri May 10 15:31:22 PDT 2024
Author: Janek van Oirschot
Date: 2024-05-10T23:31:17+01:00
New Revision: 3dcd604eb1d6612fda667793dbb52c5dfaa5fc4f
URL: https://github.com/llvm/llvm-project/commit/3dcd604eb1d6612fda667793dbb52c5dfaa5fc4f
DIFF: https://github.com/llvm/llvm-project/commit/3dcd604eb1d6612fda667793dbb52c5dfaa5fc4f.diff
LOG: [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.
Added:
Modified:
llvm/unittests/MC/AMDGPU/SIProgramInfoMCExprs.cpp
Removed:
################################################################################
diff --git a/llvm/unittests/MC/AMDGPU/SIProgramInfoMCExprs.cpp b/llvm/unittests/MC/AMDGPU/SIProgramInfoMCExprs.cpp
index f2161f71e6e99..912974fa23bdb 100644
--- a/llvm/unittests/MC/AMDGPU/SIProgramInfoMCExprs.cpp
+++ b/llvm/unittests/MC/AMDGPU/SIProgramInfoMCExprs.cpp
@@ -64,6 +64,7 @@ class SIProgramInfoMCExprsTest : public testing::Test {
TM->getTargetFeatureString(), *TM);
MF = std::make_unique<MachineFunction>(*F, *TM, *ST, 1, *MMI);
+ MF->initTargetMachineFunctionInfo(*ST);
PI.reset(*MF.get());
}
};
@@ -76,6 +77,11 @@ TEST_F(SIProgramInfoMCExprsTest, TestDeathHSAKernelEmit) {
auto &Func = MF->getFunction();
Func.setCallingConv(CallingConv::AMDGPU_KERNEL);
AMDGPU::HSAMD::MetadataStreamerMsgPackV4 MD;
- EXPECT_DEATH(MD.emitKernel(*MF, PI),
- "could not resolve expression when required.");
+
+ testing::internal::CaptureStderr();
+ MD.emitKernel(*MF, PI);
+ std::string err = testing::internal::GetCapturedStderr();
+ EXPECT_EQ(
+ err, "<unknown>:0: error: could not resolve expression when required.\n");
+ EXPECT_TRUE(Ctx.hadError());
}
More information about the llvm-commits
mailing list