使用 LLVM 8.0.1 库,我尝试使用以下代码为函数创建调试信息:
DIFile *Unit = DebugBuilder->createFile(CompileUnit->getFilename(), CompileUnit->getDirectory());
DIScope *FContext(Unit);
DISubprogram *SP = DebugBuilder->createFunction(
FContext, def->Name, def->Name, Unit, LineNo,
CreateFunctionType(ft, CompileUnit->getFile()), 0);
func->setSubprogram(SP);
但是,这会导致 IR 如下所示:
define i32 @main(i32 %y) !dbg !3 {
entry:
ret i32 2
}
; ...
!3 = !DISubprogram(name: "main", linkageName: "main", scope: !2, file: !2, type: !4, spFlags: 0, retainedNodes: !7)
; ...
!7 = <temporary!> !{}
哪个,在调用时DebugBuilder->finalize()
,抛出Assertion failed: !N->isTemporary() && "Expected all forward declarations to be resolved"
我在官方参考资料和其他教程中都没有找到该retainedNodes
字段的描述,并且网络搜索只会导致 LLVM 源代码中未注释的部分。这个领域的意义或目的是什么?临时节点是如何在那里创建的?