【发布时间】:2015-05-18 23:32:14
【问题描述】:
我正在使用 LLVM API 编写一些代码。我正在使用 llvm::CallGraph 对象循环遍历父函数调用的所有子函数:
CallGraph cg( *mod );
for( auto i = cg.begin(); i != cg.end(); ++i )
{
const Function *parent = i->first;
if( !parent )
continue;
for( auto j = i->second->begin(); j != i->second->end(); ++j )
{
Function *child = j->second->getFunction();
if( !child )
continue;
for( auto iarg = child->arg_begin(); iarg != child->arg_end(); ++iarg )
{
// Print values here!
}
}
o.flush();
我感兴趣的 IR 中的实际函数调用如下所示:
call void @_ZN3abc3FooC1Ejjj(%"struct.abc::Foo"* %5, i32 4, i32 2, i32 0)
我想做的是检索最后三个常量整数值:4、2、0。如果我也能检索到 %5,则可以加分,但这并不重要。我花了大约两个小时盯着http://llvm.org/docs/doxygen/,但我根本不知道我应该如何得到这三个值。
【问题讨论】: