Unable to clone an instruction in AsmPrinter::EmitInstruction

I’m working on a custom VLIW (we call it Escala). At the moment I’m trying to implement EscalaAsmPrinter::EmitInstruction(const MachineInstr *MI). I’m trying to clone an instruction and this produces and error. Below are the code as well as error:

void EscalaAsmPrinter::EmitInstruction(const MachineInstr *MI) {
const MachineFunction *MF = MI->getParent()->getParent();
MachineInstr *CloneMI = MF->CloneMachineInstr(MI);


}

Here is the error:

lib/Target/Escala/EscalaAsmPrinter.cpp: In member function ‘virtual void {anonymous}::EscalaAsmPrinter::EmitInstruction(const llvm::MachineInstr*)’:
lib/Target/Escala/EscalaAsmPrinter.cpp:379:51: error: no matching function for call to ‘llvm::MachineFunction::CloneMachineInstr(const llvm::MachineInstr*&) const’
MachineInstr CloneMI = MF->CloneMachineInstr(MI);
^
lib/Target/Escala/EscalaAsmPrinter.cpp:379:51: note: candidate is:
In file included from include/llvm/Target/TargetInstrInfo.h:19:0,
from lib/Target/Escala/EscalaInstrInfo.h:19,
from lib/Target/Escala/EscalaAsmPrinter.cpp:17:
include/llvm/CodeGen/MachineFunction.h:383:17: note: llvm::MachineInstr
llvm::MachineFunction::CloneMachineInstr(const llvm::MachineInstr*)
MachineInstr *CloneMachineInstr(const MachineInstr *Orig);
^

This just doesn’t make sense to me. I’m missing something, but I can’t figure out what exactly. Would someone be able to shed some light on this?

Any help is really appreciated.

It looks like it’s complaining because you are trying to call a non-const function CloneMachineInstr but MF is a pointer to a const MachineFunction?

Thanks for the help.