diff --git a/lib/Target/X86/X86ATTAsmPrinter.cpp b/lib/Target/X86/X86ATTAsmPrinter.cpp index c4639b31510..d9b263ae62a 100755 --- a/lib/Target/X86/X86ATTAsmPrinter.cpp +++ b/lib/Target/X86/X86ATTAsmPrinter.cpp @@ -220,6 +220,32 @@ void X86ATTAsmPrinter::printMemReference(const MachineInstr *MI, unsigned Op){ /// void X86ATTAsmPrinter::printMachineInstruction(const MachineInstr *MI) { ++EmittedInsts; + // This works around some Darwin assembler bugs. + if (forDarwin) { + switch (MI->getOpcode()) { + case X86::REP_MOVSB: + O << "rep/movsb (%esi),(%edi)\n"; + return; + case X86::REP_MOVSD: + O << "rep/movsl (%esi),(%edi)\n"; + return; + case X86::REP_MOVSW: + O << "rep/movsw (%esi),(%edi)\n"; + return; + case X86::REP_STOSB: + O << "rep/stosb\n"; + return; + case X86::REP_STOSD: + O << "rep/stosl\n"; + return; + case X86::REP_STOSW: + O << "rep/stosw\n"; + return; + default: + break; + } + } + // Call the autogenerated instruction printer routines. printInstruction(MI); }