aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2008-01-26 09:03:52 +0000
committerBill Wendling <isanbard@gmail.com>2008-01-26 09:03:52 +0000
commit824a721560f29eedb1427f81182e81cacf7e3ad4 (patch)
tree789a28e4c73b4295b973ad9cd204ebd979058503 /lib/Target
parentc79348d8dc43345e5c232ca421ccff6a23d0e624 (diff)
downloadexternal_llvm-824a721560f29eedb1427f81182e81cacf7e3ad4.zip
external_llvm-824a721560f29eedb1427f81182e81cacf7e3ad4.tar.gz
external_llvm-824a721560f29eedb1427f81182e81cacf7e3ad4.tar.bz2
If there's no instructions being emitted on X86 for a function, emit a
nop. Emit the nop directly for PPC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46398 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target')
-rw-r--r--lib/Target/PowerPC/PPCAsmPrinter.cpp8
-rw-r--r--lib/Target/X86/X86ATTAsmPrinter.cpp14
2 files changed, 14 insertions, 8 deletions
diff --git a/lib/Target/PowerPC/PPCAsmPrinter.cpp b/lib/Target/PowerPC/PPCAsmPrinter.cpp
index 6a1451d..6f0e41a 100644
--- a/lib/Target/PowerPC/PPCAsmPrinter.cpp
+++ b/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/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);