how to define metadata for @llvm.dbg.declare?

393 views Asked by At

I am trying to use @llvm.dbg.declare to get information about a variable inside llvm code I use the following code:

define i32 @main() nounwind ssp {
  %1 = alloca i32, align 4
  %tsi = alloca %struct.timespec, align 8
  %tsf = alloca %struct.timespec, align 8
  %elaps_s = alloca double, align 8
  %elaps_ns = alloca i64, align 8
  %N = alloca i32, align 4
  call void @llvm.dbg.declare(metadata !{i32* %N }, metadata !11, metadata !13)
  ...
}

!0 = !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang", isOptimized: true, flags: "-O2", runtimeVersion: 2, splitDebugFilename: "abc.debug", emissionKind: 1, enums: !2, retainedTypes: !3, subprograms: !4, globals: !5, imports: !6)
!1 = !DIFile(filename: "mmul.ll", directory: "/home/clereco/LLFI-master/test_programs/mmul-10x10-v3")
!2 = !{}
!3 = !{!4}
!4 = !DISubprogram(name: "main", scope: !1, file: !1, line: 18, type: !5, isLocal: false, isDefinition: true, scopeLine: 18, isOptimized: false, function: i32 ()* @main, variables: !2)
!5 = !DISubroutineType(types: !6)
!6 = !{null}
!7 = !{i32 2, !"Dwarf Version", i32 2}
!8 = !{i32 2, !"Debug Info Version", i32 3}
!9 = !{i32 1, !"PIC Level", i32 2}
!10 = !{!"clang version 3.7.0 (trunk 231150) (llvm/trunk 231154)"}
!11 = !DILocalVariable(tag: DW_TAG_auto_variable, name: "N", scope: !4, file: !1, line: 6, type: !12)
!12 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
!13 = !DIExpression()

When I compile using llc file.ll I getthe following error:

llc: mmul.ll:290:6: error: expected type
!0 = !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang", isOptimized: true, flags: "-O2", runtimeVersion: 2, splitDebugFilename: "abc.debug", emissionKind: 1, enums: !2, retainedTypes: !3, subprograms: !4, globals: !5, imports: !6)
     ^

I can not understand if it is a problem in the definition of the metadata inside the llvm code or I should specify some parameters when compiling?

Thanks for your help

0

There are 0 answers