X("dwarfwriter", "DWARF Information Writer");
char DwarfWriter::ID = 0;
-namespace {
-
-static TimerGroup *DwarfTimerGroup = 0;
-static TimerGroup *getDwarfTimerGroup() {
- if (DwarfTimerGroup) return DwarfTimerGroup;
- return DwarfTimerGroup = new TimerGroup("Dwarf Exception and Debugging");
+static TimerGroup &getDwarfTimerGroup() {
+ static TimerGroup DwarfTimerGroup("Dwarf Exception and Debugging");
+ return DwarfTimerGroup;
}
-} // end anonymous namespace
-
namespace llvm {
//===----------------------------------------------------------------------===//
/// DIEAbbrevData - Dwarf abbreviation data, describes the one attribute of a
/// Dwarf abbreviation.
class DIEAbbrevData {
-private:
/// Attribute - Dwarf attribute code.
///
unsigned Attribute;
/// Form - Dwarf form code.
///
unsigned Form;
-
public:
- DIEAbbrevData(unsigned A, unsigned F)
- : Attribute(A)
- , Form(F)
- {}
+ DIEAbbrevData(unsigned A, unsigned F) : Attribute(A), Form(F) {}
// Accessors.
unsigned getAttribute() const { return Attribute; }
/// Data - Raw data bytes for abbreviation.
///
SmallVector<DIEAbbrevData, 8> Data;
-
public:
-
- DIEAbbrev(unsigned T, unsigned C)
- : Tag(T)
- , ChildrenFlag(C)
- , Data()
- {}
- ~DIEAbbrev() {}
+ DIEAbbrev(unsigned T, unsigned C) : Tag(T), ChildrenFlag(C), Data() {}
+ virtual ~DIEAbbrev() {}
// Accessors.
unsigned getTag() const { return Tag; }
public:
explicit DIE(unsigned Tag)
- : Abbrev(Tag, DW_CHILDREN_no)
- , Offset(0)
- , Size(0)
- , Children()
- , Values()
- {}
+ : Abbrev(Tag, DW_CHILDREN_no), Offset(0), Size(0), Children(), Values() {}
virtual ~DIE();
// Accessors.
///
unsigned Type;
- explicit DIEValue(unsigned T)
- : Type(T)
- {}
+ explicit DIEValue(unsigned T) : Type(T) {}
virtual ~DIEValue() {}
// Accessors
/// DIEString - A string value DIE.
///
class DIEString : public DIEValue {
+ const std::string Str;
public:
- const std::string String;
-
- explicit DIEString(const std::string &S) : DIEValue(isString), String(S) {}
+ explicit DIEString(const std::string &S) : DIEValue(isString), Str(S) {}
// Implement isa/cast/dyncast.
static bool classof(const DIEString *) { return true; }
/// SizeOf - Determine size of string value in bytes.
///
virtual unsigned SizeOf(const DwarfDebug &DD, unsigned Form) const {
- return String.size() + sizeof(char); // sizeof('\0');
+ return Str.size() + sizeof(char); // sizeof('\0');
}
/// Profile - Used to gather unique data for the value folding set.
///
- static void Profile(FoldingSetNodeID &ID, const std::string &String) {
+ static void Profile(FoldingSetNodeID &ID, const std::string &Str) {
ID.AddInteger(isString);
- ID.AddString(String);
+ ID.AddString(Str);
}
- virtual void Profile(FoldingSetNodeID &ID) { Profile(ID, String); }
+ virtual void Profile(FoldingSetNodeID &ID) { Profile(ID, Str); }
#ifndef NDEBUG
virtual void print(std::ostream &O) {
- O << "Str: \"" << String << "\"";
+ O << "Str: \"" << Str << "\"";
}
#endif
};
/// DIEDwarfLabel - A Dwarf internal label expression DIE.
//
class DIEDwarfLabel : public DIEValue {
-public:
-
const DWLabel Label;
-
+public:
explicit DIEDwarfLabel(const DWLabel &L) : DIEValue(isLabel), Label(L) {}
// Implement isa/cast/dyncast.
#endif
};
-
//===----------------------------------------------------------------------===//
/// DIEObjectLabel - A label to an object in code or data.
//
class DIEObjectLabel : public DIEValue {
-public:
const std::string Label;
-
+public:
explicit DIEObjectLabel(const std::string &L)
: DIEValue(isAsIsLabel), Label(L) {}
/// DIESectionOffset - A section offset DIE.
//
class DIESectionOffset : public DIEValue {
-public:
const DWLabel Label;
const DWLabel Section;
bool IsEH : 1;
bool UseSet : 1;
-
+public:
DIESectionOffset(const DWLabel &Lab, const DWLabel &Sec,
bool isEH = false, bool useSet = true)
- : DIEValue(isSectionOffset), Label(Lab), Section(Sec),
- IsEH(isEH), UseSet(useSet) {}
+ : DIEValue(isSectionOffset), Label(Lab), Section(Sec),
+ IsEH(isEH), UseSet(useSet) {}
// Implement isa/cast/dyncast.
static bool classof(const DIESectionOffset *) { return true; }
/// DIEDelta - A simple label difference DIE.
///
class DIEDelta : public DIEValue {
-public:
const DWLabel LabelHi;
const DWLabel LabelLo;
-
+public:
DIEDelta(const DWLabel &Hi, const DWLabel &Lo)
- : DIEValue(isDelta), LabelHi(Hi), LabelLo(Lo) {}
+ : DIEValue(isDelta), LabelHi(Hi), LabelLo(Lo) {}
// Implement isa/cast/dyncast.
static bool classof(const DIEDelta *) { return true; }
/// class can also be used as a proxy for a debug information entry not yet
/// defined (ie. types.)
class DIEntry : public DIEValue {
-public:
DIE *Entry;
-
+public:
explicit DIEntry(DIE *E) : DIEValue(isEntry), Entry(E) {}
+ void setEntry(DIE *E) { Entry = E; }
+
// Implement isa/cast/dyncast.
static bool classof(const DIEntry *) { return true; }
static bool classof(const DIEValue *E) { return E->Type == isEntry; }
/// DIEBlock - A block of values. Primarily used for location expressions.
//
class DIEBlock : public DIEValue, public DIE {
+ unsigned Size; // Size in bytes excluding size header.
public:
- unsigned Size; // Size in bytes excluding size header.
-
DIEBlock()
- : DIEValue(isBlock)
- , DIE(0)
- , Size(0)
- {}
- ~DIEBlock() {
- }
+ : DIEValue(isBlock), DIE(0), Size(0) {}
+ virtual ~DIEBlock() {}
// Implement isa/cast/dyncast.
static bool classof(const DIEBlock *) { return true; }
///
virtual unsigned SizeOf(const DwarfDebug &DD, unsigned Form) const;
-
/// Profile - Used to gather unique data for the value folding set.
///
virtual void Profile(FoldingSetNodeID &ID) {
/// CompileUnit - This dwarf writer support class manages information associate
/// with a source file.
class CompileUnit {
-private:
/// ID - File identifier for source.
///
unsigned ID;
/// DiesSet - Used to uniquely define dies within the compile unit.
///
FoldingSet<DIE> DiesSet;
-
public:
CompileUnit(unsigned I, DIE *D)
: ID(I), Die(D), GVToDieMap(),
//
DbgScope *RootDbgScope;
- // DbgScopeMap - Tracks the scopes in the current function.
+ /// DbgScopeMap - Tracks the scopes in the current function.
DenseMap<GlobalVariable *, DbgScope *> DbgScopeMap;
+
+ /// DebugTimer - Timer for the Dwarf debug writer.
+ Timer *DebugTimer;
struct FunctionDebugFrameInfo {
unsigned Number;
std::vector<FunctionDebugFrameInfo> DebugFrames;
-public:
+private:
+ /// getSourceDirectoryAndFileIds - Return the directory and file ids that
+ /// maps to the source id. Source id starts at 1.
+ std::pair<unsigned, unsigned>
+ getSourceDirectoryAndFileIds(unsigned SId) const {
+ return SourceIds[SId-1];
+ }
- /// ShouldEmitDwarfDebug - Returns true if Dwarf debugging declarations should
- /// be emitted.
- ///
- bool ShouldEmitDwarfDebug() const { return shouldEmit; }
+ /// getNumSourceDirectories - Return the number of source directories in the
+ /// debug info.
+ unsigned getNumSourceDirectories() const {
+ return DirectoryNames.size();
+ }
+
+ /// getSourceDirectoryName - Return the name of the directory corresponding
+ /// to the id.
+ const std::string &getSourceDirectoryName(unsigned Id) const {
+ return DirectoryNames[Id - 1];
+ }
+
+ /// getSourceFileName - Return the name of the source file corresponding
+ /// to the id.
+ const std::string &getSourceFileName(unsigned Id) const {
+ return SourceFileNames[Id - 1];
+ }
+
+ /// getNumSourceIds - Return the number of unique source ids.
+ unsigned getNumSourceIds() const {
+ return SourceIds.size();
+ }
/// AssignAbbrevNumber - Define a unique number for the abbreviation.
///
/// SetDIEntry - Set a DIEntry once the debug information entry is defined.
///
void SetDIEntry(DIEntry *Value, DIE *Entry) {
- Value->Entry = Entry;
+ Value->setEntry(Entry);
// Add to values set if not already there. If it is, we merely have a
// duplicate in the values list (no harm.)
ValuesSet.GetOrInsertNode(Value);
Die->AddValue(Attribute, Block->BestForm(), Value);
}
-private:
-
/// AddSourceLine - Add location information to specified debug information
/// entry.
void AddSourceLine(DIE *Die, const DIVariable *V) {
// Emit files.
for (unsigned SI = 1, SE = getNumSourceIds()+1; SI != SE; ++SI) {
// Remember source id starts at 1.
- std::pair<unsigned, unsigned> Id = getSourceDirsectoryAndFileIds(SI);
+ std::pair<unsigned, unsigned> Id = getSourceDirectoryAndFileIds(SI);
Asm->EmitString(getSourceFileName(Id.second));
Asm->EOL("Source");
Asm->EmitULEB128Bytes(Id.first);
Asm->EOL();
else {
std::pair<unsigned, unsigned> SourceID =
- getSourceDirsectoryAndFileIds(LineInfo.getSourceID());
+ getSourceDirectoryAndFileIds(LineInfo.getSourceID());
O << '\t' << TAI->getCommentString() << ' '
<< getSourceDirectoryName(SourceID.first) << ' '
<< getSourceFileName(SourceID.second)
}
}
+ /// GetOrCreateSourceID - Look up the source id with the given directory and
+ /// source file names. If none currently exists, create a new id and insert it
+ /// in the SourceIds map. This can update DirectoryNames and SourceFileNames maps
+ /// as well.
+ unsigned GetOrCreateSourceID(const std::string &DirName,
+ const std::string &FileName) {
+ unsigned DId;
+ StringMap<unsigned>::iterator DI = DirectoryIdMap.find(DirName);
+ if (DI != DirectoryIdMap.end()) {
+ DId = DI->getValue();
+ } else {
+ DId = DirectoryNames.size() + 1;
+ DirectoryIdMap[DirName] = DId;
+ DirectoryNames.push_back(DirName);
+ }
+
+ unsigned FId;
+ StringMap<unsigned>::iterator FI = SourceFileIdMap.find(FileName);
+ if (FI != SourceFileIdMap.end()) {
+ FId = FI->getValue();
+ } else {
+ FId = SourceFileNames.size() + 1;
+ SourceFileIdMap[FileName] = FId;
+ SourceFileNames.push_back(FileName);
+ }
+
+ DenseMap<std::pair<unsigned, unsigned>, unsigned>::iterator SI =
+ SourceIdMap.find(std::make_pair(DId, FId));
+ if (SI != SourceIdMap.end())
+ return SI->second;
+
+ unsigned SrcId = SourceIds.size() + 1; // DW_AT_decl_file cannot be 0.
+ SourceIdMap[std::make_pair(DId, FId)] = SrcId;
+ SourceIds.push_back(std::make_pair(DId, FId));
+
+ return SrcId;
+ }
+
void ConstructCompileUnit(GlobalVariable *GV) {
DICompileUnit DIUnit(GV);
std::string Dir, FN, Prod;
- unsigned ID = getOrCreateSourceID(DIUnit.getDirectory(Dir),
+ unsigned ID = GetOrCreateSourceID(DIUnit.getDirectory(Dir),
DIUnit.getFilename(FN));
DIE *Die = new DIE(DW_TAG_compile_unit);
// Main entry points.
//
DwarfDebug(raw_ostream &OS, AsmPrinter *A, const TargetAsmInfo *T)
- : Dwarf(OS, A, T, "dbg")
- , MainCU(NULL)
- , AbbreviationsSet(InitAbbreviationsSetSize)
- , Abbreviations()
- , ValuesSet(InitValuesSetSize)
- , Values()
- , StringPool()
- , SectionMap()
- , SectionSourceLines()
- , didInitial(false)
- , shouldEmit(false)
- , RootDbgScope(NULL)
- {
+ : Dwarf(OS, A, T, "dbg"), MainCU(0),
+ AbbreviationsSet(InitAbbreviationsSetSize), Abbreviations(),
+ ValuesSet(InitValuesSetSize), Values(), StringPool(), SectionMap(),
+ SectionSourceLines(), didInitial(false), shouldEmit(false),
+ RootDbgScope(0), DebugTimer(0) {
+ if (TimePassesIsEnabled)
+ DebugTimer = new Timer("Dwarf Debug Writer",
+ getDwarfTimerGroup());
}
virtual ~DwarfDebug() {
for (unsigned j = 0, M = Values.size(); j < M; ++j)
delete Values[j];
+
+ delete DebugTimer;
}
+ /// ShouldEmitDwarfDebug - Returns true if Dwarf debugging declarations should
+ /// be emitted.
+ bool ShouldEmitDwarfDebug() const { return shouldEmit; }
+
/// SetDebugInfo - Create global DIEs and emit initial debug info sections.
/// This is inovked by the target AsmPrinter.
void SetDebugInfo(MachineModuleInfo *mmi) {
+ if (TimePassesIsEnabled)
+ DebugTimer->startTimer();
+
// Create all the compile unit DIEs.
ConstructCompileUnits();
- if (CompileUnits.empty())
+ if (CompileUnits.empty()) {
+ if (TimePassesIsEnabled)
+ DebugTimer->stopTimer();
+
return;
+ }
// Create DIEs for each of the externally visible global variables.
bool globalDIEs = ConstructGlobalVariableDIEs();
// If there is not any debug info available for any global variables
// and any subprograms then there is not any debug info to emit.
- if (!globalDIEs && !subprogramDIEs)
+ if (!globalDIEs && !subprogramDIEs) {
+ if (TimePassesIsEnabled)
+ DebugTimer->stopTimer();
+
return;
+ }
MMI = mmi;
shouldEmit = true;
if (TAI->hasDotLocAndDotFile()) {
for (unsigned i = 1, e = getNumSourceIds()+1; i != e; ++i) {
// Remember source id starts at 1.
- std::pair<unsigned, unsigned> Id = getSourceDirsectoryAndFileIds(i);
+ std::pair<unsigned, unsigned> Id = getSourceDirectoryAndFileIds(i);
sys::Path FullPath(getSourceDirectoryName(Id.first));
bool AppendOk =
FullPath.appendComponent(getSourceFileName(Id.second));
// Emit initial sections
EmitInitial();
+
+ if (TimePassesIsEnabled)
+ DebugTimer->stopTimer();
}
/// BeginModule - Emit all Dwarf sections that should come prior to the
/// EndModule - Emit all Dwarf sections that should come after the content.
///
void EndModule() {
- if (!ShouldEmitDwarfDebug()) return;
+ if (!ShouldEmitDwarfDebug())
+ return;
+
+ if (TimePassesIsEnabled)
+ DebugTimer->startTimer();
// Standard sections final addresses.
Asm->SwitchToSection(TAI->getTextSection());
// Emit info into a debug macinfo section.
EmitDebugMacInfo();
+
+ if (TimePassesIsEnabled)
+ DebugTimer->stopTimer();
}
/// BeginFunction - Gather pre-function debug information. Assumes being
if (!ShouldEmitDwarfDebug()) return;
+ if (TimePassesIsEnabled)
+ DebugTimer->startTimer();
+
// Begin accumulating function debug information.
MMI->BeginFunction(MF);
const SrcLineInfo &LineInfo = Lines[0];
Asm->printLabel(LineInfo.getLabelID());
}
+
+ if (TimePassesIsEnabled)
+ DebugTimer->stopTimer();
}
/// EndFunction - Gather and emit post-function debug information.
void EndFunction(MachineFunction *MF) {
if (!ShouldEmitDwarfDebug()) return;
+ if (TimePassesIsEnabled)
+ DebugTimer->startTimer();
+
// Define end label for subprogram.
EmitLabel("func_end", SubprogramCount);
DbgScopeMap.clear();
RootDbgScope = NULL;
}
+
Lines.clear();
- }
-public:
+ if (TimePassesIsEnabled)
+ DebugTimer->stopTimer();
+ }
/// ValidDebugInfo - Return true if V represents valid debug info value.
bool ValidDebugInfo(Value *V) {
if (!GV->hasInternalLinkage () && !GV->hasLinkOnceLinkage())
return false;
+ if (TimePassesIsEnabled)
+ DebugTimer->startTimer();
+
DIDescriptor DI(GV);
+
// Check current version. Allow Version6 for now.
unsigned Version = DI.getVersion();
- if (Version != LLVMDebugVersion && Version != LLVMDebugVersion6)
+ if (Version != LLVMDebugVersion && Version != LLVMDebugVersion6) {
+ if (TimePassesIsEnabled)
+ DebugTimer->stopTimer();
+
return false;
+ }
unsigned Tag = DI.getTag();
switch (Tag) {
break;
}
+ if (TimePassesIsEnabled)
+ DebugTimer->stopTimer();
+
return true;
}
/// label. Returns a unique label ID used to generate a label and provide
/// correspondence to the source line list.
unsigned RecordSourceLine(Value *V, unsigned Line, unsigned Col) {
+ if (TimePassesIsEnabled)
+ DebugTimer->startTimer();
+
CompileUnit *Unit = CompileUnitMap[V];
assert(Unit && "Unable to find CompileUnit");
unsigned ID = MMI->NextLabelID();
Lines.push_back(SrcLineInfo(Line, Col, Unit->getID(), ID));
+
+ if (TimePassesIsEnabled)
+ DebugTimer->stopTimer();
+
return ID;
}
/// label. Returns a unique label ID used to generate a label and provide
/// correspondence to the source line list.
unsigned RecordSourceLine(unsigned Line, unsigned Col, unsigned Src) {
+ if (TimePassesIsEnabled)
+ DebugTimer->startTimer();
+
unsigned ID = MMI->NextLabelID();
Lines.push_back(SrcLineInfo(Line, Col, Src, ID));
+
+ if (TimePassesIsEnabled)
+ DebugTimer->stopTimer();
+
return ID;
}
- unsigned getRecordSourceLineCount() {
+ /// getRecordSourceLineCount - Return the number of source lines in the debug
+ /// info.
+ unsigned getRecordSourceLineCount() const {
return Lines.size();
}
- /// getNumSourceDirectories - Return the number of source directories in the
- /// debug info.
- unsigned getNumSourceDirectories() const {
- return DirectoryNames.size();
- }
-
- /// getSourceDirectoryName - Return the name of the directory corresponding
- /// to the id.
- const std::string &getSourceDirectoryName(unsigned Id) const {
- return DirectoryNames[Id - 1];
- }
-
- /// getNumSourceFiles - Return the number of source files in the debug info.
- ///
- unsigned getNumSourceFiles() const {
- return SourceFileNames.size();
- }
-
- /// getSourceFileName - Return the name of the source file corresponding
- /// to the id.
- const std::string &getSourceFileName(unsigned Id) const {
- return SourceFileNames[Id - 1];
- }
-
- /// getNumSourceIds - Return the number of unique source ids.
- ///
- unsigned getNumSourceIds() const {
- return SourceIds.size();
- }
-
- /// getSourceDirsectoryAndFileIds - Return the directory and file ids that
- /// maps to the source id. Source id starts at 1.
- std::pair<unsigned, unsigned>
- getSourceDirsectoryAndFileIds(unsigned SId) const {
- return SourceIds[SId-1];
- }
-
- /// getOrCreateSourceID - Look up the source id with the given directory and
- /// source file names. If none currently exists, create a new id and insert it
- /// in the SourceIds map. This can update DirectoryNames and SourceFileNames maps
- /// as well.
+ /// getOrCreateSourceID - Public version of GetOrCreateSourceID. This can be
+ /// timed. Look up the source id with the given directory and source file
+ /// names. If none currently exists, create a new id and insert it in the
+ /// SourceIds map. This can update DirectoryNames and SourceFileNames maps as
+ /// well.
unsigned getOrCreateSourceID(const std::string &DirName,
const std::string &FileName) {
- unsigned DId;
- StringMap<unsigned>::iterator DI = DirectoryIdMap.find(DirName);
- if (DI != DirectoryIdMap.end())
- DId = DI->getValue();
- else {
- DId = DirectoryNames.size() + 1;
- DirectoryIdMap[DirName] = DId;
- DirectoryNames.push_back(DirName);
- }
-
- unsigned FId;
- StringMap<unsigned>::iterator FI = SourceFileIdMap.find(FileName);
- if (FI != SourceFileIdMap.end())
- FId = FI->getValue();
- else {
- FId = SourceFileNames.size() + 1;
- SourceFileIdMap[FileName] = FId;
- SourceFileNames.push_back(FileName);
- }
+ if (TimePassesIsEnabled)
+ DebugTimer->startTimer();
+
+ unsigned SrcId = GetOrCreateSourceID(DirName, FileName);
+
+ if (TimePassesIsEnabled)
+ DebugTimer->stopTimer();
- DenseMap<std::pair<unsigned, unsigned>, unsigned>::iterator SI =
- SourceIdMap.find(std::make_pair(DId, FId));
- if (SI != SourceIdMap.end())
- return SI->second;
- unsigned SrcId = SourceIds.size() + 1; // DW_AT_decl_file cannot be 0.
- SourceIdMap[std::make_pair(DId, FId)] = SrcId;
- SourceIds.push_back(std::make_pair(DId, FId));
return SrcId;
}
/// RecordRegionStart - Indicate the start of a region.
- ///
unsigned RecordRegionStart(GlobalVariable *V) {
+ if (TimePassesIsEnabled)
+ DebugTimer->startTimer();
+
DbgScope *Scope = getOrCreateScope(V);
unsigned ID = MMI->NextLabelID();
if (!Scope->getStartLabelID()) Scope->setStartLabelID(ID);
+
+ if (TimePassesIsEnabled)
+ DebugTimer->stopTimer();
+
return ID;
}
/// RecordRegionEnd - Indicate the end of a region.
- ///
unsigned RecordRegionEnd(GlobalVariable *V) {
+ if (TimePassesIsEnabled)
+ DebugTimer->startTimer();
+
DbgScope *Scope = getOrCreateScope(V);
unsigned ID = MMI->NextLabelID();
Scope->setEndLabelID(ID);
+
+ if (TimePassesIsEnabled)
+ DebugTimer->stopTimer();
+
return ID;
}
/// RecordVariable - Indicate the declaration of a local variable.
- ///
void RecordVariable(GlobalVariable *GV, unsigned FrameIndex) {
+ if (TimePassesIsEnabled)
+ DebugTimer->startTimer();
+
DIDescriptor Desc(GV);
DbgScope *Scope = NULL;
+
if (Desc.getTag() == DW_TAG_variable) {
// GV is a global variable.
DIGlobalVariable DG(GV);
DIVariable DV(GV);
Scope = getOrCreateScope(DV.getContext().getGV());
}
+
assert(Scope && "Unable to find variable' scope");
DbgVariable *DV = new DbgVariable(DIVariable(GV), FrameIndex);
Scope->AddVariable(DV);
+
+ if (TimePassesIsEnabled)
+ DebugTimer->stopTimer();
}
};
/// should be emitted.
bool shouldEmitMovesModule;
+ /// ExceptionTimer - Timer for the Dwarf exception writer.
+ Timer *ExceptionTimer;
+
/// EmitCommonEHFrame - Emit the common eh unwind frame.
///
void EmitCommonEHFrame(const Function *Personality, unsigned Index) {
// Main entry points.
//
DwarfException(raw_ostream &OS, AsmPrinter *A, const TargetAsmInfo *T)
- : Dwarf(OS, A, T, "eh")
- , shouldEmitTable(false)
- , shouldEmitMoves(false)
- , shouldEmitTableModule(false)
- , shouldEmitMovesModule(false)
- {}
+ : Dwarf(OS, A, T, "eh"), shouldEmitTable(false), shouldEmitMoves(false),
+ shouldEmitTableModule(false), shouldEmitMovesModule(false),
+ ExceptionTimer(0) {
+ if (TimePassesIsEnabled)
+ ExceptionTimer = new Timer("Dwarf Exception Writer",
+ getDwarfTimerGroup());
+ }
- virtual ~DwarfException() {}
+ virtual ~DwarfException() {
+ delete ExceptionTimer;
+ }
/// SetModuleInfo - Set machine module information when it's known that pass
/// manager has created it. Set by the target AsmPrinter.
/// EndModule - Emit all exception information that should come after the
/// content.
void EndModule() {
+ if (TimePassesIsEnabled)
+ ExceptionTimer->startTimer();
+
if (shouldEmitMovesModule || shouldEmitTableModule) {
const std::vector<Function *> Personalities = MMI->getPersonalities();
for (unsigned i = 0; i < Personalities.size(); ++i)
E = EHFrames.end(); I != E; ++I)
EmitEHFrame(*I);
}
+
+ if (TimePassesIsEnabled)
+ ExceptionTimer->stopTimer();
}
/// BeginFunction - Gather pre-function exception information. Assumes being
/// emitted immediately after the function entry point.
void BeginFunction(MachineFunction *MF) {
+ if (TimePassesIsEnabled)
+ ExceptionTimer->startTimer();
+
this->MF = MF;
shouldEmitTable = shouldEmitMoves = false;
- if (MMI && TAI->doesSupportExceptionHandling()) {
+ if (MMI && TAI->doesSupportExceptionHandling()) {
// Map all labels and get rid of any dead landing pads.
MMI->TidyLandingPads();
+
// If any landing pads survive, we need an EH table.
if (MMI->getLandingPads().size())
shouldEmitTable = true;
// Assumes in correct section after the entry point.
EmitLabel("eh_func_begin", ++SubprogramCount);
}
+
shouldEmitTableModule |= shouldEmitTable;
shouldEmitMovesModule |= shouldEmitMoves;
+
+ if (TimePassesIsEnabled)
+ ExceptionTimer->stopTimer();
}
/// EndFunction - Gather and emit post-function exception information.
///
void EndFunction() {
+ if (TimePassesIsEnabled)
+ ExceptionTimer->startTimer();
+
if (shouldEmitMoves || shouldEmitTable) {
EmitLabel("eh_func_end", SubprogramCount);
EmitExceptionTable();
// Save EH frame information
EHFrames.
push_back(FunctionEHFrameInfo(getAsm()->getCurrentFunctionEHName(MF),
- SubprogramCount,
- MMI->getPersonalityIndex(),
- MF->getFrameInfo()->hasCalls(),
- !MMI->getLandingPads().empty(),
- MMI->getFrameMoves(),
- MF->getFunction()));
- }
+ SubprogramCount,
+ MMI->getPersonalityIndex(),
+ MF->getFrameInfo()->hasCalls(),
+ !MMI->getLandingPads().empty(),
+ MMI->getFrameMoves(),
+ MF->getFunction()));
+ }
+
+ if (TimePassesIsEnabled)
+ ExceptionTimer->stopTimer();
}
};
/// EmitValue - Emit string value.
///
void DIEString::EmitValue(DwarfDebug &DD, unsigned Form) {
- DD.getAsm()->EmitString(String);
+ DD.getAsm()->EmitString(Str);
}
//===----------------------------------------------------------------------===//
///
DwarfWriter::DwarfWriter()
- : ImmutablePass(&ID), DD(0), DE(0), DwarfTimer(0) {
- if (TimePassesIsEnabled)
- DwarfTimer = new Timer("Dwarf Writer", *getDwarfTimerGroup());
-}
+ : ImmutablePass(&ID), DD(0), DE(0) {}
DwarfWriter::~DwarfWriter() {
delete DE;
delete DD;
- delete DwarfTimer;
- delete DwarfTimerGroup; DwarfTimerGroup = 0;
}
/// BeginModule - Emit all Dwarf sections that should come prior to the
MachineModuleInfo *MMI,
raw_ostream &OS, AsmPrinter *A,
const TargetAsmInfo *T) {
- if (TimePassesIsEnabled)
- DwarfTimer->startTimer();
-
DE = new DwarfException(OS, A, T);
DD = new DwarfDebug(OS, A, T);
DE->BeginModule(M);
DD->BeginModule(M);
DD->SetDebugInfo(MMI);
DE->SetModuleInfo(MMI);
-
- if (TimePassesIsEnabled)
- DwarfTimer->stopTimer();
}
/// EndModule - Emit all Dwarf sections that should come after the content.
///
void DwarfWriter::EndModule() {
- if (TimePassesIsEnabled)
- DwarfTimer->startTimer();
-
DE->EndModule();
DD->EndModule();
-
- if (TimePassesIsEnabled)
- DwarfTimer->stopTimer();
}
/// BeginFunction - Gather pre-function debug information. Assumes being
/// emitted immediately after the function entry point.
void DwarfWriter::BeginFunction(MachineFunction *MF) {
- if (TimePassesIsEnabled)
- DwarfTimer->startTimer();
-
DE->BeginFunction(MF);
DD->BeginFunction(MF);
-
- if (TimePassesIsEnabled)
- DwarfTimer->stopTimer();
}
/// EndFunction - Gather and emit post-function debug information.
///
void DwarfWriter::EndFunction(MachineFunction *MF) {
- if (TimePassesIsEnabled)
- DwarfTimer->startTimer();
-
DD->EndFunction(MF);
DE->EndFunction();
if (MachineModuleInfo *MMI = DD->getMMI() ? DD->getMMI() : DE->getMMI())
// Clear function debug information.
MMI->EndFunction();
-
- if (TimePassesIsEnabled)
- DwarfTimer->stopTimer();
}
/// ValidDebugInfo - Return true if V represents valid debug info value.
bool DwarfWriter::ValidDebugInfo(Value *V) {
- if (TimePassesIsEnabled)
- DwarfTimer->startTimer();
-
- bool Res = DD && DD->ValidDebugInfo(V);
-
- if (TimePassesIsEnabled)
- DwarfTimer->stopTimer();
-
- return Res;
+ return DD && DD->ValidDebugInfo(V);
}
/// RecordSourceLine - Records location information and associates it with a
/// correspondence to the source line list.
unsigned DwarfWriter::RecordSourceLine(unsigned Line, unsigned Col,
unsigned Src) {
- if (TimePassesIsEnabled)
- DwarfTimer->startTimer();
-
- unsigned Res = DD->RecordSourceLine(Line, Col, Src);
-
- if (TimePassesIsEnabled)
- DwarfTimer->stopTimer();
-
- return Res;
+ return DD->RecordSourceLine(Line, Col, Src);
}
/// getOrCreateSourceID - Look up the source id with the given directory and
/// as well.
unsigned DwarfWriter::getOrCreateSourceID(const std::string &DirName,
const std::string &FileName) {
- if (TimePassesIsEnabled)
- DwarfTimer->startTimer();
-
- unsigned Res = DD->getOrCreateSourceID(DirName, FileName);
-
- if (TimePassesIsEnabled)
- DwarfTimer->stopTimer();
-
- return Res;
+ return DD->getOrCreateSourceID(DirName, FileName);
}
/// RecordRegionStart - Indicate the start of a region.
unsigned DwarfWriter::RecordRegionStart(GlobalVariable *V) {
- if (TimePassesIsEnabled)
- DwarfTimer->startTimer();
-
- unsigned Res = DD->RecordRegionStart(V);
-
- if (TimePassesIsEnabled)
- DwarfTimer->stopTimer();
-
- return Res;
+ return DD->RecordRegionStart(V);
}
/// RecordRegionEnd - Indicate the end of a region.
unsigned DwarfWriter::RecordRegionEnd(GlobalVariable *V) {
- if (TimePassesIsEnabled)
- DwarfTimer->startTimer();
-
- unsigned Res = DD->RecordRegionEnd(V);
-
- if (TimePassesIsEnabled)
- DwarfTimer->stopTimer();
-
- return Res;
+ return DD->RecordRegionEnd(V);
}
/// getRecordSourceLineCount - Count source lines.
unsigned DwarfWriter::getRecordSourceLineCount() {
- if (TimePassesIsEnabled)
- DwarfTimer->startTimer();
-
- unsigned Res = DD->getRecordSourceLineCount();
-
- if (TimePassesIsEnabled)
- DwarfTimer->stopTimer();
-
- return Res;
+ return DD->getRecordSourceLineCount();
}
/// RecordVariable - Indicate the declaration of a local variable.
///
void DwarfWriter::RecordVariable(GlobalVariable *GV, unsigned FrameIndex) {
- if (TimePassesIsEnabled)
- DwarfTimer->startTimer();
-
DD->RecordVariable(GV, FrameIndex);
-
- if (TimePassesIsEnabled)
- DwarfTimer->stopTimer();
}
/// ShouldEmitDwarfDebug - Returns true if Dwarf debugging declarations should
/// be emitted.
bool DwarfWriter::ShouldEmitDwarfDebug() const {
- if (TimePassesIsEnabled)
- DwarfTimer->startTimer();
-
- bool Res = DD->ShouldEmitDwarfDebug();
-
- if (TimePassesIsEnabled)
- DwarfTimer->stopTimer();
-
- return Res;
+ return DD->ShouldEmitDwarfDebug();
}