aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2011-05-27 22:05:41 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2011-05-27 22:05:41 +0000
commit5b23b7fe3150b2050d6fcd6981d64f30930fd3ef (patch)
treeab1e0522945996dd5d27487fa5e0267351010d44 /lib/CodeGen/AsmPrinter/DwarfDebug.cpp
parent88c816453fac630e23785dbd1755675d139603db (diff)
Make size computation less brittle.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132222 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/AsmPrinter/DwarfDebug.cpp')
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfDebug.cpp16
1 files changed, 6 insertions, 10 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 53580d76aa..f29b1996cc 100644
--- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -2586,17 +2586,16 @@ void DwarfDebug::emitDebugLoc() {
Asm->OutStreamer.EmitSymbolValue(Entry.Begin, Size, 0);
Asm->OutStreamer.EmitSymbolValue(Entry.End, Size, 0);
DIVariable DV(Entry.Variable);
+ Asm->OutStreamer.AddComment("Loc expr size");
+ MCSymbol *begin = Asm->OutStreamer.getContext().CreateTempSymbol();
+ MCSymbol *end = Asm->OutStreamer.getContext().CreateTempSymbol();
+ Asm->EmitLabelDifference(end, begin, 2);
+ Asm->OutStreamer.EmitLabel(begin);
if (DV.hasComplexAddress()) {
unsigned N = DV.getNumAddrElements();
unsigned i = 0;
- Asm->OutStreamer.AddComment("Loc expr size");
if (N >= 2 && DV.getAddrElement(0) == DIBuilder::OpPlus) {
if (Entry.Loc.getOffset()) {
- unsigned Size = Asm->getDwarfRegOpSize(Entry.Loc);
- unsigned OffsetSize =
- MCAsmInfo::getSLEB128Size(DV.getAddrElement(1));
- // breg + deref + plus + offset
- Asm->EmitInt16(Size + 1 + 1 + OffsetSize + N - 2);
i = 2;
Asm->EmitDwarfRegOp(Entry.Loc);
Asm->OutStreamer.AddComment("DW_OP_deref");
@@ -2608,12 +2607,10 @@ void DwarfDebug::emitDebugLoc() {
// If first address element is OpPlus then emit
// DW_OP_breg + Offset instead of DW_OP_reg + Offset.
MachineLocation Loc(Entry.Loc.getReg(), DV.getAddrElement(1));
- Asm->EmitInt16(Asm->getDwarfRegOpSize(Loc) + N - 2);
Asm->EmitDwarfRegOp(Loc);
i = 2;
}
} else {
- Asm->EmitInt16(Asm->getDwarfRegOpSize(Entry.Loc) + N);
Asm->EmitDwarfRegOp(Entry.Loc);
}
@@ -2628,10 +2625,9 @@ void DwarfDebug::emitDebugLoc() {
else llvm_unreachable("unknown Opcode found in complex address");
}
} else {
- Asm->OutStreamer.AddComment("Loc expr size");
- Asm->EmitInt16(Asm->getDwarfRegOpSize(Entry.Loc));
Asm->EmitDwarfRegOp(Entry.Loc);
}
+ Asm->OutStreamer.EmitLabel(end);
}
}
}