在 "combined" LLVM IR 指令中检测自由函数?
Detecting free function inside a "combined" LLVM IR instruction?
我可以使用 getCalledFunction() 在此 IR 调用指令中轻松找到空闲:
call void @free(i8* %10) #4, !dbg !53
但是,我似乎不知道如何在这个调用指令中找到它:
%call7 = call i32 bitcast (i32 (...)* @free to i32 (%struct.Bar*)*)(%struct.Bar* %7), !dbg !56
该指令将BitCast与调用指令组合在一起。我不确定“组合”是否是正确的短语,但是,我如何在这里检测到免费?
我尝试 dyn_cast 到 Bitcast,但没有成功。我什至先使用了 getCalledOperand() 并尝试将从中获得的值转换为 BitCast,但它仍然没有检测到它。我将不胜感激。
谢谢!
@arnt 在评论中回答了这个问题,所以我为其他人添加答案。
@arnt:调用的第一个参数是 ConstantExpr,return由 getBitCast 编辑。 cast(foo)->getOperand(0) 将 return 免费。
我可以使用 getCalledFunction() 在此 IR 调用指令中轻松找到空闲:
call void @free(i8* %10) #4, !dbg !53
但是,我似乎不知道如何在这个调用指令中找到它:
%call7 = call i32 bitcast (i32 (...)* @free to i32 (%struct.Bar*)*)(%struct.Bar* %7), !dbg !56
该指令将BitCast与调用指令组合在一起。我不确定“组合”是否是正确的短语,但是,我如何在这里检测到免费?
我尝试 dyn_cast 到 Bitcast,但没有成功。我什至先使用了 getCalledOperand() 并尝试将从中获得的值转换为 BitCast,但它仍然没有检测到它。我将不胜感激。
谢谢!
@arnt 在评论中回答了这个问题,所以我为其他人添加答案。
@arnt:调用的第一个参数是 ConstantExpr,return由 getBitCast 编辑。 cast(foo)->getOperand(0) 将 return 免费。