Instead of printing unnecessary basic block labels as labels in

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.

llvm-svn: 83392
This commit is contained in:
Dan Gohman 2009-10-06 17:38:38 +00:00
parent 92e3a06623
commit 10d3dc569b
15 changed files with 16 additions and 42 deletions

View 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';
}
}

View 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) {

View 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) {

View 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) {

View 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) {

View 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)

View 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();

View 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.

View 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) {

View 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) {

View 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)

View 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.

View 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();

View 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

View 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