diff options
Diffstat (limited to 'lib/Target/X86/X86ATTAsmPrinter.cpp')
-rw-r--r-- | lib/Target/X86/X86ATTAsmPrinter.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/Target/X86/X86ATTAsmPrinter.cpp b/lib/Target/X86/X86ATTAsmPrinter.cpp index 8198fbe..20f2f00 100644 --- a/lib/Target/X86/X86ATTAsmPrinter.cpp +++ b/lib/Target/X86/X86ATTAsmPrinter.cpp @@ -165,6 +165,16 @@ bool X86ATTAsmPrinter::runOnMachineFunction(MachineFunction &MF) { DW.BeginFunction(&MF); } + if (Subtarget->isTargetDarwin()) { + // If the function is empty, then we need to emit *something*. Otherwise, + // the function's label might be associated with something that it wasn't + // meant to be associated with. We emit a noop in this situation. + MachineFunction::iterator I = MF.begin(); + + if (++I == MF.end() && MF.front().empty()) + O << "\tnop\n"; + } + // Print out code for the function. for (MachineFunction::const_iterator I = MF.begin(), E = MF.end(); I != E; ++I) { @@ -173,8 +183,8 @@ bool X86ATTAsmPrinter::runOnMachineFunction(MachineFunction &MF) { printBasicBlockLabel(I, true); O << '\n'; } - for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end(); - II != E; ++II) { + for (MachineBasicBlock::const_iterator II = I->begin(), IE = I->end(); + II != IE; ++II) { // Print the assembly for the instruction. O << "\t"; printMachineInstruction(II); |