Debug info: Bugfix for r201190: DW_OP_piece takes bytes, not bits.
authorAdrian Prantl <aprantl@apple.com>
Wed, 12 Feb 2014 19:34:44 +0000 (19:34 +0000)
committerAdrian Prantl <aprantl@apple.com>
Wed, 12 Feb 2014 19:34:44 +0000 (19:34 +0000)
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
lib/CodeGen/AsmPrinter/DwarfUnit.cpp
test/DebugInfo/X86/subreg.ll
test/DebugInfo/X86/subregisters.ll

index 32cf67ffb91f1cde3e6671d7a61ad762e57d9b0c..2f15c97f2de6ad6558b62434aa26c41b0f901004 100644 (file)
@@ -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);
     }
   }
 }
index a6bae16b6947ee0429f1d5f20f4a2705679cd4cd..68a346887a47b6c0c6accc8ea72e7641718dafed 100644 (file)
@@ -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);
     }
   }
 }
index 58e3bfc3bc31f1362b1fafb0f48937cc785422c4..94526ffae85b3c48536b3b51661917fe9a629dac 100644 (file)
@@ -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:
index ac0c38398692e2f1267c15d2ee62d8de4810b7b5..738ab02c0caa95e1a8b2f5e979b1a8b62e58adbb 100644 (file)
@@ -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;