diff options
| author | Bill Wendling <isanbard@gmail.com> | 2008-01-26 06:51:24 +0000 |
|---|---|---|
| committer | Bill Wendling <isanbard@gmail.com> | 2008-01-26 06:51:24 +0000 |
| commit | 381802f8e06668d0ec5fc760804c83e511dafc7c (patch) | |
| tree | b06c50d1c029703ef07733f84fb360e4775d1544 /lib/Target | |
| parent | 418ab3729cbf094011eeaeb92306c410ae0f8944 (diff) | |
| download | external_llvm-381802f8e06668d0ec5fc760804c83e511dafc7c.zip external_llvm-381802f8e06668d0ec5fc760804c83e511dafc7c.tar.gz external_llvm-381802f8e06668d0ec5fc760804c83e511dafc7c.tar.bz2 | |
If there are no machine instructions emitted for a function, then insert
a "nop" instruction so that we don't have the function's label associated
with something that it's not supposed to be associated with.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46394 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target')
| -rw-r--r-- | lib/Target/PowerPC/PPCAsmPrinter.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/Target/PowerPC/PPCAsmPrinter.cpp b/lib/Target/PowerPC/PPCAsmPrinter.cpp index bab1af3..6a1451d 100644 --- a/lib/Target/PowerPC/PPCAsmPrinter.cpp +++ b/lib/Target/PowerPC/PPCAsmPrinter.cpp @@ -30,6 +30,7 @@ #include "llvm/CodeGen/MachineModuleInfo.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineInstr.h" +#include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/Support/Mangler.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/CommandLine.h" @@ -813,6 +814,18 @@ bool DarwinAsmPrinter::runOnMachineFunction(MachineFunction &MF) { // Emit pre-function debug information. DW.BeginFunction(&MF); + // 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()) { + MachineBasicBlock &MBB = MF.front(); + + if (MBB.begin() == MBB.end()) + BuildMI(MBB, MBB.end(), TM.getInstrInfo()->get(PPC::NOP)); + } + // Print out code for the function. for (MachineFunction::const_iterator I = MF.begin(), E = MF.end(); I != E; ++I) { @@ -821,8 +834,8 @@ bool DarwinAsmPrinter::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); |
