@@ -30,39 +30,39 @@ void MachineModuleInfo::initialize() {
30
30
}
31
31
32
32
void MachineModuleInfo::finalize () {
33
- Context.reset ();
33
+ if (Context)
34
+ Context->reset ();
34
35
// We don't clear the ExternalContext.
35
36
36
37
delete ObjFileMMI;
37
38
ObjFileMMI = nullptr ;
38
39
}
39
40
40
41
MachineModuleInfo::MachineModuleInfo (MachineModuleInfo &&MMI)
41
- : TM(std::move(MMI.TM)),
42
- Context(TM.getTargetTriple(), TM.getMCAsmInfo(), TM.getMCRegisterInfo(),
43
- TM.getMCSubtargetInfo(), nullptr, &TM.Options.MCOptions, false),
42
+ : TM(std::move(MMI.TM)), Context(std::move(MMI.Context)),
44
43
MachineFunctions(std::move(MMI.MachineFunctions)) {
45
- Context.setObjectFileInfo (TM.getObjFileLowering ());
46
44
ObjFileMMI = MMI.ObjFileMMI ;
47
45
ExternalContext = MMI.ExternalContext ;
48
46
TheModule = MMI.TheModule ;
49
47
}
50
48
51
49
MachineModuleInfo::MachineModuleInfo (const LLVMTargetMachine *TM)
52
- : TM(*TM), Context(TM->getTargetTriple (), TM->getMCAsmInfo(),
53
- TM->getMCRegisterInfo(), TM->getMCSubtargetInfo(),
54
- nullptr, &TM->Options.MCOptions, false) {
55
- Context.setObjectFileInfo (TM->getObjFileLowering ());
50
+ : TM(*TM),
51
+ Context(std::make_unique<MCContext>(
52
+ TM->getTargetTriple (), TM->getMCAsmInfo(), TM->getMCRegisterInfo(),
53
+ TM->getMCSubtargetInfo(), nullptr, &TM->Options.MCOptions, false)) {
54
+ Context->setObjectFileInfo (TM->getObjFileLowering ());
56
55
initialize ();
57
56
}
58
57
59
58
MachineModuleInfo::MachineModuleInfo (const LLVMTargetMachine *TM,
60
59
MCContext *ExtContext)
61
- : TM(*TM), Context(TM->getTargetTriple (), TM->getMCAsmInfo(),
62
- TM->getMCRegisterInfo(), TM->getMCSubtargetInfo(),
63
- nullptr, &TM->Options.MCOptions, false),
60
+ : TM(*TM),
61
+ Context(std::make_unique<MCContext>(
62
+ TM->getTargetTriple (), TM->getMCAsmInfo(), TM->getMCRegisterInfo(),
63
+ TM->getMCSubtargetInfo(), nullptr, &TM->Options.MCOptions, false)),
64
64
ExternalContext(ExtContext) {
65
- Context. setObjectFileInfo (TM->getObjFileLowering ());
65
+ Context-> setObjectFileInfo (TM->getObjFileLowering ());
66
66
initialize ();
67
67
}
68
68
@@ -137,9 +137,7 @@ class FreeMachineFunction : public FunctionPass {
137
137
return true ;
138
138
}
139
139
140
- StringRef getPassName () const override {
141
- return " Free MachineFunction" ;
142
- }
140
+ StringRef getPassName () const override { return " Free MachineFunction" ; }
143
141
};
144
142
145
143
} // end anonymous namespace
@@ -152,13 +150,13 @@ FunctionPass *llvm::createFreeMachineFunctionPass() {
152
150
153
151
MachineModuleInfoWrapperPass::MachineModuleInfoWrapperPass (
154
152
const LLVMTargetMachine *TM)
155
- : ImmutablePass(ID), MMI(std::make_unique<MachineModuleInfo>(TM) ) {
153
+ : ImmutablePass(ID), MMI(TM ) {
156
154
initializeMachineModuleInfoWrapperPassPass (*PassRegistry::getPassRegistry ());
157
155
}
158
156
159
157
MachineModuleInfoWrapperPass::MachineModuleInfoWrapperPass (
160
158
const LLVMTargetMachine *TM, MCContext *ExtContext)
161
- : ImmutablePass(ID), MMI(std::make_unique<MachineModuleInfo>(TM, ExtContext) ) {
159
+ : ImmutablePass(ID), MMI(TM ) {
162
160
initializeMachineModuleInfoWrapperPassPass (*PassRegistry::getPassRegistry ());
163
161
}
164
162
@@ -193,10 +191,10 @@ static uint64_t getLocCookie(const SMDiagnostic &SMD, const SourceMgr &SrcMgr,
193
191
}
194
192
195
193
bool MachineModuleInfoWrapperPass::doInitialization (Module &M) {
196
- MMI-> initialize ();
197
- MMI-> TheModule = &M;
194
+ MMI. initialize ();
195
+ MMI. TheModule = &M;
198
196
LLVMContext &Ctx = M.getContext ();
199
- MMI-> getContext ().setDiagnosticHandler (
197
+ MMI. getContext ().setDiagnosticHandler (
200
198
[&Ctx, &M](const SMDiagnostic &SMD, bool IsInlineAsm,
201
199
const SourceMgr &SrcMgr,
202
200
std::vector<const MDNode *> &LocInfos) {
@@ -210,7 +208,7 @@ bool MachineModuleInfoWrapperPass::doInitialization(Module &M) {
210
208
}
211
209
212
210
bool MachineModuleInfoWrapperPass::doFinalization (Module &M) {
213
- MMI-> finalize ();
211
+ MMI. finalize ();
214
212
return false ;
215
213
}
216
214
0 commit comments