jjzjj

CallInst

全部标签

c++ - 如何从 LLVM 中的 CallInst 获取间接调用的函数名称

Function*fun=call->getCalledFunction();getCalledFunction();如果是间接调用则返回null。如何获取函数名或指针名?我在StackOverflow中发现所有与此问题相关的问题都谈到了直接调用的函数名,或者指针类型。我只想跟踪这样的案例:voidfoo(){}voidgoo(){}voidmain(){intx=1;void(*p)();if(x)p=&foo;elsep=&goo;p();//printthecalledfunctionname} 最佳答案 我遇到了同样的问题。

c++ - 在 LLVM 中间接调用时如何从 CallInst 获取 FunctionType

如果是直接调用函数,可以通过以下代码获取Function类型。Function*fun=callInst->getCalledFunction();Function*funType=fun->getFunctionType();但是,如果调用是间接的,即通过函数指针,则getCalledFunction返回NULL。所以我的问题是如何在通过函数指针调用函数时获取函数类型。 最佳答案 要从间接调用中获取类型,请使用getCalledValue而不是getCalledFunction,如下所示:Type*t=callInst->getC

c++ - 如何从 LLVM 中的 CallInst 获取函数名称?

我有一个CallInst类型的对象。我怎样才能得到被调用函数的名称(又名被调用者)。假设函数被直接调用(即没有间接函数调用)。 最佳答案 StringRefget_function_name(CallInst*call){Function*fun=call->getCalledFunction();if(fun)//thanks@AntonKorobeynikovreturnfun->getName();//inheritedfromllvm::ValueelsereturnStringRef("indirectcall");}无论