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
diff --git a/include/llvm/Target/TargetAsmInfo.h b/include/llvm/Target/TargetAsmInfo.h
index 0a9047b..7e96c09 100644
--- a/include/llvm/Target/TargetAsmInfo.h
+++ b/include/llvm/Target/TargetAsmInfo.h
@@ -282,8 +282,13 @@
/// 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 @@
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 {
diff --git a/lib/CodeGen/DwarfWriter.cpp b/lib/CodeGen/DwarfWriter.cpp
index 55c2b09..8b6edac 100644
--- a/lib/CodeGen/DwarfWriter.cpp
+++ b/lib/CodeGen/DwarfWriter.cpp
@@ -1955,7 +1955,7 @@
didInitial = true;
// Dwarf sections base addresses.
- if (TAI->getDwarfRequiresFrameSection()) {
+ if (TAI->doesDwarfRequireFrameSection()) {
Asm->SwitchToDataSection(TAI->getDwarfFrameSection());
EmitLabel("section_frame", 0);
}
@@ -2324,7 +2324,7 @@
/// 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 @@
/// 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 @@
if (MMI &&
ExceptionHandling &&
- TAI->getSupportsExceptionHandling()) {
+ TAI->doesSupportExceptionHandling()) {
shouldEmit = true;
// Assumes in correct section after the entry point.
EmitLabel("eh_func_begin", ++SubprogramCount);
diff --git a/lib/Target/TargetAsmInfo.cpp b/lib/Target/TargetAsmInfo.cpp
index 8f85366..7918678 100644
--- a/lib/Target/TargetAsmInfo.cpp
+++ b/lib/Target/TargetAsmInfo.cpp
@@ -80,6 +80,7 @@
HasLEB128(false),
HasDotLoc(false),
HasDotFile(false),
+ SupportsDebugInformation(false),
SupportsExceptionHandling(false),
DwarfRequiresFrameSection(true),
DwarfSectionOffsetDirective(0),
diff --git a/lib/Target/X86/X86ATTAsmPrinter.cpp b/lib/Target/X86/X86ATTAsmPrinter.cpp
index 634f41b..17de053 100755
--- a/lib/Target/X86/X86ATTAsmPrinter.cpp
+++ b/lib/Target/X86/X86ATTAsmPrinter.cpp
@@ -71,9 +71,7 @@
/// 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 @@
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 @@
}
}
- // 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;
}
diff --git a/lib/Target/X86/X86AsmPrinter.cpp b/lib/Target/X86/X86AsmPrinter.cpp
index 7e7dc88..3a5889d 100644
--- a/lib/Target/X86/X86AsmPrinter.cpp
+++ b/lib/Target/X86/X86AsmPrinter.cpp
@@ -115,9 +115,7 @@
/// doInitialization
bool X86SharedAsmPrinter::doInitialization(Module &M) {
- if (Subtarget->isTargetELF() ||
- Subtarget->isTargetCygMing() ||
- Subtarget->isTargetDarwin()) {
+ if (TAI->doesSupportDebugInformation()) {
// Emit initial debug information.
DW.BeginModule(&M);
}
diff --git a/lib/Target/X86/X86TargetAsmInfo.cpp b/lib/Target/X86/X86TargetAsmInfo.cpp
index 67196b6..8734ecd 100644
--- a/lib/Target/X86/X86TargetAsmInfo.cpp
+++ b/lib/Target/X86/X86TargetAsmInfo.cpp
@@ -81,7 +81,8 @@
// 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 @@
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 @@
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\"";