Instead of printing unnecessary basic block labels as labels in
authorDan Gohman <gohman@apple.com>
Tue, 6 Oct 2009 17:38:38 +0000 (17:38 +0000)
committerDan Gohman <gohman@apple.com>
Tue, 6 Oct 2009 17:38:38 +0000 (17:38 +0000)
verbose-asm mode, print comments instead. This eliminates a non-comment
difference between verbose-asm mode and non-verbose-asm mode.

Also, factor out the relevant code out of all the targets and into
target-independent code.

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

15 files changed:
lib/CodeGen/AsmPrinter/AsmPrinter.cpp
lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp
lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp
lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp
lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp
lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp
lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp
lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp
lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp
lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp
lib/Target/XCore/AsmPrinter/XCoreAsmPrinter.cpp
test/CodeGen/X86/2006-10-19-SwitchUnnecessaryBranching.ll
test/CodeGen/X86/pic.ll

index 00f398083f1d701d04bf9a3a17d1743298656fc2..f149f10f3b45e5cbb63791c6d14f7090f9de7934 100644 (file)
@@ -1623,8 +1623,15 @@ void AsmPrinter::EmitBasicBlockStart(const MachineBasicBlock *MBB) const {
   if (unsigned Align = MBB->getAlignment())
     EmitAlignment(Log2_32(Align));
 
-  GetMBBSymbol(MBB->getNumber())->print(O, MAI);
-  O << ':';
+  if (MBB->pred_empty() || MBB->isOnlyReachableByFallthrough()) {
+    if (VerboseAsm)
+      O << MAI->getCommentString() << " BB#" << MBB->getNumber() << ':';
+  } else {
+    GetMBBSymbol(MBB->getNumber())->print(O, MAI);
+    O << ':';
+    if (!VerboseAsm)
+      O << '\n';
+  }
   
   if (VerboseAsm) {
     if (const BasicBlock *BB = MBB->getBasicBlock())
@@ -1635,6 +1642,7 @@ void AsmPrinter::EmitBasicBlockStart(const MachineBasicBlock *MBB) const {
       }
 
     EmitComments(*MBB);
+    O << '\n';
   }
 }
 
index cb241dc1b4550906293a4dd013e4434a61382209..bdaae222203b1056df4df7ce215b97f54f2bd065 100644 (file)
@@ -285,7 +285,6 @@ bool ARMAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
     // Print a label for the basic block.
     if (I != MF.begin()) {
       EmitBasicBlockStart(I);
-      O << '\n';
     }
     for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
          II != E; ++II) {
index fd4a99a0640768314fc60e97e9b44ba03c7d5554..d8e8b79f5398a510331219977cd82d7f591fb392 100644 (file)
@@ -171,7 +171,6 @@ bool AlphaAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
        I != E; ++I) {
     if (I != MF.begin()) {
       EmitBasicBlockStart(I);
-      O << '\n';
     }
     for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
          II != E; ++II) {
index 9807fd25be29005c08f0b9eecfa3ded3eee992c1..91fd5dde5a23739666746564b238ec1258c534d9 100644 (file)
@@ -135,13 +135,7 @@ bool BlackfinAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
   for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
        I != E; ++I) {
     // Print a label for the basic block.
-    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.
-    } else {
-      EmitBasicBlockStart(I);
-      O << '\n';
-    }
+    EmitBasicBlockStart(I);
 
     for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
          II != E; ++II) {
index c334e509ce540ef156d6a912a9f2cb047769851b..0f8d5393ab845b3b7ff0dca1e5d033ad2654db34 100644 (file)
@@ -460,7 +460,6 @@ bool LinuxAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
     // Print a label for the basic block.
     if (I != MF.begin()) {
       EmitBasicBlockStart(I);
-      O << '\n';
     }
     for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
          II != E; ++II) {
index b6d268d5f7a559fdf5c20193fc342e5b7f97bb1f..ad40fd4776da54b15d74a0440817a2bfe00d19a7 100644 (file)
@@ -124,13 +124,7 @@ bool MSP430AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
   for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
        I != E; ++I) {
     // Print a label for the basic block.
-    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.
-    } else {
-      EmitBasicBlockStart(I);
-      O << '\n';
-    }
+    EmitBasicBlockStart(I);
 
     for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
          II != E; ++II)
index 2159555849a0583401ac36155a574b73e5d2d2c3..ccf9ee518d33188214c98c0f1d09414ebd3174d1 100644 (file)
@@ -273,7 +273,6 @@ bool MipsAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
     // Print a label for the basic block.
     if (I != MF.begin()) {
       EmitBasicBlockStart(I);
-      O << '\n';
     }
 
     for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
index 60ad2c7f8f9b5a7e6e3852f3e1553615f635879e..3f415afc10902b67f93d624da5ca7dfb2f8e893e 100644 (file)
@@ -98,7 +98,6 @@ bool PIC16AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
     // Print a label for the basic block.
     if (I != MF.begin()) {
       EmitBasicBlockStart(I);
-      O << '\n';
     }
     
     // Print a basic block.
index 8ac93050071eae9f252e12d720474f4d5d1eed08..a0fba86fa6b2368f5539ccb0210cce8e36fafe42 100644 (file)
@@ -660,7 +660,6 @@ bool PPCLinuxAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
     // Print a label for the basic block.
     if (I != MF.begin()) {
       EmitBasicBlockStart(I);
-      O << '\n';
     }
     for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
          II != E; ++II) {
@@ -844,7 +843,6 @@ bool PPCDarwinAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
     // Print a label for the basic block.
     if (I != MF.begin()) {
       EmitBasicBlockStart(I);
-      O << '\n';
     }
     for (MachineBasicBlock::const_iterator II = I->begin(), IE = I->end();
          II != IE; ++II) {
index bf479a4c1b08b8185dd9a9958a915a3a8d2f4210..a3e5fba928f09e0e956f5eb86e6c5974b8439ebb 100644 (file)
@@ -119,7 +119,6 @@ bool SparcAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
     // Print a label for the basic block.
     if (I != MF.begin()) {
       EmitBasicBlockStart(I);
-      O << '\n';
     }
     for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
          II != E; ++II) {
index 89d365cef14ccf96f0d5bf590dddc65f0fb4d196..a128992934be9b95b1764c09cd292e4e6c70b2f4 100644 (file)
@@ -129,13 +129,7 @@ bool SystemZAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
   for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
        I != E; ++I) {
     // Print a label for the basic block.
-    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.
-    } else {
-      EmitBasicBlockStart(I);
-      O << '\n';
-    }
+    EmitBasicBlockStart(I);
 
     for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
          II != E; ++II)
index f75359454faa5df58a243579560e15aefb8208dd..2a0290db97e96dd308d6ab742d5160916859f511 100644 (file)
@@ -165,13 +165,7 @@ bool X86AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
   for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
        I != E; ++I) {
     // Print a label for the basic block.
-    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.
-    } else {
-      EmitBasicBlockStart(I);
-      O << '\n';
-    }
+    EmitBasicBlockStart(I);
     for (MachineBasicBlock::const_iterator II = I->begin(), IE = I->end();
          II != IE; ++II) {
       // Print the assembly for the instruction.
index a4b1d114b7d054c7736cfd95ce1da0c22d83a269..e58edda0c5dc62ebd30976d12a394a2ca42c3fbe 100644 (file)
@@ -274,7 +274,6 @@ bool XCoreAsmPrinter::runOnMachineFunction(MachineFunction &MF)
     // Print a label for the basic block.
     if (I != MF.begin()) {
       EmitBasicBlockStart(I);
-      O << '\n';
     }
 
     for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
index 4fd80724651d83a708e2e7d3885f14da858b4014..88e8b4a4fd92408c268c826f8547b3ece8a6da34 100644 (file)
@@ -7,7 +7,7 @@ define i32 @test(i32 %argc, i8** %argv) nounwind {
 entry:
 ; CHECK: cmpl  $2
 ; CHECK-NEXT: je
-; CHECK-NEXT: LBB1_1
+; CHECK-NEXT: %entry
 
        switch i32 %argc, label %UnifiedReturnBlock [
                 i32 1, label %bb
index e9218edebf1cf21e49b66b7241faf3d9a4808341..3a547f95f83fa4a5014be969459343d4db353ec4 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llc < %s -mtriple=i686-pc-linux-gnu -relocation-model=pic | FileCheck %s -check-prefix=LINUX
+; RUN: llc < %s -mtriple=i686-pc-linux-gnu -relocation-model=pic -asm-verbose=false | FileCheck %s -check-prefix=LINUX
 
 @ptr = external global i32* 
 @dst = external global i32 
@@ -12,7 +12,6 @@ entry:
     ret void
     
 ; LINUX:    test1:
-; LINUX: .LBB1_0:
 ; LINUX:       call    .L1$pb
 ; LINUX-NEXT: .L1$pb:
 ; LINUX-NEXT:  popl