Skip to content

[AMDGPU] Initialize MachineFunctionInfo for unittest #91820

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 10, 2024

Conversation

JanekvO
Copy link
Contributor

@JanekvO JanekvO commented May 10, 2024

Initializes the MachineFunctionInfo for unittest introduced in #88257

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

@JanekvO JanekvO requested review from arsenm and thurstond May 10, 2024 22:16
@llvmbot llvmbot added backend:AMDGPU mc Machine (object) code labels May 10, 2024
@llvmbot
Copy link
Member

llvmbot commented May 10, 2024

@llvm/pr-subscribers-mc

@llvm/pr-subscribers-backend-amdgpu

Author: Janek van Oirschot (JanekvO)

Changes

Initializes the MachineFunctionInfo for unittest introduced in #88257

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


Full diff: https://github.com/llvm/llvm-project/pull/91820.diff

1 Files Affected:

  • (modified) llvm/unittests/MC/AMDGPU/SIProgramInfoMCExprs.cpp (+8-2)
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());
 }

@JanekvO JanekvO merged commit 3dcd604 into llvm:main May 10, 2024
6 of 7 checks passed
@JanekvO JanekvO deleted the fix_unittest_ubsan branch May 10, 2024 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:AMDGPU mc Machine (object) code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants