Index: lib/Target/Mips/AsmParser/MipsAsmParser.cpp =================================================================== --- lib/Target/Mips/AsmParser/MipsAsmParser.cpp +++ lib/Target/Mips/AsmParser/MipsAsmParser.cpp @@ -1931,6 +1931,11 @@ } } + bool FillDelaySlot = + MCID.hasDelaySlot() && AssemblerOptions.back()->isReorder(); + if (FillDelaySlot) + getTargetStreamer().emitDirectiveSetNoReorder(); + MacroExpanderResultTy ExpandResult = tryExpandInstruction(Inst, IDLoc, Out, STI); switch (ExpandResult) { @@ -1945,8 +1950,10 @@ // If this instruction has a delay slot and .set reorder is active, // emit a NOP after it. - if (MCID.hasDelaySlot() && AssemblerOptions.back()->isReorder()) + if (FillDelaySlot) { createNop(hasShortDelaySlot(Inst.getOpcode()), IDLoc, Out, STI); + getTargetStreamer().emitDirectiveSetReorder(); + } if ((Inst.getOpcode() == Mips::JalOneReg || Inst.getOpcode() == Mips::JalTwoReg || ExpandedJalSym) && Index: test/MC/Mips/double-expand.s =================================================================== --- /dev/null +++ test/MC/Mips/double-expand.s @@ -0,0 +1,10 @@ +# RUN: llvm-mc -triple=mipsel-unknown-linux < %s | FileCheck %s +# RUN: llvm-mc -triple=mipsel-unknown-linux < %s | \ +# RUN: llvm-mc -triple=mipsel-unknown-linux | FileCheck %s + +# CHECK: bnez $2, foo +# CHECK: nop +# CHECK-NOT: nop + + .text + bnez $2, foo