1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 03:23:01 +02:00

If there's no instructions being emitted on X86 for a function, emit a

nop. Emit the nop directly for PPC.

llvm-svn: 46398
This commit is contained in:
Bill Wendling 2008-01-26 09:03:52 +00:00
parent 26fb9335f5
commit 7b83688c73
3 changed files with 20 additions and 8 deletions

View File

@ -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();

View File

@ -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);

View File

@ -0,0 +1,6 @@
; RUN: llvm-as < %s | llc -march=x86 | grep nop
define void @bork() noreturn nounwind {
entry:
unreachable
}