aboutsummaryrefslogtreecommitdiffstats
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2008-07-20 00:11:19 +0000
committerBill Wendling <isanbard@gmail.com>2008-07-20 00:11:19 +0000
commit1983a2a6fdcd777d6d3a757baa61307b5ddcb227 (patch)
tree3445fa8b8753a06c6e91debb4641ce51a8600086 /lib/CodeGen
parentd15bc31eb240507791020eda779e74afaaf0add3 (diff)
downloadexternal_llvm-1983a2a6fdcd777d6d3a757baa61307b5ddcb227.zip
external_llvm-1983a2a6fdcd777d6d3a757baa61307b5ddcb227.tar.gz
external_llvm-1983a2a6fdcd777d6d3a757baa61307b5ddcb227.tar.bz2
Pull r53795 from Gaz into mainline:
If .loc and .file aren't used, always emit the "debug_line" section. This requires at least one entry in the line matrix. So if there's nothing to emit into the matrix, emit an end of matrix value anyway. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53803 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/DwarfWriter.cpp43
1 files changed, 29 insertions, 14 deletions
diff --git a/lib/CodeGen/DwarfWriter.cpp b/lib/CodeGen/DwarfWriter.cpp
index a5862c9..124f4ea 100644
--- a/lib/CodeGen/DwarfWriter.cpp
+++ b/lib/CodeGen/DwarfWriter.cpp
@@ -2253,12 +2253,28 @@ private:
}
}
+ /// EmitEndOfLineMatrix - Emit the last address of the section and the end of
+ /// the line matrix.
+ ///
+ void EmitEndOfLineMatrix(unsigned SectionEnd) {
+ // Define last address of section.
+ Asm->EmitInt8(0); Asm->EOL("Extended Op");
+ Asm->EmitInt8(TD->getPointerSize() + 1); Asm->EOL("Op size");
+ Asm->EmitInt8(DW_LNE_set_address); Asm->EOL("DW_LNE_set_address");
+ EmitReference("section_end", SectionEnd); Asm->EOL("Section end label");
+
+ // Mark end of matrix.
+ Asm->EmitInt8(0); Asm->EOL("DW_LNE_end_sequence");
+ Asm->EmitULEB128Bytes(1); Asm->EOL();
+ Asm->EmitInt8(1); Asm->EOL();
+ }
+
/// EmitDebugLines - Emit source line information.
///
void EmitDebugLines() {
- // If there are no lines to emit (such as when we're using .loc directives
- // to emit .debug_line information) don't emit a .debug_line header.
- if (SectionSourceLines.empty())
+ // If the target is using .loc/.file, the assembler will be emitting the
+ // .debug_line table automatically.
+ if (TAI->hasDotLocAndDotFile())
return;
// Minimum line delta, thus ranging from -10..(255-10).
@@ -2330,7 +2346,9 @@ private:
EmitLabel("line_prolog_end", 0);
// A sequence for each text section.
- for (unsigned j = 0, M = SectionSourceLines.size(); j < M; ++j) {
+ unsigned SecSrcLinesSize = SectionSourceLines.size();
+
+ for (unsigned j = 0; j < SecSrcLinesSize; ++j) {
// Isolate current sections line info.
const std::vector<SourceLineInfo> &LineInfos = SectionSourceLines[j];
@@ -2398,17 +2416,14 @@ private:
}
}
- // Define last address of section.
- Asm->EmitInt8(0); Asm->EOL("Extended Op");
- Asm->EmitInt8(TD->getPointerSize() + 1); Asm->EOL("Op size");
- Asm->EmitInt8(DW_LNE_set_address); Asm->EOL("DW_LNE_set_address");
- EmitReference("section_end", j + 1); Asm->EOL("Section end label");
-
- // Mark end of matrix.
- Asm->EmitInt8(0); Asm->EOL("DW_LNE_end_sequence");
- Asm->EmitULEB128Bytes(1); Asm->EOL();
- Asm->EmitInt8(1); Asm->EOL();
+ EmitEndOfLineMatrix(j + 1);
}
+
+ if (SecSrcLinesSize == 0)
+ // Because we're emitting a debug_line section, we still need a line
+ // table. The linker and friends expect it to exist. If there's nothing to
+ // put into it, emit an empty table.
+ EmitEndOfLineMatrix(1);
EmitLabel("line_end", 0);