Move DebugInfo checks into EmitComments and remove them from

target-specific AsmPrinters.  Not all comments need DebugInfo.

Re-enable the line numbers comment test.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@88697 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Greene 2009-11-13 21:34:57 +00:00
parent c4c550c758
commit 1924aabf99
14 changed files with 35 additions and 28 deletions

View File

@ -18,6 +18,7 @@
#include "llvm/Module.h" #include "llvm/Module.h"
#include "llvm/CodeGen/GCMetadataPrinter.h" #include "llvm/CodeGen/GCMetadataPrinter.h"
#include "llvm/CodeGen/MachineConstantPool.h" #include "llvm/CodeGen/MachineConstantPool.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineJumpTableInfo.h" #include "llvm/CodeGen/MachineJumpTableInfo.h"
#include "llvm/CodeGen/MachineLoopInfo.h" #include "llvm/CodeGen/MachineLoopInfo.h"
@ -35,6 +36,7 @@
#include "llvm/Support/Mangler.h" #include "llvm/Support/Mangler.h"
#include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCAsmInfo.h"
#include "llvm/Target/TargetData.h" #include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetInstrInfo.h"
#include "llvm/Target/TargetLowering.h" #include "llvm/Target/TargetLowering.h"
#include "llvm/Target/TargetLoweringObjectFile.h" #include "llvm/Target/TargetLoweringObjectFile.h"
#include "llvm/Target/TargetOptions.h" #include "llvm/Target/TargetOptions.h"
@ -1822,21 +1824,28 @@ GCMetadataPrinter *AsmPrinter::GetOrCreateGCPrinter(GCStrategy *S) {
/// EmitComments - Pretty-print comments for instructions /// EmitComments - Pretty-print comments for instructions
void AsmPrinter::EmitComments(const MachineInstr &MI) const { void AsmPrinter::EmitComments(const MachineInstr &MI) const {
assert(VerboseAsm && !MI.getDebugLoc().isUnknown()); if (!VerboseAsm)
return;
DebugLocTuple DLT = MF->getDebugLocTuple(MI.getDebugLoc());
// Print source line info. bool Newline = false;
O.PadToColumn(MAI->getCommentColumn());
O << MAI->getCommentString() << " SrcLine "; if (!MI.getDebugLoc().isUnknown()) {
if (DLT.Scope) { DebugLocTuple DLT = MF->getDebugLocTuple(MI.getDebugLoc());
DICompileUnit CU(DLT.Scope);
if (!CU.isNull()) // Print source line info.
O << CU.getFilename() << " "; O.PadToColumn(MAI->getCommentColumn());
O << MAI->getCommentString() << " SrcLine ";
if (DLT.Scope) {
DICompileUnit CU(DLT.Scope);
if (!CU.isNull())
O << CU.getFilename() << " ";
}
O << DLT.Line;
if (DLT.Col != 0)
O << ":" << DLT.Col;
Newline = true;
} }
O << DLT.Line;
if (DLT.Col != 0)
O << ":" << DLT.Col;
} }
/// PrintChildLoopComment - Print comments about child loops within /// PrintChildLoopComment - Print comments about child loops within
@ -1867,8 +1876,7 @@ static void PrintChildLoopComment(formatted_raw_ostream &O,
} }
/// EmitComments - Pretty-print comments for basic blocks /// EmitComments - Pretty-print comments for basic blocks
void AsmPrinter::EmitComments(const MachineBasicBlock &MBB) const void AsmPrinter::EmitComments(const MachineBasicBlock &MBB) const {
{
if (VerboseAsm) { if (VerboseAsm) {
// Add loop depth information // Add loop depth information
const MachineLoop *loop = LI->getLoopFor(&MBB); const MachineLoop *loop = LI->getLoopFor(&MBB);

View File

@ -1086,7 +1086,7 @@ void ARMAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
printInstruction(MI); printInstruction(MI);
} }
if (VerboseAsm && !MI->getDebugLoc().isUnknown()) if (VerboseAsm)
EmitComments(*MI); EmitComments(*MI);
O << '\n'; O << '\n';
processDebugLoc(MI, false); processDebugLoc(MI, false);

View File

@ -178,7 +178,7 @@ bool AlphaAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
processDebugLoc(II, true); processDebugLoc(II, true);
printInstruction(II); printInstruction(II);
if (VerboseAsm && !II->getDebugLoc().isUnknown()) if (VerboseAsm)
EmitComments(*II); EmitComments(*II);
O << '\n'; O << '\n';
processDebugLoc(II, false); processDebugLoc(II, false);

View File

@ -143,7 +143,7 @@ bool BlackfinAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
processDebugLoc(II, true); processDebugLoc(II, true);
printInstruction(II); printInstruction(II);
if (VerboseAsm && !II->getDebugLoc().isUnknown()) if (VerboseAsm)
EmitComments(*II); EmitComments(*II);
O << '\n'; O << '\n';

View File

@ -406,7 +406,7 @@ void SPUAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
++EmittedInsts; ++EmittedInsts;
processDebugLoc(MI, true); processDebugLoc(MI, true);
printInstruction(MI); printInstruction(MI);
if (VerboseAsm && !MI->getDebugLoc().isUnknown()) if (VerboseAsm)
EmitComments(*MI); EmitComments(*MI);
processDebugLoc(MI, false); processDebugLoc(MI, false);
O << '\n'; O << '\n';

View File

@ -239,7 +239,7 @@ void MSP430AsmPrinter::printMachineInstruction(const MachineInstr *MI) {
printInstructionThroughMCStreamer(MI); printInstructionThroughMCStreamer(MI);
if (VerboseAsm && !MI->getDebugLoc().isUnknown()) if (VerboseAsm)
EmitComments(*MI); EmitComments(*MI);
O << '\n'; O << '\n';

View File

@ -282,7 +282,7 @@ bool MipsAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
// Print the assembly for the instruction. // Print the assembly for the instruction.
printInstruction(II); printInstruction(II);
if (VerboseAsm && !II->getDebugLoc().isUnknown()) if (VerboseAsm)
EmitComments(*II); EmitComments(*II);
O << '\n'; O << '\n';

View File

@ -46,7 +46,7 @@ PIC16AsmPrinter::PIC16AsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
bool PIC16AsmPrinter::printMachineInstruction(const MachineInstr *MI) { bool PIC16AsmPrinter::printMachineInstruction(const MachineInstr *MI) {
processDebugLoc(MI, true); processDebugLoc(MI, true);
printInstruction(MI); printInstruction(MI);
if (VerboseAsm && !MI->getDebugLoc().isUnknown()) if (VerboseAsm)
EmitComments(*MI); EmitComments(*MI);
O << '\n'; O << '\n';
processDebugLoc(MI, false); processDebugLoc(MI, false);

View File

@ -594,7 +594,7 @@ void PPCAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
printInstruction(MI); printInstruction(MI);
if (VerboseAsm && !MI->getDebugLoc().isUnknown()) if (VerboseAsm)
EmitComments(*MI); EmitComments(*MI);
O << '\n'; O << '\n';

View File

@ -126,7 +126,7 @@ bool SparcAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
processDebugLoc(II, true); processDebugLoc(II, true);
printInstruction(II); printInstruction(II);
if (VerboseAsm && !II->getDebugLoc().isUnknown()) if (VerboseAsm)
EmitComments(*II); EmitComments(*II);
O << '\n'; O << '\n';
processDebugLoc(II, false); processDebugLoc(II, false);

View File

@ -155,7 +155,7 @@ void SystemZAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
// Call the autogenerated instruction printer routines. // Call the autogenerated instruction printer routines.
printInstruction(MI); printInstruction(MI);
if (VerboseAsm && !MI->getDebugLoc().isUnknown()) if (VerboseAsm)
EmitComments(*MI); EmitComments(*MI);
O << '\n'; O << '\n';

View File

@ -651,7 +651,7 @@ void X86AsmPrinter::printMachineInstruction(const MachineInstr *MI) {
printInstructionThroughMCStreamer(MI); printInstructionThroughMCStreamer(MI);
if (VerboseAsm && !MI->getDebugLoc().isUnknown()) if (VerboseAsm)
EmitComments(*MI); EmitComments(*MI);
O << '\n'; O << '\n';

View File

@ -361,7 +361,7 @@ void XCoreAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
return; return;
} }
printInstruction(MI); printInstruction(MI);
if (VerboseAsm && !MI->getDebugLoc().isUnknown()) if (VerboseAsm)
EmitComments(*MI); EmitComments(*MI);
O << '\n'; O << '\n';

View File

@ -2,7 +2,6 @@
// print line numbers in asm. // print line numbers in asm.
// RUN: %llvmgcc -S -O0 -g %s -o - | llvm-as | \ // RUN: %llvmgcc -S -O0 -g %s -o - | llvm-as | \
// RUN: llc --disable-fp-elim -O0 -relocation-model=pic | grep {# SrcLine 25} // RUN: llc --disable-fp-elim -O0 -relocation-model=pic | grep {# SrcLine 25}
// XFAIL: *
#include <stdlib.h> #include <stdlib.h>