diff options
| author | Bill Wendling <isanbard@gmail.com> | 2008-01-26 09:03:52 +0000 |
|---|---|---|
| committer | Bill Wendling <isanbard@gmail.com> | 2008-01-26 09:03:52 +0000 |
| commit | 1a17ef02c81f5b467dbd4a44a799ae91326e0d75 (patch) | |
| tree | 7d9da4ee1b0ae71bbde0aa241fd525700fe56804 /llvm/lib | |
| parent | a60c61dc1ae69f21d3ac66ce5099d11d4e75335b (diff) | |
| download | bcm5719-llvm-1a17ef02c81f5b467dbd4a44a799ae91326e0d75.tar.gz bcm5719-llvm-1a17ef02c81f5b467dbd4a44a799ae91326e0d75.zip | |
If there's no instructions being emitted on X86 for a function, emit a
nop. Emit the nop directly for PPC.
llvm-svn: 46398
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp | 8 | ||||
| -rw-r--r-- | llvm/lib/Target/X86/X86ATTAsmPrinter.cpp | 14 |
2 files changed, 14 insertions, 8 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp index 6a1451d5dcf..6f0e41aec5f 100644 --- a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp +++ b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp @@ -819,12 +819,8 @@ bool DarwinAsmPrinter::runOnMachineFunction(MachineFunction &MF) { // be associated with. We emit a noop in this situation. MachineFunction::iterator I = MF.begin(); - if (++I == MF.end()) { - MachineBasicBlock &MBB = MF.front(); - - if (MBB.begin() == MBB.end()) - BuildMI(MBB, MBB.end(), TM.getInstrInfo()->get(PPC::NOP)); - } + 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(); diff --git a/llvm/lib/Target/X86/X86ATTAsmPrinter.cpp b/llvm/lib/Target/X86/X86ATTAsmPrinter.cpp index 8198fbe860e..20f2f003722 100644 --- a/llvm/lib/Target/X86/X86ATTAsmPrinter.cpp +++ b/llvm/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); |

