如何知道LLVM IR中给定的行号与哪个变量相关联?

时间:2019-09-26 06:30:34

标签: c llvm llvm-ir

根据LLVM IR的任何指令,如何获取变量的详细信息,例如其名称,定义的行号 例如

Line 2: int i 

其IR:

call void @llvm.dbg.declare(metadata i32* %i, metadata !11, metadata !DIExpression()), !dbg !12
!11 = !DILocalVariable(name: "i", scope: !7, file: !1, line: 2, type: !10)
!12 = !DILocation(line: 2, column: 6, scope: !7)

假设我们有return i的IR指令

ret i32 %6, !dbg !38
!38 = !DILocation(line: 9, column: 2, scope: !7) 

我们如何从该元数据信息中知道实际的变量名是i,并且在第2行中定义了

注意:上面的示例仅显示return i,但是它可以是涉及更新i,读取i等的任何指令。

0 个答案:

没有答案