If the function has no machine instructions, then emit a "nop" so that
authorBill Wendling <isanbard@gmail.com>
Mon, 28 Jan 2008 09:15:03 +0000 (09:15 +0000)
committerBill Wendling <isanbard@gmail.com>
Mon, 28 Jan 2008 09:15:03 +0000 (09:15 +0000)
the function label isn't associated with something it shouldn't be.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46449 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/ARMAsmPrinter.cpp

index 12039672439fd6bfd10fc67b48d674208ba69831..d56f618d1ea15c29c0faa87bde4a3a1e0b5f1c6f 100644 (file)
@@ -233,6 +233,16 @@ bool ARMAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
   // Emit pre-function debug information.
   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) {