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/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\"";