[PATCH] D16867: Debug Info: Allow SROAed complex floating point types to be described by constants

Adrian Prantl via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 3 13:19:42 PST 2016


aprantl created this revision.
aprantl added reviewers: dblaikie, echristo, probinson.
aprantl added a subscriber: llvm-commits.
aprantl set the repository for this revision to rL LLVM.

When SROA splits up composite types and individual pieces are described by integer constants, we currently default to emitting these constant pieces as unsigned bytes regardless of the encoding of the underlying types. We don't make any attempt to find the correct encoding by finding the underlying element type from the composite type.

In the attached testcase a complex float is split into two 64-bit *integers* (because the target doesn't define a 64-bit double type).
This patch relaxes the assertion in isUnsignedDIType and matches the behavior so complex_float is treated consistent with other composite types.

I agree that trusting the IR to encode integer constants properly is questionable, but it is consistent with what we do for composite types, and apparently we're not doing any better elsewhere:

  void DwarfUnit::addConstantFPValue(DIE &Die, const ConstantFP *CFP) {
    // Pass this down to addConstantValue as an unsigned bag of bits.
    addConstantValue(Die, CFP->getValueAPF().bitcastToAPInt(), true);
  }

Thoughts?

Repository:
  rL LLVM

http://reviews.llvm.org/D16867

Files:
  lib/CodeGen/AsmPrinter/DwarfUnit.cpp
  test/DebugInfo/ARM/sroa-complex.ll
  test/DebugInfo/X86/float_const.ll

Index: test/DebugInfo/X86/float_const.ll
===================================================================
--- test/DebugInfo/X86/float_const.ll
+++ test/DebugInfo/X86/float_const.ll
@@ -13,7 +13,7 @@
   tail call void @llvm.dbg.declare(metadata float* undef, metadata !13, metadata !19), !dbg !20
   tail call void @llvm.dbg.value(metadata i32 1078523331, i64 0, metadata !13, metadata !19), !dbg !20
   tail call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !13, metadata !19), !dbg !20
-; CHECK:  DW_AT_const_value [DW_FORM_sdata]    (0)
+; CHECK:  DW_AT_const_value [DW_FORM_udata]    (0)
 ; CHECK-NEXT: DW_AT_name {{.*}}"a"
   ret void, !dbg !21
 }
Index: test/DebugInfo/ARM/sroa-complex.ll
===================================================================
--- /dev/null
+++ test/DebugInfo/ARM/sroa-complex.ll
@@ -0,0 +1,52 @@
+; RUN: %llc_dwarf -O0 -filetype=obj -o %t.o %s
+; RUN: llvm-dwarfdump -debug-dump=info %t.o | FileCheck %s
+; REQUIRES: object-emission
+target datalayout = "e-m:o-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
+target triple = "thumbv7-apple-unknown-macho"
+
+; generated from (-triple thumbv7-apple-unknown-macho -Os):
+;   void f(_Complex double c) { c = 0; }
+
+; Function Attrs: norecurse nounwind optsize readnone
+define arm_aapcscc void @f([2 x i64] %c.coerce) #0 !dbg !4 {
+entry:
+  ; The target has no native double type.
+  ; SROA split the complex value into two i64 values.
+  ; CHECK: DW_TAG_formal_parameter
+  ; CHECK-NEXT:  DW_AT_const_value [DW_FORM_udata]	(0)
+  tail call void @llvm.dbg.value(metadata i64 0, i64 0, metadata !10, metadata !18), !dbg !17
+  ret void, !dbg !17
+}
+
+; Function Attrs: nounwind readnone
+declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
+
+; Function Attrs: nounwind readnone
+declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1
+
+attributes #0 = { norecurse nounwind optsize readnone }
+attributes #1 = { nounwind readnone }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!11, !12, !13, !14}
+!llvm.ident = !{!15}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.9.0 (trunk 259428)", isOptimized: true, runtimeVersion: 0, emissionKind: 1, enums: !2, subprograms: !3)
+!1 = !DIFile(filename: "<stdin>", directory: "/Volumes/Data/radar/24456528")
+!2 = !{}
+!3 = !{!4}
+!4 = distinct !DISubprogram(name: "f", scope: !5, file: !5, line: 1, type: !6, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, variables: !9)
+!5 = !DIFile(filename: "test.c", directory: "/Volumes/Data/radar/24456528")
+!6 = !DISubroutineType(types: !7)
+!7 = !{null, !8}
+!8 = !DIBasicType(name: "complex", size: 128, align: 64, encoding: DW_ATE_complex_float)
+!9 = !{!10}
+!10 = !DILocalVariable(name: "c", arg: 1, scope: !4, file: !5, line: 1, type: !8)
+!11 = !{i32 2, !"Dwarf Version", i32 4}
+!12 = !{i32 2, !"Debug Info Version", i32 3}
+!13 = !{i32 1, !"wchar_size", i32 4}
+!14 = !{i32 1, !"min_enum_size", i32 4}
+!15 = !{!"clang version 3.9.0 (trunk 259428)"}
+!16 = !DIExpression()
+!17 = !DILocation(line: 1, scope: !4)
+!18 = !DIExpression(DW_OP_bit_piece, 0, 64)
Index: lib/CodeGen/AsmPrinter/DwarfUnit.cpp
===================================================================
--- lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -550,12 +550,15 @@
           Encoding == dwarf::DW_ATE_unsigned_char ||
           Encoding == dwarf::DW_ATE_signed ||
           Encoding == dwarf::DW_ATE_signed_char ||
-          Encoding == dwarf::DW_ATE_float || Encoding == dwarf::DW_ATE_UTF ||
-          Encoding == dwarf::DW_ATE_boolean ||
+          Encoding == dwarf::DW_ATE_float ||
+          Encoding == dwarf::DW_ATE_complex_float ||
+          Encoding == dwarf::DW_ATE_UTF || Encoding == dwarf::DW_ATE_boolean ||
           (Ty->getTag() == dwarf::DW_TAG_unspecified_type &&
            Ty->getName() == "decltype(nullptr)")) &&
          "Unsupported encoding");
-  return Encoding == dwarf::DW_ATE_unsigned ||
+  return Encoding == dwarf::DW_ATE_float ||
+         Encoding == dwarf::DW_ATE_complex_float ||
+         Encoding == dwarf::DW_ATE_unsigned ||
          Encoding == dwarf::DW_ATE_unsigned_char ||
          Encoding == dwarf::DW_ATE_UTF || Encoding == dwarf::DW_ATE_boolean ||
          Ty->getTag() == dwarf::DW_TAG_unspecified_type;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16867.46811.patch
Type: text/x-patch
Size: 4375 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160203/9013c557/attachment.bin>


More information about the llvm-commits mailing list