Skip to content

Commit 52c5a81

Browse files
authored
[AMDGPU] Fix unittest linking error with LLVM_LINK_LLVM_DYLIB (#91727)
Follow-up to #88257
1 parent 1351aab commit 52c5a81

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "llvm/BinaryFormat/MsgPackDocument.h"
1919
#include "llvm/Support/AMDGPUMetadata.h"
2020
#include "llvm/Support/Alignment.h"
21+
#include "llvm/Support/Compiler.h"
2122

2223
namespace llvm {
2324

@@ -61,7 +62,8 @@ class MetadataStreamer {
6162
msgpack::MapDocNode Kern) = 0;
6263
};
6364

64-
class MetadataStreamerMsgPackV4 : public MetadataStreamer {
65+
class LLVM_EXTERNAL_VISIBILITY MetadataStreamerMsgPackV4
66+
: public MetadataStreamer {
6567
protected:
6668
std::unique_ptr<msgpack::Document> HSAMetadataDoc =
6769
std::make_unique<msgpack::Document>();

llvm/lib/Target/AMDGPU/SIProgramInfo.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#define LLVM_LIB_TARGET_AMDGPU_SIPROGRAMINFO_H
1818

1919
#include "llvm/IR/CallingConv.h"
20+
#include "llvm/Support/Compiler.h"
2021
#include <cstdint>
2122

2223
namespace llvm {
@@ -27,7 +28,7 @@ class MCExpr;
2728
class MachineFunction;
2829

2930
/// Track resource usage for kernels / entry functions.
30-
struct SIProgramInfo {
31+
struct LLVM_EXTERNAL_VISIBILITY SIProgramInfo {
3132
// Fields set in PGM_RSRC1 pm4 packet.
3233
const MCExpr *VGPRBlocks = nullptr;
3334
const MCExpr *SGPRBlocks = nullptr;

llvm/unittests/MC/AMDGPU/SIProgramInfoMCExprs.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "AMDGPUHSAMetadataStreamer.h"
10-
#include "AMDGPUTargetMachine.h"
11-
#include "GCNSubtarget.h"
1210
#include "SIProgramInfo.h"
11+
#include "llvm/CodeGen/MachineFunction.h"
1312
#include "llvm/CodeGen/MachineModuleInfo.h"
1413
#include "llvm/MC/MCContext.h"
1514
#include "llvm/MC/MCExpr.h"
@@ -25,9 +24,8 @@ using namespace llvm;
2524

2625
class SIProgramInfoMCExprsTest : public testing::Test {
2726
protected:
28-
std::unique_ptr<GCNTargetMachine> TM;
27+
std::unique_ptr<LLVMTargetMachine> TM;
2928
std::unique_ptr<LLVMContext> Ctx;
30-
std::unique_ptr<GCNSubtarget> ST;
3129
std::unique_ptr<MachineModuleInfo> MMI;
3230
std::unique_ptr<MachineFunction> MF;
3331
std::unique_ptr<Module> M;
@@ -49,7 +47,7 @@ class SIProgramInfoMCExprsTest : public testing::Test {
4947
const Target *TheTarget = TargetRegistry::lookupTarget(Triple, Error);
5048
TargetOptions Options;
5149

52-
TM.reset(static_cast<GCNTargetMachine *>(TheTarget->createTargetMachine(
50+
TM.reset(static_cast<LLVMTargetMachine *>(TheTarget->createTargetMachine(
5351
Triple, CPU, FS, Options, std::nullopt, std::nullopt)));
5452

5553
Ctx = std::make_unique<LLVMContext>();
@@ -59,9 +57,7 @@ class SIProgramInfoMCExprsTest : public testing::Test {
5957
auto *F = Function::Create(FType, GlobalValue::ExternalLinkage, "Test", *M);
6058
MMI = std::make_unique<MachineModuleInfo>(TM.get());
6159

62-
ST = std::make_unique<GCNSubtarget>(TM->getTargetTriple(),
63-
TM->getTargetCPU(),
64-
TM->getTargetFeatureString(), *TM);
60+
auto *ST = TM->getSubtargetImpl(*F);
6561

6662
MF = std::make_unique<MachineFunction>(*F, *TM, *ST, 1, *MMI);
6763
MF->initTargetMachineFunctionInfo(*ST);

0 commit comments

Comments
 (0)