我正在尝试使用@ llvm.dbg.declare获取有关llvm代码中的变量的信息 我使用以下代码:
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()
当我使用llc file.ll编译时,我收到以下错误:
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)
^
我无法理解llvm代码中元数据的定义是否存在问题,或者我应该在编译时指定一些参数?
感谢您的帮助