Use DW_FORM_addr for DW_AT_entry_pc.
authorDevang Patel <dpatel@apple.com>
Mon, 28 Jun 2010 22:22:47 +0000 (22:22 +0000)
committerDevang Patel <dpatel@apple.com>
Mon, 28 Jun 2010 22:22:47 +0000 (22:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107085 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/AsmPrinter/DIE.cpp
lib/CodeGen/AsmPrinter/DwarfDebug.cpp
test/FrontendC/2010-06-28-DbgEntryPC.c [new file with mode: 0644]

index b2c70d51f5a53fb8872f78a52af275417d1b2e0f..21396ca37f065dc90b3eea635e61d65d5f7c44df 100644 (file)
@@ -201,6 +201,7 @@ void DIEInteger::EmitValue(AsmPrinter *Asm, unsigned Form) const {
   case dwarf::DW_FORM_data8: Size = 8; break;
   case dwarf::DW_FORM_udata: Asm->EmitULEB128(Integer); return;
   case dwarf::DW_FORM_sdata: Asm->EmitSLEB128(Integer); return;
+  case dwarf::DW_FORM_addr:  Size = Asm->getTargetData().getPointerSize(); break;
   default: llvm_unreachable("DIE Value form not supported yet");
   }
   Asm->OutStreamer.EmitIntValue(Integer, Size, 0/*addrspace*/);
@@ -221,6 +222,7 @@ unsigned DIEInteger::SizeOf(AsmPrinter *AP, unsigned Form) const {
   case dwarf::DW_FORM_data8: return sizeof(int64_t);
   case dwarf::DW_FORM_udata: return MCAsmInfo::getULEB128Size(Integer);
   case dwarf::DW_FORM_sdata: return MCAsmInfo::getSLEB128Size(Integer);
+  case dwarf::DW_FORM_addr:  return AP->getTargetData().getPointerSize();
   default: llvm_unreachable("DIE Value form not supported yet"); break;
   }
   return 0;
index 9ff929f0b1716fdf64b9a790ce74b254a23b0d8b..2a25cb910100b3d773ecb131b74a9b058e2cbdad 100644 (file)
@@ -1792,7 +1792,7 @@ void DwarfDebug::constructCompileUnit(const MDNode *N) {
   addString(Die, dwarf::DW_AT_name, dwarf::DW_FORM_string, FN);
   // Use DW_AT_entry_pc instead of DW_AT_low_pc/DW_AT_high_pc pair. This
   // simplifies debug range entries.
-  addUInt(Die, dwarf::DW_AT_entry_pc, dwarf::DW_FORM_data4, 0);
+  addUInt(Die, dwarf::DW_AT_entry_pc, dwarf::DW_FORM_addr, 0);
   // DW_AT_stmt_list is a offset of line number information for this
   // compile unit in debug_line section. It is always zero when only one
   // compile unit is emitted in one object file.
diff --git a/test/FrontendC/2010-06-28-DbgEntryPC.c b/test/FrontendC/2010-06-28-DbgEntryPC.c
new file mode 100644 (file)
index 0000000..9ce2364
--- /dev/null
@@ -0,0 +1,48 @@
+// RUN: %llvmgcc -S -O2 -g %s -o - | llc -O2 | FileCheck %s
+// Use DW_FORM_addr for DW_AT_entry_pc.
+// Radar 8094785
+
+// CHECK:      .byte   17                      ## DW_TAG_compile_unit
+// CHECK-NEXT: .byte   1                       ## DW_CHILDREN_yes
+// CHECK-NEXT: .byte   37                      ## DW_AT_producer
+// CHECK-NEXT: .byte   8                       ## DW_FORM_string
+// CHECK-NEXT: .byte   19                      ## DW_AT_language
+// CHECK-NEXT: .byte   11                      ## DW_FORM_data1
+// CHECK-NEXT: .byte   3                       ## DW_AT_name
+// CHECK-NEXT: .byte   8                       ## DW_FORM_string
+// CHECK-NEXT: .byte   82                      ## DW_AT_entry_pc
+// CHECK-NEXT: .byte   1                       ## DW_FORM_addr
+// CHECK-NEXT: .byte   16                      ## DW_AT_stmt_list
+// CHECK-NEXT: .byte   6                       ## DW_FORM_data4
+// CHECK-NEXT: .byte   27                      ## DW_AT_comp_dir
+// CHECK-NEXT: .byte   8                       ## DW_FORM_string
+// CHECK-NEXT: .byte   225                     ## DW_AT_APPLE_optimized
+
+struct a {
+  int c;
+  struct a *d;
+};
+
+int ret;
+
+void foo(int x) __attribute__((noinline));
+void *bar(struct a *b) __attribute__((noinline));
+
+void foo(int x)
+{
+  ret = x;
+}
+
+void *bar(struct a *b) {
+  foo(b->c);
+  return b;
+}
+
+int main(int argc, char *argv[]) {
+  struct a e;
+  e.c = 4;
+  e.d = &e;
+
+  (void)bar(&e);
+  return ret;
+}