[llvm-dev] Debug info scope of explicit casting type does not seem correct

Aboud, Amjad via llvm-dev llvm-dev at lists.llvm.org
Sat Apr 30 03:32:13 PDT 2016


Hi,
I am wondering if this behavior of creating debug info is correct.
A type in compile unit entry is pointing to a type under subprogram entry?!

This is the root cause of https://llvm.org/bugs/show_bug.cgi?id=27579

0x0000000b: DW_TAG_compile_unit [1] *

0x00000026:   DW_TAG_pointer_type [2]
                            DW_AT_type [DW_FORM_ref4]       (cu + 0x002c => {0x0000002c})

0x0000002b:   DW_TAG_subprogram [3] *

0x0000002c:     DW_TAG_typedef [4]
                               DW_AT_type [DW_FORM_ref4]     (cu + 0x0040 => {0x00000040})
                               DW_AT_name [DW_FORM_strp]     ( .debug_str[0x00000060] = "T")
                               DW_AT_decl_file [DW_FORM_data1]       ("c:\temp\ICL\LB\retain.cpp")
                               DW_AT_decl_line [DW_FORM_data1]       (16)

0x00000037:     NULL


command line:
clang -cc1 -triple i386-apple-ios9.0.0 -emit-obj -debug-info-kind=limited -O2 test.cpp -o - | llvm-dwarfdump -debug-dump=info -

> cat test.cpp
class A {
public:
  int x;
};


class B {
public:
  typedef A type;
};

template<typename X>
int foo(void* in) {
  typedef typename X::type T;
  const T* p = (T*) in;
  return p->x;
}

int bar() {
A a;
  return foo<B>(&a);
}

Reason for this behavior is the explicit cast "(T*)", which leads into the following IR:

!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.9.0 (trunk 267335)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3)
!3 = !{!4}
!4 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !5, size: 32, align: 32)  <----------------- No Scope, leads to compile unit scope!!
!5 = !DIDerivedType(tag: DW_TAG_typedef, name: "T", scope: !7, file: !6, line: 16, baseType: !20)
!7 = distinct !DISubprogram(name: "foo<B>", linkageName: "_Z3fooI1BEiPv", scope: !6, file: !6, line: 15, type: !8, isLocal: false, isDefinition: true, scopeLine: 15, flags: DIFlagPrototyped, isOptimized: true, unit: !0, templateParams: !12, variables: !15)


Thanks,
Amjad

---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160430/36162ab0/attachment.html>


More information about the llvm-dev mailing list