[llvm-commits] [llvm] r81652 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/Target/X86/AsmPrinter/X86MCInstLower.cpp lib/Target/X86/AsmPrinter/X86MCInstLower.h

Chris Lattner sabre at nondot.org
Sat Sep 12 16:02:08 PDT 2009


Author: lattner
Date: Sat Sep 12 18:02:08 2009
New Revision: 81652

URL: http://llvm.org/viewvc/llvm-project?rev=81652&view=rev
Log:
devirtualize AsmPrinter::printBasicBlockLabel since it is never overridden.
Move GetMBBSymbol up to AsmPrinter and make printBasicBlockLabel use it so that
we only have one place that decides what to name bb labels.  Hopefully various
clients of printBasicBlockLabel can start using GetMBBSymbol instead.

Modified:
    llvm/trunk/include/llvm/CodeGen/AsmPrinter.h
    llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
    llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp
    llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.h

Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AsmPrinter.h?rev=81652&r1=81651&r2=81652&view=diff

==============================================================================
--- llvm/trunk/include/llvm/CodeGen/AsmPrinter.h (original)
+++ llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Sat Sep 12 18:02:08 2009
@@ -46,6 +46,7 @@
   class MCContext;
   class MCSection;
   class MCStreamer;
+  class MCSymbol;
   class DwarfWriter;
   class Mangler;
   class MCAsmInfo;
@@ -345,6 +346,16 @@
     /// instructions, do not use this function outside of llvm-mc.
     virtual void printMCInst(const MCInst *MI);
 
+    /// GetMBBSymbol - Return the MCSymbol corresponding to the specified basic
+    /// block label.
+    MCSymbol *GetMBBSymbol(unsigned MBBID) const;
+    
+    /// printBasicBlockLabel - This method prints the label for the specified
+    /// MachineBasicBlock
+    void printBasicBlockLabel(const MachineBasicBlock *MBB,
+                              bool printAlign = false,
+                              bool printColon = false,
+                              bool printComment = true) const;
   protected:
     /// EmitZeros - Emit a block of zeros.
     ///
@@ -375,13 +386,7 @@
     /// that is an implicit def.
     virtual void printImplicitDef(const MachineInstr *MI) const;
     
-    /// printBasicBlockLabel - This method prints the label for the specified
-    /// MachineBasicBlock
-    virtual void printBasicBlockLabel(const MachineBasicBlock *MBB,
-                                      bool printAlign = false,
-                                      bool printColon = false,
-                                      bool printComment = true) const;
-                                      
+    
     /// printPICJumpTableSetLabel - This method prints a set label for the
     /// specified MachineBasicBlock for a jumptable entry.
     virtual void printPICJumpTableSetLabel(unsigned uid,

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=81652&r1=81651&r2=81652&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Sat Sep 12 18:02:08 2009
@@ -28,6 +28,7 @@
 #include "llvm/MC/MCInst.h"
 #include "llvm/MC/MCSection.h"
 #include "llvm/MC/MCStreamer.h"
+#include "llvm/MC/MCSymbol.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FormattedStream.h"
@@ -1634,6 +1635,15 @@
   return true;
 }
 
+MCSymbol *AsmPrinter::GetMBBSymbol(unsigned MBBID) const {
+  SmallString<60> Name;
+  raw_svector_ostream(Name) << MAI->getPrivateGlobalPrefix() << "BB"
+    << getFunctionNumber() << '_' << MBBID;
+  
+  return OutContext.GetOrCreateSymbol(Name.str());
+}
+
+
 /// printBasicBlockLabel - This method prints the label for the specified
 /// MachineBasicBlock
 void AsmPrinter::printBasicBlockLabel(const MachineBasicBlock *MBB,
@@ -1646,8 +1656,8 @@
       EmitAlignment(Log2_32(Align));
   }
 
-  O << MAI->getPrivateGlobalPrefix() << "BB" << getFunctionNumber() << '_'
-    << MBB->getNumber();
+  GetMBBSymbol(MBB->getNumber())->print(O, MAI);
+  
   if (printColon)
     O << ':';
   if (printComment) {

Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp?rev=81652&r1=81651&r2=81652&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp Sat Sep 12 18:02:08 2009
@@ -45,15 +45,6 @@
   return Ctx.GetOrCreateSymbol(Name.str());
 }
 
-MCSymbol *X86MCInstLower::GetMBBSymbol(unsigned MBBID) const {
-  SmallString<60> Name;
-  raw_svector_ostream(Name) << AsmPrinter.MAI->getPrivateGlobalPrefix() << "BB"
-      << AsmPrinter.getFunctionNumber() << '_' << MBBID;
-
-  return Ctx.GetOrCreateSymbol(Name.str());
-}
-
-
 
 /// LowerGlobalAddressOperand - Lower an MO_GlobalAddress operand to an
 /// MCOperand.
@@ -320,7 +311,7 @@
       break;
     case MachineOperand::MO_MachineBasicBlock:
       MCOp = MCOperand::CreateExpr(MCSymbolRefExpr::Create(
-                              GetMBBSymbol(MO.getMBB()->getNumber()), Ctx));
+                       AsmPrinter.GetMBBSymbol(MO.getMBB()->getNumber()), Ctx));
       break;
     case MachineOperand::MO_GlobalAddress:
       MCOp = LowerSymbolOperand(MO, GetGlobalAddressSymbol(MO));

Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.h?rev=81652&r1=81651&r2=81652&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.h (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.h Sat Sep 12 18:02:08 2009
@@ -36,7 +36,6 @@
 
   MCSymbol *GetPICBaseSymbol() const;
   
-  MCSymbol *GetMBBSymbol(unsigned MBBID) const;
   MCSymbol *GetGlobalAddressSymbol(const MachineOperand &MO) const;
   MCSymbol *GetExternalSymbolSymbol(const MachineOperand &MO) const;
   MCSymbol *GetJumpTableSymbol(const MachineOperand &MO) const;





More information about the llvm-commits mailing list