Emit sections/directives in the proper order. This fixes PR1376. Also,

some small cleanup was made.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36780 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Anton Korobeynikov 2007-05-05 09:04:50 +00:00
parent 440168b00e
commit 2a07e2f4df
6 changed files with 37 additions and 42 deletions

View File

@ -282,8 +282,13 @@ namespace llvm {
/// HasDotFile - True if target asm supports .file directives.
///
bool HasDotFile; // Defaults to false.
/// SupportsExceptionHandling - True if target supports exception handling.
/// SupportsDebugInformation - True if target supports emission of debugging
/// information.
bool SupportsDebugInformation;
/// SupportsExceptionHandling - True if target supports
/// exception handling.
///
bool SupportsExceptionHandling; // Defaults to false.
@ -549,10 +554,13 @@ namespace llvm {
bool hasDotFile() const {
return HasDotFile;
}
bool getSupportsExceptionHandling() const {
bool doesSupportDebugInformation() const {
return SupportsDebugInformation;
}
bool doesSupportExceptionHandling() const {
return SupportsExceptionHandling;
}
bool getDwarfRequiresFrameSection() const {
bool doesDwarfRequireFrameSection() const {
return DwarfRequiresFrameSection;
}
const char *getDwarfSectionOffsetDirective() const {

View File

@ -1955,7 +1955,7 @@ private:
didInitial = true;
// Dwarf sections base addresses.
if (TAI->getDwarfRequiresFrameSection()) {
if (TAI->doesDwarfRequireFrameSection()) {
Asm->SwitchToDataSection(TAI->getDwarfFrameSection());
EmitLabel("section_frame", 0);
}
@ -2324,7 +2324,7 @@ private:
/// EmitInitialDebugFrame - Emit common frame info into a debug frame section.
///
void EmitInitialDebugFrame() {
if (!TAI->getDwarfRequiresFrameSection())
if (!TAI->doesDwarfRequireFrameSection())
return;
int stackGrowth =
@ -2367,7 +2367,7 @@ private:
/// EmitFunctionDebugFrame - Emit per function frame info into a debug frame
/// section.
void EmitFunctionDebugFrame() {
if (!TAI->getDwarfRequiresFrameSection())
if (!TAI->doesDwarfRequireFrameSection())
return;
// Start the dwarf frame section.
@ -3124,7 +3124,7 @@ public:
if (MMI &&
ExceptionHandling &&
TAI->getSupportsExceptionHandling()) {
TAI->doesSupportExceptionHandling()) {
shouldEmit = true;
// Assumes in correct section after the entry point.
EmitLabel("eh_func_begin", ++SubprogramCount);

View File

@ -80,6 +80,7 @@ TargetAsmInfo::TargetAsmInfo() :
HasLEB128(false),
HasDotLoc(false),
HasDotFile(false),
SupportsDebugInformation(false),
SupportsExceptionHandling(false),
DwarfRequiresFrameSection(true),
DwarfSectionOffsetDirective(0),

View File

@ -71,9 +71,7 @@ std::string X86ATTAsmPrinter::getSectionForFunction(const Function &F) const {
/// method to print assembly for each instruction.
///
bool X86ATTAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
if (Subtarget->isTargetDarwin() ||
Subtarget->isTargetELF() ||
Subtarget->isTargetCygMing()) {
if (TAI->doesSupportDebugInformation()) {
// Let PassManager know we need debug information and relay
// the MachineModuleInfo address on to DwarfWriter.
DW.SetModuleInfo(&getAnalysis<MachineModuleInfo>());
@ -150,9 +148,7 @@ bool X86ATTAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
F->getLinkage() == Function::WeakLinkage))
O << "Lllvm$workaround$fake$stub$" << CurrentFnName << ":\n";
if (Subtarget->isTargetDarwin() ||
Subtarget->isTargetELF() ||
Subtarget->isTargetCygMing()) {
if (TAI->doesSupportDebugInformation()) {
// Emit pre-function debug information.
DW.BeginFunction(&MF);
}
@ -173,22 +169,17 @@ bool X86ATTAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
}
}
// Print out jump tables referenced by the function.
// Mac OS X requires that the jump table follow the function, so that the jump
// table is part of the same atom that the function is in.
EmitJumpTableInfo(MF.getJumpTableInfo(), MF);
if (TAI->hasDotTypeDotSizeDirective())
O << "\t.size " << CurrentFnName << ", .-" << CurrentFnName << "\n";
if (Subtarget->isTargetDarwin() ||
Subtarget->isTargetELF() ||
Subtarget->isTargetCygMing()) {
if (TAI->doesSupportDebugInformation()) {
// Emit post-function debug information.
DW.EndFunction();
}
// Print out jump tables referenced by the function.
EmitJumpTableInfo(MF.getJumpTableInfo(), MF);
// We didn't modify anything.
return false;
}

View File

@ -115,9 +115,7 @@ void X86SharedAsmPrinter::decorateName(std::string &Name,
/// doInitialization
bool X86SharedAsmPrinter::doInitialization(Module &M) {
if (Subtarget->isTargetELF() ||
Subtarget->isTargetCygMing() ||
Subtarget->isTargetDarwin()) {
if (TAI->doesSupportDebugInformation()) {
// Emit initial debug information.
DW.BeginModule(&M);
}

View File

@ -81,7 +81,8 @@ X86TargetAsmInfo::X86TargetAsmInfo(const X86TargetMachine &TM) {
// Emit a local label that is preserved until the linker runs.
JumpTableSpecialLabelPrefix = "l";
}
SupportsDebugInformation = true;
NeedsSet = true;
DwarfAbbrevSection = ".section __DWARF,__debug_abbrev,regular,debug";
DwarfInfoSection = ".section __DWARF,__debug_info,regular,debug";
@ -97,26 +98,21 @@ X86TargetAsmInfo::X86TargetAsmInfo(const X86TargetMachine &TM) {
break;
case X86Subtarget::isELF:
// Set up DWARF directives
HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
AbsoluteDebugSectionOffsets = true;
AbsoluteEHSectionOffsets = false;
// 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.
ReadOnlySection = "\t.section\t.rodata\n";
FourByteConstantSection = "\t.section\t.rodata.cst4,\"aM\",@progbits,4";
EightByteConstantSection = "\t.section\t.rodata.cst8,\"aM\",@progbits,8";
SixteenByteConstantSection =
"\t.section\t.rodata.cst16,\"aM\",@progbits,16";
SixteenByteConstantSection = "\t.section\t.rodata.cst16,\"aM\",@progbits,16";
CStringSection = "\t.section\t.rodata.str1.1,\"aMS\",@progbits,1";
PrivateGlobalPrefix = ".L";
WeakRefDirective = "\t.weak\t";
SetDirective = "\t.set\t";
PCSymbol = ".";
// Set up DWARF directives
HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
AbsoluteDebugSectionOffsets = true;
AbsoluteEHSectionOffsets = false;
SupportsDebugInformation = true;
DwarfRequiresFrameSection = false;
DwarfAbbrevSection = "\t.section\t.debug_abbrev,\"\",@progbits";
DwarfInfoSection = "\t.section\t.debug_info,\"\",@progbits";
@ -144,14 +140,15 @@ X86TargetAsmInfo::X86TargetAsmInfo(const X86TargetMachine &TM) {
StaticCtorsSection = "\t.section .ctors,\"aw\"";
StaticDtorsSection = "\t.section .dtors,\"aw\"";
HiddenDirective = NULL;
PrivateGlobalPrefix = "L"; // Prefix for private global symbols
WeakRefDirective = "\t.weak\t";
SetDirective = "\t.set\t";
// Set up DWARF directives
HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
AbsoluteDebugSectionOffsets = true;
AbsoluteEHSectionOffsets = false;
PrivateGlobalPrefix = "L"; // Prefix for private global symbols
WeakRefDirective = "\t.weak\t";
SetDirective = "\t.set\t";
SupportsDebugInformation = true;
DwarfRequiresFrameSection = false;
DwarfSectionOffsetDirective = "\t.secrel32\t";
DwarfAbbrevSection = "\t.section\t.debug_abbrev,\"dr\"";