12
12
#include " llvm/CodeGen/MachineModuleInfo.h"
13
13
#include " llvm/MC/TargetRegistry.h"
14
14
#include " llvm/Support/TargetSelect.h"
15
+ #include " llvm/Target/TargetLoweringObjectFile.h"
15
16
#include " llvm/Target/TargetMachine.h"
16
17
#include " llvm/Target/TargetOptions.h"
17
18
@@ -25,6 +26,7 @@ namespace {
25
26
26
27
class RISCVInstrInfoTest : public testing ::TestWithParam<const char *> {
27
28
protected:
29
+ std::unique_ptr<RISCVTargetMachine> TM;
28
30
std::unique_ptr<LLVMContext> Ctx;
29
31
std::unique_ptr<RISCVSubtarget> ST;
30
32
std::unique_ptr<MachineModuleInfo> MMI;
@@ -42,16 +44,16 @@ class RISCVInstrInfoTest : public testing::TestWithParam<const char *> {
42
44
const Target *TheTarget = TargetRegistry::lookupTarget (TT, Error);
43
45
TargetOptions Options;
44
46
45
- RISCVTargetMachine *TM = static_cast <RISCVTargetMachine *>(
46
- TheTarget-> createTargetMachine ( TT, " generic" , " " , Options, std::nullopt,
47
- std::nullopt, CodeGenOptLevel::Default));
47
+ TM. reset ( static_cast <RISCVTargetMachine *>(TheTarget-> createTargetMachine (
48
+ TT, " generic" , " " , Options, std::nullopt , std::nullopt,
49
+ CodeGenOptLevel::Default) ));
48
50
49
51
Ctx = std::make_unique<LLVMContext>();
50
52
Module M (" Module" , *Ctx);
51
53
M.setDataLayout (TM->createDataLayout ());
52
54
auto *FType = FunctionType::get (Type::getVoidTy (*Ctx), false );
53
55
auto *F = Function::Create (FType, GlobalValue::ExternalLinkage, " Test" , &M);
54
- MMI = std::make_unique<MachineModuleInfo>(TM);
56
+ MMI = std::make_unique<MachineModuleInfo>(TM. get () );
55
57
56
58
ST = std::make_unique<RISCVSubtarget>(
57
59
TM->getTargetTriple (), TM->getTargetCPU (), TM->getTargetCPU (),
0 commit comments