[llvm-commits] [llvm] r68073 - in /llvm/trunk: include/llvm/CodeGen/MachineBasicBlock.h lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp

Dan Gohman gohman at apple.com
Mon Mar 30 15:55:18 PDT 2009


Author: djg
Date: Mon Mar 30 17:55:17 2009
New Revision: 68073

URL: http://llvm.org/viewvc/llvm-project?rev=68073&view=rev
Log:
Except in asm-verbose mode, avoid printing labels for blocks that are
only reachable via fall-through edges. This dramatically reduces the
number of labels printed, and thus also the number of labels the
assembler must parse and remember.

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

Modified: llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h?rev=68073&r1=68072&r2=68073&view=diff

==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h Mon Mar 30 17:55:17 2009
@@ -253,6 +253,15 @@
   /// it returns end()
   iterator getFirstTerminator();
 
+  /// isOnlyReachableViaFallthough - Return true if this basic block has
+  /// exactly one predecessor and the control transfer mechanism between
+  /// the predecessor and this block is a fall-through.
+  bool isOnlyReachableByFallthrough() const {
+    return !pred_empty() &&
+           next(pred_begin()) == pred_end() &&
+           (*pred_begin())->getFirstTerminator() == (*pred_begin())->end();
+  }
+
   void pop_front() { Insts.pop_front(); }
   void pop_back() { Insts.pop_back(); }
   void push_back(MachineInstr *MI) { Insts.push_back(MI); }

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

==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Mon Mar 30 17:55:17 2009
@@ -238,7 +238,12 @@
   for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
        I != E; ++I) {
     // Print a label for the basic block.
-    if (!I->pred_empty()) {
+    if (!VerboseAsm && (I->pred_empty() || I->isOnlyReachableByFallthrough())) {
+      // This is an entry block or a block that's only reachable via a
+      // fallthrough edge. In non-VerboseAsm mode, don't print the label.
+      assert((I->pred_empty() || (*I->pred_begin())->isLayoutSuccessor(I)) &&
+             "Fall-through predecessor not adjacent to its successor!");
+    } else {
       printBasicBlockLabel(I, true, true, VerboseAsm);
       O << '\n';
     }





More information about the llvm-commits mailing list