[llvm-commits] [llvm] r100374 - in /llvm/trunk/lib/CodeGen/AsmPrinter: DwarfException.cpp DwarfException.h DwarfWriter.cpp
Chris Lattner
sabre at nondot.org
Sun Apr 4 17:26:50 PDT 2010
Author: lattner
Date: Sun Apr 4 19:26:50 2010
New Revision: 100374
URL: http://llvm.org/viewvc/llvm-project?rev=100374&view=rev
Log:
make DwarfException not inherit from DwarfPrinter.
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp?rev=100374&r1=100373&r2=100374&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp Sun Apr 4 19:26:50 2010
@@ -39,7 +39,7 @@
using namespace llvm;
DwarfException::DwarfException(AsmPrinter *A)
- : DwarfPrinter(A), shouldEmitTable(false), shouldEmitMoves(false),
+ : Asm(A), MMI(Asm->MMI), shouldEmitTable(false), shouldEmitMoves(false),
shouldEmitTableModule(false), shouldEmitMovesModule(false),
ExceptionTimer(0) {
if (TimePassesIsEnabled)
@@ -55,10 +55,10 @@
/// in every non-empty .debug_frame section.
void DwarfException::EmitCIE(const Function *PersonalityFn, unsigned Index) {
// Size and sign of stack growth.
- int stackGrowth =
- Asm->TM.getFrameInfo()->getStackGrowthDirection() ==
- TargetFrameInfo::StackGrowsUp ?
- TD->getPointerSize() : -TD->getPointerSize();
+ int stackGrowth = Asm->getTargetData().getPointerSize();
+ if (Asm->TM.getFrameInfo()->getStackGrowthDirection() ==
+ TargetFrameInfo::StackGrowsDown)
+ stackGrowth *= -1;
const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
@@ -131,6 +131,8 @@
Asm->EmitULEB128(1, "CIE Code Alignment Factor");
Asm->EmitSLEB128(stackGrowth, "CIE Data Alignment Factor");
Asm->OutStreamer.AddComment("CIE Return Address Column");
+
+ const TargetRegisterInfo *RI = Asm->TM.getRegisterInfo();
Asm->EmitInt8(RI->getDwarfRegNum(RI->getRARegister(), true));
if (Augmentation[0]) {
@@ -156,7 +158,8 @@
// On Darwin the linker honors the alignment of eh_frame, which means it must
// be 8-byte on 64-bit targets to match what gcc does. Otherwise you get
// holes which confuse readers of eh_frame.
- Asm->EmitAlignment(TD->getPointerSize() == 4 ? 2 : 3, 0, 0, false);
+ Asm->EmitAlignment(Asm->getTargetData().getPointerSize() == 4 ? 2 : 3,
+ 0, 0, false);
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_frame_common_end", Index));
}
@@ -179,13 +182,13 @@
Asm->OutStreamer.EmitSymbolAttribute(EHFrameInfo.FunctionEHSym,MCSA_Global);
// If corresponding function is weak definition, this should be too.
- if (TheFunc->isWeakForLinker() && MAI->getWeakDefDirective())
+ if (TheFunc->isWeakForLinker() && Asm->MAI->getWeakDefDirective())
Asm->OutStreamer.EmitSymbolAttribute(EHFrameInfo.FunctionEHSym,
MCSA_WeakDefinition);
// If corresponding function is hidden, this should be too.
if (TheFunc->hasHiddenVisibility())
- if (MCSymbolAttr HiddenAttr = MAI->getHiddenVisibilityAttr())
+ if (MCSymbolAttr HiddenAttr = Asm->MAI->getHiddenVisibilityAttr())
Asm->OutStreamer.EmitSymbolAttribute(EHFrameInfo.FunctionEHSym,
HiddenAttr);
@@ -195,14 +198,14 @@
// info is to be available for non-EH uses.
if (!EHFrameInfo.hasCalls && !UnwindTablesMandatory &&
(!TheFunc->isWeakForLinker() ||
- !MAI->getWeakDefDirective() ||
+ !Asm->MAI->getWeakDefDirective() ||
TLOF.getSupportsWeakOmittedEHFrame())) {
Asm->OutStreamer.EmitAssignment(EHFrameInfo.FunctionEHSym,
MCConstantExpr::Create(0, Asm->OutContext));
// This name has no connection to the function, so it might get
// dead-stripped when the function is not, erroneously. Prohibit
// dead-stripping unconditionally.
- if (MAI->hasNoDeadStrip())
+ if (Asm->MAI->hasNoDeadStrip())
Asm->OutStreamer.EmitSymbolAttribute(EHFrameInfo.FunctionEHSym,
MCSA_NoDeadStrip);
} else {
@@ -258,7 +261,7 @@
// On Darwin the linker honors the alignment of eh_frame, which means it
// must be 8-byte on 64-bit targets to match what gcc does. Otherwise you
// get holes which confuse readers of eh_frame.
- Asm->EmitAlignment(TD->getPointerSize() == sizeof(int32_t) ? 2 : 3,
+ Asm->EmitAlignment(Asm->getTargetData().getPointerSize() == 4 ? 2 : 3,
0, 0, false);
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_frame_end",
EHFrameInfo.Number));
@@ -269,7 +272,7 @@
// on unused functions (calling undefined externals) being dead-stripped to
// link correctly. Yes, there really is.
if (MMI->isUsedFunction(EHFrameInfo.function))
- if (MAI->hasNoDeadStrip())
+ if (Asm->MAI->hasNoDeadStrip())
Asm->OutStreamer.EmitSymbolAttribute(EHFrameInfo.FunctionEHSym,
MCSA_NoDeadStrip);
}
@@ -472,7 +475,7 @@
bool PreviousIsInvoke = false;
// Visit all instructions in order of address.
- for (MachineFunction::const_iterator I = MF->begin(), E = MF->end();
+ for (MachineFunction::const_iterator I = Asm->MF->begin(), E = Asm->MF->end();
I != E; ++I) {
for (MachineBasicBlock::const_iterator MI = I->begin(), E = I->end();
MI != E; ++MI) {
@@ -503,7 +506,7 @@
// create a call-site entry with no landing pad for the region between the
// try-ranges.
if (SawPotentiallyThrowing &&
- MAI->getExceptionHandlingType() == ExceptionHandling::Dwarf) {
+ Asm->MAI->getExceptionHandlingType() == ExceptionHandling::Dwarf) {
CallSiteEntry Site = { LastLabel, BeginLabel, 0, 0 };
CallSites.push_back(Site);
PreviousIsInvoke = false;
@@ -526,7 +529,7 @@
// Try to merge with the previous call-site. SJLJ doesn't do this
if (PreviousIsInvoke &&
- MAI->getExceptionHandlingType() == ExceptionHandling::Dwarf) {
+ Asm->MAI->getExceptionHandlingType() == ExceptionHandling::Dwarf) {
CallSiteEntry &Prev = CallSites.back();
if (Site.PadLabel == Prev.PadLabel && Site.Action == Prev.Action) {
// Extend the range of the previous entry.
@@ -536,7 +539,7 @@
}
// Otherwise, create a new call-site.
- if (MAI->getExceptionHandlingType() == ExceptionHandling::Dwarf)
+ if (Asm->MAI->getExceptionHandlingType() == ExceptionHandling::Dwarf)
CallSites.push_back(Site);
else {
// SjLj EH must maintain the call sites in the order assigned
@@ -555,7 +558,7 @@
// function may throw, create a call-site entry with no landing pad for the
// region following the try-range.
if (SawPotentiallyThrowing &&
- MAI->getExceptionHandlingType() == ExceptionHandling::Dwarf) {
+ Asm->MAI->getExceptionHandlingType() == ExceptionHandling::Dwarf) {
CallSiteEntry Site = { LastLabel, 0, 0, 0 };
CallSites.push_back(Site);
}
@@ -623,7 +626,7 @@
// Final tallies.
// Call sites.
- bool IsSJLJ = MAI->getExceptionHandlingType() == ExceptionHandling::SjLj;
+ bool IsSJLJ = Asm->MAI->getExceptionHandlingType() == ExceptionHandling::SjLj;
bool HaveTTData = IsSJLJ ? (!TypeInfos.empty() || !FilterIds.empty()) : true;
unsigned CallSiteTableLength;
@@ -652,7 +655,8 @@
// For SjLj exceptions, if there is no TypeInfo, then we just explicitly say
// that we're omitting that bit.
TTypeEncoding = dwarf::DW_EH_PE_omit;
- TypeFormatSize = TD->getPointerSize(); // dwarf::DW_EH_PE_absptr
+ // dwarf::DW_EH_PE_absptr
+ TypeFormatSize = Asm->getTargetData().getPointerSize();
} else {
// Okay, we have actual filters or typeinfos to emit. As such, we need to
// pick a type encoding for them. We're about to emit a list of pointers to
@@ -692,9 +696,10 @@
// Emit the LSDA.
MCSymbol *GCCETSym =
Asm->OutContext.GetOrCreateSymbol(Twine("GCC_except_table")+
- Twine(SubprogramCount));
+ Twine(Asm->getFunctionNumber()));
Asm->OutStreamer.EmitLabel(GCCETSym);
- Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("exception", SubprogramCount));
+ Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("exception",
+ Asm->getFunctionNumber()));
if (IsSJLJ)
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("_LSDA_",
@@ -767,7 +772,7 @@
}
} else {
// DWARF Exception handling
- assert(MAI->getExceptionHandlingType() == ExceptionHandling::Dwarf);
+ assert(Asm->MAI->getExceptionHandlingType() == ExceptionHandling::Dwarf);
// The call-site table is a list of all call sites that may throw an
// exception (including C++ 'throw' statements) in the procedure
@@ -798,14 +803,14 @@
const CallSiteEntry &S = *I;
MCSymbol *EHFuncBeginSym =
- Asm->GetTempSymbol("eh_func_begin", SubprogramCount);
+ Asm->GetTempSymbol("eh_func_begin", Asm->getFunctionNumber());
MCSymbol *BeginLabel = S.BeginLabel;
if (BeginLabel == 0)
BeginLabel = EHFuncBeginSym;
MCSymbol *EndLabel = S.EndLabel;
if (EndLabel == 0)
- EndLabel = Asm->GetTempSymbol("eh_func_end", SubprogramCount);
+ EndLabel = Asm->GetTempSymbol("eh_func_end", Asm->getFunctionNumber());
// Offset of the call site relative to the previous call site, counted in
// number of 16-byte bundles. The first call site is counted relative to
@@ -891,7 +896,7 @@
/// EndModule - Emit all exception information that should come after the
/// content.
void DwarfException::EndModule() {
- if (MAI->getExceptionHandlingType() != ExceptionHandling::Dwarf)
+ if (Asm->MAI->getExceptionHandlingType() != ExceptionHandling::Dwarf)
return;
if (!shouldEmitMovesModule && !shouldEmitTableModule)
@@ -912,22 +917,22 @@
/// BeginFunction - Gather pre-function exception information. Assumes it's
/// being emitted immediately after the function entry point.
void DwarfException::BeginFunction(const MachineFunction *MF) {
- if (!MMI || !MAI->doesSupportExceptionHandling()) return;
+ if (!MMI || !Asm->MAI->doesSupportExceptionHandling()) return;
TimeRegion Timer(ExceptionTimer);
- this->MF = MF;
shouldEmitTable = shouldEmitMoves = false;
// If any landing pads survive, we need an EH table.
shouldEmitTable = !MMI->getLandingPads().empty();
// See if we need frame move info.
- shouldEmitMoves = !MF->getFunction()->doesNotThrow() || UnwindTablesMandatory;
+ shouldEmitMoves =
+ !Asm->MF->getFunction()->doesNotThrow() || UnwindTablesMandatory;
if (shouldEmitMoves || shouldEmitTable)
// Assumes in correct section after the entry point.
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_func_begin",
- ++SubprogramCount));
+ Asm->getFunctionNumber()));
shouldEmitTableModule |= shouldEmitTable;
shouldEmitMovesModule |= shouldEmitMoves;
@@ -939,7 +944,8 @@
if (!shouldEmitMoves && !shouldEmitTable) return;
TimeRegion Timer(ExceptionTimer);
- Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_func_end",SubprogramCount));
+ Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_func_end",
+ Asm->getFunctionNumber()));
// Record if this personality index uses a landing pad.
bool HasLandingPad = !MMI->getLandingPads().empty();
@@ -953,14 +959,15 @@
const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
MCSymbol *FunctionEHSym =
- Asm->GetSymbolWithGlobalValueBase(MF->getFunction(), ".eh",
+ Asm->GetSymbolWithGlobalValueBase(Asm->MF->getFunction(), ".eh",
TLOF.isFunctionEHFrameSymbolPrivate());
// Save EH frame information
- EHFrames.push_back(FunctionEHFrameInfo(FunctionEHSym, SubprogramCount,
+ EHFrames.push_back(FunctionEHFrameInfo(FunctionEHSym,
+ Asm->getFunctionNumber(),
MMI->getPersonalityIndex(),
- MF->getFrameInfo()->hasCalls(),
+ Asm->MF->getFrameInfo()->hasCalls(),
!MMI->getLandingPads().empty(),
MMI->getFrameMoves(),
- MF->getFunction()));
+ Asm->MF->getFunction()));
}
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h?rev=100374&r1=100373&r2=100374&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h Sun Apr 4 19:26:50 2010
@@ -14,8 +14,6 @@
#ifndef LLVM_CODEGEN_ASMPRINTER_DWARFEXCEPTION_H
#define LLVM_CODEGEN_ASMPRINTER_DWARFEXCEPTION_H
-#include "DIE.h"
-#include "DwarfPrinter.h"
#include "llvm/CodeGen/AsmPrinter.h"
#include "llvm/ADT/DenseMap.h"
#include <string>
@@ -32,7 +30,14 @@
//===----------------------------------------------------------------------===//
/// DwarfException - Emits Dwarf exception handling directives.
///
-class DwarfException : public DwarfPrinter {
+class DwarfException {
+ /// Asm - Target of Dwarf emission.
+ AsmPrinter *Asm;
+public:
+ /// MMI - Collected machine module information.
+ MachineModuleInfo *MMI;
+private:
+
struct FunctionEHFrameInfo {
MCSymbol *FunctionEHSym; // L_foo.eh
unsigned Number;
@@ -169,13 +174,6 @@
DwarfException(AsmPrinter *A);
virtual ~DwarfException();
- /// BeginModule - Emit all exception information that should come prior to the
- /// content.
- void BeginModule(Module *m) {
- this->M = m;
- this->MMI = Asm->MMI;
- }
-
/// EndModule - Emit all exception information that should come after the
/// content.
void EndModule();
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp?rev=100374&r1=100373&r2=100374&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp Sun Apr 4 19:26:50 2010
@@ -39,7 +39,6 @@
void DwarfWriter::BeginModule(Module *M, AsmPrinter *A) {
DE = new DwarfException(A);
DD = new DwarfDebug(A);
- DE->BeginModule(M);
DD->beginModule(M);
}
@@ -65,7 +64,7 @@
DD->endFunction(MF);
DE->EndFunction();
- if (MachineModuleInfo *MMI = DE->getMMI())
+ if (MachineModuleInfo *MMI = DE->MMI)
// Clear function debug information.
MMI->EndFunction();
}
More information about the llvm-commits
mailing list