Skip to content

Commit 6a78a68

Browse files
committed
Made MMIWP not have control over the lifetime of MMI.
1 parent 76f2fa8 commit 6a78a68

File tree

2 files changed

+9
-27
lines changed

2 files changed

+9
-27
lines changed

llvm/include/llvm/CodeGen/MachineModuleInfo.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,18 @@ class MachineModuleInfo {
106106
const Function *LastRequest = nullptr; ///< Used for shortcut/cache.
107107
MachineFunction *LastResult = nullptr; ///< Used for shortcut/cache.
108108

109-
MachineModuleInfo &operator=(MachineModuleInfo &&MMII) = delete;
109+
/// Deleted copy constructor
110+
MachineModuleInfo(MachineModuleInfo &MMI) = delete;
111+
112+
/// Deleted copy assignment operator
113+
MachineModuleInfo &operator=(MachineModuleInfo &MMI) = delete;
110114

111115
public:
112116
explicit MachineModuleInfo(const LLVMTargetMachine *TM = nullptr);
113117

114118
explicit MachineModuleInfo(const LLVMTargetMachine *TM,
115119
MCContext *ExtContext);
116120

117-
MachineModuleInfo(MachineModuleInfo &&MMII);
118-
119121
~MachineModuleInfo();
120122

121123
void initialize();
@@ -169,14 +171,11 @@ class MachineModuleInfo {
169171
}; // End class MachineModuleInfo
170172

171173
class MachineModuleInfoWrapperPass : public ImmutablePass {
172-
MachineModuleInfo MMI;
174+
MachineModuleInfo &MMI;
173175

174176
public:
175177
static char ID; // Pass identification, replacement for typeid
176-
explicit MachineModuleInfoWrapperPass(const LLVMTargetMachine *TM = nullptr);
177-
178-
explicit MachineModuleInfoWrapperPass(const LLVMTargetMachine *TM,
179-
MCContext *ExtContext);
178+
explicit MachineModuleInfoWrapperPass(MachineModuleInfo &MMI);
180179

181180
// Initialization and Finalization
182181
bool doInitialization(Module &) override;

llvm/lib/CodeGen/MachineModuleInfo.cpp

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,6 @@ void MachineModuleInfo::finalize() {
3737
ObjFileMMI = nullptr;
3838
}
3939

40-
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),
44-
MachineFunctions(std::move(MMI.MachineFunctions)) {
45-
Context.setObjectFileInfo(TM.getObjFileLowering());
46-
ObjFileMMI = MMI.ObjFileMMI;
47-
ExternalContext = MMI.ExternalContext;
48-
TheModule = MMI.TheModule;
49-
}
50-
5140
MachineModuleInfo::MachineModuleInfo(const LLVMTargetMachine *TM)
5241
: TM(*TM), Context(TM->getTargetTriple(), TM->getMCAsmInfo(),
5342
TM->getMCRegisterInfo(), TM->getMCSubtargetInfo(),
@@ -151,14 +140,8 @@ FunctionPass *llvm::createFreeMachineFunctionPass() {
151140
}
152141

153142
MachineModuleInfoWrapperPass::MachineModuleInfoWrapperPass(
154-
const LLVMTargetMachine *TM)
155-
: ImmutablePass(ID), MMI(TM) {
156-
initializeMachineModuleInfoWrapperPassPass(*PassRegistry::getPassRegistry());
157-
}
158-
159-
MachineModuleInfoWrapperPass::MachineModuleInfoWrapperPass(
160-
const LLVMTargetMachine *TM, MCContext *ExtContext)
161-
: ImmutablePass(ID), MMI(TM, ExtContext) {
143+
MachineModuleInfo &MMI)
144+
: ImmutablePass(ID), MMI(MMI) {
162145
initializeMachineModuleInfoWrapperPassPass(*PassRegistry::getPassRegistry());
163146
}
164147

0 commit comments

Comments
 (0)