[llvm] [AMDGPU] Fix unittest linking error with `LLVM_LINK_LLVM_DYLIB` (PR #91727)
via llvm-commits
llvm-commits at lists.llvm.org
Fri May 10 04:16:17 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mc
@llvm/pr-subscribers-backend-amdgpu
Author: Jonas Hahnfeld (hahnjo)
<details>
<summary>Changes</summary>
Follow-up to https://github.com/llvm/llvm-project/pull/88257
---
Full diff: https://github.com/llvm/llvm-project/pull/91727.diff
3 Files Affected:
- (modified) llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.h (+3-1)
- (modified) llvm/lib/Target/AMDGPU/SIProgramInfo.h (+2-1)
- (modified) llvm/unittests/MC/AMDGPU/SIProgramInfoMCExprs.cpp (+4-8)
``````````diff
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.h b/llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.h
index 26229af638f22..0e3bc63919f06 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.h
@@ -18,6 +18,7 @@
#include "llvm/BinaryFormat/MsgPackDocument.h"
#include "llvm/Support/AMDGPUMetadata.h"
#include "llvm/Support/Alignment.h"
+#include "llvm/Support/Compiler.h"
namespace llvm {
@@ -61,7 +62,8 @@ class MetadataStreamer {
msgpack::MapDocNode Kern) = 0;
};
-class MetadataStreamerMsgPackV4 : public MetadataStreamer {
+class LLVM_EXTERNAL_VISIBILITY MetadataStreamerMsgPackV4
+ : public MetadataStreamer {
protected:
std::unique_ptr<msgpack::Document> HSAMetadataDoc =
std::make_unique<msgpack::Document>();
diff --git a/llvm/lib/Target/AMDGPU/SIProgramInfo.h b/llvm/lib/Target/AMDGPU/SIProgramInfo.h
index c0a353033c3c5..e66e5a194c8b5 100644
--- a/llvm/lib/Target/AMDGPU/SIProgramInfo.h
+++ b/llvm/lib/Target/AMDGPU/SIProgramInfo.h
@@ -17,6 +17,7 @@
#define LLVM_LIB_TARGET_AMDGPU_SIPROGRAMINFO_H
#include "llvm/IR/CallingConv.h"
+#include "llvm/Support/Compiler.h"
#include <cstdint>
namespace llvm {
@@ -27,7 +28,7 @@ class MCExpr;
class MachineFunction;
/// Track resource usage for kernels / entry functions.
-struct SIProgramInfo {
+struct LLVM_EXTERNAL_VISIBILITY SIProgramInfo {
// Fields set in PGM_RSRC1 pm4 packet.
const MCExpr *VGPRBlocks = nullptr;
const MCExpr *SGPRBlocks = nullptr;
diff --git a/llvm/unittests/MC/AMDGPU/SIProgramInfoMCExprs.cpp b/llvm/unittests/MC/AMDGPU/SIProgramInfoMCExprs.cpp
index f2161f71e6e99..a0e03347e6914 100644
--- a/llvm/unittests/MC/AMDGPU/SIProgramInfoMCExprs.cpp
+++ b/llvm/unittests/MC/AMDGPU/SIProgramInfoMCExprs.cpp
@@ -7,9 +7,8 @@
//===----------------------------------------------------------------------===//
#include "AMDGPUHSAMetadataStreamer.h"
-#include "AMDGPUTargetMachine.h"
-#include "GCNSubtarget.h"
#include "SIProgramInfo.h"
+#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineModuleInfo.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCExpr.h"
@@ -25,9 +24,8 @@ using namespace llvm;
class SIProgramInfoMCExprsTest : public testing::Test {
protected:
- std::unique_ptr<GCNTargetMachine> TM;
+ std::unique_ptr<LLVMTargetMachine> TM;
std::unique_ptr<LLVMContext> Ctx;
- std::unique_ptr<GCNSubtarget> ST;
std::unique_ptr<MachineModuleInfo> MMI;
std::unique_ptr<MachineFunction> MF;
std::unique_ptr<Module> M;
@@ -49,7 +47,7 @@ class SIProgramInfoMCExprsTest : public testing::Test {
const Target *TheTarget = TargetRegistry::lookupTarget(Triple, Error);
TargetOptions Options;
- TM.reset(static_cast<GCNTargetMachine *>(TheTarget->createTargetMachine(
+ TM.reset(static_cast<LLVMTargetMachine *>(TheTarget->createTargetMachine(
Triple, CPU, FS, Options, std::nullopt, std::nullopt)));
Ctx = std::make_unique<LLVMContext>();
@@ -59,9 +57,7 @@ class SIProgramInfoMCExprsTest : public testing::Test {
auto *F = Function::Create(FType, GlobalValue::ExternalLinkage, "Test", *M);
MMI = std::make_unique<MachineModuleInfo>(TM.get());
- ST = std::make_unique<GCNSubtarget>(TM->getTargetTriple(),
- TM->getTargetCPU(),
- TM->getTargetFeatureString(), *TM);
+ auto *ST = TM->getSubtargetImpl(*F);
MF = std::make_unique<MachineFunction>(*F, *TM, *ST, 1, *MMI);
PI.reset(*MF.get());
``````````
</details>
https://github.com/llvm/llvm-project/pull/91727
More information about the llvm-commits
mailing list