最近,我使用llvm在LLVM-IR中插入調用指令。問題是,如果我有一個名爲add
的函數,我無法使用getFuntion(string)來查找它,因爲IR中的add()可能爲_Z3addv_
。我知道IR中的所有功能都有一個新名字,但我不知道這個新名字到底是什麼。LLVM-如何通過函數的真實/原始名稱獲取函數
Module *m = f->getParent();
IRBuilder<> builder(m->getContext());
Function *call = m->getFunction("add");
// call is NULL.
std::vector<Value *> args;
......
Module *m = f->getParent();
IRBuilder<> builder(m->getContext());
Function *call = m->getFunction("_Z3addv");
// call is not NULL.
std::vector<Value *> args;
......
如何使用原始名稱查找函數?
C++的名字mangling是由clang完成的,因此請查看clang的API。 –