Add a possibility to switch between CFI directives- and table-based frame description emission. Currently all the backends use table-based stuff.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123476 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Anton Korobeynikov
2011-01-14 21:58:08 +00:00
parent e749911372
commit 3965b5e974
8 changed files with 32 additions and 18 deletions

View File

@ -25,7 +25,9 @@ namespace llvm {
/// MCAsmInfo - This class is intended to be used as a base class for asm /// MCAsmInfo - This class is intended to be used as a base class for asm
/// properties and features specific to the target. /// properties and features specific to the target.
namespace ExceptionHandling { enum ExceptionsType { None, Dwarf, SjLj }; } namespace ExceptionHandling {
enum ExceptionsType { None, DwarfTable, DwarfCFI, SjLj };
}
class MCAsmInfo { class MCAsmInfo {
protected: protected:
@ -438,6 +440,12 @@ namespace llvm {
ExceptionHandling::ExceptionsType getExceptionHandlingType() const { ExceptionHandling::ExceptionsType getExceptionHandlingType() const {
return ExceptionsType; return ExceptionsType;
} }
bool isExceptionHandlingDwarf() const {
return
(ExceptionsType == ExceptionHandling::DwarfTable ||
ExceptionsType == ExceptionHandling::DwarfCFI);
}
bool doesDwarfRequireFrameSection() const { bool doesDwarfRequireFrameSection() const {
return DwarfRequiresFrameSection; return DwarfRequiresFrameSection;
} }

View File

@ -188,7 +188,15 @@ bool AsmPrinter::doInitialization(Module &M) {
DD = new DwarfDebug(this, &M); DD = new DwarfDebug(this, &M);
if (MAI->doesSupportExceptionHandling()) if (MAI->doesSupportExceptionHandling())
DE = new DwarfTableException(this); switch (MAI->getExceptionHandlingType()) {
default:
case ExceptionHandling::DwarfTable:
DE = new DwarfTableException(this);
break;
case ExceptionHandling::DwarfCFI:
DE = new DwarfCFIException(this);
break;
}
return false; return false;
} }

View File

@ -48,7 +48,7 @@ DwarfCFIException::~DwarfCFIException() {}
/// EndModule - Emit all exception information that should come after the /// EndModule - Emit all exception information that should come after the
/// content. /// content.
void DwarfCFIException::EndModule() { void DwarfCFIException::EndModule() {
if (Asm->MAI->getExceptionHandlingType() != ExceptionHandling::Dwarf) if (!Asm->MAI->isExceptionHandlingDwarf())
return; return;
if (!shouldEmitTableModule) if (!shouldEmitTableModule)

View File

@ -269,8 +269,7 @@ ComputeCallSiteTable(SmallVectorImpl<CallSiteEntry> &CallSites,
// instruction between the previous try-range and this one may throw, // instruction between the previous try-range and this one may throw,
// create a call-site entry with no landing pad for the region between the // create a call-site entry with no landing pad for the region between the
// try-ranges. // try-ranges.
if (SawPotentiallyThrowing && if (SawPotentiallyThrowing && Asm->MAI->isExceptionHandlingDwarf()) {
Asm->MAI->getExceptionHandlingType() == ExceptionHandling::Dwarf) {
CallSiteEntry Site = { LastLabel, BeginLabel, 0, 0 }; CallSiteEntry Site = { LastLabel, BeginLabel, 0, 0 };
CallSites.push_back(Site); CallSites.push_back(Site);
PreviousIsInvoke = false; PreviousIsInvoke = false;
@ -292,8 +291,7 @@ ComputeCallSiteTable(SmallVectorImpl<CallSiteEntry> &CallSites,
}; };
// Try to merge with the previous call-site. SJLJ doesn't do this // Try to merge with the previous call-site. SJLJ doesn't do this
if (PreviousIsInvoke && if (PreviousIsInvoke && Asm->MAI->isExceptionHandlingDwarf()) {
Asm->MAI->getExceptionHandlingType() == ExceptionHandling::Dwarf) {
CallSiteEntry &Prev = CallSites.back(); CallSiteEntry &Prev = CallSites.back();
if (Site.PadLabel == Prev.PadLabel && Site.Action == Prev.Action) { if (Site.PadLabel == Prev.PadLabel && Site.Action == Prev.Action) {
// Extend the range of the previous entry. // Extend the range of the previous entry.
@ -303,7 +301,7 @@ ComputeCallSiteTable(SmallVectorImpl<CallSiteEntry> &CallSites,
} }
// Otherwise, create a new call-site. // Otherwise, create a new call-site.
if (Asm->MAI->getExceptionHandlingType() == ExceptionHandling::Dwarf) if (Asm->MAI->isExceptionHandlingDwarf())
CallSites.push_back(Site); CallSites.push_back(Site);
else { else {
// SjLj EH must maintain the call sites in the order assigned // SjLj EH must maintain the call sites in the order assigned
@ -321,8 +319,7 @@ ComputeCallSiteTable(SmallVectorImpl<CallSiteEntry> &CallSites,
// If some instruction between the previous try-range and the end of the // If some instruction between the previous try-range and the end of the
// function may throw, create a call-site entry with no landing pad for the // function may throw, create a call-site entry with no landing pad for the
// region following the try-range. // region following the try-range.
if (SawPotentiallyThrowing && if (SawPotentiallyThrowing && Asm->MAI->isExceptionHandlingDwarf()) {
Asm->MAI->getExceptionHandlingType() == ExceptionHandling::Dwarf) {
CallSiteEntry Site = { LastLabel, 0, 0, 0 }; CallSiteEntry Site = { LastLabel, 0, 0, 0 };
CallSites.push_back(Site); CallSites.push_back(Site);
} }
@ -536,7 +533,7 @@ void DwarfException::EmitExceptionTable() {
} }
} else { } else {
// DWARF Exception handling // DWARF Exception handling
assert(Asm->MAI->getExceptionHandlingType() == ExceptionHandling::Dwarf); assert(Asm->MAI->isExceptionHandlingDwarf());
// The call-site table is a list of all call sites that may throw an // The call-site table is a list of all call sites that may throw an
// exception (including C++ 'throw' statements) in the procedure // exception (including C++ 'throw' statements) in the procedure

View File

@ -277,7 +277,7 @@ void DwarfTableException::EmitFDE(const FunctionEHFrameInfo &EHFrameInfo) {
/// EndModule - Emit all exception information that should come after the /// EndModule - Emit all exception information that should come after the
/// content. /// content.
void DwarfTableException::EndModule() { void DwarfTableException::EndModule() {
if (Asm->MAI->getExceptionHandlingType() != ExceptionHandling::Dwarf) if (!Asm->MAI->isExceptionHandlingDwarf())
return; return;
if (!shouldEmitMovesModule && !shouldEmitTableModule) if (!shouldEmitMovesModule && !shouldEmitTableModule)

View File

@ -301,7 +301,8 @@ bool LLVMTargetMachine::addCommonCodeGenPasses(PassManagerBase &PM,
// edge from elsewhere. // edge from elsewhere.
PM.add(createSjLjEHPass(getTargetLowering())); PM.add(createSjLjEHPass(getTargetLowering()));
// FALLTHROUGH // FALLTHROUGH
case ExceptionHandling::Dwarf: case ExceptionHandling::DwarfCFI:
case ExceptionHandling::DwarfTable:
PM.add(createDwarfEHPass(this)); PM.add(createDwarfEHPass(this));
break; break;
case ExceptionHandling::None: case ExceptionHandling::None:

View File

@ -17,7 +17,7 @@ using namespace llvm;
PPCMCAsmInfoDarwin::PPCMCAsmInfoDarwin(bool is64Bit) { PPCMCAsmInfoDarwin::PPCMCAsmInfoDarwin(bool is64Bit) {
PCSymbol = "."; PCSymbol = ".";
CommentString = ";"; CommentString = ";";
ExceptionsType = ExceptionHandling::Dwarf; ExceptionsType = ExceptionHandling::DwarfTable;
if (!is64Bit) if (!is64Bit)
Data64bitsDirective = 0; // We can't emit a 64-bit unit in PPC32 mode. Data64bitsDirective = 0; // We can't emit a 64-bit unit in PPC32 mode.
@ -48,7 +48,7 @@ PPCLinuxMCAsmInfo::PPCLinuxMCAsmInfo(bool is64Bit) {
// Exceptions handling // Exceptions handling
if (!is64Bit) if (!is64Bit)
ExceptionsType = ExceptionHandling::Dwarf; ExceptionsType = ExceptionHandling::DwarfTable;
ZeroDirective = "\t.space\t"; ZeroDirective = "\t.space\t";
Data64bitsDirective = is64Bit ? "\t.quad\t" : 0; Data64bitsDirective = is64Bit ? "\t.quad\t" : 0;

View File

@ -68,7 +68,7 @@ X86MCAsmInfoDarwin::X86MCAsmInfoDarwin(const Triple &Triple) {
DwarfUsesInlineInfoSection = true; DwarfUsesInlineInfoSection = true;
// Exceptions handling // Exceptions handling
ExceptionsType = ExceptionHandling::Dwarf; ExceptionsType = ExceptionHandling::DwarfTable;
} }
X86ELFMCAsmInfo::X86ELFMCAsmInfo(const Triple &T) { X86ELFMCAsmInfo::X86ELFMCAsmInfo(const Triple &T) {
@ -88,8 +88,8 @@ X86ELFMCAsmInfo::X86ELFMCAsmInfo(const Triple &T) {
SupportsDebugInformation = true; SupportsDebugInformation = true;
// Exceptions handling // Exceptions handling
ExceptionsType = ExceptionHandling::Dwarf; ExceptionsType = ExceptionHandling::DwarfTable;
// OpenBSD has buggy support for .quad in 32-bit mode, just split into two // OpenBSD has buggy support for .quad in 32-bit mode, just split into two
// .words. // .words.
if (T.getOS() == Triple::OpenBSD && T.getArch() == Triple::x86) if (T.getOS() == Triple::OpenBSD && T.getArch() == Triple::x86)