LLVM 2.9 metadata

Hi all,

In LLVM documentation about source level debugging ([http://www.llvm.org/releases/2.9/docs/SourceLevelDebugging.html](http://www.llvm.org/releases/2.9/docs/SourceLevelDebugging.html))

Subprogram descriptor is defined as:

!2 = metadata !{
  i32,      ;; Tag = 46 + [LLVMDebugVersion](http://www.llvm.org/releases/2.9/docs/SourceLevelDebugging.html#LLVMDebugVersion)
            ;; (DW_TAG_subprogram)

  i32,      ;; Unused field.
  metadata, ;; Reference to context descriptor
  metadata, ;; Name
  metadata, ;; Display name (fully qualified C++ name)
  metadata, ;; MIPS linkage name (for C++)
  metadata, ;; Reference to file where defined

  i32,      ;; Line number where defined
  metadata, ;; Reference to type descriptor
  i1,       ;; True if the global is local to compile unit (static)
  i1        ;; True if the global is defined in the compile unit (not extern)

  i32       ;; Virtuality, e.g. dwarf::DW_VIRTUALITY__virtual
  i32       ;; Index into a virtual function
  metadata, ;; indicates which base type contains the vtable pointer for the 
            ;; derived class

  i1        ;; isArtificial
  i1        ;; isOptimized
  Function *;; Pointer to LLVM function

}

When I use clang 2.9 and emit-llvm code metadata generated for a routine foo is:

!0 = metadata !{i32 589870, i32 0, metadata !1, metadata !"foo", metadata !"foo", metadata !"", metadata !1, i32 1, metadata !3, i1 false, i1 true, i32 0, i32 0, i32 0, i32 0, i1 false, void ()* @foo} ; [ DW_TAG_subprogram ]

!1 = metadata !{i32 589865, metadata !"foodbg.c", metadata !"/home/deldon/tmp", metadata !2} ; [ DW_TAG_file_type ]
!2 = metadata !{i32 589841, i32 0, i32 12, metadata !"foodbg.c", metadata !"/home/deldon/tmp", metadata !"clang version 2.9 (tags/RELEASE_29/final)", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ]

!3 = metadata !{i32 589845, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i32 0, i32 0, i32 0, metadata !4, i32 0, i32 0} ; [ DW_TAG_subroutine_type ]
!4 = metadata !{null}
...

As you can see metadata definition !0 doesn't match documentation. What is the correct definition (CLANG or LLVM documentation ?).

Thanks for your answer
Seb

If you’re wondering about this field then it is unused in ‘c’ style functions so it does not matter. I fixed it in r146665.
Thanks!

Hi Devang,

Not only “vtable ptr” is a problem, for this field it seems that CLANG emits a NULL metadata node which is translated into ‘i32 0’. The other problem is for ‘isArtificial’ field with is described as being of type i1 and CLANG emits i32. Looking at sources, it seems that it should be a i32 flag field.

Hope this helps,
Best Regards
Seb

2011/12/15 Devang Patel <dpatel@apple.com>

Hi Devang,

In addition, metadata node definition with tag ‘DW_TAG_subroutine_type’ doesn’t match what’s described in documentation for composite type descriptor.

Best Regards
Seb

2011/12/16 Seb <babslachem@gmail.com>

I fixed these in r146743 & r146744.

Thanks!