Applied some recommend changes from sabre. The dominate one beginning "let the

pass manager do it's thing."  Fixes crash when compiling -g files and suppresses
dwarf statements if no debug info is present.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25100 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jim Laskey
2006-01-04 22:28:25 +00:00
parent 62281a132f
commit b2efb853f0
11 changed files with 257 additions and 218 deletions

View File

@@ -36,7 +36,7 @@ namespace llvm {
///
unsigned FunctionNumber;
protected:
public:
/// Output stream on which we're printing assembly code.
///
std::ostream &O;
@@ -162,7 +162,8 @@ namespace llvm {
/// HasDotTypeDotSizeDirective - True if the target has .type and .size
/// directives, this is true for most ELF targets.
bool HasDotTypeDotSizeDirective; // Defaults to true.
protected:
AsmPrinter(std::ostream &o, TargetMachine &TM);
public:
@@ -194,7 +195,7 @@ namespace llvm {
/// doFinalization - Shut down the asmprinter. If you override this in your
/// pass, you must make sure to call it explicitly.
bool doFinalization(Module &M);
/// SetupMachineFunction - This should be called when a new MachineFunction
/// is being processed from runOnMachineFunction.
void SetupMachineFunction(MachineFunction &MF);
@@ -231,43 +232,7 @@ namespace llvm {
private:
void EmitXXStructorList(Constant *List);
public:
/// getCommentString - get the comment string.
///
const char *getCommentString() {
return CommentString;
}
/// getData8bitsDirective - get the 8-bit data directive string.
///
const char *getData8bitsDirective() {
return Data8bitsDirective;
}
/// getData16bitsDirective - get the 16-bit data directive string.
///
const char *getData16bitsDirective() {
return Data16bitsDirective;
}
/// getData32bitsDirective - get the 32-bit data directive string.
///
const char *getData32bitsDirective() {
return Data32bitsDirective;
}
/// getData64bitsDirective - get the 64-bit data directive string.
///
const char *getData64bitsDirective() {
return Data64bitsDirective;
}
/// getPrivateGlobalPrefix - get private label prefix.
///
const char *getPrivateGlobalPrefix() {
return PrivateGlobalPrefix;
}
};
}

View File

@@ -14,8 +14,7 @@
#ifndef LLVM_CODEGEN_DWARFPRINTER_H
#define LLVM_CODEGEN_DWARFPRINTER_H
#include <iostream>
#include "llvm/CodeGen/MachineDebugInfo.h"
#include <iosfwd>
namespace llvm {
@@ -429,6 +428,7 @@ namespace llvm {
// Forward declarations.
//
class AsmPrinter;
class MachineDebugInfo;
//===--------------------------------------------------------------------===//
// DwarfWriter - emits dwarf debug and exception handling directives.
@@ -447,12 +447,28 @@ namespace llvm {
/// DebugInfo - Collected debug information.
///
MachineDebugInfo &DebugInfo;
MachineDebugInfo *DebugInfo;
/// didInitial - Flag to indicate if initial emission has been done.
///
bool didInitial;
//===------------------------------------------------------------------===//
// Properties to be set by the derived class ctor, used to configure the
// dwarf writer.
/// hasLEB128 - True if target asm supports leb128 directives.
///
bool hasLEB128; /// Defaults to false.
/// hasDotLoc - True if target asm supports .loc directives.
///
bool hasDotLoc; /// Defaults to false.
/// hasDotFile - True if target asm supports .file directives.
///
bool hasDotFile; /// Defaults to false.
/// needsSet - True if target asm can't compute addresses on data
/// directives.
bool needsSet; /// Defaults to false.
@@ -469,94 +485,89 @@ namespace llvm {
///
const char *DwarfLineSection; /// Defaults to ".debug_line".
//===------------------------------------------------------------------===//
public:
// Ctor.
DwarfWriter(std::ostream &o, AsmPrinter *ap, MachineDebugInfo &di)
DwarfWriter(std::ostream &o, AsmPrinter *ap)
: O(o)
, Asm(ap)
, DebugInfo(di)
, DebugInfo(NULL)
, didInitial(false)
, hasLEB128(false)
, hasDotLoc(false)
, hasDotFile(false)
, needsSet(false)
, DwarfAbbrevSection(".debug_abbrev")
, DwarfInfoSection(".debug_info")
, DwarfLineSection(".debug_line")
{}
/// SetDebugInfo - Set DebugInfo at when it's know that pass manager
/// has created it.
void SetDebugInfo(MachineDebugInfo *di) { DebugInfo = di; }
/// EmitHex - Emit a hexidecimal string to the output stream.
///
void EmitHex(unsigned Value) {
O << "0x"
<< std::hex
<< Value
<< std::dec;
}
void EmitHex(unsigned Value) const;
/// EmitComment - Emit a simple string comment.
///
void EmitComment(const char *Comment) {
O << "\t"
<< Asm->getCommentString()
<< " "
<< Comment
<< "\n";
}
void EmitComment(const char *Comment) const;
/// EmitULEB128 - Emit a series of hexidecimal values (separated by commas)
/// representing an unsigned leb128 value.
///
void EmitULEB128(unsigned Value) {
do {
unsigned Byte = Value & 0x7f;
Value >>= 7;
if (Value) Byte |= 0x80;
EmitHex(Byte);
if (Value) O << ", ";
} while (Value);
}
void EmitULEB128(unsigned Value) const;
/// EmitSLEB128 - Emit a series of hexidecimal values (separated by commas)
/// representing a signed leb128 value.
///
void EmitSLEB128(int Value) {
int Sign = Value >> (8 * sizeof(Value) - 1);
bool IsMore;
do {
unsigned Byte = Value & 0x7f;
Value >>= 7;
IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
if (IsMore) Byte |= 0x80;
EmitHex(Byte);
if (IsMore) O << ", ";
} while (IsMore);
}
void EmitSLEB128(int Value) const;
/// EmitLabelName - Emit label name for internal use by dwarf.
///
void EmitLabelName(const char *Tag, int Num) {
O << Asm->getPrivateGlobalPrefix()
<< "debug_"
<< Tag
<< Num;
}
void EmitLabelName(const char *Tag, int Num) const;
/// EmitLabel - Emit location label for internal use by dwarf.
///
void EmitLabel(const char *Tag, int Num) {
EmitLabelName(Tag, Num);
O << ":\n";
}
void EmitLabel(const char *Tag, int Num) const;
// Defined elsewhere
void EmitULEB128Bytes(unsigned Value, std::string Comment);
void EmitSLEB128Bytes(int Value, std::string Comment);
/// EmitULEB128Bytes - Emit an assembler byte data directive to compose an
/// unsigned leb128 value. Comment is added to the end of the directive if
/// DwarfVerbose is true (should not contain any newlines.)
///
void EmitULEB128Bytes(unsigned Value, const char *Comment) const;
/// EmitSLEB128Bytes - Emit an assembler byte data directive to compose a
/// signed leb128 value. Comment is added to the end of the directive if
/// DwarfVerbose is true (should not contain any newlines.)
///
void EmitSLEB128Bytes(int Value, const char *Comment) const;
/// EmitInitial - Emit initial dwarf declarations.
///
void EmitInitial() const;
/// ShouldEmitDwarf - Determine if dwarf declarations should be made.
///
bool ShouldEmitDwarf();
/// BeginModule - Emit all dwarf sections that should come prior to the
/// content.
void BeginModule();
/// EndModule - Emit all dwarf sections that should come after the content.
///
void EndModule();
/// BeginFunction - Emit pre-function debug information.
///
void BeginFunction();
/// EndFunction - Emit post-function debug information.
///
void EndFunction();
};

View File

@@ -28,11 +28,7 @@ namespace llvm {
///
class MachineDebugInfo : public ImmutablePass {
private:
// convenience types
typedef std::map<std::string, unsigned> StrIntMap;
typedef StrIntMap::iterator StrIntMapIter;
StrIntMap SourceMap; // Map of source file path to id
std::map<std::string, unsigned> SourceMap; // Map of source file path to id
unsigned SourceCount; // Number of source files (used to
// generate id)
unsigned UniqueID; // Number used to unique labels used
@@ -50,25 +46,25 @@ public:
/// hasInfo - Returns true if debug info is present.
///
// FIXME - need scheme to suppress debug output.
bool hasInfo() { return true; }
bool hasInfo() const { return SourceCount != 0; }
/// NextUniqueID - Returns a unique number for labels used by debugger.
/// getNextUniqueID - Returns a unique number for labels used by debugger.
///
unsigned NextUniqueID() { return UniqueID++; }
unsigned getNextUniqueID() { return UniqueID++; }
bool doInitialization();
bool doFinalization();
unsigned RecordSource(std::string fname, std::string dirname);
std::vector<std::string> getSourceFiles();
/// getUniqueSourceID - Register a source file with debug info. Returns an id.
///
unsigned getUniqueSourceID(const std::string &fname,
const std::string &dirname);
/// getSourceFiles - Return a vector of files. Vector index + 1 equals id.
///
std::vector<std::string> getSourceFiles() const;
}; // End class MachineDebugInfo
//===----------------------------------------------------------------------===//
// FIXME - temporary hack until we can find a place to hang debug info from.
MachineDebugInfo &getMachineDebugInfo();
// FIXME - temporary hack until we can find a place to hand debug info from.
ModulePass *createDebugInfoPass();
} // End llvm namespace

View File

@@ -25,6 +25,7 @@
namespace llvm {
class TargetLowering;
class TargetMachine;
class MachineDebugInfo;
class MachineFunction;
/// SelectionDAG class - This is used to represent a portion of an LLVM function
@@ -41,6 +42,7 @@ namespace llvm {
class SelectionDAG {
TargetLowering &TLI;
MachineFunction &MF;
MachineDebugInfo *DI;
// Root - The root of the entire DAG. EntryNode - The starting token.
SDOperand Root, EntryNode;
@@ -52,7 +54,8 @@ class SelectionDAG {
std::map<std::pair<const Value*, int>, SDNode*> ValueNodes;
public:
SelectionDAG(TargetLowering &tli, MachineFunction &mf) : TLI(tli), MF(mf) {
SelectionDAG(TargetLowering &tli, MachineFunction &mf, MachineDebugInfo *di)
: TLI(tli), MF(mf), DI(di) {
EntryNode = Root = getNode(ISD::EntryToken, MVT::Other);
}
~SelectionDAG();
@@ -60,6 +63,7 @@ public:
MachineFunction &getMachineFunction() const { return MF; }
const TargetMachine &getTarget() const;
TargetLowering &getTargetLoweringInfo() const { return TLI; }
MachineDebugInfo *getMachineDebugInfo() const { return DI; }
/// viewGraph - Pop up a ghostview window with the DAG rendered using 'dot'.
///