From 4c1ea6b115235208d3f812cb4c30e0b7cd385c13 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Wed, 12 Feb 2014 19:34:44 +0000 Subject: [PATCH] Debug info: Bugfix for r201190: DW_OP_piece takes bytes, not bits. rdar://problem/16015314 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201253 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 5 +++-- lib/CodeGen/AsmPrinter/DwarfUnit.cpp | 3 ++- test/DebugInfo/X86/subreg.ll | 2 +- test/DebugInfo/X86/subregisters.ll | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 32cf67ffb91..2f15c97f2de 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -931,8 +931,9 @@ void AsmPrinter::EmitDwarfRegOp(const MachineLocation &MLoc, } else { OutStreamer.AddComment("DW_OP_piece"); EmitInt8(dwarf::DW_OP_piece); - OutStreamer.AddComment(Twine(Size)); - EmitULEB128(Size); + unsigned ByteSize = Size / 8; // Assuming 8 bits per byte. + OutStreamer.AddComment(Twine(ByteSize)); + EmitULEB128(ByteSize); } } } diff --git a/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/lib/CodeGen/AsmPrinter/DwarfUnit.cpp index a6bae16b694..68a346887a4 100644 --- a/lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -470,8 +470,9 @@ void DwarfUnit::addRegisterOp(DIEBlock *TheDie, unsigned Reg) { addUInt(TheDie, dwarf::DW_FORM_data1, Size); addUInt(TheDie, dwarf::DW_FORM_data1, Offset); } else { + unsigned ByteSize = Size / 8; // Assuming 8 bits per byte. addUInt(TheDie, dwarf::DW_FORM_data1, dwarf::DW_OP_piece); - addUInt(TheDie, dwarf::DW_FORM_data1, Size); + addUInt(TheDie, dwarf::DW_FORM_data1, ByteSize); } } } diff --git a/test/DebugInfo/X86/subreg.ll b/test/DebugInfo/X86/subreg.ll index 58e3bfc3bc3..94526ffae85 100644 --- a/test/DebugInfo/X86/subreg.ll +++ b/test/DebugInfo/X86/subreg.ll @@ -5,7 +5,7 @@ ; CHECK: .byte 80 # DW_OP_reg0 ; CHECK: .byte 147 # DW_OP_piece -; CHECK: .byte 16 # 16 +; CHECK: .byte 2 # 2 define i16 @f(i16 signext %zzz) nounwind { entry: diff --git a/test/DebugInfo/X86/subregisters.ll b/test/DebugInfo/X86/subregisters.ll index ac0c3839869..738ab02c0ca 100644 --- a/test/DebugInfo/X86/subregisters.ll +++ b/test/DebugInfo/X86/subregisters.ll @@ -7,7 +7,7 @@ ; rdar://problem/16015314 ; ; CHECK: DW_AT_name [DW_FORM_strp]{{.*}} "a" -; CHECK: DW_AT_location [DW_FORM_block1] (<0x03> 54 93 20 ) +; CHECK: DW_AT_location [DW_FORM_block1] (<0x03> 54 93 04 ) ; ; struct bar { ; int a; -- 2.34.1