[llvm-commits] [llvm] r49366 - /llvm/trunk/lib/Target/X86/X86ATTAsmPrinter.cpp

Dale Johannesen dalej at apple.com
Mon Apr 7 17:37:56 PDT 2008


Author: johannes
Date: Mon Apr  7 19:37:56 2008
New Revision: 49366

URL: http://llvm.org/viewvc/llvm-project?rev=49366&view=rev
Log:
Handle the situation in 2008-01-25-EmptyFunction.ll
correctly when unwind info is being generated.


Modified:
    llvm/trunk/lib/Target/X86/X86ATTAsmPrinter.cpp

Modified: llvm/trunk/lib/Target/X86/X86ATTAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ATTAsmPrinter.cpp?rev=49366&r1=49365&r2=49366&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/X86ATTAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ATTAsmPrinter.cpp Mon Apr  7 19:37:56 2008
@@ -156,17 +156,8 @@
     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.
+  bool hasAnyRealCode = false;
   for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
        I != E; ++I) {
     // Print a label for the basic block.
@@ -177,10 +168,20 @@
     for (MachineBasicBlock::const_iterator II = I->begin(), IE = I->end();
          II != IE; ++II) {
       // Print the assembly for the instruction.
+      if (II->getOpcode() != X86::LABEL)
+        hasAnyRealCode = true;
       printMachineInstruction(II);
     }
   }
 
+  if (Subtarget->isTargetDarwin() && !hasAnyRealCode) {
+    // 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.
+    // We are assuming inline asms are code.
+    O << "\tnop\n";
+  }
+
   if (TAI->hasDotTypeDotSizeDirective())
     O << "\t.size\t" << CurrentFnName << ", .-" << CurrentFnName << "\n";
 





More information about the llvm-commits mailing list