Factor some code to needsCFIMoves. Avoid printing moves when we don't have to.
authorRafael Espindola <rafael.espindola@gmail.com>
Fri, 29 Apr 2011 14:14:06 +0000 (14:14 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Fri, 29 Apr 2011 14:14:06 +0000 (14:14 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130501 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/AsmPrinter.h
lib/CodeGen/AsmPrinter/AsmPrinter.cpp
lib/CodeGen/AsmPrinter/DwarfCFIException.cpp

index 600b218b7748d3ce5341cc0a5b118f6bc159b61b..58395ba9b4dbc8dfdd79f396870342c543d6e399 100644 (file)
@@ -185,6 +185,8 @@ namespace llvm {
 
     void emitPrologLabel(const MachineInstr &MI);
 
+    bool needsCFIMoves();
+
     /// EmitConstantPool - Print to the current output stream assembly
     /// representations of the constants in the constant pool MCP. This is
     /// used to print out constants which have been "spilled to memory" by
index 86e8bb6c3436515bd91b9ba0cb63f7c9eb72e685..549bdcb6687a5a55edda498ddba5096a80ed05ce 100644 (file)
@@ -38,6 +38,7 @@
 #include "llvm/Target/TargetInstrInfo.h"
 #include "llvm/Target/TargetLowering.h"
 #include "llvm/Target/TargetLoweringObjectFile.h"
+#include "llvm/Target/TargetOptions.h"
 #include "llvm/Target/TargetRegisterInfo.h"
 #include "llvm/Assembly/Writer.h"
 #include "llvm/ADT/SmallString.h"
@@ -591,6 +592,19 @@ static bool EmitDebugValueComment(const MachineInstr *MI, AsmPrinter &AP) {
   return true;
 }
 
+bool AsmPrinter::needsCFIMoves() {
+  if (UnwindTablesMandatory)
+    return true;
+
+  if (MMI->hasDebugInfo() && !MAI->doesDwarfRequireFrameSection())
+    return true;
+
+  if (MF->getFunction()->doesNotThrow())
+    return false;
+
+  return true;
+}
+
 void AsmPrinter::emitPrologLabel(const MachineInstr &MI) {
   MCSymbol *Label = MI.getOperand(0).getMCSymbol();
 
@@ -601,8 +615,10 @@ void AsmPrinter::emitPrologLabel(const MachineInstr &MI) {
   if (MAI->getExceptionHandlingType() != ExceptionHandling::DwarfCFI)
     return;
 
-  const MachineFunction &MF = *MI.getParent()->getParent();
-  MachineModuleInfo &MMI = MF.getMMI();
+  if (!needsCFIMoves())
+    return;
+
+  MachineModuleInfo &MMI = MF->getMMI();
   std::vector<MachineMove> &Moves = MMI.getFrameMoves();
   bool FoundOne = false;
   (void)FoundOne;
index 1dcfddf1a1858c88f6564aa86aa86ee1b2204f4b..e85d5298a0c573ed79fc4da333f0f0cd051d5836 100644 (file)
@@ -78,8 +78,7 @@ void DwarfCFIException::BeginFunction(const MachineFunction *MF) {
   shouldEmitTable = !MMI->getLandingPads().empty();
 
   // See if we need frame move info.
-  shouldEmitMoves = MMI->hasDebugInfo() ||
-    !Asm->MF->getFunction()->doesNotThrow() || UnwindTablesMandatory;
+  shouldEmitMoves = Asm->needsCFIMoves();
 
   if (shouldEmitMoves || shouldEmitTable)
     // Assumes in correct section after the entry point.