在LLVM IR中查找函数的参数

sha*_*ran 7 llvm

请建议我找到传递给llvm IR中的函数的参数声明的方法.

arr*_*owd 12

您可以使用Function::getArgumentList()方法获取函数参数的列表.然后,您使用迭代器遍历它 - ArgumentListType::begin()ArgumentListType::end().

请参阅class Function文档 - http://llvm.org/doxygen/classllvm_1_1Function.html

UPD:

迭代参数的当前方法是arg_begin()/ arg_end()/ args()方法.

  • 使用C++ 11 for-each结构,这更容易.设F是你正在观察的函数,A是F的ArgumentListType的一个参数:`for(auto&A:F.getArgumentList()){A.dump(); }` (5认同)
  • 我想,我的答案已经过时了。我现在就更新。 (2认同)
  • 请注意,这个答案在最近的 LLVM 版本中已经过时,因为“.getArgumentList()”函数已被删除,以支持“.args()”迭代器(请参阅[此处](https://reviews.llvm.org /D31052)了解更多信息)。 (2认同)