diff --git a/llvm/include/llvm/CodeGen/MachineFunction.h b/llvm/include/llvm/CodeGen/MachineFunction.h --- a/llvm/include/llvm/CodeGen/MachineFunction.h +++ b/llvm/include/llvm/CodeGen/MachineFunction.h @@ -224,7 +224,7 @@ }; class MachineFunction { - const Function &F; + Function &F; const LLVMTargetMachine &Target; const TargetSubtargetInfo *STI; MCContext &Ctx; @@ -435,7 +435,7 @@ using VariableDbgInfoMapTy = SmallVector; VariableDbgInfoMapTy VariableDbgInfos; - MachineFunction(const Function &F, const LLVMTargetMachine &Target, + MachineFunction(Function &F, const LLVMTargetMachine &Target, const TargetSubtargetInfo &STI, unsigned FunctionNum, MachineModuleInfo &MMI); MachineFunction(const MachineFunction &) = delete; @@ -484,6 +484,9 @@ const DataLayout &getDataLayout() const; /// Return the LLVM function that this machine code represents + Function &getFunction() { return F; } + + /// Return the LLVM function that this machine code represents const Function &getFunction() const { return F; } /// getName - Return the name of the corresponding LLVM function. diff --git a/llvm/include/llvm/CodeGen/MachineModuleInfo.h b/llvm/include/llvm/CodeGen/MachineModuleInfo.h --- a/llvm/include/llvm/CodeGen/MachineModuleInfo.h +++ b/llvm/include/llvm/CodeGen/MachineModuleInfo.h @@ -165,9 +165,9 @@ /// Returns the MachineFunction constructed for the IR function \p F. /// Creates a new MachineFunction if none exists yet. - MachineFunction &getOrCreateMachineFunction(const Function &F); + MachineFunction &getOrCreateMachineFunction(Function &F); - /// \bried Returns the MachineFunction associated to IR function \p F if there + /// \brief Returns the MachineFunction associated to IR function \p F if there /// is one, otherwise nullptr. MachineFunction *getMachineFunction(const Function &F) const; diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp --- a/llvm/lib/CodeGen/MachineFunction.cpp +++ b/llvm/lib/CodeGen/MachineFunction.cpp @@ -133,8 +133,7 @@ return STI->getFrameLowering()->getStackAlign().value(); } -MachineFunction::MachineFunction(const Function &F, - const LLVMTargetMachine &Target, +MachineFunction::MachineFunction(Function &F, const LLVMTargetMachine &Target, const TargetSubtargetInfo &STI, unsigned FunctionNum, MachineModuleInfo &mmi) : F(F), Target(Target), STI(&STI), Ctx(mmi.getContext()), MMI(mmi) { diff --git a/llvm/lib/CodeGen/MachineModuleInfo.cpp b/llvm/lib/CodeGen/MachineModuleInfo.cpp --- a/llvm/lib/CodeGen/MachineModuleInfo.cpp +++ b/llvm/lib/CodeGen/MachineModuleInfo.cpp @@ -225,8 +225,7 @@ return I != MachineFunctions.end() ? I->second.get() : nullptr; } -MachineFunction & -MachineModuleInfo::getOrCreateMachineFunction(const Function &F) { +MachineFunction &MachineModuleInfo::getOrCreateMachineFunction(Function &F) { // Shortcut for the common case where a sequence of MachineFunctionPasses // all query for the same Function. if (LastRequest == &F)