[llvm] [AMDGPU] Initialize MachineFunctionInfo for unittest (PR #91820)

Janek van Oirschot via llvm-commits llvm-commits at lists.llvm.org
Fri May 10 15:16:17 PDT 2024


https://github.com/JanekvO created https://github.com/llvm/llvm-project/pull/91820

Initializes the MachineFunctionInfo for unittest introduced in #88257

Should fix the sanitizer buildbot: https://lab.llvm.org/buildbot/#/builders/5 

>From 8a780b6fe4b9d8b3c4b3fef820ddf58d3d652e7b Mon Sep 17 00:00:00 2001
From: Janek van Oirschot <janek.vanoirschot at amd.com>
Date: Fri, 10 May 2024 23:13:09 +0100
Subject: [PATCH] [AMDGPU] Initialize MachineFunctionInfo for unittest

---
 llvm/unittests/MC/AMDGPU/SIProgramInfoMCExprs.cpp | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

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