aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2011-05-24 00:22:25 +0000
committerDevang Patel <dpatel@apple.com>2011-05-24 00:22:25 +0000
commita9b324be9ca4a1f46d1ddf39ea0f6b6bbec86ae9 (patch)
treef79f257c371eb81680a04e1eb85e6fae6f74aa33 /lib/CodeGen/AsmPrinter/DwarfDebug.cpp
parent3a2f557bdc10156ad9877ed960ca98e1a1daa68c (diff)
Fix debug info for blocks' variable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131940 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/AsmPrinter/DwarfDebug.cpp')
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfDebug.cpp27
1 files changed, 21 insertions, 6 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index e6e3979fc1..f0ba675723 100644
--- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -2590,12 +2590,27 @@ void DwarfDebug::emitDebugLoc() {
unsigned i = 0;
Asm->OutStreamer.AddComment("Loc expr size");
if (N >= 2 && DV.getAddrElement(0) == DIBuilder::OpPlus) {
- // 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;
+ 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");
+ Asm->EmitInt8(dwarf::DW_OP_deref);
+ Asm->OutStreamer.AddComment("DW_OP_plus_uconst");
+ Asm->EmitInt8(dwarf::DW_OP_plus_uconst);
+ Asm->EmitSLEB128(DV.getAddrElement(1));
+ } else {
+ // 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);